keycloak
静的公開メンバ関数 | 静的公開変数類 | 非公開メンバ関数 | 静的非公開メンバ関数 | 全メンバ一覧
org.keycloak.common.util.reflections.Reflections クラス
org.keycloak.common.util.reflections.Reflections 連携図
Collaboration graph

静的公開メンバ関数

static< T > T cast (Object obj)
 
static Set< Field > getAllDeclaredFields (Class<?> clazz)
 
static Field findDeclaredField (Class<?> clazz, String name)
 
static Set< Annotation > getAnnotationsWithMetaAnnotation (Set< Annotation > annotations, Class<? extends Annotation > metaAnnotationType)
 
static boolean methodExists (Class<?> clazz, String name)
 
static Set< Method > getAllDeclaredMethods (Class<?> clazz)
 
static Method findDeclaredMethod (Class<?> clazz, String name, Class<?>... args)
 
static Constructor<?> findDeclaredConstructor (Class<?> clazz, Class<?>... args)
 
static Set< Constructor<?> > getAllDeclaredConstructors (Class<?> clazz)
 
static Class<?> getMemberType (Member member)
 
static< T > Class< T > classForName (String name, ClassLoader... loaders) throws ClassNotFoundException
 
static Object invokeMethod (Method method, Object instance, Object... args)
 
static Object invokeMethod (boolean setAccessible, Method method, Object instance, Object... args)
 
static< T > T invokeMethod (Method method, Class< T > expectedReturnType, Object instance, Object... args)
 
static< T > T invokeMethod (boolean setAccessible, Method method, Class< T > expectedReturnType, Object instance, Object... args)
 
static< A extends AccessibleObject > A setAccessible (A member)
 
static Object getFieldValue (Field field, Object instance)
 
static< T > T getFieldValue (Field field, Object instance, Class< T > expectedType)
 
static< T > Class< T > getRawType (Type type)
 
static boolean isSerializable (Class<?> clazz)
 
static Map< Class<?>, Type > buildTypeMap (Set< Type > types)
 
static boolean isCacheable (Set< Annotation > annotations)
 
static boolean isCacheable (Annotation[] annotations)
 
static String getPropertyName (Method method)
 
static boolean isFinal (Class<?> clazz)
 
static int getNesting (Class<?> clazz)
 
static boolean isFinal (Member member)
 
static boolean isPrivate (Member member)
 
static boolean isTypeOrAnyMethodFinal (Class<?> type)
 
static Object getNonPrivateFinalMethodOrType (Class<?> type)
 
static boolean isPackagePrivate (int mod)
 
static boolean isStatic (Class<?> type)
 
static boolean isStatic (Member member)
 
static boolean isTransient (Member member)
 
static boolean isAbstract (Method method)
 
static boolean isArrayType (Class<?> rawType)
 
static boolean isParameterizedType (Class<?> type)
 
static boolean isParamerterizedTypeWithWildcard (Class<?> type)
 
static boolean containsWildcards (Type[] types)
 
static boolean isAssignableFrom (Class<?> rawType1, Type[] actualTypeArguments1, Class<?> rawType2, Type[] actualTypeArguments2)
 
static boolean matches (Class<?> rawType1, Type[] actualTypeArguments1, Class<?> rawType2, Type[] actualTypeArguments2)
 
static boolean isAssignableFrom (Type[] actualTypeArguments1, Type[] actualTypeArguments2)
 
static boolean isAssignableFrom (Type type1, Set<? extends Type > types2)
 
static boolean matches (Type type1, Set<? extends Type > types2)
 
static boolean isAssignableFrom (Type type1, Type[] types2)
 
static boolean isAssignableFrom (Type type1, Type type2)
 
static boolean matches (Type type1, Type type2)
 
static boolean isTypeBounded (Type type, Type[] lowerBounds, Type[] upperBounds)
 
static boolean isAssignableFrom (Class<?> rawType1, Type[] actualTypeArguments1, Type type2)
 
static boolean matches (Class<?> rawType1, Type[] actualTypeArguments1, Type type2)
 
static boolean isAssignableFrom (Set< Type > types1, Set< Type > types2)
 
static boolean matches (Set< Type > types1, Set< Type > types2)
 
static boolean isAssignableFrom (Set< Type > types1, Type type2)
 
static boolean isAssignableFrom (Type[] types1, Type type2)
 
static boolean isPrimitive (Type type)
 
static< T > T newInstance (final Class< T > fromClass) throws ClassNotFoundException, IllegalAccessException, InstantiationException
 
static< T > T newInstance (final Class<?> type, final String fullQualifiedName) throws ClassNotFoundException, IllegalAccessException, InstantiationException
 

静的公開変数類

static final Annotation [] EMPTY_ANNOTATION_ARRAY = new Annotation[0]
 
static final Object [] EMPTY_OBJECT_ARRAY = new Object[0]
 
static final Type [] EMPTY_TYPES = {}
 
static final Class<?> [] EMPTY_CLASSES = new Class<?>[0]
 

非公開メンバ関数

 Reflections ()
 

静的非公開メンバ関数

static String buildInvokeMethodErrorMessage (Method method, Object obj, Object... args)
 
static String buildSetFieldValueErrorMessage (Field field, Object obj, Object value)
 
static String buildGetFieldValueErrorMessage (Field field, Object obj)
 

詳解

Utility class for working with JDK Reflection and also CDI's {link Annotated} metadata.

構築子と解体子

◆ Reflections()

org.keycloak.common.util.reflections.Reflections.Reflections ( )
inlineprivate
59  {
60  }

関数詳解

◆ buildGetFieldValueErrorMessage()

static String org.keycloak.common.util.reflections.Reflections.buildGetFieldValueErrorMessage ( Field  field,
Object  obj 
)
inlinestaticprivate
416  {
417  return String.format("Exception reading [%s] field from object [%s].", field.getName(), obj);
418  }

◆ buildInvokeMethodErrorMessage()

static String org.keycloak.common.util.reflections.Reflections.buildInvokeMethodErrorMessage ( Method  method,
Object  obj,
Object...  args 
)
inlinestaticprivate
291  {
292  StringBuilder message = new StringBuilder(
293  String.format("Exception invoking method [%s] on object [%s], using arguments [",
294  method.getName(), obj));
295  if (args != null) {
296  for (int i = 0; i < args.length; i++) {
297  message.append((i > 0 ? "," : "") + args[i]);
298  }
299  }
300  message.append("]");
301  return message.toString();
302  }

◆ buildSetFieldValueErrorMessage()

static String org.keycloak.common.util.reflections.Reflections.buildSetFieldValueErrorMessage ( Field  field,
Object  obj,
Object  value 
)
inlinestaticprivate
412  {
413  return String.format("Exception setting [%s] field on object [%s] to value [%s]", field.getName(), obj, value);
414  }

◆ buildTypeMap()

static Map<Class<?>, Type> org.keycloak.common.util.reflections.Reflections.buildTypeMap ( Set< Type >  types)
inlinestatic
491  {
492  Map<Class<?>, Type> map = new HashMap<Class<?>, Type>();
493  for (Type type : types) {
494  if (type instanceof Class<?>) {
495  map.put((Class<?>) type, type);
496  } else if (type instanceof ParameterizedType) {
497  if (((ParameterizedType) type).getRawType() instanceof Class<?>) {
498  map.put((Class<?>) ((ParameterizedType) type).getRawType(), type);
499  }
500  } else if (type instanceof TypeVariable<?>) {
501 
502  }
503  }
504  return map;
505  }
static< T > Class< T > getRawType(Type type)
Definition: Reflections.java:468

◆ cast()

static <T> T org.keycloak.common.util.reflections.Reflections.cast ( Object  obj)
inlinestatic

Perform a runtime cast. Similar to Class#cast(Object), but useful when you do not have a Class object for type you wish to cast to.

Class#cast(Object) should be used if possible

引数
<T>the type to cast to
objthe object to perform the cast on
戻り値
the casted object
例外
ClassCastExceptionif the type T is not a subtype of the object
参照
Class::cast(Object)
76  {
77  return (T) obj;
78  }

◆ classForName()

static <T> Class<T> org.keycloak.common.util.reflections.Reflections.classForName ( String  name,
ClassLoader...  loaders 
) throws ClassNotFoundException
inlinestatic

Loads and initializes a class for the given name.

If the Thread Context Class Loader is available, it will be used, otherwise the classloader used to load Reflections will be used

It is also possible to specify additional classloaders to attempt to load the class with. If the first attempt fails, then these additional loaders are tried in order.

引数
namethe name of the class to load
loadersadditional classloaders to use to attempt to load the class
戻り値
the class object
例外
ClassNotFoundExceptionif the class cannot be found
264  {
265  try {
266  if (Thread.currentThread().getContextClassLoader() != null) {
267  return (Class<T>) Class.forName(name, true, Thread.currentThread().getContextClassLoader());
268  } else {
269  return (Class<T>) Class.forName(name);
270  }
271  } catch (ClassNotFoundException e) {
272  for (ClassLoader l : loaders) {
273  try {
274  return (Class<T>) Class.forName(name, true, l);
275  } catch (ClassNotFoundException ex) {
276 
277  }
278  }
279  }
280  if (Thread.currentThread().getContextClassLoader() != null) {
281  throw new ClassNotFoundException("Could not load class " + name +
282  " with the context class loader " + Thread.currentThread().getContextClassLoader().toString() +
283  " or any of the additional ClassLoaders: " + Arrays.toString(loaders));
284  } else {
285  throw new ClassNotFoundException("Could not load class " + name +
286  " using Class.forName or using any of the additional ClassLoaders: " +
287  Arrays.toString(loaders));
288  }
289  }

◆ containsWildcards()

static boolean org.keycloak.common.util.reflections.Reflections.containsWildcards ( Type []  types)
inlinestatic
683  {
684  for (Type type : types) {
685  if (type instanceof WildcardType) {
686  return true;
687  }
688  }
689  return false;
690  }

◆ findDeclaredConstructor()

static Constructor<?> org.keycloak.common.util.reflections.Reflections.findDeclaredConstructor ( Class<?>  clazz,
Class<?>...  args 
)
inlinestatic

Search the class hierarchy for a constructor with the given arguments. Will return the nearest match, starting with the class specified and searching up the hierarchy.

引数
clazzThe class to search
argsThe arguments of the constructor to search for
戻り値
The constructor found, or null if no constructor is found
202  {
203  for (Class<?> c = clazz; c != null && c != Object.class; c = c.getSuperclass()) {
204  try {
205  return c.getDeclaredConstructor(args);
206  } catch (NoSuchMethodException e) {
207  // No-op, continue the search
208  }
209  }
210  return null;
211  }

◆ findDeclaredField()

static Field org.keycloak.common.util.reflections.Reflections.findDeclaredField ( Class<?>  clazz,
String  name 
)
inlinestatic

Search the class hierarchy for a field with the given name. Will return the nearest match, starting with the class specified and searching up the hierarchy.

引数
clazzThe class to search
nameThe name of the field to search for
戻り値
The field found, or null if no field is found
106  {
107  for (Class<?> c = clazz; c != null && c != Object.class; c = c.getSuperclass()) {
108  try {
109  return c.getDeclaredField(name);
110  } catch (NoSuchFieldException e) {
111  // No-op, we continue looking up the class hierarchy
112  }
113  }
114  return null;
115  }

◆ findDeclaredMethod()

static Method org.keycloak.common.util.reflections.Reflections.findDeclaredMethod ( Class<?>  clazz,
String  name,
Class<?>...  args 
)
inlinestatic

Search the class hierarchy for a method with the given name and arguments. Will return the nearest match, starting with the class specified and searching up the hierarchy.

引数
clazzThe class to search
nameThe name of the method to search for
argsThe arguments of the method to search for
戻り値
The method found, or null if no method is found
182  {
183  for (Class<?> c = clazz; c != null && c != Object.class; c = c.getSuperclass()) {
184  try {
185  return c.getDeclaredMethod(name, args);
186  } catch (NoSuchMethodException e) {
187  // No-op, continue the search
188  }
189  }
190  return null;
191  }

◆ getAllDeclaredConstructors()

static Set<Constructor<?> > org.keycloak.common.util.reflections.Reflections.getAllDeclaredConstructors ( Class<?>  clazz)
inlinestatic

Get all the declared constructors on the class hierarchy. This will return overridden constructors.

引数
clazzThe class to search
戻り値
the set of all declared constructors or an empty set if there are none
220  {
221  HashSet<Constructor<?>> constructors = new HashSet<Constructor<?>>();
222  for (Class<?> c = clazz; c != null && c != Object.class; c = c.getSuperclass()) {
223  for (Constructor<?> constructor : c.getDeclaredConstructors()) {
224  constructors.add(constructor);
225  }
226  }
227  return constructors;
228  }

◆ getAllDeclaredFields()

static Set<Field> org.keycloak.common.util.reflections.Reflections.getAllDeclaredFields ( Class<?>  clazz)
inlinestatic

Get all the declared fields on the class hierarchy. This will return overridden fields.

引数
clazzThe class to search
戻り値
the set of all declared fields or an empty set if there are none
87  {
88  HashSet<Field> fields = new HashSet<Field>();
89  for (Class<?> c = clazz; c != null && c != Object.class; c = c.getSuperclass()) {
90  for (Field a : c.getDeclaredFields()) {
91  fields.add(a);
92  }
93  }
94  return fields;
95  }

◆ getAllDeclaredMethods()

static Set<Method> org.keycloak.common.util.reflections.Reflections.getAllDeclaredMethods ( Class<?>  clazz)
inlinestatic

Get all the declared methods on the class hierarchy. This will return overridden methods.

引数
clazzThe class to search
戻り値
the set of all declared methods or an empty set if there are none
162  {
163  HashSet<Method> methods = new HashSet<Method>();
164  for (Class<?> c = clazz; c != null && c != Object.class; c = c.getSuperclass()) {
165  for (Method a : c.getDeclaredMethods()) {
166  methods.add(a);
167  }
168  }
169  return methods;
170  }

◆ getAnnotationsWithMetaAnnotation()

static Set<Annotation> org.keycloak.common.util.reflections.Reflections.getAnnotationsWithMetaAnnotation ( Set< Annotation >  annotations,
Class<? extends Annotation >  metaAnnotationType 
)
inlinestatic

Search for annotations with the specified meta annotation type

引数
annotationsThe annotation set to search
metaAnnotationTypeThe type of the meta annotation to search for
戻り値
The set of annotations with the specified meta annotation, or an empty set if none are found
126  {
127  Set<Annotation> set = new HashSet<Annotation>();
128  for (Annotation annotation : annotations) {
129  if (annotation.annotationType().isAnnotationPresent(metaAnnotationType)) {
130  set.add(annotation);
131  }
132  }
133  return set;
134  }

◆ getFieldValue() [1/2]

static Object org.keycloak.common.util.reflections.Reflections.getFieldValue ( Field  field,
Object  instance 
)
inlinestatic
420  {
421  return getFieldValue(field, instance, Object.class);
422  }
static Object getFieldValue(Field field, Object instance)
Definition: Reflections.java:420

◆ getFieldValue() [2/2]

static <T> T org.keycloak.common.util.reflections.Reflections.getFieldValue ( Field  field,
Object  instance,
Class< T >  expectedType 
)
inlinestatic

Get the value of the field, on the specified instance, casting the value of the field to the expected type.

This method wraps Field#get(Object), converting the checked exceptions that Field#get(Object) specifies to runtime exceptions.

引数
<T>the type of the field's value
fieldthe field to operate on
instancethe instance from which to retrieve the value
expectedTypethe expected type of the field's value
戻り値
the value of the field
例外
RuntimeExceptionif the underlying field is inaccessible.
IllegalArgumentExceptionif the specified instance is not an instance of the class or interface declaring the underlying field (or a subclass or implementor thereof).
NullPointerExceptionif the specified instance is null and the field is an instance field.
ExceptionInInitializerErrorif the initialization provoked by this method fails.
442  {
443  try {
444  return Reflections.cast(field.get(instance));
445  } catch (IllegalAccessException e) {
446  throw new RuntimeException(buildGetFieldValueErrorMessage(field, instance), e);
447  } catch (NullPointerException ex) {
448  NullPointerException ex2 = new NullPointerException(buildGetFieldValueErrorMessage(field, instance));
449  ex2.initCause(ex.getCause());
450  throw ex2;
451  } catch (ExceptionInInitializerError e) {
452  ExceptionInInitializerError e2 = new ExceptionInInitializerError(
453  buildGetFieldValueErrorMessage(field, instance));
454  e2.initCause(e.getCause());
455  throw e2;
456  }
457  }
static String buildGetFieldValueErrorMessage(Field field, Object obj)
Definition: Reflections.java:416
Reflections()
Definition: Reflections.java:59

◆ getMemberType()

static Class<?> org.keycloak.common.util.reflections.Reflections.getMemberType ( Member  member)
inlinestatic

Get the type of the member

引数
memberThe member
戻り値
The type of the member
例外
UnsupportedOperationExceptionif the member is not a field, method, or constructor
239  {
240  if (member instanceof Field) {
241  return ((Field) member).getType();
242  } else if (member instanceof Method) {
243  return ((Method) member).getReturnType();
244  } else if (member instanceof Constructor<?>) {
245  return ((Constructor<?>) member).getDeclaringClass();
246  } else {
247  throw new UnsupportedOperationException("Cannot operate on a member of type " + member.getClass());
248  }
249  }

◆ getNesting()

static int org.keycloak.common.util.reflections.Reflections.getNesting ( Class<?>  clazz)
inlinestatic
559  {
560  if (clazz.isMemberClass() && !isStatic(clazz)) {
561  return 1 + getNesting(clazz.getDeclaringClass());
562  } else {
563  return 0;
564  }
565  }
static boolean isStatic(Class<?> type)
Definition: Reflections.java:623
static int getNesting(Class<?> clazz)
Definition: Reflections.java:559

◆ getNonPrivateFinalMethodOrType()

static Object org.keycloak.common.util.reflections.Reflections.getNonPrivateFinalMethodOrType ( Class<?>  type)
inlinestatic
600  {
601  if (isFinal(type)) {
602  return type;
603  }
604  for (Method method : type.getDeclaredMethods()) {
605  if (isFinal(method) && !isPrivate(method)) {
606  return method;
607  }
608  }
609  return null;
610  }
static boolean isPrivate(Member member)
Definition: Reflections.java:585
static boolean isFinal(Class<?> clazz)
Definition: Reflections.java:555

◆ getPropertyName()

static String org.keycloak.common.util.reflections.Reflections.getPropertyName ( Method  method)
inlinestatic

Gets the property name from a getter method.

We extend JavaBean conventions, allowing the getter method to have parameters

引数
methodThe getter method
戻り値
The name of the property. Returns null if method wasn't JavaBean getter-styled
536  {
537  String methodName = method.getName();
538  if (methodName.matches("^(get).*")) {
539  return Introspector.decapitalize(methodName.substring(3));
540  } else if (methodName.matches("^(is).*")) {
541  return Introspector.decapitalize(methodName.substring(2));
542  } else {
543  return null;
544  }
545 
546  }

◆ getRawType()

static <T> Class<T> org.keycloak.common.util.reflections.Reflections.getRawType ( Type  type)
inlinestatic

Extract the raw type, given a type.

引数
<T>the type
typethe type to extract the raw type from
戻り値
the raw type, or null if the raw type cannot be determined.
468  {
469  if (type instanceof Class<?>) {
470  return (Class<T>) type;
471  } else if (type instanceof ParameterizedType) {
472  if (((ParameterizedType) type).getRawType() instanceof Class<?>) {
473  return (Class<T>) ((ParameterizedType) type).getRawType();
474  }
475  }
476  return null;
477  }
static< T > Class< T > getRawType(Type type)
Definition: Reflections.java:468

◆ invokeMethod() [1/4]

static Object org.keycloak.common.util.reflections.Reflections.invokeMethod ( Method  method,
Object  instance,
Object...  args 
)
inlinestatic

Invoke the specified method on the provided instance, passing any additional arguments included in this method as arguments to the specified method.

This method provides the same functionality and throws the same exceptions as Reflections#invokeMethod(boolean, Method, Class, Object, Object...), with the expected return type set to Object and no change to the method's accessibility.

参照
Reflections::invokeMethod(boolean, Method, Class, Object, Object...)
Method::invoke(Object, Object...)
313  {
314  return invokeMethod(false, method, Object.class, instance, args);
315  }
static Object invokeMethod(Method method, Object instance, Object... args)
Definition: Reflections.java:313

◆ invokeMethod() [2/4]

static Object org.keycloak.common.util.reflections.Reflections.invokeMethod ( boolean  setAccessible,
Method  method,
Object  instance,
Object...  args 
)
inlinestatic

Invoke the specified method on the provided instance, passing any additional arguments included in this method as arguments to the specified method.

This method attempts to set the accessible flag of the method in a {link PrivilegedAction} before invoking the method if the first argument is true.

This method provides the same functionality and throws the same exceptions as Method, Class, Object, Object...), with the expected return type set to Object.

参照
Reflections::invokeMethod(boolean, Method, Class, Object, Object...)
Method::invoke(Object, Object...)
327  {
328  return invokeMethod(setAccessible, method, Object.class, instance, args);
329  }
static< A extends AccessibleObject > A setAccessible(A member)
Definition: Reflections.java:407
static Object invokeMethod(Method method, Object instance, Object... args)
Definition: Reflections.java:313

◆ invokeMethod() [3/4]

static <T> T org.keycloak.common.util.reflections.Reflections.invokeMethod ( Method  method,
Class< T >  expectedReturnType,
Object  instance,
Object...  args 
)
inlinestatic

Invoke the specified method on the provided instance, passing any additional arguments included in this method as arguments to the specified method.

This method provides the same functionality and throws the same exceptions as Reflections#invokeMethod(boolean, Method, Class, Object, Object...), with the expected return type set to Object and honoring the accessibility of the method.

参照
Reflections::invokeMethod(boolean, Method, Class, Object, Object...)
Method::invoke(Object, Object...)
340  {
341  return invokeMethod(false, method, expectedReturnType, instance, args);
342  }
static Object invokeMethod(Method method, Object instance, Object... args)
Definition: Reflections.java:313

◆ invokeMethod() [4/4]

static <T> T org.keycloak.common.util.reflections.Reflections.invokeMethod ( boolean  setAccessible,
Method  method,
Class< T >  expectedReturnType,
Object  instance,
Object...  args 
)
inlinestatic

Invoke the method on the instance, with any arguments specified, casting the result of invoking the method to the expected return type.

This method wraps Method#invoke(Object, Object...), converting the checked exceptions that Method#invoke(Object, Object...) specifies to runtime exceptions.

If instructed, this method attempts to set the accessible flag of the method in a {link PrivilegedAction} before invoking the method.

引数
setAccessibleflag indicating whether method should first be set as accessible
methodthe method to invoke
instancethe instance to invoke the method
argsthe arguments to the method
戻り値
the result of invoking the method, or null if the method's return type is void
例外
RuntimeExceptionif this Method object enforces Java language access control and the underlying method is inaccessible or if the underlying method throws an exception or if the initialization provoked by this method fails.
IllegalArgumentExceptionif the method is an instance method and the specified instance argument is not an instance of the class or interface declaring the underlying method (or of a subclass or implementor thereof); if the number of actual and formal parameters differ; if an unwrapping conversion for primitive arguments fails; or if, after possible unwrapping, a parameter value cannot be converted to the corresponding formal parameter type by a method invocation conversion.
NullPointerExceptionif the specified instance is null and the method is an instance method.
ClassCastExceptionif the result of invoking the method cannot be cast to the expectedReturnType
ExceptionInInitializerErrorif the initialization provoked by this method fails.
参照
Method::invoke(Object, Object...)
373  {
374  if (setAccessible && !method.isAccessible()) {
375  setAccessible(method);
376  }
377 
378  try {
379  return expectedReturnType.cast(method.invoke(instance, args));
380  } catch (IllegalAccessException ex) {
381  throw new RuntimeException(buildInvokeMethodErrorMessage(method, instance, args), ex);
382  } catch (IllegalArgumentException ex) {
383  throw new IllegalArgumentException(buildInvokeMethodErrorMessage(method, instance, args), ex);
384  } catch (InvocationTargetException ex) {
385  throw new RuntimeException(buildInvokeMethodErrorMessage(method, instance, args), ex.getCause());
386  } catch (NullPointerException ex) {
387  NullPointerException ex2 = new NullPointerException(buildInvokeMethodErrorMessage(method, instance, args));
388  ex2.initCause(ex.getCause());
389  throw ex2;
390  } catch (ExceptionInInitializerError e) {
391  ExceptionInInitializerError e2 = new ExceptionInInitializerError(
392  buildInvokeMethodErrorMessage(method, instance, args));
393  e2.initCause(e.getCause());
394  throw e2;
395  }
396  }
static< A extends AccessibleObject > A setAccessible(A member)
Definition: Reflections.java:407
static String buildInvokeMethodErrorMessage(Method method, Object obj, Object... args)
Definition: Reflections.java:291

◆ isAbstract()

static boolean org.keycloak.common.util.reflections.Reflections.isAbstract ( Method  method)
inlinestatic

Checks if a method is abstract

引数
method
戻り値
649  {
650  return Modifier.isAbstract(method.getModifiers());
651  }

◆ isArrayType()

static boolean org.keycloak.common.util.reflections.Reflections.isArrayType ( Class<?>  rawType)
inlinestatic

Checks if raw type is array type

引数
rawTypeThe raw type to check
戻り値
True if array, false otherwise
660  {
661  return rawType.isArray();
662  }

◆ isAssignableFrom() [1/9]

static boolean org.keycloak.common.util.reflections.Reflections.isAssignableFrom ( Class<?>  rawType1,
Type []  actualTypeArguments1,
Class<?>  rawType2,
Type []  actualTypeArguments2 
)
inlinestatic

Check the assignability of one type to another, taking into account the actual type arguements

引数
rawType1the raw type of the class to check
actualTypeArguments1the actual type arguements to check, or an empty array if not a parameterized type
rawType2the raw type of the class to check
actualTypeArguments2the actual type arguements to check, or an empty array if not a parameterized type
戻り値
703  {
704  return Types.boxedClass(rawType1).isAssignableFrom(Types.boxedClass(rawType2)) &&
705  isAssignableFrom(actualTypeArguments1, actualTypeArguments2);
706  }
static boolean isAssignableFrom(Class<?> rawType1, Type[] actualTypeArguments1, Class<?> rawType2, Type[] actualTypeArguments2)
Definition: Reflections.java:702

◆ isAssignableFrom() [2/9]

static boolean org.keycloak.common.util.reflections.Reflections.isAssignableFrom ( Type []  actualTypeArguments1,
Type []  actualTypeArguments2 
)
inlinestatic
714  {
715  for (int i = 0; i < actualTypeArguments1.length; i++) {
716  Type type1 = actualTypeArguments1[i];
717  Type type2 = Object.class;
718  if (actualTypeArguments2.length > i) {
719  type2 = actualTypeArguments2[i];
720  }
721  if (!isAssignableFrom(type1, type2)) {
722  return false;
723  }
724  }
725  return true;
726  }
static boolean isAssignableFrom(Class<?> rawType1, Type[] actualTypeArguments1, Class<?> rawType2, Type[] actualTypeArguments2)
Definition: Reflections.java:702

◆ isAssignableFrom() [3/9]

static boolean org.keycloak.common.util.reflections.Reflections.isAssignableFrom ( Type  type1,
Set<? extends Type >  types2 
)
inlinestatic
728  {
729  for (Type type2 : types2) {
730  if (isAssignableFrom(type1, type2)) {
731  return true;
732  }
733  }
734  return false;
735  }
static boolean isAssignableFrom(Class<?> rawType1, Type[] actualTypeArguments1, Class<?> rawType2, Type[] actualTypeArguments2)
Definition: Reflections.java:702

◆ isAssignableFrom() [4/9]

static boolean org.keycloak.common.util.reflections.Reflections.isAssignableFrom ( Type  type1,
Type []  types2 
)
inlinestatic
746  {
747  for (Type type2 : types2) {
748  if (isAssignableFrom(type1, type2)) {
749  return true;
750  }
751  }
752  return false;
753  }
static boolean isAssignableFrom(Class<?> rawType1, Type[] actualTypeArguments1, Class<?> rawType2, Type[] actualTypeArguments2)
Definition: Reflections.java:702

◆ isAssignableFrom() [5/9]

static boolean org.keycloak.common.util.reflections.Reflections.isAssignableFrom ( Type  type1,
Type  type2 
)
inlinestatic
755  {
756  if (type1 instanceof Class<?>) {
757  Class<?> clazz = (Class<?>) type1;
758  if (isAssignableFrom(clazz, EMPTY_TYPES, type2)) {
759  return true;
760  }
761  }
762  if (type1 instanceof ParameterizedType) {
763  ParameterizedType parameterizedType1 = (ParameterizedType) type1;
764  if (parameterizedType1.getRawType() instanceof Class<?>) {
765  if (isAssignableFrom((Class<?>) parameterizedType1.getRawType(),
766  parameterizedType1.getActualTypeArguments(), type2)) {
767  return true;
768  }
769  }
770  }
771  if (type1 instanceof WildcardType) {
772  WildcardType wildcardType = (WildcardType) type1;
773  if (isTypeBounded(type2, wildcardType.getLowerBounds(), wildcardType.getUpperBounds())) {
774  return true;
775  }
776  }
777  if (type2 instanceof WildcardType) {
778  WildcardType wildcardType = (WildcardType) type2;
779  if (isTypeBounded(type1, wildcardType.getUpperBounds(), wildcardType.getLowerBounds())) {
780  return true;
781  }
782  }
783  if (type1 instanceof TypeVariable<?>) {
784  TypeVariable<?> typeVariable = (TypeVariable<?>) type1;
785  if (isTypeBounded(type2, EMPTY_TYPES, typeVariable.getBounds())) {
786  return true;
787  }
788  }
789  if (type2 instanceof TypeVariable<?>) {
790  TypeVariable<?> typeVariable = (TypeVariable<?>) type2;
791  if (isTypeBounded(type1, typeVariable.getBounds(), EMPTY_TYPES)) {
792  return true;
793  }
794  }
795  return false;
796  }
static boolean isTypeBounded(Type type, Type[] lowerBounds, Type[] upperBounds)
Definition: Reflections.java:841
static boolean isAssignableFrom(Class<?> rawType1, Type[] actualTypeArguments1, Class<?> rawType2, Type[] actualTypeArguments2)
Definition: Reflections.java:702
static final Type [] EMPTY_TYPES
Definition: Reflections.java:55

◆ isAssignableFrom() [6/9]

static boolean org.keycloak.common.util.reflections.Reflections.isAssignableFrom ( Class<?>  rawType1,
Type []  actualTypeArguments1,
Type  type2 
)
inlinestatic
855  {
856  if (type2 instanceof ParameterizedType) {
857  ParameterizedType parameterizedType = (ParameterizedType) type2;
858  if (parameterizedType.getRawType() instanceof Class<?>) {
859  if (isAssignableFrom(rawType1, actualTypeArguments1, (Class<?>) parameterizedType.getRawType(),
860  parameterizedType.getActualTypeArguments())) {
861  return true;
862  }
863  }
864  } else if (type2 instanceof Class<?>) {
865  Class<?> clazz = (Class<?>) type2;
866  if (isAssignableFrom(rawType1, actualTypeArguments1, clazz, EMPTY_TYPES)) {
867  return true;
868  }
869  } else if (type2 instanceof TypeVariable<?>) {
870  TypeVariable<?> typeVariable = (TypeVariable<?>) type2;
871  if (isTypeBounded(rawType1, actualTypeArguments1, typeVariable.getBounds())) {
872  return true;
873  }
874  }
875  return false;
876  }
static boolean isTypeBounded(Type type, Type[] lowerBounds, Type[] upperBounds)
Definition: Reflections.java:841
static boolean isAssignableFrom(Class<?> rawType1, Type[] actualTypeArguments1, Class<?> rawType2, Type[] actualTypeArguments2)
Definition: Reflections.java:702
static final Type [] EMPTY_TYPES
Definition: Reflections.java:55

◆ isAssignableFrom() [7/9]

static boolean org.keycloak.common.util.reflections.Reflections.isAssignableFrom ( Set< Type >  types1,
Set< Type >  types2 
)
inlinestatic

Check the assiginability of a set of flattened types. This algorithm will check whether any of the types1 matches a type in types2

引数
types1
types2
戻り値
905  {
906  for (Type type : types1) {
907  if (isAssignableFrom(type, types2)) {
908  return true;
909  }
910  }
911  return false;
912  }
static boolean isAssignableFrom(Class<?> rawType1, Type[] actualTypeArguments1, Class<?> rawType2, Type[] actualTypeArguments2)
Definition: Reflections.java:702

◆ isAssignableFrom() [8/9]

static boolean org.keycloak.common.util.reflections.Reflections.isAssignableFrom ( Set< Type >  types1,
Type  type2 
)
inlinestatic

Check the assignability of a set of flattened types. This algorithm will check whether any of the types1 matches a type in types2

引数
types1
type2
戻り値
940  {
941  for (Type type : types1) {
942  if (isAssignableFrom(type, type2)) {
943  return true;
944  }
945  }
946  return false;
947  }
static boolean isAssignableFrom(Class<?> rawType1, Type[] actualTypeArguments1, Class<?> rawType2, Type[] actualTypeArguments2)
Definition: Reflections.java:702

◆ isAssignableFrom() [9/9]

static boolean org.keycloak.common.util.reflections.Reflections.isAssignableFrom ( Type []  types1,
Type  type2 
)
inlinestatic
949  {
950  for (Type type : types1) {
951  if (isAssignableFrom(type, type2)) {
952  return true;
953  }
954  }
955  return false;
956  }
static boolean isAssignableFrom(Class<?> rawType1, Type[] actualTypeArguments1, Class<?> rawType2, Type[] actualTypeArguments2)
Definition: Reflections.java:702

◆ isCacheable() [1/2]

static boolean org.keycloak.common.util.reflections.Reflections.isCacheable ( Set< Annotation >  annotations)
inlinestatic
507  {
508  for (Annotation qualifier : annotations) {
509  Class<?> clazz = qualifier.getClass();
510  if (clazz.isAnonymousClass() || (clazz.isMemberClass() && isStatic(clazz))) {
511  return false;
512  }
513  }
514  return true;
515  }
static boolean isStatic(Class<?> type)
Definition: Reflections.java:623

◆ isCacheable() [2/2]

static boolean org.keycloak.common.util.reflections.Reflections.isCacheable ( Annotation []  annotations)
inlinestatic
517  {
518  for (Annotation qualifier : annotations) {
519  Class<?> clazz = qualifier.getClass();
520  if (clazz.isAnonymousClass() || (clazz.isMemberClass() && isStatic(clazz))) {
521  return false;
522  }
523  }
524  return true;
525  }
static boolean isStatic(Class<?> type)
Definition: Reflections.java:623

◆ isFinal() [1/2]

static boolean org.keycloak.common.util.reflections.Reflections.isFinal ( Class<?>  clazz)
inlinestatic

Checks if class is final

引数
clazzThe class to check
戻り値
True if final, false otherwise
555  {
556  return Modifier.isFinal(clazz.getModifiers());
557  }

◆ isFinal() [2/2]

static boolean org.keycloak.common.util.reflections.Reflections.isFinal ( Member  member)
inlinestatic

Checks if member is final

引数
memberThe member to check
戻り値
True if final, false otherwise
574  {
575  return Modifier.isFinal(member.getModifiers());
576  }

◆ isPackagePrivate()

static boolean org.keycloak.common.util.reflections.Reflections.isPackagePrivate ( int  mod)
inlinestatic
612  {
613  return !(Modifier.isPrivate(mod) || Modifier.isProtected(mod) || Modifier.isPublic(mod));
614  }

◆ isParamerterizedTypeWithWildcard()

static boolean org.keycloak.common.util.reflections.Reflections.isParamerterizedTypeWithWildcard ( Class<?>  type)
inlinestatic
675  {
676  if (isParameterizedType(type)) {
677  return containsWildcards(type.getTypeParameters());
678  } else {
679  return false;
680  }
681  }
static boolean isParameterizedType(Class<?> type)
Definition: Reflections.java:671
static boolean containsWildcards(Type[] types)
Definition: Reflections.java:683

◆ isParameterizedType()

static boolean org.keycloak.common.util.reflections.Reflections.isParameterizedType ( Class<?>  type)
inlinestatic

Checks if type is parameterized type

引数
typeThe type to check
戻り値
True if parameterized, false otherwise
671  {
672  return type.getTypeParameters().length > 0;
673  }

◆ isPrimitive()

static boolean org.keycloak.common.util.reflections.Reflections.isPrimitive ( Type  type)
inlinestatic
958  {
959  Class<?> rawType = getRawType(type);
960  return rawType == null ? false : rawType.isPrimitive();
961  }
static< T > Class< T > getRawType(Type type)
Definition: Reflections.java:468

◆ isPrivate()

static boolean org.keycloak.common.util.reflections.Reflections.isPrivate ( Member  member)
inlinestatic

Checks if member is private

引数
memberThe member to check
戻り値
True if final, false otherwise
585  {
586  return Modifier.isPrivate(member.getModifiers());
587  }

◆ isSerializable()

static boolean org.keycloak.common.util.reflections.Reflections.isSerializable ( Class<?>  clazz)
inlinestatic

Check if a class is serializable.

引数
clazzThe class to check
戻り値
true if the class implements serializable or is a primitive
486  {
487  return clazz.isPrimitive() || Serializable.class.isAssignableFrom(clazz);
488  }

◆ isStatic() [1/2]

static boolean org.keycloak.common.util.reflections.Reflections.isStatic ( Class<?>  type)
inlinestatic

Checks if type is static

引数
typeType to check
戻り値
True if static, false otherwise
623  {
624  return Modifier.isStatic(type.getModifiers());
625  }

◆ isStatic() [2/2]

static boolean org.keycloak.common.util.reflections.Reflections.isStatic ( Member  member)
inlinestatic

Checks if member is static

引数
memberMember to check
戻り値
True if static, false otherwise
634  {
635  return Modifier.isStatic(member.getModifiers());
636  }

◆ isTransient()

static boolean org.keycloak.common.util.reflections.Reflections.isTransient ( Member  member)
inlinestatic
638  {
639  return Modifier.isTransient(member.getModifiers());
640  }

◆ isTypeBounded()

static boolean org.keycloak.common.util.reflections.Reflections.isTypeBounded ( Type  type,
Type []  lowerBounds,
Type []  upperBounds 
)
inlinestatic
841  {
842  if (lowerBounds.length > 0) {
843  if (!isAssignableFrom(type, lowerBounds)) {
844  return false;
845  }
846  }
847  if (upperBounds.length > 0) {
848  if (!isAssignableFrom(upperBounds, type)) {
849  return false;
850  }
851  }
852  return true;
853  }
static boolean isAssignableFrom(Class<?> rawType1, Type[] actualTypeArguments1, Class<?> rawType2, Type[] actualTypeArguments2)
Definition: Reflections.java:702

◆ isTypeOrAnyMethodFinal()

static boolean org.keycloak.common.util.reflections.Reflections.isTypeOrAnyMethodFinal ( Class<?>  type)
inlinestatic

Checks if type or member is final

引数
typeType or member
戻り値
True if final, false otherwise
596  {
597  return getNonPrivateFinalMethodOrType(type) != null;
598  }
static Object getNonPrivateFinalMethodOrType(Class<?> type)
Definition: Reflections.java:600

◆ matches() [1/5]

static boolean org.keycloak.common.util.reflections.Reflections.matches ( Class<?>  rawType1,
Type []  actualTypeArguments1,
Class<?>  rawType2,
Type []  actualTypeArguments2 
)
inlinestatic
709  {
710  return Types.boxedClass(rawType1).equals(Types.boxedClass(rawType2)) &&
711  isAssignableFrom(actualTypeArguments1, actualTypeArguments2);
712  }
static boolean isAssignableFrom(Class<?> rawType1, Type[] actualTypeArguments1, Class<?> rawType2, Type[] actualTypeArguments2)
Definition: Reflections.java:702

◆ matches() [2/5]

static boolean org.keycloak.common.util.reflections.Reflections.matches ( Type  type1,
Set<? extends Type >  types2 
)
inlinestatic
737  {
738  for (Type type2 : types2) {
739  if (matches(type1, type2)) {
740  return true;
741  }
742  }
743  return false;
744  }
static boolean matches(Class<?> rawType1, Type[] actualTypeArguments1, Class<?> rawType2, Type[] actualTypeArguments2)
Definition: Reflections.java:708

◆ matches() [3/5]

static boolean org.keycloak.common.util.reflections.Reflections.matches ( Type  type1,
Type  type2 
)
inlinestatic
798  {
799  if (type1 instanceof Class<?>) {
800  Class<?> clazz = (Class<?>) type1;
801  if (matches(clazz, EMPTY_TYPES, type2)) {
802  return true;
803  }
804  }
805  if (type1 instanceof ParameterizedType) {
806  ParameterizedType parameterizedType1 = (ParameterizedType) type1;
807  if (parameterizedType1.getRawType() instanceof Class<?>) {
808  if (matches((Class<?>) parameterizedType1.getRawType(),
809  parameterizedType1.getActualTypeArguments(), type2)) {
810  return true;
811  }
812  }
813  }
814  if (type1 instanceof WildcardType) {
815  WildcardType wildcardType = (WildcardType) type1;
816  if (isTypeBounded(type2, wildcardType.getLowerBounds(), wildcardType.getUpperBounds())) {
817  return true;
818  }
819  }
820  if (type2 instanceof WildcardType) {
821  WildcardType wildcardType = (WildcardType) type2;
822  if (isTypeBounded(type1, wildcardType.getUpperBounds(), wildcardType.getLowerBounds())) {
823  return true;
824  }
825  }
826  if (type1 instanceof TypeVariable<?>) {
827  TypeVariable<?> typeVariable = (TypeVariable<?>) type1;
828  if (isTypeBounded(type2, EMPTY_TYPES, typeVariable.getBounds())) {
829  return true;
830  }
831  }
832  if (type2 instanceof TypeVariable<?>) {
833  TypeVariable<?> typeVariable = (TypeVariable<?>) type2;
834  if (isTypeBounded(type1, typeVariable.getBounds(), EMPTY_TYPES)) {
835  return true;
836  }
837  }
838  return false;
839  }
static boolean isTypeBounded(Type type, Type[] lowerBounds, Type[] upperBounds)
Definition: Reflections.java:841
static final Type [] EMPTY_TYPES
Definition: Reflections.java:55
static boolean matches(Class<?> rawType1, Type[] actualTypeArguments1, Class<?> rawType2, Type[] actualTypeArguments2)
Definition: Reflections.java:708

◆ matches() [4/5]

static boolean org.keycloak.common.util.reflections.Reflections.matches ( Class<?>  rawType1,
Type []  actualTypeArguments1,
Type  type2 
)
inlinestatic
878  {
879  if (type2 instanceof ParameterizedType) {
880  ParameterizedType parameterizedType = (ParameterizedType) type2;
881  if (parameterizedType.getRawType() instanceof Class<?>) {
882  if (matches(rawType1, actualTypeArguments1, (Class<?>) parameterizedType.getRawType(),
883  parameterizedType.getActualTypeArguments())) {
884  return true;
885  }
886  }
887  } else if (type2 instanceof Class<?>) {
888  Class<?> clazz = (Class<?>) type2;
889  if (matches(rawType1, actualTypeArguments1, clazz, EMPTY_TYPES)) {
890  return true;
891  }
892  }
893  return false;
894  }
static final Type [] EMPTY_TYPES
Definition: Reflections.java:55
static boolean matches(Class<?> rawType1, Type[] actualTypeArguments1, Class<?> rawType2, Type[] actualTypeArguments2)
Definition: Reflections.java:708

◆ matches() [5/5]

static boolean org.keycloak.common.util.reflections.Reflections.matches ( Set< Type >  types1,
Set< Type >  types2 
)
inlinestatic

Check whether whether any of the types1 matches a type in types2

引数
types1
types2
戻り値
922  {
923  for (Type type : types1) {
924  if (matches(type, types2)) {
925  return true;
926  }
927  }
928  return false;
929  }
static boolean matches(Class<?> rawType1, Type[] actualTypeArguments1, Class<?> rawType2, Type[] actualTypeArguments2)
Definition: Reflections.java:708

◆ methodExists()

static boolean org.keycloak.common.util.reflections.Reflections.methodExists ( Class<?>  clazz,
String  name 
)
inlinestatic

Determine if a method exists in a specified class hierarchy

引数
clazzThe class to search
nameThe name of the method
戻り値
true if a method is found, otherwise false
144  {
145  for (Class<?> c = clazz; c != null && c != Object.class; c = c.getSuperclass()) {
146  for (Method m : c.getDeclaredMethods()) {
147  if (m.getName().equals(name)) {
148  return true;
149  }
150  }
151  }
152  return false;
153  }

◆ newInstance() [1/2]

static <T> T org.keycloak.common.util.reflections.Reflections.newInstance ( final Class< T >  fromClass) throws ClassNotFoundException, IllegalAccessException, InstantiationException
inlinestatic

Creates a new instance of a class.

This method will use the same class loader of the given class to create the new instance.

引数
fromClassThe class from where the instance should be created.
戻り値
A newly allocated instance of the class.
例外
ClassNotFoundException
IllegalAccessException
InstantiationException
976  {
977  return newInstance(fromClass, fromClass.getName());
978  }
static< T > T newInstance(final Class< T > fromClass)
Definition: Reflections.java:976

◆ newInstance() [2/2]

static <T> T org.keycloak.common.util.reflections.Reflections.newInstance ( final Class<?>  type,
final String  fullQualifiedName 
) throws ClassNotFoundException, IllegalAccessException, InstantiationException
inlinestatic

Creates a new instance of a class given its fullQualifiedName.

This method will use the same class loader of type to create the new instance.

引数
typeThe class that will be used to get the class loader from.
fullQualifiedNameThe full qualified name of the class from which the instance will be created.
戻り値
A newly allocated instance of the class.
例外
ClassNotFoundException
IllegalAccessException
InstantiationException
994  {
995  return (T) classForName(fullQualifiedName, type.getClassLoader()).newInstance();
996  }
static< T > T newInstance(final Class< T > fromClass)
Definition: Reflections.java:976
static< T > Class< T > classForName(String name, ClassLoader... loaders)
Definition: Reflections.java:264

◆ setAccessible()

static <A extends AccessibleObject> A org.keycloak.common.util.reflections.Reflections.setAccessible ( member)
inlinestatic

Set the accessibility flag on the AccessibleObject as described in AccessibleObject#setAccessible(boolean) within the context of a {link PrivilegedAction}.

引数
<A>member the accessible object type
memberthe accessible object
戻り値
the accessible object after the accessible flag has been altered
407  {
408  AccessController.doPrivileged(new SetAccessiblePrivilegedAction(member));
409  return member;
410  }

メンバ詳解

◆ EMPTY_ANNOTATION_ARRAY

final Annotation [] org.keycloak.common.util.reflections.Reflections.EMPTY_ANNOTATION_ARRAY = new Annotation[0]
static

An empty array of type java.lang.annotation.Annotation, useful converting lists to arrays.

◆ EMPTY_CLASSES

final Class<?> [] org.keycloak.common.util.reflections.Reflections.EMPTY_CLASSES = new Class<?>[0]
static

◆ EMPTY_OBJECT_ARRAY

final Object [] org.keycloak.common.util.reflections.Reflections.EMPTY_OBJECT_ARRAY = new Object[0]
static

An empty array of type Object, useful for converting lists to arrays.

◆ EMPTY_TYPES

final Type [] org.keycloak.common.util.reflections.Reflections.EMPTY_TYPES = {}
static

このクラス詳解は次のファイルから抽出されました: