Class Conversion<FROM,TO>
- java.lang.Object
-
- de.gebit.integrity.parameter.conversion.Conversion<FROM,TO>
-
- Type Parameters:
FROM
- the source typeTO
- the target type
- Direct Known Subclasses:
AbstractBooleanToString
,AbstractBooleanValueToString
,AbstractCalendarToString
,AbstractCharacterToString
,AbstractDateAndTimeValueToString
,AbstractDateToString
,AbstractDateValueToString
,AbstractDecimalValueToString
,AbstractEnumToString
,AbstractEnumValueToString
,AbstractFormattedStringToString
,AbstractIntegerValueToString
,AbstractJavaConstantConversion
,AbstractMapToString
,AbstractNestedObjectToString
,AbstractNumberToString
,AbstractObjectToString
,AbstractRegexValueToString
,AbstractStringToString
,AbstractStringValueToString
,AbstractTimeValueToString
,BigDecimalToBigDecimal
,BigIntegerToBigDecimal
,BigIntegerToBigInteger
,BooleanToBoolean
,BooleanValueToBoolean
,ByteToBigDecimal
,ByteToByte
,CalendarToDate
,CalendarToInstant
,CalendarToLocalDate
,CalendarToLocalDateTime
,CalendarToLocalTime
,CalendarToSQLDate
,CalendarToSQLTime
,CalendarToTimestamp
,CalendarToZonedDateTime
,CharacterToBigDecimal
,CharacterToBigInteger
,CharacterToCharacter
,DateAndTimeValueToCalendar
,DateAndTimeValueToDate
,DateAndTimeValueToInstant
,DateAndTimeValueToLocalDate
,DateAndTimeValueToLocalDateTime
,DateAndTimeValueToLocalTime
,DateAndTimeValueToSQLDate
,DateAndTimeValueToSQLTime
,DateAndTimeValueToTimestamp
,DateAndTimeValueToZonedDateTime
,DateToCalendar
,DateToSQLDate
,DateToSQLTime
,DateToTimestamp
,DateValueToCalendar
,DateValueToDate
,DateValueToInstant
,DateValueToLocalDate
,DateValueToLocalDateTime
,DateValueToSQLDate
,DateValueToSQLTime
,DateValueToTimestamp
,DateValueToZonedDateTime
,DecimalValueToBigDecimal
,DecimalValueToCharacter
,DecimalValueToDouble
,DecimalValueToFloat
,DecimalValueToNumber
,DoubleToBigDecimal
,DoubleToDouble
,EmptyValueToEmptyString
,EmptyValueToFormattedString
,EnumValueToEnumConstant
,FloatToBigDecimal
,FloatToFloat
,InexistentValueToFormattedString
,InexistentValueToInexistentString
,IntegerToBigDecimal
,IntegerToInteger
,IntegerValueToBigDecimal
,IntegerValueToBigInteger
,IntegerValueToByte
,IntegerValueToCharacter
,IntegerValueToDouble
,IntegerValueToFloat
,IntegerValueToInteger
,IntegerValueToLong
,IntegerValueToNumber
,IntegerValueToShort
,LongToBigDecimal
,LongToLong
,MapToBean
,MapToMap
,NestedObjectToBean
,NestedObjectToMap
,NullValueToNull
,NumberToBigInteger
,NumberToByte
,NumberToCharacter
,NumberToDouble
,NumberToFloat
,NumberToInteger
,NumberToLong
,NumberToShort
,ObjectToMap
,ObjectToObject
,OptionalToContainedObject
,OptionalToFormattedString
,PatternToPattern
,RegexValueToPattern
,ShortToBigDecimal
,ShortToShort
,SQLDateToCalendar
,SQLDateToTimestamp
,SQLTimeToCalendar
,SQLTimeToTimestamp
,StringToBigDecimal
,StringToBigInteger
,StringToByte
,StringToCharacter
,StringToDouble
,StringToEnumConstant
,StringToFloat
,StringToInteger
,StringToLong
,StringToNumber
,StringToPattern
,StringToShort
,StringValueToBigDecimal
,StringValueToBigInteger
,StringValueToBoolean
,StringValueToByte
,StringValueToCharacter
,StringValueToDouble
,StringValueToEnumConstant
,StringValueToFloat
,StringValueToInteger
,StringValueToLong
,StringValueToNumber
,StringValueToPattern
,StringValueToShort
,TimestampToCalendar
,TimeValueToCalendar
,TimeValueToDate
,TimeValueToInstant
,TimeValueToLocalDateTime
,TimeValueToLocalTime
,TimeValueToSQLDate
,TimeValueToSQLTime
,TimeValueToTimestamp
,TimeValueToZonedDateTime
,TypedNestedObjectToBean
,TypedNestedObjectToFormattedString
,TypedNestedObjectToMap
,TypedNestedObjectToString
public abstract class Conversion<FROM,TO> extends java.lang.Object
AConversion
defines a transformation from one type into another.- Author:
- Rene Schneider - initial API and implementation
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
Conversion.Priority
Add this annotation to aConversion
implementation to set the priority of this conversion.
-
Constructor Summary
Constructors Constructor Description Conversion()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract TO
convert(FROM aSource, java.lang.Class<? extends TO> aTargetType, ConversionContext aConversionContext)
Performs the conversion.protected java.lang.Object
convertValueRecursive(java.lang.Class<?> aTargetType, java.lang.Class<?> aParameterizedType, java.lang.Object aValue, ConversionContext aConversionContext)
Recursively converts the given value to the defined target type.protected FormattedString[]
convertValueToFormattedStringArrayRecursive(java.lang.Object aValue, ConversionContext aConversionContext)
Recursively converts the given value to a string array.void
setVisitedObjects(java.util.Set<java.lang.Object> someVisitedObjects)
-
-
-
Method Detail
-
convert
public abstract TO convert(FROM aSource, java.lang.Class<? extends TO> aTargetType, ConversionContext aConversionContext) throws ConversionFailedException
Performs the conversion.- Parameters:
aSource
- the source object to convertaTargetType
- TODOaConversionContext
- controls some conversion parameters and rules; may be null if the defaultConversionContext
values shall be used- Returns:
- the converted object
- Throws:
ConversionFailedException
- in case of conversion errors
-
setVisitedObjects
public void setVisitedObjects(java.util.Set<java.lang.Object> someVisitedObjects)
-
convertValueRecursive
protected java.lang.Object convertValueRecursive(java.lang.Class<?> aTargetType, java.lang.Class<?> aParameterizedType, java.lang.Object aValue, ConversionContext aConversionContext) throws ParameterUtil.UnresolvableVariableException, java.lang.ClassNotFoundException, UnexecutableException, java.lang.InstantiationException
Recursively converts the given value to the defined target type. This method provides implicit protection against endless recursion loops.- Parameters:
aTargetType
- the target typeaParameterizedType
- the parameterized type in case of genericsaValue
- the value to convertaConversionContext
- some parameters controlling the conversion (if null, a default context is used)- Returns:
- the converted value
- Throws:
ParameterUtil.UnresolvableVariableException
java.lang.ClassNotFoundException
UnexecutableException
java.lang.InstantiationException
-
convertValueToFormattedStringArrayRecursive
protected FormattedString[] convertValueToFormattedStringArrayRecursive(java.lang.Object aValue, ConversionContext aConversionContext)
Recursively converts the given value to a string array. This method provides implicit protection against endless recursion loops.- Parameters:
aValue
- the value to convertaConversionContext
- some parameters controlling the conversion (if null, a default context is used)- Returns:
- the converted string array
-
-