Package org.keycloak.models.map.common
Class CastUtils
java.lang.Object
org.keycloak.models.map.common.CastUtils
This class contains utility classes for type conversion.
- Author:
- hmlnarik
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> T
Converts value to destination class (if it can).getCastFunc
(Class<?> fromClass, Class<?> toClass) Provides a function to convert value of a given class to destination class (if it can).
-
Constructor Details
-
CastUtils
public CastUtils()
-
-
Method Details
-
cast
Converts value to destination class (if it can).- Parameters:
value
- Value to converttoClass
- Class to convert value to- Returns:
- Value converted to the given class
- Throws:
IllegalStateException
- if the value cannot be converted to the requested class
-
getCastFunc
Provides a function to convert value of a given class to destination class (if it can).- Parameters:
fromClass
- Class to convert value fromtoClass
- Class to convert value to- Returns:
- Function
fromClass -> toClass
converting values from thefromClass
to thetoClass
- Throws:
IllegalStateException
- if the value cannot be converted to the requested class
-