Class ObjectHelper
- java.lang.Object
-
- org.exoplatform.social.common.service.utils.ObjectHelper
-
public class ObjectHelper extends Object
-
-
Constructor Summary
Constructors Constructor Description ObjectHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> Tcast(Class<T> toType, Object value)Converts the given value to the required type or throw a meaningful exceptionstatic Class<?>convertPrimitiveTypeToWrapperType(Class<?> type)Converts primitive types such as int to its wrapper type likeIntegerstatic Iterator<Throwable>createExceptionIterator(Throwable exception)Creates an iterator to walk the exception from the bottom up (the last caused by going upwards to the root exception).static <T> TgetException(Class<T> type, Throwable exception)Retrieves the given exception type from the exception.
-
-
-
Method Detail
-
getException
public static <T> T getException(Class<T> type, Throwable exception)
Retrieves the given exception type from the exception.
Is used to get the caused exception that typically have been wrapped in some sort of Camel wrapper exception
The strategy is to look in the exception hierarchy to find the first given cause that matches the type. Will start from the bottom (the real cause) and walk upwards.- Parameters:
type- the exception type wanted to retrieveexception- the caused exception- Returns:
- the exception found (or null if not found in the exception hierarchy)
-
createExceptionIterator
public static Iterator<Throwable> createExceptionIterator(Throwable exception)
Creates an iterator to walk the exception from the bottom up (the last caused by going upwards to the root exception).- Parameters:
exception- the exception- Returns:
- the iterator
-
cast
public static <T> T cast(Class<T> toType, Object value)
Converts the given value to the required type or throw a meaningful exception
-
-