-
@Target(PARAMETER) @Retention(CLASS) @Documented public @interface Producer
Identifies a parameter has the ability to produce aThrowableor a super type of aThrowable. The parameter type must be aFunctionor aBiFunction.For a
Functionthe input parameter must be aStringwhich will be the message associated with the method. The result type mustThrowableor a super type of aThrowable.For a
BiFunctionone of the input parameters must be aStringwhich will be the message associated with the method. The other input parameter must be aThrowableor a super type of aThrowableand must be assignable from the parameter annotated withCause. The result type mustThrowableor a super type of aThrowable.Example
@Message("The operation failed due to %s")T operationFailed(@Producer Function function, String op); @Message("The operation failed due to %s") T operationFailed(@Producer BiFunction function, @Cause Throwable cause, String op); Example Usage
throw Bundle.MESSAGES.operationFailed(IllegalArgumentException::new, "start"); throw Bundle.MESSAGES.operationFailed(IllegalStateException::new, cause, "start");
- Author:
- James R. Perkins