|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.camel.util.ObjectHelper
public class ObjectHelper
A number of useful helper methods for working with Objects
Method Summary | |
---|---|
static String |
asString(Object[] objects)
Turns the given object arrays into a meaningful string |
static String |
className(Object value)
Returns the type name of the given value |
static int |
compare(Object a,
Object b)
A helper method for performing an ordered comparsion on the objects handling nulls and objects which do not handle sorting gracefully |
static boolean |
contains(Object collectionOrArray,
Object value)
Returns true if the collection contains the specified value |
static Class |
convertPrimitiveTypeToWrapperType(Class type)
Converts primitive types such as int to its wrapper type like Integer |
static boolean |
equals(Object a,
Object b)
A helper method for comparing objects for equality while handling nulls |
static List<Method> |
findMethodsWithAnnotation(Class<?> type,
Class<? extends Annotation> annotationType)
Returns a list of methods which are annotated with the given annotation |
static String |
getDefaultCharacterSet()
Helper method to return the default character set name |
static String |
getSystemProperty(String name,
String defaultValue)
A helper method to access a system property, catching any security exceptions |
static Object |
invokeMethod(Method method,
Object instance,
Object... parameters)
A helper method to invoke a method via reflection and wrap any exceptions as RuntimeCamelException instances |
static boolean |
isAssignableFrom(Class a,
Class b)
Returns true if a class is assignable from another class like the Class.isAssignableFrom(Class) method but which also includes
coercion between primitive types to deal with Java 5 primitive type
wrapping |
static boolean |
isEqualToAny(Object object,
Object... values)
Returns true if the given object is equal to any of the expected value |
static boolean |
isNotNullAndNonEmpty(String text)
|
static boolean |
isNullOrBlank(String text)
|
static Class<?> |
loadClass(String name)
Attempts to load the given class name using the thread context class loader or the class loader used to load this class |
static Class<?> |
loadClass(String name,
ClassLoader loader)
Attempts to load the given class name using the thread context class loader or the given class loader |
static boolean |
matches(List list)
Returns the predicate matching boolean on a List result set where
if the first element is a boolean its value is used otherwise this method
returns true if the collection is not empty |
static String |
name(Class type)
Returns the type name of the given type or null if the type variable is null |
static void |
notNull(Object value,
String name)
|
static String |
removeStartingCharacters(String text,
char ch)
Removes any starting characters on the given text which match the given character |
static String[] |
splitOnCharacter(String value,
String needle,
int count)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static boolean equals(Object a, Object b)
public static boolean isEqualToAny(Object object, Object... values)
expression
- s
- s1
-
public static int compare(Object a, Object b)
public static void notNull(Object value, String name)
public static String[] splitOnCharacter(String value, String needle, int count)
public static String removeStartingCharacters(String text, char ch)
text
- the stringch
- the initial characters to remove
public static boolean contains(Object collectionOrArray, Object value)
public static boolean matches(List list)
List
result set where
if the first element is a boolean its value is used otherwise this method
returns true if the collection is not empty
public static boolean isNotNullAndNonEmpty(String text)
public static boolean isNullOrBlank(String text)
public static String getSystemProperty(String name, String defaultValue)
name
- the name of the system property requireddefaultValue
- the default value to use if the property is not
available or a security exception prevents access
public static String name(Class type)
public static String className(Object value)
public static Class<?> loadClass(String name)
name
- the name of the class to load
public static Class<?> loadClass(String name, ClassLoader loader)
name
- the name of the class to loadloader
- the class loader to use after the thread context class
loader
public static Object invokeMethod(Method method, Object instance, Object... parameters)
RuntimeCamelException
instances
method
- the method to invokeinstance
- the object instance (or null for static methods)parameters
- the parameters to the method
public static List<Method> findMethodsWithAnnotation(Class<?> type, Class<? extends Annotation> annotationType)
type
- the type to reflect onannotationType
- the annotation type
public static String asString(Object[] objects)
objects
- an array of objects or null
public static boolean isAssignableFrom(Class a, Class b)
Class.isAssignableFrom(Class)
method but which also includes
coercion between primitive types to deal with Java 5 primitive type
wrapping
public static Class convertPrimitiveTypeToWrapperType(Class type)
Integer
public static String getDefaultCharacterSet()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |