static public Class[] getInterfaces(Class c) { return c.getInterfaces(); }
@Override public String[] getInterfaceNames() { Class<?>[] ifcs = this.introspectedClass.getInterfaces(); String[] ifcNames = new String[ifcs.length]; for (int i = 0; i < ifcs.length; i++) { ifcNames[i] = ifcs[i].getName(); } return ifcNames; }
@Override Iterable<? extends Class<?>> getInterfaces(Class<?> type) { return Arrays.asList(type.getInterfaces()); }
private static boolean isProxyOfSameInterfaces(Object arg, Class<?> proxyClass) { return proxyClass.isInstance(arg) // Equal proxy instances should mostly be instance of proxyClass // Under some edge cases (such as the proxy of JDK types serialized and then deserialized) // the proxy type may not be the same. // We first check isProxyClass() so that the common case of comparing with non-proxy objects // is efficient. || (Proxy.isProxyClass(arg.getClass()) && Arrays.equals(arg.getClass().getInterfaces(), proxyClass.getInterfaces())); } }
static <T> void validateServiceInterface(Class<T> service) { if (!service.isInterface()) { throw new IllegalArgumentException("API declarations must be interfaces."); } // Prevent API interfaces from extending other interfaces. This not only avoids a bug in // Android (http://b.android.com/58753) but it forces composition of API declarations which is // the recommended pattern. if (service.getInterfaces().length > 0) { throw new IllegalArgumentException("API interfaces must not extend other interfaces."); } }
@Nullable private static List<Method> findConcreteMethodsOnInterfaces(Class<?> clazz) { List<Method> result = null; for (Class<?> ifc : clazz.getInterfaces()) { for (Method ifcMethod : ifc.getMethods()) { if (!Modifier.isAbstract(ifcMethod.getModifiers())) { if (result == null) { result = new ArrayList<>(); } result.add(ifcMethod); } } } return result; }
public static List addAllInterfaces(Class type, List list) { Class superclass = type.getSuperclass(); if (superclass != null) { list.addAll(Arrays.asList(type.getInterfaces())); addAllInterfaces(superclass, list); } return list; }
/** * Determine whether the given interface is just a container callback and * therefore not to be considered as a reasonable proxy interface. * <p>If no reasonable proxy interface is found for a given bean, it will get * proxied with its full target class, assuming that as the user's intention. * @param ifc the interface to check * @return whether the given interface is just a container callback */ protected boolean isConfigurationCallbackInterface(Class<?> ifc) { return (InitializingBean.class == ifc || DisposableBean.class == ifc || Closeable.class == ifc || AutoCloseable.class == ifc || ObjectUtils.containsElement(ifc.getInterfaces(), Aware.class)); }
private void addInterfacesToClassHierarchy(Class<?> type, boolean asArray, List<Class<?>> hierarchy, Set<Class<?>> visited) { for (Class<?> implementedInterface : type.getInterfaces()) { addToClassHierarchy(hierarchy.size(), implementedInterface, asArray, hierarchy, visited); } }
public Type[] getInterfaces() { return TypeUtils.getTypes(clazz.getInterfaces()); } public int getModifiers() {
/** Recurses through super interfaces. */ static void addInterfaces(List<Class<?>> eventTypes, Class<?>[] interfaces) { for (Class<?> interfaceClass : interfaces) { if (!eventTypes.contains(interfaceClass)) { eventTypes.add(interfaceClass); addInterfaces(eventTypes, interfaceClass.getInterfaces()); } } }
private List<Annotation[][]> getInterfaceParameterAnnotations() { List<Annotation[][]> parameterAnnotations = this.interfaceParameterAnnotations; if (parameterAnnotations == null) { parameterAnnotations = new ArrayList<>(); for (Class<?> ifc : this.method.getDeclaringClass().getInterfaces()) { for (Method candidate : ifc.getMethods()) { if (isOverrideFor(candidate)) { parameterAnnotations.add(candidate.getParameterAnnotations()); } } } this.interfaceParameterAnnotations = parameterAnnotations; } return parameterAnnotations; }
public static List addAllMethods(final Class type, final List list) { if (type == Object.class) { list.addAll(OBJECT_METHODS); } else list.addAll(java.util.Arrays.asList(type.getDeclaredMethods())); Class superclass = type.getSuperclass(); if (superclass != null) { addAllMethods(superclass, list); } Class[] interfaces = type.getInterfaces(); for (int i = 0; i < interfaces.length; i++) { addAllMethods(interfaces[i], list); } return list; }
@Nullable private static Method searchInterfaces(Class<?>[] interfaces, Method bridgeMethod) { for (Class<?> ifc : interfaces) { Method method = searchForMatch(ifc, bridgeMethod); if (method != null && !method.isBridge()) { return method; } else { method = searchInterfaces(ifc.getInterfaces(), bridgeMethod); if (method != null) { return method; } } } return null; }
private static boolean isSuperTypesStaplerRelevant(@Nonnull Class<?> clazz) { Class<?> superclass = clazz.getSuperclass(); if (superclass != null && isStaplerRelevantCached(superclass)) { return true; } for (Class<?> interfaceClass : clazz.getInterfaces()) { if (isStaplerRelevantCached(interfaceClass)) { return true; } } return false; }
public Set<SourceClass> getInterfaces() throws IOException { Set<SourceClass> result = new LinkedHashSet<>(); if (this.source instanceof Class) { Class<?> sourceClass = (Class<?>) this.source; for (Class<?> ifcClass : sourceClass.getInterfaces()) { result.add(asSourceClass(ifcClass)); } } else { for (String className : this.metadata.getInterfaceNames()) { result.add(asSourceClass(className)); } } return result; }
private void addInterfaces(Set<Class<?>> types, Class<?>[] interfaces) { for (Class<?> type : interfaces) { if (mocked.add(type)) { types.add(type); addInterfaces(types, type.getInterfaces()); } } }
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); } } }
private static ImmutableSet<TypeToken<?>> arrayInterfaces() { ImmutableSet.Builder<TypeToken<?>> builder = ImmutableSet.builder(); for (Class<?> interfaceType : Object[].class.getInterfaces()) { builder.add(TypeToken.of(interfaceType)); } return builder.build(); }
public <T, T1 extends T> void testAssignableGenericArrayToClass() { assertTrue(TypeToken.of(Object[].class.getSuperclass()).isSupertypeOf(new TypeToken<T[]>() {})); for (Class<?> interfaceType : Object[].class.getInterfaces()) { assertTrue(TypeToken.of(interfaceType).isSupertypeOf(new TypeToken<T[]>() {})); } assertTrue(TypeToken.of(Object.class).isSupertypeOf(new TypeToken<T[]>() {})); assertFalse(TypeToken.of(String.class).isSupertypeOf(new TypeToken<T[]>() {})); }