public class InvalidValues extends Object
For example '42A' cannot be converted to an Integer. But temporarily it should be stored in an Integer field because it's entered by the user or was imported from an invalid source.
Invalid values cannot be persisted. They are only temporary objects in the vm.
The form class converts the String in an InvalidValues object. So the value can be stored in the Integer field. All validators should check for invalid values when validating. And when a form field displays a value it should check with the 'isInvalid' method if the value represents an invalid value.
Constructor and Description |
---|
InvalidValues() |
Modifier and Type | Method and Description |
---|---|
static BigDecimal |
createInvalidBigDecimal(String string) |
static Boolean |
createInvalidBoolean(String string) |
static <T extends Enum<T>> |
createInvalidEnum(Class<T> enumClass,
String value) |
static Integer |
createInvalidInteger(String string) |
static java.time.LocalDate |
createInvalidLocalDate(String string) |
static java.time.LocalDateTime |
createInvalidLocalDateTime(String string) |
static java.time.LocalTime |
createInvalidLocalTime(String string) |
static Long |
createInvalidLong(String string) |
static java.time.temporal.Temporal |
createInvalidPartial(String string) |
static String |
createInvalidString(String string) |
static String |
getInvalidValue(Object value) |
static String |
getMessage(Object object) |
static boolean |
isInvalid(Object value) |
public static boolean isInvalid(Object value)
value
- to be checkedpublic static String getInvalidValue(Object value)
value
- a value with one of the createInvalid methodsIllegalArgumentException
- if the value wasn't created by one of the
createInvalid methodspublic static <T extends Enum<T>> T createInvalidEnum(Class<T> enumClass, String value)
public static java.time.temporal.Temporal createInvalidPartial(String string)
public static java.time.LocalDate createInvalidLocalDate(String string)
public static java.time.LocalDateTime createInvalidLocalDateTime(String string)
public static java.time.LocalTime createInvalidLocalTime(String string)
public static BigDecimal createInvalidBigDecimal(String string)
Copyright © 2019. All rights reserved.