|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.webbeans.util.ClassUtil
public final class ClassUtil
Utility classes with respect to the class operations.
| Field Summary | |
|---|---|
static Object[] |
OBJECT_EMPTY
|
static Map<Class<?>,Object> |
PRIMITIVE_CLASS_DEFAULT_VALUES
|
static Map<Class<?>,Class<?>> |
PRIMITIVE_TO_WRAPPERS_MAP
|
static Set<Class<?>> |
VALUE_TYPES
|
static String |
WEBBEANS_DATE_FORMAT
|
| Method Summary | ||
|---|---|---|
static Object |
callInstanceMethod(Method method,
Object instance,
Object[] args)
Call method on the instance with given arguments. |
|
static boolean |
checkBeanAndRequiredTypeisParametrized(Type beanTypeArg,
Type requiredTypeArg)
Check parametrized bean type and parametrized required types. |
|
static boolean |
checkBeanTypeAndRequiredIsTypeVariable(Type beanTypeArg,
Type requiredTypeArg)
|
|
static boolean |
checkEqual(TypeVariable<?>[] variables,
Type[] types)
Check the parametrized type actual arguments equals with the class type variables at the injection point. |
|
static boolean |
checkEventTypeAssignability(Type eventType,
Type observerType)
Checks that event is applicable for the given observer type. |
|
static boolean |
checkForTypeArguments(Class<?> src,
Type[] typeArguments,
Class<?> target)
|
|
static boolean |
checkParametrizedType(ParameterizedType pType)
Return true if it does not contain type variable for wildcard type false otherwise. |
|
static boolean |
checkRequiredTypeIsClassAndBeanTypeIsVariable(Type beanTypeArg,
Type requiredTypeArg)
Checking bean type and required type. |
|
static boolean |
checkRequiredTypeIsTypeVariableAndBeanTypeIsClass(Type beanTypeArg,
Type requiredTypeArg)
|
|
static boolean |
checkRequiredTypeisWildCard(Type beanTypeArg,
Type requiredTypeArg)
Check bean type and required type. |
|
static boolean |
classHasFieldWithName(Class<?> clazz,
String fieldName)
|
|
static boolean |
classHasMoreThanOneFieldWithName(Class<?> clazz,
String fieldName)
|
|
static
|
defaultJavaValues(Class<T> clazz)
Gets the Java Standart Class default value. |
|
static Type[] |
getActualTypeArguements(Class<?> clazz)
|
|
static Type[] |
getActualTypeArguements(Type type)
|
|
static Class<?> |
getClass(Type type)
Gets the class of the given type arguments. |
|
static Class<?> |
getClassFromName(String name)
|
|
static List<Method> |
getClassMethodsWithTypes(Class<?> clazz,
String methodName,
List<Class<?>> parameterTypes)
|
|
static Method |
getClassMethodWithTypes(Class<?> clazz,
String methodName,
List<Class<?>> parameterTypes)
|
|
static Class<?> |
getClazz(Type type)
Return raw class type for given type. |
|
static Constructor<?> |
getConstructor(Class<?> clazz,
Class<?>[] parameterTypes)
|
|
static
|
getConstructors(Class<T> clazz)
Returns class constructor array. |
|
static Method |
getDeclaredMethod(Class<?> clazz,
String methodName,
Class<?>[] parameters)
|
|
static Method[] |
getDeclaredMethods(Class<?> clazz)
Gets the declared methods of the given class. |
|
static Field[] |
getFieldsWithType(Class<?> clazz,
Type type)
|
|
static Field |
getFieldWithAnnotation(Class<?> clazz,
Class<? extends Annotation> annotation)
|
|
static Field |
getFieldWithName(Class<?> clazz,
String fieldName)
|
|
static Class<?> |
getFirstRawType(Type type)
|
|
static Type[] |
getGenericSuperClassTypeArguments(Class<?> clazz)
|
|
static List<Type[]> |
getGenericSuperInterfacesTypeArguments(Class<?> clazz)
|
|
static Class<?>[] |
getMethodParameterTypes(Method method)
|
|
static List<String> |
getObjectMethodNames()
|
|
Package |
getPackage(String packageName)
Gets java package if exist. |
|
static Class<?> |
getPrimitiveWrapper(Class<?> clazz)
|
|
static Class<?> |
getRawTypeForInjectionPoint(InjectionPoint injectionPoint)
Returns injection point raw type. |
|
static Class<?> |
getReturnType(Method method)
Gets the return type of the method. |
|
static Throwable |
getRootException(Throwable throwable)
|
|
static List<Class<?>> |
getSuperClasses(Class<?> clazz,
List<Class<?>> list)
|
|
static TypeVariable<?>[] |
getTypeVariables(Class<?> clazz)
|
|
static Class<?> |
getWrapperPrimitive(Class<?> clazz)
|
|
static
|
hasDefaultConstructor(Class<T> clazz)
Returns true if class has a default constructor. |
|
static boolean |
hasFinalMethod(Class<?> clazz)
Check for class that has a final method or not. |
|
static boolean |
hasMethodWithName(Class<?> clazz,
String methodName)
|
|
static boolean |
isAbstract(Integer modifier)
Check abstract modifier. |
|
static boolean |
isArray(Class<?> clazz)
|
|
static boolean |
isAssignable(Type beanType,
Type requiredType)
See specification 5.2.3. |
|
static boolean |
isAssignableForParametrized(ParameterizedType beanType,
ParameterizedType requiredType)
Returns true if given bean's api type is injectable to injection point required type. |
|
static boolean |
isClassAssignable(Class<?> lhs,
Class<?> rhs)
Returns true if rhs is assignable type to the lhs, false otherwise. |
|
static boolean |
isConcrete(Class<?> clazz)
Returna true if the class is not abstract and interface. |
|
static
|
isContaintNoArgConstructor(Class<T> clazz)
|
|
static boolean |
isDefinitionConstainsTypeVariables(Class<?> clazz)
|
|
static boolean |
isEnum(Class<?> clazz)
|
|
static boolean |
isFinal(Integer modifier)
Check final modifier. |
|
static boolean |
isFirstParametricTypeArgGeneric(ParameterizedType type)
|
|
static boolean |
isInnerClazz(Class<?> clazz)
Check the class is inner or not |
|
static boolean |
isInterface(Integer modifier)
Check interface modifier. |
|
static boolean |
isInValueTypes(Class<?> clazz)
|
|
static boolean |
isMethodHasCheckedException(Method method)
Check method throws checked exception or not. |
|
static boolean |
isMethodHasException(Method method)
Check method throws Exception or not. |
|
static boolean |
isMethodHasParameter(Method method)
Check that method has any formal arguments. |
|
static boolean |
isMoreThanOneMethodWithName(String methodName,
Class<?> clazz)
|
|
static boolean |
isObjectMethod(String methodName)
|
|
static boolean |
isOverriden(Method subClassMethod,
Method superClassMethod)
|
|
static boolean |
isParametrizedType(Type type)
Returns true if type is an instance of ParameterizedType
else otherwise. |
|
static boolean |
isPrimitive(Class<?> clazz)
|
|
static boolean |
isPrimitiveWrapper(Class<?> clazz)
|
|
static boolean |
isPrivate(Integer modifier)
Check the modifier contains static keyword. |
|
static boolean |
isPublic(int modifs)
Check the modifiers contains the public keyword. |
|
static boolean |
isPublic(Integer modifier)
Check the modifier contains static keyword. |
|
static boolean |
isStatic(Integer modifier)
Check the modifier contains static keyword. |
|
static boolean |
isTypeVariable(Type type)
Returns true if type is an instance of TypeVariable
else otherwise. |
|
static boolean |
isUnboundedTypeVariable(Type type)
|
|
static Object |
isValueOkForBigDecimalOrInteger(Class<?> type,
String value)
|
|
static Calendar |
isValueOkForCalendar(String value)
|
|
static Date |
isValueOkForDate(String value)
|
|
static Enum |
isValueOkForEnum(Class clazz,
String value)
|
|
static Object |
isValueOkForPrimitiveOrWrapper(Class<?> type,
String value)
Gets the primitive/wrapper value of the parsed String parameter. |
|
static boolean |
isWildCardType(Type type)
Returns true if type is an instance of WildcardType
else otherwise. |
|
static Object |
newInstance(Class<?> clazz)
|
|
static Set<Type> |
setClassTypeHierarchy(Set<Type> set,
Class<?> clazz)
|
|
static void |
setField(Object instance,
Field field,
Object value)
|
|
static Set<Type> |
setInterfaceTypeHierarchy(Set<Type> set,
Class<?> clazz)
|
|
static Set<Type> |
setTypeHierarchy(Set<Type> set,
Type clazz)
|
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final Map<Class<?>,Object> PRIMITIVE_CLASS_DEFAULT_VALUES
public static final Set<Class<?>> VALUE_TYPES
public static final Map<Class<?>,Class<?>> PRIMITIVE_TO_WRAPPERS_MAP
public static final String WEBBEANS_DATE_FORMAT
public static final Object[] OBJECT_EMPTY
| Method Detail |
|---|
public static boolean checkEqual(TypeVariable<?>[] variables,
Type[] types)
variables - type variabletypes - type
public static Object newInstance(Class<?> clazz)
public static Class<?> getClassFromName(String name)
public static boolean isFinal(Integer modifier)
modifier - modifier
public static boolean isAbstract(Integer modifier)
modifier - modifier
public static boolean isInterface(Integer modifier)
modifier - modifier
public static boolean hasFinalMethod(Class<?> clazz)
clazz - check methods of it
public static boolean isInnerClazz(Class<?> clazz)
modifier - modifier
public static boolean isStatic(Integer modifier)
modifier - modifier
public static boolean isPublic(Integer modifier)
modifier - modifier
public static boolean isPrivate(Integer modifier)
modifier - modifier
public static <T> T defaultJavaValues(Class<T> clazz)
T - parametrized typeclazz - class instance
public static Class<?> getPrimitiveWrapper(Class<?> clazz)
public static Class<?> getWrapperPrimitive(Class<?> clazz)
public static Class<?> getClass(Type type)
If the given type Type parameters is an instance of the
ParameterizedType, it returns the raw type otherwise it return
the casted Class of the type argument.
type - class or parametrized type
public static Method[] getDeclaredMethods(Class<?> clazz)
clazz - class instance
public static boolean isMethodHasParameter(Method method)
method - method instance
public static Class<?> getReturnType(Method method)
method - method instance
public static boolean isMethodHasCheckedException(Method method)
method - method instance
public static boolean isMethodHasException(Method method)
method - method instance
public static Object callInstanceMethod(Method method,
Object instance,
Object[] args)
method - method instanceinstance - object instanceargs - arguments
public static List<Class<?>> getSuperClasses(Class<?> clazz,
List<Class<?>> list)
public static Class<?>[] getMethodParameterTypes(Method method)
public static List<String> getObjectMethodNames()
public static boolean isObjectMethod(String methodName)
public static boolean isMoreThanOneMethodWithName(String methodName,
Class<?> clazz)
public static <T> Constructor<T> isContaintNoArgConstructor(Class<T> clazz)
public static boolean isPublic(int modifs)
modifs - modifiers
public Package getPackage(String packageName)
packageName - package name
public static boolean isParametrizedType(Type type)
ParameterizedType
else otherwise.
type - type of the artifact
ParameterizedTypepublic static boolean isWildCardType(Type type)
WildcardType
else otherwise.
type - type of the artifact
WildcardTypepublic static boolean isUnboundedTypeVariable(Type type)
public static boolean isTypeVariable(Type type)
TypeVariable
else otherwise.
type - type of the artifact
TypeVariablepublic static boolean isConcrete(Class<?> clazz)
clazz - class type
public static <T> Constructor<T>[] getConstructors(Class<T> clazz)
T - class type arfumentclazz - class that is searched for constructor.
public static <T> boolean hasDefaultConstructor(Class<T> clazz)
T - type argument of classclazz - class type
public static boolean isAssignable(Type beanType,
Type requiredType)
beanType - bean typerequiredType - required type
public static boolean checkEventTypeAssignability(Type eventType,
Type observerType)
eventType - event typeobserverType - observer type
public static boolean isClassAssignable(Class<?> lhs,
Class<?> rhs)
lhs - left hand side classrhs - right hand side class
public static boolean isAssignableForParametrized(ParameterizedType beanType,
ParameterizedType requiredType)
beanType - bean parametrized api typerequiredType - injection point parametrized api type
public static boolean checkBeanAndRequiredTypeisParametrized(Type beanTypeArg,
Type requiredTypeArg)
beanTypeArg - parametrized bean typerequiredTypeArg - parametrized required type
public static boolean checkRequiredTypeisWildCard(Type beanTypeArg,
Type requiredTypeArg)
Required type is a wildcard type.
beanTypeArg - bean typerequiredTypeArg - required type
public static boolean checkRequiredTypeIsClassAndBeanTypeIsVariable(Type beanTypeArg,
Type requiredTypeArg)
Required type is class and bean type is a type variable.
beanTypeArg - bean typerequiredTypeArg - required type
public static boolean checkRequiredTypeIsTypeVariableAndBeanTypeIsClass(Type beanTypeArg,
Type requiredTypeArg)
public static boolean checkBeanTypeAndRequiredIsTypeVariable(Type beanTypeArg,
Type requiredTypeArg)
public static boolean classHasFieldWithName(Class<?> clazz,
String fieldName)
public static boolean classHasMoreThanOneFieldWithName(Class<?> clazz,
String fieldName)
public static Field getFieldWithName(Class<?> clazz,
String fieldName)
public static List<Method> getClassMethodsWithTypes(Class<?> clazz,
String methodName,
List<Class<?>> parameterTypes)
clazz - webbeans implementation classmethodName - name of the method that is searchedparameterTypes - parameter types of the method(it can be subtype of
the actual type arguments of the method)
public static Method getClassMethodWithTypes(Class<?> clazz,
String methodName,
List<Class<?>> parameterTypes)
public static boolean hasMethodWithName(Class<?> clazz,
String methodName)
public static boolean isPrimitive(Class<?> clazz)
public static boolean isPrimitiveWrapper(Class<?> clazz)
public static boolean isArray(Class<?> clazz)
public static boolean isEnum(Class<?> clazz)
public static boolean isInValueTypes(Class<?> clazz)
public static Object isValueOkForPrimitiveOrWrapper(Class<?> type,
String value)
String parameter.
type - primitive or wrapper of the primitive typevalue - value of the type
String value into the
corresponding value, if any exception occurs, returns null as the
value.
public static Enum isValueOkForEnum(Class clazz,
String value)
public static Date isValueOkForDate(String value)
throws ParseException
ParseException
public static Calendar isValueOkForCalendar(String value)
throws ParseException
ParseException
public static Object isValueOkForBigDecimalOrInteger(Class<?> type,
String value)
public static boolean isDefinitionConstainsTypeVariables(Class<?> clazz)
public static TypeVariable<?>[] getTypeVariables(Class<?> clazz)
public static Type[] getActualTypeArguements(Class<?> clazz)
public static Type[] getActualTypeArguements(Type type)
public static Class<?> getFirstRawType(Type type)
public static Set<Type> setTypeHierarchy(Set<Type> set,
Type clazz)
public static Class<?> getClazz(Type type)
type - base type instance
public static Set<Type> setClassTypeHierarchy(Set<Type> set,
Class<?> clazz)
public static Set<Type> setInterfaceTypeHierarchy(Set<Type> set,
Class<?> clazz)
public static Type[] getGenericSuperClassTypeArguments(Class<?> clazz)
public static boolean checkParametrizedType(ParameterizedType pType)
pType - parameterized type
public static boolean isFirstParametricTypeArgGeneric(ParameterizedType type)
public static List<Type[]> getGenericSuperInterfacesTypeArguments(Class<?> clazz)
public static Field getFieldWithAnnotation(Class<?> clazz,
Class<? extends Annotation> annotation)
public static Field[] getFieldsWithType(Class<?> clazz,
Type type)
public static boolean checkForTypeArguments(Class<?> src,
Type[] typeArguments,
Class<?> target)
public static void setField(Object instance,
Field field,
Object value)
public static Throwable getRootException(Throwable throwable)
public static Class<?> getRawTypeForInjectionPoint(InjectionPoint injectionPoint)
injectionPoint - injection point definition
public static boolean isOverriden(Method subClassMethod,
Method superClassMethod)
public static Method getDeclaredMethod(Class<?> clazz,
String methodName,
Class<?>[] parameters)
public static Constructor<?> getConstructor(Class<?> clazz,
Class<?>[] parameterTypes)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||