Class ContractRuntime
This class is part of the supported generated-code API. Application code
normally declares contracts with media.barney.contract.Contract;
annotation-processor-generated checks call this bridge to evaluate
contracts and throw the documented exception types.
Object-valued bridge methods are null-safe. A null value is
treated as passing because nullness is outside the contract model.
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidrequireParameterValue(byte value, String methodName, String parameterName, RuntimeContract contract, String description, boolean customDescription, @Nullable Class<? extends MaskRenderer> maskRenderer, long min, long max, boolean minInclusive, boolean maxInclusive, int sizeMin, int sizeMax, @Nullable String regexp) Evaluates a generated parameter contract without boxing a primitive value on the successful validation path.static voidrequireParameterValue(double value, String methodName, String parameterName, RuntimeContract contract, String description, boolean customDescription, @Nullable Class<? extends MaskRenderer> maskRenderer, long min, long max, boolean minInclusive, boolean maxInclusive, int sizeMin, int sizeMax, @Nullable String regexp) Evaluates a generated parameter contract without boxing a primitive value on the successful validation path.static voidrequireParameterValue(float value, String methodName, String parameterName, RuntimeContract contract, String description, boolean customDescription, @Nullable Class<? extends MaskRenderer> maskRenderer, long min, long max, boolean minInclusive, boolean maxInclusive, int sizeMin, int sizeMax, @Nullable String regexp) Evaluates a generated parameter contract without boxing a primitive value on the successful validation path.static voidrequireParameterValue(int value, String methodName, String parameterName, RuntimeContract contract, String description, boolean customDescription, @Nullable Class<? extends MaskRenderer> maskRenderer, long min, long max, boolean minInclusive, boolean maxInclusive, int sizeMin, int sizeMax, @Nullable String regexp) Evaluates a generated parameter contract without boxing a primitive value on the successful validation path.static voidrequireParameterValue(long value, String methodName, String parameterName, RuntimeContract contract, String description, boolean customDescription, @Nullable Class<? extends MaskRenderer> maskRenderer, long min, long max, boolean minInclusive, boolean maxInclusive, int sizeMin, int sizeMax, @Nullable String regexp) Evaluates a generated parameter contract without boxing a primitive value on the successful validation path.static voidrequireParameterValue(short value, String methodName, String parameterName, RuntimeContract contract, String description, boolean customDescription, @Nullable Class<? extends MaskRenderer> maskRenderer, long min, long max, boolean minInclusive, boolean maxInclusive, int sizeMin, int sizeMax, @Nullable String regexp) Evaluates a generated parameter contract without boxing a primitive value on the successful validation path.static voidrequireParameterValue(@Nullable Object value, String methodName, String parameterName, RuntimeContract contract, String description, boolean customDescription, @Nullable Class<? extends MaskRenderer> maskRenderer, long min, long max, boolean minInclusive, boolean maxInclusive, int sizeMin, int sizeMax, @Nullable String regexp) Evaluates a generated parameter contract with pre-resolved metadata.static byterequireReturnValue(byte value, String methodName, RuntimeContract contract, String description, boolean customDescription, @Nullable Class<? extends MaskRenderer> maskRenderer, long min, long max, boolean minInclusive, boolean maxInclusive, int sizeMin, int sizeMax, @Nullable String regexp) Evaluates a generated primitive return-value contract without boxing the value on the successful validation path.static doublerequireReturnValue(double value, String methodName, RuntimeContract contract, String description, boolean customDescription, @Nullable Class<? extends MaskRenderer> maskRenderer, long min, long max, boolean minInclusive, boolean maxInclusive, int sizeMin, int sizeMax, @Nullable String regexp) Evaluates a generated primitive return-value contract without boxing the value on the successful validation path.static floatrequireReturnValue(float value, String methodName, RuntimeContract contract, String description, boolean customDescription, @Nullable Class<? extends MaskRenderer> maskRenderer, long min, long max, boolean minInclusive, boolean maxInclusive, int sizeMin, int sizeMax, @Nullable String regexp) Evaluates a generated primitive return-value contract without boxing the value on the successful validation path.static intrequireReturnValue(int value, String methodName, RuntimeContract contract, String description, boolean customDescription, @Nullable Class<? extends MaskRenderer> maskRenderer, long min, long max, boolean minInclusive, boolean maxInclusive, int sizeMin, int sizeMax, @Nullable String regexp) Evaluates a generated primitive return-value contract without boxing the value on the successful validation path.static longrequireReturnValue(long value, String methodName, RuntimeContract contract, String description, boolean customDescription, @Nullable Class<? extends MaskRenderer> maskRenderer, long min, long max, boolean minInclusive, boolean maxInclusive, int sizeMin, int sizeMax, @Nullable String regexp) Evaluates a generated primitive return-value contract without boxing the value on the successful validation path.static shortrequireReturnValue(short value, String methodName, RuntimeContract contract, String description, boolean customDescription, @Nullable Class<? extends MaskRenderer> maskRenderer, long min, long max, boolean minInclusive, boolean maxInclusive, int sizeMin, int sizeMax, @Nullable String regexp) Evaluates a generated primitive return-value contract without boxing the value on the successful validation path.static <T extends @Nullable Object>
TrequireReturnValue(T value, String methodName, RuntimeContract contract, String description, boolean customDescription, @Nullable Class<? extends MaskRenderer> maskRenderer, long min, long max, boolean minInclusive, boolean maxInclusive, int sizeMin, int sizeMax, @Nullable String regexp) Evaluates a generated return-value contract with pre-resolved metadata.
-
Method Details
-
requireParameterValue
public static void requireParameterValue(@Nullable Object value, String methodName, String parameterName, RuntimeContract contract, String description, boolean customDescription, @Nullable Class<? extends MaskRenderer> maskRenderer, long min, long max, boolean minInclusive, boolean maxInclusive, int sizeMin, int sizeMax, @Nullable String regexp) Evaluates a generated parameter contract with pre-resolved metadata.Generated code calls this entry point with the runtime contract kind, message description, mask renderer, and attribute values that the annotation processor resolved from source annotations.
- Parameters:
value- the parameter value to evaluate;nullpasses semantic contractsmethodName- the fully qualified executable name used in messagesparameterName- the parameter name used in messagescontract- the contract kind to evaluatedescription- the generated or custom violation descriptioncustomDescription- whetherdescriptioncame from a custom annotation messagemaskRenderer- renderer type for confidential values, ornullwhen no masking appliesmin- numeric lower bound for range contractsmax- numeric upper bound for range contractsminInclusive- whether the numeric lower bound is inclusivemaxInclusive- whether the numeric upper bound is inclusivesizeMin- inclusive lower bound for size contractssizeMax- inclusive upper bound for size contractsregexp- regular expression for pattern contracts- Throws:
IllegalArgumentException- when the parameter contract fails
-
requireParameterValue
public static void requireParameterValue(byte value, String methodName, String parameterName, RuntimeContract contract, String description, boolean customDescription, @Nullable Class<? extends MaskRenderer> maskRenderer, long min, long max, boolean minInclusive, boolean maxInclusive, int sizeMin, int sizeMax, @Nullable String regexp) Evaluates a generated parameter contract without boxing a primitive value on the successful validation path. -
requireParameterValue
public static void requireParameterValue(short value, String methodName, String parameterName, RuntimeContract contract, String description, boolean customDescription, @Nullable Class<? extends MaskRenderer> maskRenderer, long min, long max, boolean minInclusive, boolean maxInclusive, int sizeMin, int sizeMax, @Nullable String regexp) Evaluates a generated parameter contract without boxing a primitive value on the successful validation path. -
requireParameterValue
public static void requireParameterValue(int value, String methodName, String parameterName, RuntimeContract contract, String description, boolean customDescription, @Nullable Class<? extends MaskRenderer> maskRenderer, long min, long max, boolean minInclusive, boolean maxInclusive, int sizeMin, int sizeMax, @Nullable String regexp) Evaluates a generated parameter contract without boxing a primitive value on the successful validation path. -
requireParameterValue
public static void requireParameterValue(long value, String methodName, String parameterName, RuntimeContract contract, String description, boolean customDescription, @Nullable Class<? extends MaskRenderer> maskRenderer, long min, long max, boolean minInclusive, boolean maxInclusive, int sizeMin, int sizeMax, @Nullable String regexp) Evaluates a generated parameter contract without boxing a primitive value on the successful validation path. -
requireParameterValue
public static void requireParameterValue(float value, String methodName, String parameterName, RuntimeContract contract, String description, boolean customDescription, @Nullable Class<? extends MaskRenderer> maskRenderer, long min, long max, boolean minInclusive, boolean maxInclusive, int sizeMin, int sizeMax, @Nullable String regexp) Evaluates a generated parameter contract without boxing a primitive value on the successful validation path. -
requireParameterValue
public static void requireParameterValue(double value, String methodName, String parameterName, RuntimeContract contract, String description, boolean customDescription, @Nullable Class<? extends MaskRenderer> maskRenderer, long min, long max, boolean minInclusive, boolean maxInclusive, int sizeMin, int sizeMax, @Nullable String regexp) Evaluates a generated parameter contract without boxing a primitive value on the successful validation path. -
requireReturnValue
public static <T extends @Nullable Object> T requireReturnValue(T value, String methodName, RuntimeContract contract, String description, boolean customDescription, @Nullable Class<? extends MaskRenderer> maskRenderer, long min, long max, boolean minInclusive, boolean maxInclusive, int sizeMin, int sizeMax, @Nullable String regexp) Evaluates a generated return-value contract with pre-resolved metadata.Generated code calls this entry point with the runtime contract kind, message description, mask renderer, and attribute values that the annotation processor resolved from source annotations. The original value is returned unchanged when the contract passes so generated return statements can remain expression-shaped.
- Type Parameters:
T- the return-value type- Parameters:
value- the return value to evaluate;nullpasses semantic contractsmethodName- the fully qualified method name used in messagescontract- the contract kind to evaluatedescription- the generated or custom violation descriptioncustomDescription- whetherdescriptioncame from a custom annotation messagemaskRenderer- renderer type for confidential values, ornullwhen no masking appliesmin- numeric lower bound for range contractsmax- numeric upper bound for range contractsminInclusive- whether the numeric lower bound is inclusivemaxInclusive- whether the numeric upper bound is inclusivesizeMin- inclusive lower bound for size contractssizeMax- inclusive upper bound for size contractsregexp- regular expression for pattern contracts- Returns:
valuewhen the contract passes- Throws:
IllegalStateException- when the return-value contract fails
-
requireReturnValue
public static byte requireReturnValue(byte value, String methodName, RuntimeContract contract, String description, boolean customDescription, @Nullable Class<? extends MaskRenderer> maskRenderer, long min, long max, boolean minInclusive, boolean maxInclusive, int sizeMin, int sizeMax, @Nullable String regexp) Evaluates a generated primitive return-value contract without boxing the value on the successful validation path. -
requireReturnValue
public static short requireReturnValue(short value, String methodName, RuntimeContract contract, String description, boolean customDescription, @Nullable Class<? extends MaskRenderer> maskRenderer, long min, long max, boolean minInclusive, boolean maxInclusive, int sizeMin, int sizeMax, @Nullable String regexp) Evaluates a generated primitive return-value contract without boxing the value on the successful validation path. -
requireReturnValue
public static int requireReturnValue(int value, String methodName, RuntimeContract contract, String description, boolean customDescription, @Nullable Class<? extends MaskRenderer> maskRenderer, long min, long max, boolean minInclusive, boolean maxInclusive, int sizeMin, int sizeMax, @Nullable String regexp) Evaluates a generated primitive return-value contract without boxing the value on the successful validation path. -
requireReturnValue
public static long requireReturnValue(long value, String methodName, RuntimeContract contract, String description, boolean customDescription, @Nullable Class<? extends MaskRenderer> maskRenderer, long min, long max, boolean minInclusive, boolean maxInclusive, int sizeMin, int sizeMax, @Nullable String regexp) Evaluates a generated primitive return-value contract without boxing the value on the successful validation path. -
requireReturnValue
public static float requireReturnValue(float value, String methodName, RuntimeContract contract, String description, boolean customDescription, @Nullable Class<? extends MaskRenderer> maskRenderer, long min, long max, boolean minInclusive, boolean maxInclusive, int sizeMin, int sizeMax, @Nullable String regexp) Evaluates a generated primitive return-value contract without boxing the value on the successful validation path. -
requireReturnValue
public static double requireReturnValue(double value, String methodName, RuntimeContract contract, String description, boolean customDescription, @Nullable Class<? extends MaskRenderer> maskRenderer, long min, long max, boolean minInclusive, boolean maxInclusive, int sizeMin, int sizeMax, @Nullable String regexp) Evaluates a generated primitive return-value contract without boxing the value on the successful validation path.
-