Class Conversions
java.lang.Object
com.univocity.parsers.conversions.Conversions
This class provides default instances of common implementations if
com.univocity.parsers.conversions.Conversion
, as well as useful methods for obtaining new instances of these.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final LowerCaseConversion
private static final ToStringConversion
private static final TrimConversion
private static final UpperCaseConversion
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionformatToBigDecimal
(String... numberFormats) Returns a new instance ofFormattedBigDecimalConversion
formatToBigDecimal
(BigDecimal defaultValueForNullString, String... numberFormats) Returns a new instance ofFormattedBigDecimalConversion
formatToBigDecimal
(BigDecimal defaultValueForNullString, String stringIfNull, String... numberFormats) Returns a new instance ofFormattedBigDecimalConversion
static <T extends Number>
NumericConversion<T>formatToNumber
(Class<T> numberType, String... numberFormats) Returns a new instance ofNumericConversion
static NumericConversion<Number>
formatToNumber
(String... numberFormats) Returns a new instance ofNumericConversion
static ValidatedConversion
Returns a new instance ofValidatedConversion
to validate values of a record Nulls and blanks are not be allowed by default.static ValidatedConversion
notBlank()
Returns aValidatedConversion
that doesn't allow null or blank valuesstatic ValidatedConversion
Returns aValidatedConversion
that verifies the format of a given valuestatic ValidatedConversion
notNull()
Returns aValidatedConversion
that doesn't allow null valuesstatic ValidatedConversion
Returns a new instance ofValidatedConversion
to validate values of a record Nulls and blanks are not be allowed by default.static RegexConversion
Returns a new instance ofRegexConversion
static ToStringConversion
string()
Returns a singleton instance ofToStringConversion
static BigDecimalConversion
Returns a new instance ofBigDecimalConversion
static BigIntegerConversion
Returns a new instance ofBigIntegerConversion
static BooleanConversion
Returns a new instance ofBooleanConversion
that converts the string "true" to true, and the String "false" to false.static BooleanConversion
toBoolean
(Boolean defaultValueForNullString, String defaultValueForNullBoolean, String[] valuesForTrue, String[] valuesForFalse) Returns a new instance ofBooleanConversion
static BooleanConversion
toBoolean
(Boolean defaultValueForNullString, String defaultValueForNullBoolean, String valueForTrue, String valueForFalse) Returns a new instance ofBooleanConversion
static BooleanConversion
Returns a new instance ofBooleanConversion
static BooleanConversion
Returns a new instance ofBooleanConversion
static ByteConversion
toByte()
Returns a new instance ofByteConversion
static CalendarConversion
toCalendar
(String... dateFormats) Returns a new instance ofCalendarConversion
static CalendarConversion
toCalendar
(Calendar dateIfNull, String... dateFormats) Returns a new instance ofCalendarConversion
static CalendarConversion
toCalendar
(Calendar dateIfNull, String stringIfNull, String... dateFormats) Returns a new instance ofCalendarConversion
static CalendarConversion
toCalendar
(Locale locale, String... dateFormats) Returns a new instance ofCalendarConversion
static CalendarConversion
toCalendar
(Locale locale, Calendar dateIfNull, String... dateFormats) Returns a new instance ofCalendarConversion
static CalendarConversion
toCalendar
(Locale locale, Calendar dateIfNull, String stringIfNull, String... dateFormats) Returns a new instance ofCalendarConversion
static CalendarConversion
toCalendar
(TimeZone timeZone, Locale locale, Calendar dateIfNull, String stringIfNull, String... dateFormats) Returns a new instance ofCalendarConversion
static CharacterConversion
toChar()
Returns a new instance ofCharacterConversion
static CharacterConversion
Returns a new instance ofCharacterConversion
static CharacterConversion
Returns a new instance ofCharacterConversion
static DateConversion
Returns a new instance ofDateConversion
static DateConversion
Returns a new instance ofDateConversion
static DateConversion
Returns a new instance ofDateConversion
static DateConversion
Returns a new instance ofDateConversion
static DateConversion
Returns a new instance ofDateConversion
static DateConversion
Returns a new instance ofDateConversion
static DateConversion
toDate
(TimeZone timeZone, Locale locale, Date dateIfNull, String stringIfNull, String... dateFormats) Returns a new instance ofDateConversion
static DoubleConversion
toDouble()
Returns a new instance ofDoubleConversion
static <T extends Enum<T>>
EnumConversion<T>Returns a new instance ofEnumConversion
static <T extends Enum<T>>
EnumConversion<T>toEnum
(Class<T> enumType, EnumSelector... selectors) Returns a new instance ofEnumConversion
static <T extends Enum<T>>
EnumConversion<T>toEnum
(Class<T> enumType, String customEnumElement, EnumSelector... selectors) Returns a new instance ofEnumConversion
static <T extends Enum<T>>
EnumConversion<T>toEnum
(Class<T> enumType, T valueIfStringIsNull, String valueIfEnumIsNull, String customEnumElement, EnumSelector... selectors) Returns a new instance ofEnumConversion
static FloatConversion
toFloat()
Returns a new instance ofFloatConversion
static FormattedDateConversion
toFormattedDate
(String pattern) Returns a new instance ofFormattedDateConversion
static FormattedDateConversion
toFormattedDate
(String pattern, String valueIfObjectIsNull) Returns a new instance ofFormattedDateConversion
static FormattedDateConversion
toFormattedDate
(String pattern, Locale locale) Returns a new instance ofFormattedDateConversion
static FormattedDateConversion
toFormattedDate
(String pattern, Locale locale, String valueIfObjectIsNull) Returns a new instance ofFormattedDateConversion
static IntegerConversion
Returns a new instance ofIntegerConversion
static LongConversion
toLong()
Returns a new instance ofLongConversion
static LowerCaseConversion
Returns a singleton instance ofLowerCaseConversion
static NullStringConversion
Returns a new instance ofNullStringConversion
static ShortConversion
toShort()
Returns a new instance ofShortConversion
static UpperCaseConversion
Returns a singleton instance ofUpperCaseConversion
static TrimConversion
trim()
Returns a singleton instance ofTrimConversion
static TrimConversion
trim
(int length) Returns aTrimConversion
that limits the output to a fixed lengthstatic ValidatedConversion
validate
(boolean nullable, boolean allowBlanks) Returns aValidatedConversion
that checks for nulls or blank values.static ValidatedConversion
Returns aValidatedConversion
that checks for nulls or blank values.static ValidatedConversion
Returns a new instance ofValidatedConversion
to validate values of a recordstatic ValidatedConversion
validate
(boolean nullable, boolean allowBlanks, String[] oneOf, String[] noneOf, String regexToMatch) Returns a new instance ofValidatedConversion
to validate values of a record
-
Field Details
-
upperCase
-
lowerCase
-
trim
-
toString
-
-
Constructor Details
-
Conversions
private Conversions()
-
-
Method Details
-
string
Returns a singleton instance ofToStringConversion
- Returns:
- a singleton instance of
ToStringConversion
-
toUpperCase
Returns a singleton instance ofUpperCaseConversion
- Returns:
- a singleton instance of
UpperCaseConversion
-
toLowerCase
Returns a singleton instance ofLowerCaseConversion
- Returns:
- a singleton instance of
LowerCaseConversion
-
trim
Returns a singleton instance ofTrimConversion
- Returns:
- a singleton instance of
TrimConversion
-
trim
Returns aTrimConversion
that limits the output to a fixed length- Parameters:
length
- the maximum length a value can contain. Characters after this limit will be discarded.- Returns:
- a trim-to-length conversion
-
replace
Returns a new instance ofRegexConversion
- Parameters:
replaceRegex
- the regular expression used to match contents of a given input Stringreplacement
- the replacement content to replace any contents matched by the given regular expression- Returns:
- the new instance of
RegexConversion
created with the given parameters.
-
toNull
Returns a new instance ofNullStringConversion
- Parameters:
nullRepresentations
- the sequence of Strings that represent a null value.- Returns:
- the new instance of
NullStringConversion
created with the given parameters.
-
toDate
Returns a new instance ofDateConversion
- Parameters:
locale
- theLocale
that determines how the date mask should be formatted.dateFormats
- list of acceptable date patterns. The first pattern in this sequence will be used to convert a Date into a String inDateConversion.revert(Date)
.- Returns:
- the new instance of
DateConversion
created with the given parameters.
-
toDate
Returns a new instance ofDateConversion
- Parameters:
dateFormats
- list of acceptable date patterns. The first pattern in this sequence will be used to convert a Date into a String inDateConversion.revert(Date)
.- Returns:
- the new instance of
DateConversion
created with the given parameters.
-
toDate
Returns a new instance ofDateConversion
- Parameters:
locale
- theLocale
that determines how the date mask should be formatted.dateIfNull
- default Date value to be returned when the input String is null. Used whenObjectConversion.execute(String)
is invoked.dateFormats
- list of acceptable date patterns. The first pattern in this sequence will be used to convert a Date into a String inDateConversion.revert(Date)
.- Returns:
- the new instance of
DateConversion
created with the given parameters.
-
toDate
Returns a new instance ofDateConversion
- Parameters:
dateIfNull
- default Date value to be returned when the input String is null. Used whenObjectConversion.execute(String)
is invoked.dateFormats
- list of acceptable date patterns. The first pattern in this sequence will be used to convert a Date into a String inDateConversion.revert(Date)
.- Returns:
- the new instance of
DateConversion
created with the given parameters.
-
toDate
public static DateConversion toDate(TimeZone timeZone, Locale locale, Date dateIfNull, String stringIfNull, String... dateFormats) Returns a new instance ofDateConversion
- Parameters:
timeZone
- theTimeZone
of the date to be formattedlocale
- theLocale
that determines how the date mask should be formatted.dateIfNull
- default Date value to be returned when the input String is null. Used whenObjectConversion.execute(String)
is invoked.stringIfNull
- default String value to be returned when a Date input is null. Used whenDateConversion.revert(Date)
is invoked.dateFormats
- list of acceptable date patterns. The first pattern in this sequence will be used to convert a Date into a String inDateConversion.revert(Date)
.- Returns:
- the new instance of
DateConversion
created with the given parameters.
-
toDate
public static DateConversion toDate(Locale locale, Date dateIfNull, String stringIfNull, String... dateFormats) Returns a new instance ofDateConversion
- Parameters:
locale
- theLocale
that determines how the date mask should be formatted.dateIfNull
- default Date value to be returned when the input String is null. Used whenObjectConversion.execute(String)
is invoked.stringIfNull
- default String value to be returned when a Date input is null. Used whenDateConversion.revert(Date)
is invoked.dateFormats
- list of acceptable date patterns. The first pattern in this sequence will be used to convert a Date into a String inDateConversion.revert(Date)
.- Returns:
- the new instance of
DateConversion
created with the given parameters.
-
toDate
Returns a new instance ofDateConversion
- Parameters:
dateIfNull
- default Date value to be returned when the input String is null. Used whenObjectConversion.execute(String)
is invoked.stringIfNull
- default String value to be returned when a Date input is null. Used whenDateConversion.revert(Date)
is invoked.dateFormats
- list of acceptable date patterns. The first pattern in this sequence will be used to convert a Date into a String inDateConversion.revert(Date)
.- Returns:
- the new instance of
DateConversion
created with the given parameters.
-
toCalendar
Returns a new instance ofCalendarConversion
- Parameters:
locale
- theLocale
that determines how the date mask should be formatted.dateFormats
- list of acceptable date patterns. The first pattern in this sequence will be used to convert a Calendar into a String inCalendarConversion.revert(Calendar)
.- Returns:
- the new instance of
CalendarConversion
created with the given parameters.
-
toCalendar
Returns a new instance ofCalendarConversion
- Parameters:
dateFormats
- list of acceptable date patterns. The first pattern in this sequence will be used to convert a Calendar into a String inCalendarConversion.revert(Calendar)
.- Returns:
- the new instance of
CalendarConversion
created with the given parameters.
-
toCalendar
public static CalendarConversion toCalendar(Locale locale, Calendar dateIfNull, String... dateFormats) Returns a new instance ofCalendarConversion
- Parameters:
locale
- theLocale
that determines how the date mask should be formatted.dateIfNull
- default Calendar value to be returned when the input String is null. Used whenObjectConversion.execute(String)
is invoked.dateFormats
- list of acceptable date patterns. The first pattern in this sequence will be used to convert a Calendar into a String inCalendarConversion.revert(Calendar)
.- Returns:
- the new instance of
CalendarConversion
created with the given parameters.
-
toCalendar
Returns a new instance ofCalendarConversion
- Parameters:
dateIfNull
- default Calendar value to be returned when the input String is null. Used whenObjectConversion.execute(String)
is invoked.dateFormats
- list of acceptable date patterns. The first pattern in this sequence will be used to convert a Calendar into a String inCalendarConversion.revert(Calendar)
.- Returns:
- the new instance of
CalendarConversion
created with the given parameters.
-
toCalendar
public static CalendarConversion toCalendar(Locale locale, Calendar dateIfNull, String stringIfNull, String... dateFormats) Returns a new instance ofCalendarConversion
- Parameters:
locale
- theLocale
that determines how the date mask should be formatted.dateIfNull
- default Calendar value to be returned when the input String is null. Used whenObjectConversion.execute(String)
is invoked.stringIfNull
- default String value to be returned when a Date input is null. Used whenCalendarConversion.revert(Calendar)
is invoked.dateFormats
- list of acceptable date patterns. The first pattern in this sequence will be used to convert a Calendar into a String inCalendarConversion.revert(Calendar)
.- Returns:
- the new instance of
CalendarConversion
created with the given parameters.
-
toCalendar
public static CalendarConversion toCalendar(TimeZone timeZone, Locale locale, Calendar dateIfNull, String stringIfNull, String... dateFormats) Returns a new instance ofCalendarConversion
- Parameters:
timeZone
- theTimeZone
to be consideredlocale
- theLocale
that determines how the date mask should be formatted.dateIfNull
- default Calendar value to be returned when the input String is null. Used whenObjectConversion.execute(String)
is invoked.stringIfNull
- default String value to be returned when a Date input is null. Used whenCalendarConversion.revert(Calendar)
is invoked.dateFormats
- list of acceptable date patterns. The first pattern in this sequence will be used to convert a Calendar into a String inCalendarConversion.revert(Calendar)
.- Returns:
- the new instance of
CalendarConversion
created with the given parameters.
-
toCalendar
public static CalendarConversion toCalendar(Calendar dateIfNull, String stringIfNull, String... dateFormats) Returns a new instance ofCalendarConversion
- Parameters:
dateIfNull
- default Calendar value to be returned when the input String is null. Used whenObjectConversion.execute(String)
is invoked.stringIfNull
- default String value to be returned when a Date input is null. Used whenCalendarConversion.revert(Calendar)
is invoked.dateFormats
- list of acceptable date patterns. The first pattern in this sequence will be used to convert a Calendar into a String inCalendarConversion.revert(Calendar)
.- Returns:
- the new instance of
CalendarConversion
created with the given parameters.
-
toByte
Returns a new instance ofByteConversion
- Returns:
- a new instance of
ByteConversion
-
toShort
Returns a new instance ofShortConversion
- Returns:
- a new instance of
ShortConversion
-
toInteger
Returns a new instance ofIntegerConversion
- Returns:
- a new instance of
IntegerConversion
-
toLong
Returns a new instance ofLongConversion
- Returns:
- a new instance of
LongConversion
-
toBigInteger
Returns a new instance ofBigIntegerConversion
- Returns:
- a new instance of
BigIntegerConversion
-
toFloat
Returns a new instance ofFloatConversion
- Returns:
- a new instance of
FloatConversion
-
toDouble
Returns a new instance ofDoubleConversion
- Returns:
- a new instance of
DoubleConversion
-
toBigDecimal
Returns a new instance ofBigDecimalConversion
- Returns:
- a new instance of
BigDecimalConversion
-
formatToNumber
Returns a new instance ofNumericConversion
- Parameters:
numberFormats
- list of acceptable numeric patterns. The first pattern in this sequence will be used to convert a Number into a String inNumericConversion.revert(Number)
.- Returns:
- a new instance of
NumericConversion
that supports the given number formats
-
formatToNumber
public static <T extends Number> NumericConversion<T> formatToNumber(Class<T> numberType, String... numberFormats) Returns a new instance ofNumericConversion
- Type Parameters:
T
- type of number- Parameters:
numberType
- type of number to be returned. The resulting instance ofNumber
will be cast to the expected type.numberFormats
- list of acceptable numeric patterns. The first pattern in this sequence will be used to convert a Number into a String inNumericConversion.revert(Number)
.- Returns:
- a new instance of
NumericConversion
that supports the given number formats
-
formatToBigDecimal
Returns a new instance ofFormattedBigDecimalConversion
- Parameters:
numberFormats
- list of acceptable numeric patterns. The first pattern in this sequence will be used to convert a BigDecimal into a String inNumericConversion.revert(Number)
.- Returns:
- a new instance of
FormattedBigDecimalConversion
that supports the given number formats
-
formatToBigDecimal
public static FormattedBigDecimalConversion formatToBigDecimal(BigDecimal defaultValueForNullString, String... numberFormats) Returns a new instance ofFormattedBigDecimalConversion
- Parameters:
defaultValueForNullString
- default BigDecimal to be returned when the input String is null. Used whenObjectConversion.execute(String)
is invoked.numberFormats
- list of acceptable numeric patterns. The first pattern in this sequence will be used to convert a BigDecimal into a String inNumericConversion.revert(Number)
.- Returns:
- a new instance of
FormattedBigDecimalConversion
that supports the given number formats
-
formatToBigDecimal
public static FormattedBigDecimalConversion formatToBigDecimal(BigDecimal defaultValueForNullString, String stringIfNull, String... numberFormats) Returns a new instance ofFormattedBigDecimalConversion
- Parameters:
defaultValueForNullString
- default BigDecimal to be returned when the input String is null. Used whenObjectConversion.execute(String)
is invoked.stringIfNull
- default String value to be returned when a BigDecimal input is null. Used whenFormattedBigDecimalConversion#revert(BigDecimal)
is invoked.numberFormats
- list of acceptable numeric patterns. The first pattern in this sequence will be used to convert a BigDecimal into a String inNumericConversion.revert(Number)
.- Returns:
- a new instance of
FormattedBigDecimalConversion
that supports the given number formats
-
toBoolean
public static BooleanConversion toBoolean(Boolean defaultValueForNullString, String defaultValueForNullBoolean, String[] valuesForTrue, String[] valuesForFalse) Returns a new instance ofBooleanConversion
- Parameters:
defaultValueForNullString
- default Boolean value to be returned when the input String is null. Used whenObjectConversion.execute(String)
is invoked.defaultValueForNullBoolean
- default String value to be returned when a Boolean input is null. Used whenBooleanConversion.revert(Boolean)
is invoked.valuesForTrue
- Strings that identify the boolean value true. The first element will be returned when executingBooleanConversion.revert(true)
valuesForFalse
- Strings that identify the boolean value false. The first element will be returned when executingBooleanConversion.revert(false)
- Returns:
- a new instance of
BooleanConversion
with support for multiple representations of true and false
-
toBoolean
public static BooleanConversion toBoolean(Boolean defaultValueForNullString, String defaultValueForNullBoolean, String valueForTrue, String valueForFalse) Returns a new instance ofBooleanConversion
- Parameters:
defaultValueForNullString
- default Boolean value to be returned when the input String is null. Used whenObjectConversion.execute(String)
is invoked.defaultValueForNullBoolean
- default String value to be returned when a Boolean input is null. Used whenBooleanConversion.revert(Boolean)
is invoked.valueForTrue
- String that identify the boolean value true.valueForFalse
- String that identify the boolean value false.- Returns:
- a new instance of
BooleanConversion
with support for multiple representations of true and false
-
toBoolean
Returns a new instance ofBooleanConversion
- Parameters:
valuesForTrue
- Strings that identify the boolean value true. The first element will be returned when executingBooleanConversion.revert(true)
valuesForFalse
- Strings that identify the boolean value false. The first element will be returned when executingBooleanConversion.revert(false)
- Returns:
- a new instance of
BooleanConversion
with support for multiple representations of true and false
-
toBoolean
Returns a new instance ofBooleanConversion
that converts the string "true" to true, and the String "false" to false.- Returns:
- a new instance of
BooleanConversion
with support for multiple representations of true and false
-
toBoolean
Returns a new instance ofBooleanConversion
- Parameters:
valueForTrue
- String that identifies the boolean value true.valueForFalse
- String that identifies the boolean value false.- Returns:
- a new instance of
BooleanConversion
with support for multiple representations of true and false
-
toChar
Returns a new instance ofCharacterConversion
- Returns:
- a new instance of
CharacterConversion
-
toChar
public static CharacterConversion toChar(Character defaultValueForNullString, String defaultValueForNullChar) Returns a new instance ofCharacterConversion
- Parameters:
defaultValueForNullString
- default Character value to be returned when the input String is null. Used whenObjectConversion.execute(String)
is invoked.defaultValueForNullChar
- default String value to be returned when a Character input is null. Used whenCharacterConversion#revert(Character)
is invoked.- Returns:
- a new instance of
CharacterConversion
-
toChar
Returns a new instance ofCharacterConversion
- Parameters:
defaultValueForNullString
- default Character value to be returned when the input String is null. Used whenObjectConversion.execute(String)
is invoked.- Returns:
- a new instance of
CharacterConversion
-
toEnum
Returns a new instance ofEnumConversion
- Type Parameters:
T
- theenum
type- Parameters:
enumType
- the enumeration type to be converted from/toString
- Returns:
- new instance of
EnumConversion
-
toEnum
public static <T extends Enum<T>> EnumConversion<T> toEnum(Class<T> enumType, EnumSelector... selectors) Returns a new instance ofEnumConversion
- Type Parameters:
T
- theenum
type- Parameters:
enumType
- the enumeration type to be converted from/toString
selectors
- the selection elements of the enumeration to use for matchingString
s.- Returns:
- new instance of
EnumConversion
-
toEnum
public static <T extends Enum<T>> EnumConversion<T> toEnum(Class<T> enumType, String customEnumElement, EnumSelector... selectors) Returns a new instance ofEnumConversion
- Type Parameters:
T
- theenum
type- Parameters:
enumType
- the enumeration type to be converted from/toString
customEnumElement
- name of custom element of the enumeration (attribute or method) whose values should be used to match equivalentString
s.selectors
- the selection elements of the enumeration to use for matchingString
s.- Returns:
- new instance of
EnumConversion
-
toEnum
public static <T extends Enum<T>> EnumConversion<T> toEnum(Class<T> enumType, T valueIfStringIsNull, String valueIfEnumIsNull, String customEnumElement, EnumSelector... selectors) Returns a new instance ofEnumConversion
- Type Parameters:
T
- theenum
type- Parameters:
enumType
- the enumeration type to be converted from/toString
valueIfStringIsNull
- the default enumeration constant to use if the inputString
isnull
valueIfEnumIsNull
- the defaultString
value to use if the inputenum
constant isnull
customEnumElement
- name of custom element of the enumeration (attribute or method) whose values should be used to match equivalentString
s.selectors
- the selection elements of the enumeration to use for matchingString
s.- Returns:
- new instance of
EnumConversion
-
toFormattedDate
Returns a new instance ofFormattedDateConversion
- Parameters:
pattern
- Date mask to be be used to convert a date object (i.e.Date
orCalendar
) into a String.- Returns:
- new instance of
FormattedDateConversion
configured with the given parameters
-
toFormattedDate
Returns a new instance ofFormattedDateConversion
- Parameters:
pattern
- Date mask to be be used to convert a date object (i.e.Date
orCalendar
) into a String.valueIfObjectIsNull
- Default string value to be returned when the input object is null.- Returns:
- new instance of
FormattedDateConversion
configured with the given parameters
-
toFormattedDate
Returns a new instance ofFormattedDateConversion
- Parameters:
pattern
- Date mask to be be used to convert a date object (i.e.Date
orCalendar
) into a String.locale
- TheLocale
that determines how the date pattern should be formatted.- Returns:
- new instance of
FormattedDateConversion
configured with the given parameters
-
toFormattedDate
public static FormattedDateConversion toFormattedDate(String pattern, Locale locale, String valueIfObjectIsNull) Returns a new instance ofFormattedDateConversion
- Parameters:
pattern
- Date mask to be be used to convert a date object (i.e.Date
orCalendar
) into a String.locale
- TheLocale
that determines how the date pattern should be formatted.valueIfObjectIsNull
- Default string value to be returned when the input object is null.- Returns:
- new instance of
FormattedDateConversion
configured with the given parameters
-
notNull
Returns aValidatedConversion
that doesn't allow null values- Returns:
- a not-null validator
-
notBlank
Returns aValidatedConversion
that doesn't allow null or blank values- Returns:
- a not-blank validator
-
notBlank
Returns aValidatedConversion
that verifies the format of a given value- Parameters:
regexToMatch
- regular expression to match and ensure the value has a given format- Returns:
- a value format validator
-
validate
Returns aValidatedConversion
that checks for nulls or blank values.- Parameters:
nullable
- flag to indicate whether values can be nullallowBlanks
- flag to indicate whether values can be blank- Returns:
- new instance of
ValidatedConversion
configured with the given parameters
-
validate
public static ValidatedConversion validate(boolean nullable, boolean allowBlanks, String[] oneOf, String[] noneOf) Returns a new instance ofValidatedConversion
to validate values of a record- Parameters:
nullable
- flag to indicate whether values can be nullallowBlanks
- flag to indicate whether values can be blankoneOf
- list of accepted values.noneOf
- list of unacceptable values- Returns:
- new instance of
ValidatedConversion
configured with the given parameters
-
validate
public static ValidatedConversion validate(boolean nullable, boolean allowBlanks, String regexToMatch) Returns aValidatedConversion
that checks for nulls or blank values.- Parameters:
nullable
- flag to indicate whether values can be nullallowBlanks
- flag to indicate whether values can be blankregexToMatch
- regular expression to match and ensure the value has a given format- Returns:
- new instance of
ValidatedConversion
configured with the given parameters
-
validate
public static ValidatedConversion validate(boolean nullable, boolean allowBlanks, String[] oneOf, String[] noneOf, String regexToMatch) Returns a new instance ofValidatedConversion
to validate values of a record- Parameters:
nullable
- flag to indicate whether values can be nullallowBlanks
- flag to indicate whether values can be blankoneOf
- list of accepted values.noneOf
- list of unacceptable valuesregexToMatch
- regular expression to match and ensure the value has a given format- Returns:
- new instance of
ValidatedConversion
configured with the given parameters
-
oneOf
Returns a new instance ofValidatedConversion
to validate values of a record Nulls and blanks are not be allowed by default.- Parameters:
oneOf
- list of accepted values.- Returns:
- new instance of
ValidatedConversion
configured with the given parameters
-
noneOf
Returns a new instance ofValidatedConversion
to validate values of a record Nulls and blanks are not be allowed by default.- Parameters:
noneOf
- list of values that are not allowed.- Returns:
- new instance of
ValidatedConversion
configured with the given parameters
-