Interface Conversion
- All Known Implementing Classes:
DefaultConversion
public interface Conversion
Conversion from one type to another.
-
Method Summary
Modifier and TypeMethodDescription<S,T> boolean canConvert(Class<S> sourceTypeClass, Class<T> targetTypeClass) Returns whether the given source type can be converted to the given target type.<T> booleancanConvert(Object object, Class<T> targetTypeClass) Returns whether the given object can be converted to the given target type.<S,T> List<T> Converts each object from a set to the target type.<S,T> List<T> Converts each object from an iterable to the target type.<S,T> List<T> Converts each object from a list to the target type.<S,T> List<T> Converts each object from a list to the target type.<S,T> Set<T> Converts each object from a set to the target type.<S,T> Set<T> Converts each object from a set to the target type.<S,T> T Converts an object to the target type.<S,T> T Converts an object to the target type.
-
Method Details
-
canConvert
Returns whether the given source type can be converted to the given target type.- Type Parameters:
S- The source generic typeT- The target generic type- Parameters:
sourceTypeClass- The source type classtargetTypeClass- The target type class- Returns:
trueif conversion is possible, otherwise,false
-
canConvert
Returns whether the given object can be converted to the given target type.- Type Parameters:
T- The target generic type- Parameters:
object- The source objecttargetTypeClass- The target type class- Returns:
trueif conversion is possible, otherwise,false
-
convert
Converts an object to the target type.- Type Parameters:
S- The source generic typeT- The target generic type- Parameters:
object- The object to converttargetTypeClass- The target type class- Returns:
- converted object
- Throws:
ConversionException.ConverterDoesNotExist- If the needed converter does not exist
-
convert
Converts an object to the target type.- Type Parameters:
S- The source generic typeT- The target generic type- Parameters:
object- The object to convertsourceTypeClass- The source type classtargetTypeClass- The target type class- Returns:
- converted object
- Throws:
ConversionException.ConverterDoesNotExist- If the needed converter does not exist
-
convert
Converts each object from an iterable to the target type.- Type Parameters:
S- The source generic typeT- The target generic type- Parameters:
objectIterable- The iterable of objects to converttargetTypeClass- The target type class- Returns:
- converted collection of objects
- Throws:
ConversionException.ConverterDoesNotExist- If the needed converter does not exist
-
convert
<S,T> List<T> convert(Iterable<S> objectIterable, Class<S> sourceTypeClass, Class<T> targetTypeClass) Converts each object from a set to the target type.- Type Parameters:
S- The source generic typeT- The target generic type- Parameters:
objectIterable- The iterable of objects to convertsourceTypeClass- The source type classtargetTypeClass- The target type class- Returns:
- converted collection of objects
- Throws:
ConversionException.ConverterDoesNotExist- If the needed converter does not exist
-
convert
Converts each object from a list to the target type.- Type Parameters:
S- The source generic typeT- The target generic type- Parameters:
objectList- The list of objects to converttargetTypeClass- The target type class- Returns:
- converted collection of objects
- Throws:
ConversionException.ConverterDoesNotExist- If the needed converter does not exist
-
convert
Converts each object from a list to the target type.- Type Parameters:
S- The source generic typeT- The target generic type- Parameters:
objectList- The list of objects to convertsourceTypeClass- The source type classtargetTypeClass- The target type class- Returns:
- converted collection of objects
- Throws:
ConversionException.ConverterDoesNotExist- If the needed converter does not exist
-
convert
Converts each object from a set to the target type.- Type Parameters:
S- The source generic typeT- The target generic type- Parameters:
objectList- The set of objects to converttargetTypeClass- The target type class- Returns:
- converted collection of objects
- Throws:
ConversionException.ConverterDoesNotExist- If the needed converter does not exist
-
convert
Converts each object from a set to the target type.- Type Parameters:
S- The source generic typeT- The target generic type- Parameters:
objectList- The set of objects to convertsourceTypeClass- The source type classtargetTypeClass- The target type class- Returns:
- converted collection of objects
- Throws:
ConversionException.ConverterDoesNotExist- If the needed converter does not exist
-