public abstract class Verifiable extends Object implements Serializable
This Class contains checks for different fields that is used as part of the input and output Objects. Reason for having this, is because it is important that all data is 100% reliable when it is coming in so it can be processed correctly without any errors occurring.
Although all Classes and Fields are annotated with the necessary checks, this is not a guarantee that the data will also correctly be passed through, since different frameworks may choose to discard the Annotated requirements or have flaws. Hence, this simple PoJo approach will act as a last line of defense before data is being processed.
Constructor and Description |
---|
Verifiable() |
Modifier and Type | Method and Description |
---|---|
protected static void |
checkIntegerWithMax(Map<String,String> errors,
String field,
int value,
int max,
String message) |
protected static void |
checkNotNull(Map<String,String> errors,
String field,
Object value,
String message) |
protected static void |
checkNotNullAndValidId(Map<String,String> errors,
String field,
String value,
String message) |
protected static void |
checkNotNullEmptyOrTooLong(Map<String,String> errors,
String field,
String value,
int maxLength,
String message) |
protected static void |
checkNotNullOrEmpty(Map<String,String> errors,
String field,
byte[] value,
String message) |
protected static void |
checkNotNullOrEmpty(Map<String,String> errors,
String field,
String value,
String message) |
protected static void |
checkNotTooLong(Map<String,String> errors,
String field,
String value,
int maxLength,
String message) |
protected static void |
checkUrl(Map<String,String> errors,
String value) |
protected static void |
checkValidId(Map<String,String> errors,
String field,
String value,
String message) |
static boolean |
isEmpty(String value)
Method added as per PMD rule InefficientEmptyStringCheck.
|
abstract Map<String,String> |
validate()
Simple Validation method, which checks if the required values are usable
or not.
|
public abstract Map<String,String> validate()
protected static void checkNotNull(Map<String,String> errors, String field, Object value, String message)
protected static void checkNotNullOrEmpty(Map<String,String> errors, String field, byte[] value, String message)
protected static void checkNotNullOrEmpty(Map<String,String> errors, String field, String value, String message)
protected static void checkNotNullEmptyOrTooLong(Map<String,String> errors, String field, String value, int maxLength, String message)
protected static void checkNotTooLong(Map<String,String> errors, String field, String value, int maxLength, String message)
protected static void checkValidId(Map<String,String> errors, String field, String value, String message)
protected static void checkNotNullAndValidId(Map<String,String> errors, String field, String value, String message)
protected static void checkIntegerWithMax(Map<String,String> errors, String field, int value, int max, String message)
public static boolean isEmpty(String value)
value
- Nullable value to check if is emptyCopyright © 2019 JavaDog.io. All rights reserved.