Class Conversions
- java.lang.Object
-
- com.univocity.parsers.conversions.Conversions
-
public class Conversions extends java.lang.ObjectThis class provides default instances of common implementations ifcom.univocity.parsers.conversions.Conversion, as well as useful methods for obtaining new instances of these.- Author:
- Univocity Software Pty Ltd - parsers@univocity.com
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static FormattedBigDecimalConversionformatToBigDecimal(java.lang.String... numberFormats)Returns a new instance ofFormattedBigDecimalConversionstatic FormattedBigDecimalConversionformatToBigDecimal(java.math.BigDecimal defaultValueForNullString, java.lang.String... numberFormats)Returns a new instance ofFormattedBigDecimalConversionstatic FormattedBigDecimalConversionformatToBigDecimal(java.math.BigDecimal defaultValueForNullString, java.lang.String stringIfNull, java.lang.String... numberFormats)Returns a new instance ofFormattedBigDecimalConversionstatic <T extends java.lang.Number>
NumericConversion<T>formatToNumber(java.lang.Class<T> numberType, java.lang.String... numberFormats)Returns a new instance ofNumericConversionstatic NumericConversion<java.lang.Number>formatToNumber(java.lang.String... numberFormats)Returns a new instance ofNumericConversionstatic ValidatedConversionnoneOf(java.lang.String... noneOf)Returns a new instance ofValidatedConversionto validate values of a record Nulls and blanks are not be allowed by default.static ValidatedConversionnotBlank()Returns aValidatedConversionthat doesn't allow null or blank valuesstatic ValidatedConversionnotBlank(java.lang.String regexToMatch)Returns aValidatedConversionthat verifies the format of a given valuestatic ValidatedConversionnotNull()Returns aValidatedConversionthat doesn't allow null valuesstatic ValidatedConversiononeOf(java.lang.String... oneOf)Returns a new instance ofValidatedConversionto validate values of a record Nulls and blanks are not be allowed by default.static RegexConversionreplace(java.lang.String replaceRegex, java.lang.String replacement)Returns a new instance ofRegexConversionstatic ToStringConversionstring()Returns a singleton instance ofToStringConversionstatic BigDecimalConversiontoBigDecimal()Returns a new instance ofBigDecimalConversionstatic BigIntegerConversiontoBigInteger()Returns a new instance ofBigIntegerConversionstatic BooleanConversiontoBoolean()Returns a new instance ofBooleanConversionthat converts the string "true" to true, and the String "false" to false.static BooleanConversiontoBoolean(java.lang.Boolean defaultValueForNullString, java.lang.String defaultValueForNullBoolean, java.lang.String[] valuesForTrue, java.lang.String[] valuesForFalse)Returns a new instance ofBooleanConversionstatic BooleanConversiontoBoolean(java.lang.Boolean defaultValueForNullString, java.lang.String defaultValueForNullBoolean, java.lang.String valueForTrue, java.lang.String valueForFalse)Returns a new instance ofBooleanConversionstatic BooleanConversiontoBoolean(java.lang.String[] valuesForTrue, java.lang.String[] valuesForFalse)Returns a new instance ofBooleanConversionstatic BooleanConversiontoBoolean(java.lang.String valueForTrue, java.lang.String valueForFalse)Returns a new instance ofBooleanConversionstatic ByteConversiontoByte()Returns a new instance ofByteConversionstatic CalendarConversiontoCalendar(java.lang.String... dateFormats)Returns a new instance ofCalendarConversionstatic CalendarConversiontoCalendar(java.util.Calendar dateIfNull, java.lang.String... dateFormats)Returns a new instance ofCalendarConversionstatic CalendarConversiontoCalendar(java.util.Calendar dateIfNull, java.lang.String stringIfNull, java.lang.String... dateFormats)Returns a new instance ofCalendarConversionstatic CalendarConversiontoCalendar(java.util.Locale locale, java.lang.String... dateFormats)Returns a new instance ofCalendarConversionstatic CalendarConversiontoCalendar(java.util.Locale locale, java.util.Calendar dateIfNull, java.lang.String... dateFormats)Returns a new instance ofCalendarConversionstatic CalendarConversiontoCalendar(java.util.Locale locale, java.util.Calendar dateIfNull, java.lang.String stringIfNull, java.lang.String... dateFormats)Returns a new instance ofCalendarConversionstatic CalendarConversiontoCalendar(java.util.TimeZone timeZone, java.util.Locale locale, java.util.Calendar dateIfNull, java.lang.String stringIfNull, java.lang.String... dateFormats)Returns a new instance ofCalendarConversionstatic CharacterConversiontoChar()Returns a new instance ofCharacterConversionstatic CharacterConversiontoChar(java.lang.Character defaultValueForNullString)Returns a new instance ofCharacterConversionstatic CharacterConversiontoChar(java.lang.Character defaultValueForNullString, java.lang.String defaultValueForNullChar)Returns a new instance ofCharacterConversionstatic DateConversiontoDate(java.lang.String... dateFormats)Returns a new instance ofDateConversionstatic DateConversiontoDate(java.util.Date dateIfNull, java.lang.String... dateFormats)Returns a new instance ofDateConversionstatic DateConversiontoDate(java.util.Date dateIfNull, java.lang.String stringIfNull, java.lang.String... dateFormats)Returns a new instance ofDateConversionstatic DateConversiontoDate(java.util.Locale locale, java.lang.String... dateFormats)Returns a new instance ofDateConversionstatic DateConversiontoDate(java.util.Locale locale, java.util.Date dateIfNull, java.lang.String... dateFormats)Returns a new instance ofDateConversionstatic DateConversiontoDate(java.util.Locale locale, java.util.Date dateIfNull, java.lang.String stringIfNull, java.lang.String... dateFormats)Returns a new instance ofDateConversionstatic DateConversiontoDate(java.util.TimeZone timeZone, java.util.Locale locale, java.util.Date dateIfNull, java.lang.String stringIfNull, java.lang.String... dateFormats)Returns a new instance ofDateConversionstatic DoubleConversiontoDouble()Returns a new instance ofDoubleConversionstatic <T extends java.lang.Enum<T>>
EnumConversion<T>toEnum(java.lang.Class<T> enumType)Returns a new instance ofEnumConversionstatic <T extends java.lang.Enum<T>>
EnumConversion<T>toEnum(java.lang.Class<T> enumType, EnumSelector... selectors)Returns a new instance ofEnumConversionstatic <T extends java.lang.Enum<T>>
EnumConversion<T>toEnum(java.lang.Class<T> enumType, java.lang.String customEnumElement, EnumSelector... selectors)Returns a new instance ofEnumConversionstatic <T extends java.lang.Enum<T>>
EnumConversion<T>toEnum(java.lang.Class<T> enumType, T valueIfStringIsNull, java.lang.String valueIfEnumIsNull, java.lang.String customEnumElement, EnumSelector... selectors)Returns a new instance ofEnumConversionstatic FloatConversiontoFloat()Returns a new instance ofFloatConversionstatic FormattedDateConversiontoFormattedDate(java.lang.String pattern)Returns a new instance ofFormattedDateConversionstatic FormattedDateConversiontoFormattedDate(java.lang.String pattern, java.lang.String valueIfObjectIsNull)Returns a new instance ofFormattedDateConversionstatic FormattedDateConversiontoFormattedDate(java.lang.String pattern, java.util.Locale locale)Returns a new instance ofFormattedDateConversionstatic FormattedDateConversiontoFormattedDate(java.lang.String pattern, java.util.Locale locale, java.lang.String valueIfObjectIsNull)Returns a new instance ofFormattedDateConversionstatic IntegerConversiontoInteger()Returns a new instance ofIntegerConversionstatic LongConversiontoLong()Returns a new instance ofLongConversionstatic LowerCaseConversiontoLowerCase()Returns a singleton instance ofLowerCaseConversionstatic NullStringConversiontoNull(java.lang.String... nullRepresentations)Returns a new instance ofNullStringConversionstatic ShortConversiontoShort()Returns a new instance ofShortConversionstatic UpperCaseConversiontoUpperCase()Returns a singleton instance ofUpperCaseConversionstatic TrimConversiontrim()Returns a singleton instance ofTrimConversionstatic TrimConversiontrim(int length)Returns aTrimConversionthat limits the output to a fixed lengthstatic ValidatedConversionvalidate(boolean nullable, boolean allowBlanks)Returns aValidatedConversionthat checks for nulls or blank values.static ValidatedConversionvalidate(boolean nullable, boolean allowBlanks, java.lang.String regexToMatch)Returns aValidatedConversionthat checks for nulls or blank values.static ValidatedConversionvalidate(boolean nullable, boolean allowBlanks, java.lang.String[] oneOf, java.lang.String[] noneOf)Returns a new instance ofValidatedConversionto validate values of a recordstatic ValidatedConversionvalidate(boolean nullable, boolean allowBlanks, java.lang.String[] oneOf, java.lang.String[] noneOf, java.lang.String regexToMatch)Returns a new instance ofValidatedConversionto validate values of a record
-
-
-
Method Detail
-
string
public static ToStringConversion string()
Returns a singleton instance ofToStringConversion- Returns:
- a singleton instance of
ToStringConversion
-
toUpperCase
public static UpperCaseConversion toUpperCase()
Returns a singleton instance ofUpperCaseConversion- Returns:
- a singleton instance of
UpperCaseConversion
-
toLowerCase
public static LowerCaseConversion toLowerCase()
Returns a singleton instance ofLowerCaseConversion- Returns:
- a singleton instance of
LowerCaseConversion
-
trim
public static TrimConversion trim()
Returns a singleton instance ofTrimConversion- Returns:
- a singleton instance of
TrimConversion
-
trim
public static TrimConversion trim(int length)
Returns aTrimConversionthat 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
public static RegexConversion replace(java.lang.String replaceRegex, java.lang.String replacement)
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
RegexConversioncreated with the given parameters.
-
toNull
public static NullStringConversion toNull(java.lang.String... nullRepresentations)
Returns a new instance ofNullStringConversion- Parameters:
nullRepresentations- the sequence of Strings that represent a null value.- Returns:
- the new instance of
NullStringConversioncreated with the given parameters.
-
toDate
public static DateConversion toDate(java.util.Locale locale, java.lang.String... dateFormats)
Returns a new instance ofDateConversion- Parameters:
locale- theLocalethat 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
DateConversioncreated with the given parameters.
-
toDate
public static DateConversion toDate(java.lang.String... dateFormats)
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
DateConversioncreated with the given parameters.
-
toDate
public static DateConversion toDate(java.util.Locale locale, java.util.Date dateIfNull, java.lang.String... dateFormats)
Returns a new instance ofDateConversion- Parameters:
locale- theLocalethat 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
DateConversioncreated with the given parameters.
-
toDate
public static DateConversion toDate(java.util.Date dateIfNull, java.lang.String... dateFormats)
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
DateConversioncreated with the given parameters.
-
toDate
public static DateConversion toDate(java.util.TimeZone timeZone, java.util.Locale locale, java.util.Date dateIfNull, java.lang.String stringIfNull, java.lang.String... dateFormats)
Returns a new instance ofDateConversion- Parameters:
timeZone- theTimeZoneof the date to be formattedlocale- theLocalethat 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
DateConversioncreated with the given parameters.
-
toDate
public static DateConversion toDate(java.util.Locale locale, java.util.Date dateIfNull, java.lang.String stringIfNull, java.lang.String... dateFormats)
Returns a new instance ofDateConversion- Parameters:
locale- theLocalethat 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
DateConversioncreated with the given parameters.
-
toDate
public static DateConversion toDate(java.util.Date dateIfNull, java.lang.String stringIfNull, java.lang.String... dateFormats)
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
DateConversioncreated with the given parameters.
-
toCalendar
public static CalendarConversion toCalendar(java.util.Locale locale, java.lang.String... dateFormats)
Returns a new instance ofCalendarConversion- Parameters:
locale- theLocalethat 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
CalendarConversioncreated with the given parameters.
-
toCalendar
public static CalendarConversion toCalendar(java.lang.String... dateFormats)
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
CalendarConversioncreated with the given parameters.
-
toCalendar
public static CalendarConversion toCalendar(java.util.Locale locale, java.util.Calendar dateIfNull, java.lang.String... dateFormats)
Returns a new instance ofCalendarConversion- Parameters:
locale- theLocalethat 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
CalendarConversioncreated with the given parameters.
-
toCalendar
public static CalendarConversion toCalendar(java.util.Calendar dateIfNull, java.lang.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.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
CalendarConversioncreated with the given parameters.
-
toCalendar
public static CalendarConversion toCalendar(java.util.Locale locale, java.util.Calendar dateIfNull, java.lang.String stringIfNull, java.lang.String... dateFormats)
Returns a new instance ofCalendarConversion- Parameters:
locale- theLocalethat 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
CalendarConversioncreated with the given parameters.
-
toCalendar
public static CalendarConversion toCalendar(java.util.TimeZone timeZone, java.util.Locale locale, java.util.Calendar dateIfNull, java.lang.String stringIfNull, java.lang.String... dateFormats)
Returns a new instance ofCalendarConversion- Parameters:
timeZone- theTimeZoneto be consideredlocale- theLocalethat 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
CalendarConversioncreated with the given parameters.
-
toCalendar
public static CalendarConversion toCalendar(java.util.Calendar dateIfNull, java.lang.String stringIfNull, java.lang.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
CalendarConversioncreated with the given parameters.
-
toByte
public static ByteConversion toByte()
Returns a new instance ofByteConversion- Returns:
- a new instance of
ByteConversion
-
toShort
public static ShortConversion toShort()
Returns a new instance ofShortConversion- Returns:
- a new instance of
ShortConversion
-
toInteger
public static IntegerConversion toInteger()
Returns a new instance ofIntegerConversion- Returns:
- a new instance of
IntegerConversion
-
toLong
public static LongConversion toLong()
Returns a new instance ofLongConversion- Returns:
- a new instance of
LongConversion
-
toBigInteger
public static BigIntegerConversion toBigInteger()
Returns a new instance ofBigIntegerConversion- Returns:
- a new instance of
BigIntegerConversion
-
toFloat
public static FloatConversion toFloat()
Returns a new instance ofFloatConversion- Returns:
- a new instance of
FloatConversion
-
toDouble
public static DoubleConversion toDouble()
Returns a new instance ofDoubleConversion- Returns:
- a new instance of
DoubleConversion
-
toBigDecimal
public static BigDecimalConversion toBigDecimal()
Returns a new instance ofBigDecimalConversion- Returns:
- a new instance of
BigDecimalConversion
-
formatToNumber
public static NumericConversion<java.lang.Number> formatToNumber(java.lang.String... numberFormats)
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
NumericConversionthat supports the given number formats
-
formatToNumber
public static <T extends java.lang.Number> NumericConversion<T> formatToNumber(java.lang.Class<T> numberType, java.lang.String... numberFormats)
Returns a new instance ofNumericConversion- Type Parameters:
T- type of number- Parameters:
numberType- type of number to be returned. The resulting instance ofNumberwill 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
NumericConversionthat supports the given number formats
-
formatToBigDecimal
public static FormattedBigDecimalConversion formatToBigDecimal(java.lang.String... numberFormats)
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
FormattedBigDecimalConversionthat supports the given number formats
-
formatToBigDecimal
public static FormattedBigDecimalConversion formatToBigDecimal(java.math.BigDecimal defaultValueForNullString, java.lang.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
FormattedBigDecimalConversionthat supports the given number formats
-
formatToBigDecimal
public static FormattedBigDecimalConversion formatToBigDecimal(java.math.BigDecimal defaultValueForNullString, java.lang.String stringIfNull, java.lang.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
FormattedBigDecimalConversionthat supports the given number formats
-
toBoolean
public static BooleanConversion toBoolean(java.lang.Boolean defaultValueForNullString, java.lang.String defaultValueForNullBoolean, java.lang.String[] valuesForTrue, java.lang.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
BooleanConversionwith support for multiple representations of true and false
-
toBoolean
public static BooleanConversion toBoolean(java.lang.Boolean defaultValueForNullString, java.lang.String defaultValueForNullBoolean, java.lang.String valueForTrue, java.lang.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
BooleanConversionwith support for multiple representations of true and false
-
toBoolean
public static BooleanConversion toBoolean(java.lang.String[] valuesForTrue, java.lang.String[] valuesForFalse)
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
BooleanConversionwith support for multiple representations of true and false
-
toBoolean
public static BooleanConversion toBoolean()
Returns a new instance ofBooleanConversionthat converts the string "true" to true, and the String "false" to false.- Returns:
- a new instance of
BooleanConversionwith support for multiple representations of true and false
-
toBoolean
public static BooleanConversion toBoolean(java.lang.String valueForTrue, java.lang.String valueForFalse)
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
BooleanConversionwith support for multiple representations of true and false
-
toChar
public static CharacterConversion toChar()
Returns a new instance ofCharacterConversion- Returns:
- a new instance of
CharacterConversion
-
toChar
public static CharacterConversion toChar(java.lang.Character defaultValueForNullString, java.lang.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
public static CharacterConversion toChar(java.lang.Character defaultValueForNullString)
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
public static <T extends java.lang.Enum<T>> EnumConversion<T> toEnum(java.lang.Class<T> enumType)
Returns a new instance ofEnumConversion- Type Parameters:
T- theenumtype- Parameters:
enumType- the enumeration type to be converted from/toString- Returns:
- new instance of
EnumConversion
-
toEnum
public static <T extends java.lang.Enum<T>> EnumConversion<T> toEnum(java.lang.Class<T> enumType, EnumSelector... selectors)
Returns a new instance ofEnumConversion- Type Parameters:
T- theenumtype- Parameters:
enumType- the enumeration type to be converted from/toStringselectors- the selection elements of the enumeration to use for matchingStrings.- Returns:
- new instance of
EnumConversion
-
toEnum
public static <T extends java.lang.Enum<T>> EnumConversion<T> toEnum(java.lang.Class<T> enumType, java.lang.String customEnumElement, EnumSelector... selectors)
Returns a new instance ofEnumConversion- Type Parameters:
T- theenumtype- Parameters:
enumType- the enumeration type to be converted from/toStringcustomEnumElement- name of custom element of the enumeration (attribute or method) whose values should be used to match equivalentStrings.selectors- the selection elements of the enumeration to use for matchingStrings.- Returns:
- new instance of
EnumConversion
-
toEnum
public static <T extends java.lang.Enum<T>> EnumConversion<T> toEnum(java.lang.Class<T> enumType, T valueIfStringIsNull, java.lang.String valueIfEnumIsNull, java.lang.String customEnumElement, EnumSelector... selectors)
Returns a new instance ofEnumConversion- Type Parameters:
T- theenumtype- Parameters:
enumType- the enumeration type to be converted from/toStringvalueIfStringIsNull- the default enumeration constant to use if the inputStringisnullvalueIfEnumIsNull- the defaultStringvalue to use if the inputenumconstant isnullcustomEnumElement- name of custom element of the enumeration (attribute or method) whose values should be used to match equivalentStrings.selectors- the selection elements of the enumeration to use for matchingStrings.- Returns:
- new instance of
EnumConversion
-
toFormattedDate
public static FormattedDateConversion toFormattedDate(java.lang.String pattern)
Returns a new instance ofFormattedDateConversion- Parameters:
pattern- Date mask to be be used to convert a date object (i.e.DateorCalendar) into a String.- Returns:
- new instance of
FormattedDateConversionconfigured with the given parameters
-
toFormattedDate
public static FormattedDateConversion toFormattedDate(java.lang.String pattern, java.lang.String valueIfObjectIsNull)
Returns a new instance ofFormattedDateConversion- Parameters:
pattern- Date mask to be be used to convert a date object (i.e.DateorCalendar) into a String.valueIfObjectIsNull- Default string value to be returned when the input object is null.- Returns:
- new instance of
FormattedDateConversionconfigured with the given parameters
-
toFormattedDate
public static FormattedDateConversion toFormattedDate(java.lang.String pattern, java.util.Locale locale)
Returns a new instance ofFormattedDateConversion- Parameters:
pattern- Date mask to be be used to convert a date object (i.e.DateorCalendar) into a String.locale- TheLocalethat determines how the date pattern should be formatted.- Returns:
- new instance of
FormattedDateConversionconfigured with the given parameters
-
toFormattedDate
public static FormattedDateConversion toFormattedDate(java.lang.String pattern, java.util.Locale locale, java.lang.String valueIfObjectIsNull)
Returns a new instance ofFormattedDateConversion- Parameters:
pattern- Date mask to be be used to convert a date object (i.e.DateorCalendar) into a String.locale- TheLocalethat 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
FormattedDateConversionconfigured with the given parameters
-
notNull
public static ValidatedConversion notNull()
Returns aValidatedConversionthat doesn't allow null values- Returns:
- a not-null validator
-
notBlank
public static ValidatedConversion notBlank()
Returns aValidatedConversionthat doesn't allow null or blank values- Returns:
- a not-blank validator
-
notBlank
public static ValidatedConversion notBlank(java.lang.String regexToMatch)
Returns aValidatedConversionthat 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
public static ValidatedConversion validate(boolean nullable, boolean allowBlanks)
Returns aValidatedConversionthat 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
ValidatedConversionconfigured with the given parameters
-
validate
public static ValidatedConversion validate(boolean nullable, boolean allowBlanks, java.lang.String[] oneOf, java.lang.String[] noneOf)
Returns a new instance ofValidatedConversionto 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
ValidatedConversionconfigured with the given parameters
-
validate
public static ValidatedConversion validate(boolean nullable, boolean allowBlanks, java.lang.String regexToMatch)
Returns aValidatedConversionthat 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
ValidatedConversionconfigured with the given parameters
-
validate
public static ValidatedConversion validate(boolean nullable, boolean allowBlanks, java.lang.String[] oneOf, java.lang.String[] noneOf, java.lang.String regexToMatch)
Returns a new instance ofValidatedConversionto 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
ValidatedConversionconfigured with the given parameters
-
oneOf
public static ValidatedConversion oneOf(java.lang.String... oneOf)
Returns a new instance ofValidatedConversionto validate values of a record Nulls and blanks are not be allowed by default.- Parameters:
oneOf- list of accepted values.- Returns:
- new instance of
ValidatedConversionconfigured with the given parameters
-
noneOf
public static ValidatedConversion noneOf(java.lang.String... noneOf)
Returns a new instance ofValidatedConversionto 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
ValidatedConversionconfigured with the given parameters
-
-