public interface IFailerCustomizer
The same effect can be achieved in code by inheriting all check-failer specifications and customizing the {link:NFail} attributes in each failer specification (a lot of work).
The same effect can also be achieved by customizing every {link:ICallContract} in your application code in each checker-failer section (also alot of work with consistency hard to reach).
With these customize methods your application can do the customization once e.g. at startup (less work and with consistency within reach).
However, be aware that to reach consistency in your application, you might need to assert all the failer-methods.
One use-case for this could be to customize all exception messages with application info.
Another use-case for this could be support localization to all exception messages.
Modifier and Type | Method and Description |
---|---|
Class<? extends RuntimeException> |
getCustomFailExceptionTypeOrNull(String failerSpecificationAndMethodID)
Retrieves a custom exception class, if set, that the fail-method should
throw instead of the default class set in its {link:NFail}.
|
String |
getCustomFailMessageArgumentsOrNull(String failerSpecificationAndMethodID)
Retrieves custom message arguments, if set, that the fail-method should
use instead of the default message arguments set in its {link:NFail}.
|
String |
getCustomFailMessageFormatOrNull(String failerSpecificationAndMethodID)
Retrieves custom message format, if set, that the fail-method should use
instead of the default message format set in its {link:NFail}.
|
void |
registerCustomFailExceptionType(String failerSpecificationAndMethodID,
Class<? extends RuntimeException> failExceptionType)
Registers a custom exception class that the supplied failer
specification method should throw instead of the default
class set in its {link:NFail}.
|
void |
registerCustomFailMessageArguments(String failerSpecificationAndMethodID,
String failMessageArguments)
Registers custom message arguments that the supplied failer
specification method should throw instead of the default
class set in its {link:NFail}.
|
void |
registerCustomFailMessageFormat(String failerSpecificationAndMethodID,
String failMessageFormat)
Registers a custom message format that the supplied failer
specification method should throw instead of the default
class set in its {link:NFail}.
|
void |
unregisterCustomFailExceptionType(String failerSpecificationAndMethodID)
Unregisters a previously registered custom exception class for the
supplied failer specification method.
|
void |
unregisterCustomFailMessageArguments(String failerSpecificationAndMethodID)
Unregisters a previously registered custom message arguments that the
supplied failer specification method should use instead
of the default message arguments set in its {link:NFail}.
|
void |
unregisterCustomFailMessageFormat(String failerSpecificationAndMethodID)
Unregisters a previously registered custom message format for the
supplied failer specification method.
|
Class<? extends RuntimeException> getCustomFailExceptionTypeOrNull(String failerSpecificationAndMethodID)
failerSpecificationAndMethodID
- unique id of a failer specification method to to affectIllegalArgumentException
- if any of the arguments are nullvoid registerCustomFailExceptionType(String failerSpecificationAndMethodID, Class<? extends RuntimeException> failExceptionType)
If failExceptionType inherits
If failExceptionType does not inherit
failerSpecificationAndMethodID
- unique id of a failer specification method to to affectfailExceptionType
- a custom exception class that the failer specification
method should throwIllegalArgumentException
- if any of the arguments are nullIllegalStateException
- if the failerSpecificationAndMethodID already has a registrationvoid unregisterCustomFailExceptionType(String failerSpecificationAndMethodID)
failerSpecificationAndMethodID
- unique id of a failer specification method to to affectIllegalArgumentException
- if any of the arguments are nullIllegalStateException
- if the failerSpecificationAndMethodID has no registration to unregisterString getCustomFailMessageFormatOrNull(String failerSpecificationAndMethodID)
failerSpecificationAndMethodID
- unique id of a failer specification method to to affectIllegalArgumentException
- if any of the arguments are nullvoid registerCustomFailMessageFormat(String failerSpecificationAndMethodID, String failMessageFormat)
failerSpecificationAndMethodID
- unique id of a failer specification method to to affectfailMessageFormat
- custom message format that fail-method should useIllegalArgumentException
- if any of the arguments are nullIllegalStateException
- if the failerSpecificationAndMethodID already has a registrationvoid unregisterCustomFailMessageFormat(String failerSpecificationAndMethodID)
failerSpecificationAndMethodID
- unique id of a failer specification method to to affectIllegalArgumentException
- if any of the arguments are nullIllegalStateException
- if the failerSpecificationAndMethodID has no registration to unregisterString getCustomFailMessageArgumentsOrNull(String failerSpecificationAndMethodID)
failerSpecificationAndMethodID
- unique id of a failer specification method to to affectIllegalArgumentException
- if any of the arguments are nullvoid registerCustomFailMessageArguments(String failerSpecificationAndMethodID, String failMessageArguments)
failerSpecificationAndMethodID
- unique id of a failer specification method to to affectfailMessageArguments
- custom message arguments that fail-method should useIllegalArgumentException
- if any of the arguments are nullIllegalStateException
- if the failerSpecificationAndMethodID already has a registrationvoid unregisterCustomFailMessageArguments(String failerSpecificationAndMethodID)
failerSpecificationAndMethodID
- unique id of a failer specification method to to affectIllegalArgumentException
- if any of the arguments are nullIllegalStateException
- if the failerSpecificationAndMethodID has no registration to unregisterThe MIT License (MIT) - Copyright © 2014-2015 Keld Oelykke. All Rights Reserved.