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

静的公開メンバ関数

static Type boxedType (Type type)
 
static Class<?> boxedClass (Class<?> type)
 
static boolean isA (Class clazz, ParameterizedType pType)
 
static Class getArgumentType (ParameterizedType pType, int index)
 
static Class getTemplateParameterOfInterface (Class base, Class desiredInterface)
 
static boolean isCompatible (Method method, Method intfMethod)
 
static Method getImplementingMethod (Class clazz, Method intfMethod)
 
static Class<?> getRawType (Type type)
 
static Class<?> getRawTypeNoException (Type type)
 
static Class<?> getTypeArgument (Type genericType)
 
static Class getCollectionBaseType (Class type, Type genericType)
 
static Class getMapKeyType (Type genericType)
 
static Class getMapValueType (Type genericType)
 
static Type resolveTypeVariables (Class<?> root, Type type)
 
static Type resolveTypeVariable (Class<?> root, TypeVariable<?> typeVariable)
 
static Type [] getActualTypeArgumentsOfAnInterface (Class<?> classToSearch, Class<?> interfaceToFind)
 
static Type [] findParameterizedTypes (Class<?> root, Class<?> searchedFor)
 
static Type [] findClassParameterizedTypes (Class<?> root, ParameterizedType rootType, Class<?> searchedForClass)
 
static Type [] findInterfaceParameterizedTypes (Class<?> root, ParameterizedType rootType, Class<?> searchedForInterface)
 
static< T > boolean supports (Class< T > type, Object object, Class<?> fromInterface)
 

非公開メンバ関数

 Types ()
 

静的非公開メンバ関数

static Object searchForInterfaceTemplateParameter (Class base, Class desiredInterface)
 
static Map< String, Type > populateParameterizedMap (Class<?> root, ParameterizedType rootType)
 
static Type [] recurseSuperclassForInterface (Class<?> searchedForInterface, Map< String, Type > typeVarMap, Type genericSub, Class<?> sub)
 
static Type [] extractTypeVariables (Map< String, Type > typeVarMap, Type[] types)
 
static Type [] extractTypes (Map< String, Type > typeVarMap, Type genericSub)
 

静的非公開変数類

static final Type [] EMPTY_TYPE_ARRAY = {}
 

詳解

Utility class for Types

構築子と解体子

◆ Types()

org.keycloak.common.util.reflections.Types.Types ( )
inlineprivate
33  {
34 
35  }

関数詳解

◆ boxedClass()

static Class<?> org.keycloak.common.util.reflections.Types.boxedClass ( Class<?>  type)
inlinestatic
52  {
53  if (!type.isPrimitive()) {
54  return type;
55  } else if (type.equals(Boolean.TYPE)) {
56  return Boolean.class;
57  } else if (type.equals(Character.TYPE)) {
58  return Character.class;
59  } else if (type.equals(Byte.TYPE)) {
60  return Byte.class;
61  } else if (type.equals(Short.TYPE)) {
62  return Short.class;
63  } else if (type.equals(Integer.TYPE)) {
64  return Integer.class;
65  } else if (type.equals(Long.TYPE)) {
66  return Long.class;
67  } else if (type.equals(Float.TYPE)) {
68  return Float.class;
69  } else if (type.equals(Double.TYPE)) {
70  return Double.class;
71  } else if (type.equals(Void.TYPE)) {
72  return Void.class;
73  } else {
74  // Vagaries of if/else statement, can't be reached ;-)
75  return type;
76  }
77  }

◆ boxedType()

static Type org.keycloak.common.util.reflections.Types.boxedType ( Type  type)
inlinestatic

Gets the boxed type of a class

引数
typeThe type
戻り値
The boxed type
44  {
45  if (type instanceof Class<?>) {
46  return boxedClass((Class<?>) type);
47  } else {
48  return type;
49  }
50  }
static Class<?> boxedClass(Class<?> type)
Definition: Types.java:52

◆ extractTypes()

static Type [] org.keycloak.common.util.reflections.Types.extractTypes ( Map< String, Type >  typeVarMap,
Type  genericSub 
)
inlinestaticprivate
605  {
606  if (genericSub instanceof ParameterizedType)
607  {
608  ParameterizedType param = (ParameterizedType) genericSub;
609  Type[] types = param.getActualTypeArguments();
610  Type[] returnTypes = new Type[types.length];
611  System.arraycopy(types, 0, returnTypes, 0, types.length);
612  extractTypeVariables(typeVarMap, returnTypes);
613  return returnTypes;
614  }
615  else
616  {
617  return EMPTY_TYPE_ARRAY;
618  }
619  }
static Type [] extractTypeVariables(Map< String, Type > typeVarMap, Type[] types)
Definition: Types.java:587
static final Type [] EMPTY_TYPE_ARRAY
Definition: Types.java:465

◆ extractTypeVariables()

static Type [] org.keycloak.common.util.reflections.Types.extractTypeVariables ( Map< String, Type >  typeVarMap,
Type []  types 
)
inlinestaticprivate
588  {
589  for (int j = 0; j < types.length; j++)
590  {
591  if (types[j] instanceof TypeVariable)
592  {
593  TypeVariable tv = (TypeVariable) types[j];
594  types[j] = typeVarMap.get(tv.getName());
595  }
596  else
597  {
598  types[j] = types[j];
599  }
600  }
601  return types;
602  }

◆ findClassParameterizedTypes()

static Type [] org.keycloak.common.util.reflections.Types.findClassParameterizedTypes ( Class<?>  root,
ParameterizedType  rootType,
Class<?>  searchedForClass 
)
inlinestatic
485  {
486  if (Object.class.equals(root)) return null;
487 
488  Map<String, Type> typeVarMap = populateParameterizedMap(root, rootType);
489 
490  Class<?> superclass = root.getSuperclass();
491  Type genericSuper = root.getGenericSuperclass();
492 
493  if (superclass.equals(searchedForClass))
494  {
495  return extractTypes(typeVarMap, genericSuper);
496  }
497 
498 
499  if (genericSuper instanceof ParameterizedType)
500  {
501  ParameterizedType intfParam = (ParameterizedType) genericSuper;
502  Type[] types = findClassParameterizedTypes(superclass, intfParam, searchedForClass);
503  if (types != null)
504  {
505  return extractTypeVariables(typeVarMap, types);
506  }
507  }
508  else
509  {
510  Type[] types = findClassParameterizedTypes(superclass, null, searchedForClass);
511  if (types != null)
512  {
513  return types;
514  }
515  }
516  return null;
517  }
static Type [] extractTypeVariables(Map< String, Type > typeVarMap, Type[] types)
Definition: Types.java:587
static Type [] findClassParameterizedTypes(Class<?> root, ParameterizedType rootType, Class<?> searchedForClass)
Definition: Types.java:484
static Type [] extractTypes(Map< String, Type > typeVarMap, Type genericSub)
Definition: Types.java:604
static Map< String, Type > populateParameterizedMap(Class<?> root, ParameterizedType rootType)
Definition: Types.java:519

◆ findInterfaceParameterizedTypes()

static Type [] org.keycloak.common.util.reflections.Types.findInterfaceParameterizedTypes ( Class<?>  root,
ParameterizedType  rootType,
Class<?>  searchedForInterface 
)
inlinestatic
535  {
536  Map<String, Type> typeVarMap = populateParameterizedMap(root, rootType);
537 
538  for (int i = 0; i < root.getInterfaces().length; i++)
539  {
540  Class<?> sub = root.getInterfaces()[i];
541  Type genericSub = root.getGenericInterfaces()[i];
542  if (sub.equals(searchedForInterface))
543  {
544  return extractTypes(typeVarMap, genericSub);
545  }
546  }
547 
548  for (int i = 0; i < root.getInterfaces().length; i++)
549  {
550  Type genericSub = root.getGenericInterfaces()[i];
551  Class<?> sub = root.getInterfaces()[i];
552 
553  Type[] types = recurseSuperclassForInterface(searchedForInterface, typeVarMap, genericSub, sub);
554  if (types != null) return types;
555  }
556  if (root.isInterface()) return null;
557 
558  Class<?> superclass = root.getSuperclass();
559  Type genericSuper = root.getGenericSuperclass();
560 
561 
562  return recurseSuperclassForInterface(searchedForInterface, typeVarMap, genericSuper, superclass);
563  }
static Type [] recurseSuperclassForInterface(Class<?> searchedForInterface, Map< String, Type > typeVarMap, Type genericSub, Class<?> sub)
Definition: Types.java:565
static Type [] extractTypes(Map< String, Type > typeVarMap, Type genericSub)
Definition: Types.java:604
static Map< String, Type > populateParameterizedMap(Class<?> root, ParameterizedType rootType)
Definition: Types.java:519

◆ findParameterizedTypes()

static Type [] org.keycloak.common.util.reflections.Types.findParameterizedTypes ( Class<?>  root,
Class<?>  searchedFor 
)
inlinestatic

Search for the given interface or class within the root's class/interface hierarchy. If the searched for class/interface is a generic return an array of real types that fill it out.

引数
root
searchedFor
戻り値
476  {
477  if (searchedFor.isInterface())
478  {
479  return findInterfaceParameterizedTypes(root, null, searchedFor);
480  }
481  return findClassParameterizedTypes(root, null, searchedFor);
482  }
static Type [] findClassParameterizedTypes(Class<?> root, ParameterizedType rootType, Class<?> searchedForClass)
Definition: Types.java:484
static Type [] findInterfaceParameterizedTypes(Class<?> root, ParameterizedType rootType, Class<?> searchedForInterface)
Definition: Types.java:534

◆ getActualTypeArgumentsOfAnInterface()

static Type [] org.keycloak.common.util.reflections.Types.getActualTypeArgumentsOfAnInterface ( Class<?>  classToSearch,
Class<?>  interfaceToFind 
)
inlinestatic

Given a class and an interfaces, go through the class hierarchy to find the interface and return its type arguments.

引数
classToSearch
interfaceToFind
戻り値
type arguments of the interface
459  {
460  Type[] types = findParameterizedTypes(classToSearch, interfaceToFind);
461  if (types == null) throw new RuntimeException("Unable to find type arguments");
462  return types;
463  }
static Type [] findParameterizedTypes(Class<?> root, Class<?> searchedFor)
Definition: Types.java:475

◆ getArgumentType()

static Class org.keycloak.common.util.reflections.Types.getArgumentType ( ParameterizedType  pType,
int  index 
)
inlinestatic

Gets the index-th type argument.

91  {
92  return (Class) pType.getActualTypeArguments()[index];
93  }

◆ getCollectionBaseType()

static Class org.keycloak.common.util.reflections.Types.getCollectionBaseType ( Class  type,
Type  genericType 
)
inlinestatic
323  {
324  if (genericType instanceof ParameterizedType)
325  {
326  ParameterizedType parameterizedType = (ParameterizedType) genericType;
327  Type componentGenericType = parameterizedType.getActualTypeArguments()[0];
328  return getRawType(componentGenericType);
329  }
330  else if (genericType instanceof GenericArrayType)
331  {
332  final GenericArrayType genericArrayType = (GenericArrayType) genericType;
333  Type componentGenericType = genericArrayType.getGenericComponentType();
334  return getRawType(componentGenericType);
335  }
336  else if (type.isArray())
337  {
338  return type.getComponentType();
339  }
340  return null;
341  }
static Class<?> getRawType(Type type)
Definition: Types.java:252

◆ getImplementingMethod()

static Method org.keycloak.common.util.reflections.Types.getImplementingMethod ( Class  clazz,
Method  intfMethod 
)
inlinestatic

Given a method and a root class, find the actual method declared in the root that implements the method.

引数
clazz
intfMethod
戻り値
185  {
186  Class<?> declaringClass = intfMethod.getDeclaringClass();
187  if (declaringClass.equals(clazz)) return intfMethod;
188 
189  Class[] paramTypes = intfMethod.getParameterTypes();
190 
191  if (declaringClass.getTypeParameters().length > 0 && paramTypes.length > 0)
192  {
193  Type[] intfTypes = findParameterizedTypes(clazz, declaringClass);
194  Map<String, Type> typeVarMap = new HashMap<String, Type>();
195  TypeVariable<? extends Class<?>>[] vars = declaringClass.getTypeParameters();
196  for (int i = 0; i < vars.length; i++)
197  {
198  if (intfTypes != null && i < intfTypes.length)
199  {
200  typeVarMap.put(vars[i].getName(), intfTypes[i]);
201  }
202  else
203  {
204  // Interface type parameters may not have been filled out
205  typeVarMap.put(vars[i].getName(), vars[i].getGenericDeclaration());
206  }
207  }
208  Type[] paramGenericTypes = intfMethod.getGenericParameterTypes();
209  paramTypes = new Class[paramTypes.length];
210 
211  for (int i = 0; i < paramTypes.length; i++)
212  {
213  if (paramGenericTypes[i] instanceof TypeVariable)
214  {
215  TypeVariable tv = (TypeVariable)paramGenericTypes[i];
216  Type t = typeVarMap.get(tv.getName());
217  if (t == null)
218  {
219  throw new RuntimeException("Unable to resolve type variable");
220  }
221  paramTypes[i] = getRawType(t);
222  }
223  else
224  {
225  paramTypes[i] = getRawType(paramGenericTypes[i]);
226  }
227  }
228 
229  }
230 
231  try
232  {
233  return clazz.getMethod(intfMethod.getName(), paramTypes);
234  }
235  catch (NoSuchMethodException e)
236  {
237  }
238 
239  try
240  {
241  Method tmp = clazz.getMethod(intfMethod.getName(), intfMethod.getParameterTypes());
242  return tmp;
243  }
244  catch (NoSuchMethodException e)
245  {
246 
247  }
248  return intfMethod;
249  }
static Type [] findParameterizedTypes(Class<?> root, Class<?> searchedFor)
Definition: Types.java:475
static Class<?> getRawType(Type type)
Definition: Types.java:252

◆ getMapKeyType()

static Class org.keycloak.common.util.reflections.Types.getMapKeyType ( Type  genericType)
inlinestatic
345  {
346  if (genericType instanceof ParameterizedType)
347  {
348  ParameterizedType parameterizedType = (ParameterizedType) genericType;
349  Type componentGenericType = parameterizedType.getActualTypeArguments()[0];
350  return getRawType(componentGenericType);
351  }
352  return null;
353  }
static Class<?> getRawType(Type type)
Definition: Types.java:252

◆ getMapValueType()

static Class org.keycloak.common.util.reflections.Types.getMapValueType ( Type  genericType)
inlinestatic
356  {
357  if (genericType instanceof ParameterizedType)
358  {
359  ParameterizedType parameterizedType = (ParameterizedType) genericType;
360  Type componentGenericType = parameterizedType.getActualTypeArguments()[1];
361  return getRawType(componentGenericType);
362  }
363  return null;
364  }
static Class<?> getRawType(Type type)
Definition: Types.java:252

◆ getRawType()

static Class<?> org.keycloak.common.util.reflections.Types.getRawType ( Type  type)
inlinestatic
253  {
254  if (type instanceof Class<?>)
255  {
256  // type is a normal class.
257  return (Class<?>) type;
258 
259  }
260  else if (type instanceof ParameterizedType)
261  {
262  ParameterizedType parameterizedType = (ParameterizedType) type;
263  Type rawType = parameterizedType.getRawType();
264  return (Class<?>) rawType;
265  }
266  else if (type instanceof GenericArrayType)
267  {
268  final GenericArrayType genericArrayType = (GenericArrayType) type;
269  final Class<?> componentRawType = getRawType(genericArrayType.getGenericComponentType());
270  return Array.newInstance(componentRawType, 0).getClass();
271  }
272  else if (type instanceof TypeVariable)
273  {
274  final TypeVariable typeVar = (TypeVariable) type;
275  if (typeVar.getBounds() != null && typeVar.getBounds().length > 0)
276  {
277  return getRawType(typeVar.getBounds()[0]);
278  }
279  }
280  throw new RuntimeException("unable to determine base class");
281  }
static Class<?> getRawType(Type type)
Definition: Types.java:252

◆ getRawTypeNoException()

static Class<?> org.keycloak.common.util.reflections.Types.getRawTypeNoException ( Type  type)
inlinestatic
285  {
286  if (type instanceof Class<?>)
287  {
288  // type is a normal class.
289  return (Class<?>) type;
290 
291  }
292  else if (type instanceof ParameterizedType)
293  {
294  ParameterizedType parameterizedType = (ParameterizedType) type;
295  Type rawType = parameterizedType.getRawType();
296  return (Class<?>) rawType;
297  }
298  else if (type instanceof GenericArrayType)
299  {
300  final GenericArrayType genericArrayType = (GenericArrayType) type;
301  final Class<?> componentRawType = getRawType(genericArrayType.getGenericComponentType());
302  return Array.newInstance(componentRawType, 0).getClass();
303  }
304  return null;
305  }
static Class<?> getRawType(Type type)
Definition: Types.java:252

◆ getTemplateParameterOfInterface()

static Class org.keycloak.common.util.reflections.Types.getTemplateParameterOfInterface ( Class  base,
Class  desiredInterface 
)
inlinestatic
96  {
97  Object rtn = searchForInterfaceTemplateParameter(base, desiredInterface);
98  if (rtn != null && rtn instanceof Class) return (Class) rtn;
99  return null;
100  }
static Object searchForInterfaceTemplateParameter(Class base, Class desiredInterface)
Definition: Types.java:103

◆ getTypeArgument()

static Class<?> org.keycloak.common.util.reflections.Types.getTypeArgument ( Type  genericType)
inlinestatic

Returns the type argument from a parameterized type

引数
genericType
戻り値
null if there is no type parameter
314  {
315  if (!(genericType instanceof ParameterizedType)) return null;
316  ParameterizedType parameterizedType = (ParameterizedType) genericType;
317  Class<?> typeArg = (Class<?>) parameterizedType.getActualTypeArguments()[0];
318  return typeArg;
319  }

◆ isA()

static boolean org.keycloak.common.util.reflections.Types.isA ( Class  clazz,
ParameterizedType  pType 
)
inlinestatic

Is the genericType of a certain class?

83  {
84  return clazz.isAssignableFrom((Class) pType.getRawType());
85  }

◆ isCompatible()

static boolean org.keycloak.common.util.reflections.Types.isCompatible ( Method  method,
Method  intfMethod 
)
inlinestatic

See if the two methods are compatible, that is they have the same relative signature

引数
method
intfMethod
戻り値
162  {
163  if (method == intfMethod) return true;
164 
165  if (!method.getName().equals(intfMethod.getName())) return false;
166  if (method.getParameterTypes().length != intfMethod.getParameterTypes().length) return false;
167 
168  for (int i = 0; i < method.getParameterTypes().length; i++)
169  {
170  Class rootParam = method.getParameterTypes()[i];
171  Class intfParam = intfMethod.getParameterTypes()[i];
172  if (!intfParam.isAssignableFrom(rootParam)) return false;
173  }
174  return true;
175  }

◆ populateParameterizedMap()

static Map<String, Type> org.keycloak.common.util.reflections.Types.populateParameterizedMap ( Class<?>  root,
ParameterizedType  rootType 
)
inlinestaticprivate
520  {
521  Map<String, Type> typeVarMap = new HashMap<String, Type>();
522  if (rootType != null)
523  {
524  TypeVariable<? extends Class<?>>[] vars = root.getTypeParameters();
525  for (int i = 0; i < vars.length; i++)
526  {
527  typeVarMap.put(vars[i].getName(), rootType.getActualTypeArguments()[i]);
528  }
529  }
530  return typeVarMap;
531  }

◆ recurseSuperclassForInterface()

static Type [] org.keycloak.common.util.reflections.Types.recurseSuperclassForInterface ( Class<?>  searchedForInterface,
Map< String, Type >  typeVarMap,
Type  genericSub,
Class<?>  sub 
)
inlinestaticprivate
566  {
567  if (genericSub instanceof ParameterizedType)
568  {
569  ParameterizedType intfParam = (ParameterizedType) genericSub;
570  Type[] types = findInterfaceParameterizedTypes(sub, intfParam, searchedForInterface);
571  if (types != null)
572  {
573  return extractTypeVariables(typeVarMap, types);
574  }
575  }
576  else
577  {
578  Type[] types = findInterfaceParameterizedTypes(sub, null, searchedForInterface);
579  if (types != null)
580  {
581  return types;
582  }
583  }
584  return null;
585  }
static Type [] extractTypeVariables(Map< String, Type > typeVarMap, Type[] types)
Definition: Types.java:587
static Type [] findInterfaceParameterizedTypes(Class<?> root, ParameterizedType rootType, Class<?> searchedForInterface)
Definition: Types.java:534

◆ resolveTypeVariable()

static Type org.keycloak.common.util.reflections.Types.resolveTypeVariable ( Class<?>  root,
TypeVariable<?>  typeVariable 
)
inlinestatic

Finds an actual value of a type variable. The method looks in a class hierarchy for a class defining the variable and returns the value if present.

引数
root
typeVariable
戻り値
actual type of the type variable
432  {
433  if (typeVariable.getGenericDeclaration() instanceof Class<?>)
434  {
435  Class<?> classDeclaringTypeVariable = (Class<?>) typeVariable.getGenericDeclaration();
436  Type[] types = findParameterizedTypes(root, classDeclaringTypeVariable);
437  if (types == null) return null;
438  for (int i = 0; i < types.length; i++)
439  {
440  TypeVariable<?> tv = classDeclaringTypeVariable.getTypeParameters()[i];
441  if (tv.equals(typeVariable))
442  {
443  return types[i];
444  }
445  }
446  }
447  return null;
448  }
static Type [] findParameterizedTypes(Class<?> root, Class<?> searchedFor)
Definition: Types.java:475

◆ resolveTypeVariables()

static Type org.keycloak.common.util.reflections.Types.resolveTypeVariables ( Class<?>  root,
Type  type 
)
inlinestatic
367  {
368  if (type instanceof TypeVariable)
369  {
370  Type newType = resolveTypeVariable(root, (TypeVariable)type);
371  return (newType == null) ? type : newType;
372  }
373  else if (type instanceof ParameterizedType)
374  {
375  final ParameterizedType param = (ParameterizedType)type;
376  final Type[] actuals = new Type[param.getActualTypeArguments().length];
377  for (int i = 0; i < actuals.length; i++)
378  {
379  Type newType = resolveTypeVariables(root, param.getActualTypeArguments()[i]);
380  actuals[i] = newType == null ? param.getActualTypeArguments()[i] : newType;
381  }
382  return new ParameterizedType() {
383  @Override
384  public Type[] getActualTypeArguments()
385  {
386  return actuals;
387  }
388 
389  @Override
390  public Type getRawType()
391  {
392  return param.getRawType();
393  }
394 
395  @Override
396  public Type getOwnerType()
397  {
398  return param.getOwnerType();
399  }
400  };
401  }
402  else if (type instanceof GenericArrayType)
403  {
404  GenericArrayType arrayType = (GenericArrayType)type;
405  final Type componentType = resolveTypeVariables(root, arrayType.getGenericComponentType());
406  if (componentType == null) return type;
407  return new GenericArrayType()
408  {
409  @Override
410  public Type getGenericComponentType()
411  {
412  return componentType;
413  }
414  };
415  }
416  else
417  {
418  return type;
419  }
420  }
static Type resolveTypeVariable(Class<?> root, TypeVariable<?> typeVariable)
Definition: Types.java:431
static Type resolveTypeVariables(Class<?> root, Type type)
Definition: Types.java:366
static Class<?> getRawType(Type type)
Definition: Types.java:252

◆ searchForInterfaceTemplateParameter()

static Object org.keycloak.common.util.reflections.Types.searchForInterfaceTemplateParameter ( Class  base,
Class  desiredInterface 
)
inlinestaticprivate
104  {
105  for (int i = 0; i < base.getInterfaces().length; i++)
106  {
107  Class intf = base.getInterfaces()[i];
108  if (intf.equals(desiredInterface))
109  {
110  Type generic = base.getGenericInterfaces()[i];
111  if (generic instanceof ParameterizedType)
112  {
113  ParameterizedType p = (ParameterizedType) generic;
114  Type type = p.getActualTypeArguments()[0];
115  Class rtn = getRawTypeNoException(type);
116  if (rtn != null) return rtn;
117  return type;
118  }
119  else
120  {
121  return null;
122  }
123  }
124  }
125  if (base.getSuperclass() == null || base.getSuperclass().equals(Object.class)) return null;
126  Object rtn = searchForInterfaceTemplateParameter(base.getSuperclass(), desiredInterface);
127  if (rtn == null || rtn instanceof Class) return rtn;
128  if (!(rtn instanceof TypeVariable)) return null;
129 
130  String name = ((TypeVariable) rtn).getName();
131  int index = -1;
132  TypeVariable[] variables = base.getSuperclass().getTypeParameters();
133  if (variables == null || variables.length < 1) return null;
134 
135  for (int i = 0; i < variables.length; i++)
136  {
137  if (variables[i].getName().equals(name)) index = i;
138  }
139  if (index == -1) return null;
140 
141 
142  Type genericSuperclass = base.getGenericSuperclass();
143  if (!(genericSuperclass instanceof ParameterizedType)) return null;
144 
145  ParameterizedType pt = (ParameterizedType) genericSuperclass;
146  Type type = pt.getActualTypeArguments()[index];
147 
148  Class clazz = getRawTypeNoException(type);
149  if (clazz != null) return clazz;
150  return type;
151  }
static Object searchForInterfaceTemplateParameter(Class base, Class desiredInterface)
Definition: Types.java:103
static Class<?> getRawTypeNoException(Type type)
Definition: Types.java:284

◆ supports()

static <T> boolean org.keycloak.common.util.reflections.Types.supports ( Class< T >  type,
Object  object,
Class<?>  fromInterface 
)
inlinestatic

Grabs the parameterized type of fromInterface that object implements and sees if it is assignable from type.

引数
type
object
fromInterface
<T>
戻り値
631  {
632  Type providerType = getActualTypeArgumentsOfAnInterface(object.getClass(), fromInterface)[0];
633  Class providerClass = getRawType(providerType);
634  return type.isAssignableFrom(providerClass);
635  }
static Type [] getActualTypeArgumentsOfAnInterface(Class<?> classToSearch, Class<?> interfaceToFind)
Definition: Types.java:458
static Class<?> getRawType(Type type)
Definition: Types.java:252

メンバ詳解

◆ EMPTY_TYPE_ARRAY

final Type [] org.keycloak.common.util.reflections.Types.EMPTY_TYPE_ARRAY = {}
staticprivate

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