public interface ICallContract
The data is everything needed for the fail-method to throw an exception with an informative well-formatted error message.
Please note! ALL properties not named "OrNull" MUST be supplied (cannot be null).
Implementations of this should be extensible (not final).
Modifier and Type | Method and Description |
---|---|
IChecker |
getAssertingChecker()
The checker with asserting check-method.
|
Object |
getCaller()
The caller that called asserting check-method and therefore must call fail-method.
|
Object[] |
getCheckArguments()
The arguments supplied the asserting check-method by the caller.
|
Object[] |
getCheckExtraArguments()
The extra arguments supplied by the asserting check-method implementation.
|
Class<? extends ICheck> |
getCheckSpecification()
The check specification (interface) with specification of asserting check-method.
|
Class<? extends RuntimeException> |
getCustomFailExceptionTypeOrNull()
Retrieves a custom exception class, if set, that fail-method should throw instead of the default class set in attribute of fail-method.
|
String |
getCustomFailMessageArgumentsOrNull()
Retrieves custom message arguments, if set, that fail-method should use instead of the
default arguments set in attribute of fail-method.
|
String |
getCustomFailMessageFormatOrNull()
Retrieves custom message format, if set, that fail-method should use instead of the
default format set in attribute of fail-method.
|
String |
getCustomFailMessagePostfixOrNull()
Retrieves a custom message postfix, if set, that will be added the exception message.
|
Class<? extends IFail> |
reflectFailSpecificationType()
Reflects the fail specification (interface) that should be used to end this contract.
|
void |
setAssertingChecker(IChecker assertingChecker)
The checker with asserting check-method.
|
void |
setCaller(Object caller)
The caller that called asserting check-method and therefore must call fail-method.
|
void |
setCheckArguments(Object[] checkArguments)
The arguments supplied the asserting check-method by the caller.
|
void |
setCheckExtraArguments(Object[] checkExtraArguments)
The extra arguments supplied by the asserting check-method implementation.
|
void |
setCheckSpecification(Class<? extends ICheck> checkSpecification)
The check specification (interface) with specification of asserting check-method.
|
void |
setCustomFailExceptionType(Class<? extends RuntimeException> failExceptionType)
Sets a custom exception class that fail-method should throw instead of
the default class set in attribute of fail-method.
|
void |
setCustomFailMessageArguments(String failMessageArguments)
Sets custom message arguments that fail-method should use instead of the
default arguments set in attribute of fail-method.
|
void |
setCustomFailMessageFormat(String failMessageFormat)
Sets custom message format that fail-method should use instead of the
default format set in attribute of fail-method.
|
void |
setCustomFailMessagePostfix(String failMessagePostfix)
Sets a custom message postfix that will be added the exception message of the exception to throw.
|
void |
validateContractData()
Validates the contract data e.g.
|
Object getCaller()
void setCaller(Object caller)
caller
- caller that called asserting check-method and therefore must call fail-methodIChecker getAssertingChecker()
void setAssertingChecker(IChecker assertingChecker)
assertingChecker
- checker with asserting check-methodClass<? extends ICheck> getCheckSpecification()
The checkSpecification is annotated with a fail specification that needs to be called by the caller to end this contract.
void setCheckSpecification(Class<? extends ICheck> checkSpecification)
The checkSpecification is annotated with a fail specification that needs to be called by the caller to end this contract.
checkSpecification
- check specification (interface) with specification of asserting check-methodObject[] getCheckArguments()
void setCheckArguments(Object[] checkArguments)
checkArguments
- arguments supplied the asserting check-method by the callerObject[] getCheckExtraArguments()
void setCheckExtraArguments(Object[] checkExtraArguments)
checkExtraArguments
- extra arguments supplied by the asserting check-method implementationvoid validateContractData()
IllegalArgumentException
- if any contract data is missingClass<? extends IFail> reflectFailSpecificationType()
Class<? extends RuntimeException> getCustomFailExceptionTypeOrNull()
void setCustomFailExceptionType(Class<? extends RuntimeException> failExceptionType)
If failExceptionType inherits
If failExceptionType does not inherit
failExceptionType
- a custom exception class that fail-method should throwString getCustomFailMessageFormatOrNull()
void setCustomFailMessageFormat(String failMessageFormat)
failMessageFormat
- custom message format that fail-method should useString getCustomFailMessageArgumentsOrNull()
void setCustomFailMessageArguments(String failMessageArguments)
failMessageArguments
- custom message arguments that fail-method should useString getCustomFailMessagePostfixOrNull()
void setCustomFailMessagePostfix(String failMessagePostfix)
The MIT License (MIT) - Copyright © 2014-2015 Keld Oelykke. All Rights Reserved.