Java Code Examples for org.springframework.util.ClassUtils#isJavaLanguageInterface()
The following examples show how to use
org.springframework.util.ClassUtils#isJavaLanguageInterface() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Conventions.java From spring-analysis-note with MIT License | 6 votes |
/** * Determine the class to use for naming a variable containing the given value. * <p>Will return the class of the given value, except when encountering a * JDK proxy, in which case it will determine the 'primary' interface * implemented by that proxy. * @param value the value to check * @return the class to use for naming a variable */ private static Class<?> getClassForValue(Object value) { Class<?> valueClass = value.getClass(); if (Proxy.isProxyClass(valueClass)) { Class<?>[] ifcs = valueClass.getInterfaces(); for (Class<?> ifc : ifcs) { if (!ClassUtils.isJavaLanguageInterface(ifc)) { return ifc; } } } else if (valueClass.getName().lastIndexOf('$') != -1 && valueClass.getDeclaringClass() == null) { // '$' in the class name but no inner class - // assuming it's a special subclass (e.g. by OpenJPA) valueClass = valueClass.getSuperclass(); } return valueClass; }
Example 2
Source File: CachedIntrospectionResults.java From spring-analysis-note with MIT License | 6 votes |
private void introspectInterfaces(Class<?> beanClass, Class<?> currClass) throws IntrospectionException { for (Class<?> ifc : currClass.getInterfaces()) { if (!ClassUtils.isJavaLanguageInterface(ifc)) { for (PropertyDescriptor pd : getBeanInfo(ifc).getPropertyDescriptors()) { PropertyDescriptor existingPd = this.propertyDescriptorCache.get(pd.getName()); if (existingPd == null || (existingPd.getReadMethod() == null && pd.getReadMethod() != null)) { // GenericTypeAwarePropertyDescriptor leniently resolves a set* write method // against a declared read method, so we prefer read method descriptors here. pd = buildGenericTypeAwarePropertyDescriptor(beanClass, pd); this.propertyDescriptorCache.put(pd.getName(), pd); } } introspectInterfaces(ifc, ifc); } } }
Example 3
Source File: Conventions.java From java-technology-stack with MIT License | 6 votes |
/** * Determine the class to use for naming a variable containing the given value. * <p>Will return the class of the given value, except when encountering a * JDK proxy, in which case it will determine the 'primary' interface * implemented by that proxy. * @param value the value to check * @return the class to use for naming a variable */ private static Class<?> getClassForValue(Object value) { Class<?> valueClass = value.getClass(); if (Proxy.isProxyClass(valueClass)) { Class<?>[] ifcs = valueClass.getInterfaces(); for (Class<?> ifc : ifcs) { if (!ClassUtils.isJavaLanguageInterface(ifc)) { return ifc; } } } else if (valueClass.getName().lastIndexOf('$') != -1 && valueClass.getDeclaringClass() == null) { // '$' in the class name but no inner class - // assuming it's a special subclass (e.g. by OpenJPA) valueClass = valueClass.getSuperclass(); } return valueClass; }
Example 4
Source File: CachedIntrospectionResults.java From java-technology-stack with MIT License | 6 votes |
private void introspectInterfaces(Class<?> beanClass, Class<?> currClass) throws IntrospectionException { for (Class<?> ifc : currClass.getInterfaces()) { if (!ClassUtils.isJavaLanguageInterface(ifc)) { for (PropertyDescriptor pd : getBeanInfo(ifc).getPropertyDescriptors()) { PropertyDescriptor existingPd = this.propertyDescriptorCache.get(pd.getName()); if (existingPd == null || (existingPd.getReadMethod() == null && pd.getReadMethod() != null)) { // GenericTypeAwarePropertyDescriptor leniently resolves a set* write method // against a declared read method, so we prefer read method descriptors here. pd = buildGenericTypeAwarePropertyDescriptor(beanClass, pd); this.propertyDescriptorCache.put(pd.getName(), pd); } } introspectInterfaces(ifc, ifc); } } }
Example 5
Source File: AnnotationUtils.java From java-technology-stack with MIT License | 5 votes |
/** * Determine the methods on the given type with searchable annotations on them. * @param baseType the superclass or interface to search * @return the cached set of annotated methods * @since 5.0.5 */ static Set<Method> getAnnotatedMethodsInBaseType(Class<?> baseType) { boolean ifcCheck = baseType.isInterface(); if (ifcCheck && ClassUtils.isJavaLanguageInterface(baseType)) { return Collections.emptySet(); } Set<Method> annotatedMethods = annotatedBaseTypeCache.get(baseType); if (annotatedMethods != null) { return annotatedMethods; } Method[] methods = (ifcCheck ? baseType.getMethods() : baseType.getDeclaredMethods()); for (Method baseMethod : methods) { try { // Public methods on interfaces (including interface hierarchy), // non-private (and therefore overridable) methods on base classes if ((ifcCheck || !Modifier.isPrivate(baseMethod.getModifiers())) && hasSearchableAnnotations(baseMethod)) { if (annotatedMethods == null) { annotatedMethods = new HashSet<>(); } annotatedMethods.add(baseMethod); } } catch (Throwable ex) { handleIntrospectionFailure(baseMethod, ex); } } if (annotatedMethods == null) { annotatedMethods = Collections.emptySet(); } annotatedBaseTypeCache.put(baseType, annotatedMethods); return annotatedMethods; }