public class ValidatableUtil extends Object
Validatable objects and control when the
checks occur.| Constructor and Description |
|---|
ValidatableUtil() |
| Modifier and Type | Method and Description |
|---|---|
static void |
endValidateDisabled()
Ends the block started with
startValidateDisabled(). |
static void |
requireNonNull(Object tested,
String name)
requires that a reference not be null, or throw an InvalidMarshallableException with an appropriate message
|
static void |
requireTrue(boolean test,
String msg)
requires a test flag be true, otherwise throw an InvalidMarshallableException with the message provided
|
static void |
startValidateDisabled()
Starts a nestable block where validation is disabled.
|
static <T> T |
validate(T t)
Check an object is valid if it implements
Validatable. |
static boolean |
validateEnabled()
Checks if validation is enabled.
|
public static boolean validateEnabled()
true if validation is enabled, false otherwise.public static void startValidateDisabled()
public static void endValidateDisabled()
startValidateDisabled().public static <T> T validate(T t)
throws InvalidMarshallableException
Validatable.
For logging purposes validation can be turned off e.g. for toString()
with the following pattern
ValidatableUtil.startValidatableDisabled();
try {
// some code
} finally {
ValidatableUtil.endValidateDisabled();
}
T - type of objectt - object to validateInvalidMarshallableException - if validate() method failspublic static void requireNonNull(Object tested, String name) throws InvalidMarshallableException
tested - referencename - of referenceInvalidMarshallableException - if tested is nullpublic static void requireTrue(boolean test,
String msg)
throws InvalidMarshallableException
test - to check for truemsg - to use if falseInvalidMarshallableException - to throw is falseCopyright © 2026 Chronicle Software Ltd. All rights reserved.