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 Object
AConversiondefines 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 interfaceConversion.PriorityAdd this annotation to aConversionimplementation 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 TOconvert(FROM aSource, Class<? extends TO> aTargetType, ConversionContext aConversionContext)Performs the conversion.protected ObjectconvertValueRecursive(Class<?> aTargetType, Class<?> aParameterizedType, Object aValue, ConversionContext aConversionContext)Recursively converts the given value to the defined target type.protected FormattedString[]convertValueToFormattedStringArrayRecursive(Object aValue, ConversionContext aConversionContext)Recursively converts the given value to a string array.voidsetVisitedObjects(Set<Object> someVisitedObjects)
-
-
-
Method Detail
-
convert
public abstract TO convert(FROM aSource, 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 defaultConversionContextvalues shall be used- Returns:
- the converted object
- Throws:
ConversionFailedException- in case of conversion errors
-
convertValueRecursive
protected Object convertValueRecursive(Class<?> aTargetType, Class<?> aParameterizedType, Object aValue, ConversionContext aConversionContext) throws ParameterUtil.UnresolvableVariableException, ClassNotFoundException, UnexecutableException, 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.UnresolvableVariableExceptionClassNotFoundExceptionUnexecutableExceptionInstantiationException
-
convertValueToFormattedStringArrayRecursive
protected FormattedString[] convertValueToFormattedStringArrayRecursive(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
-
-