Package org.keycloak.models.map.common
Class CastUtils
- java.lang.Object
- 
- org.keycloak.models.map.common.CastUtils
 
- 
 public class CastUtils extends Object This class contains utility classes for type conversion.- Author:
- hmlnarik
 
- 
- 
Constructor SummaryConstructors Constructor Description CastUtils()
 - 
Method SummaryAll Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> Tcast(Object value, Class<T> toClass)Converts value to destination class (if it can).static <E extends Enum<E>>
 Function<?,?>getCastFunc(Class<?> fromClass, Class<?> toClass)Provides a function to convert value of a given class to destination class (if it can).
 
- 
- 
- 
Method Detail- 
castpublic static <T> T cast(Object value, Class<T> toClass) Converts value to destination class (if it can).- Parameters:
- value- Value to convert
- toClass- Class to convert value to
- Returns:
- Value converted to the given class
- Throws:
- IllegalStateException- if the value cannot be converted to the requested class
 
 - 
getCastFuncpublic static <E extends Enum<E>> Function<?,?> getCastFunc(Class<?> fromClass, Class<?> toClass) Provides a function to convert value of a given class to destination class (if it can).- Parameters:
- fromClass- Class to convert value from
- toClass- Class to convert value to
- Returns:
- Function fromClass -> toClassconverting values from thefromClassto thetoClass
- Throws:
- IllegalStateException- if the value cannot be converted to the requested class
 
 
- 
 
-