List of usage examples for java.lang Class getInterfaces
public Class<?>[] getInterfaces()
From source file:Main.java
public static <T> void validateScriptInterface(Class<T> service) { if (!service.isInterface()) { throw new IllegalArgumentException("API declarations must be interfaces."); }/*from w w w . j a v a 2 s . c om*/ if (service.getInterfaces().length > 0) { throw new IllegalArgumentException("Script interfaces must not extend other interfaces."); } }
From source file:Main.java
public static void printMemberClasses(final Class dataType) { final Class[] nestedClasses = dataType.getClasses(); final Class[] declaredNestedClasses = dataType.getDeclaredClasses(); final Class[] nestedInterfaces = dataType.getInterfaces(); final Class declaringClass = dataType.getDeclaringClass(); System.out.println("Member Class infor for: " + dataType.getName()); System.out.println("Nested Classes: " + Arrays.asList(nestedClasses)); System.out.println("Declared Nested Classes: " + Arrays.asList(declaredNestedClasses)); System.out.println("Interfaces: " + Arrays.asList(nestedInterfaces)); System.out.println("Declaring Class: " + declaringClass); }
From source file:Main.java
static <T> void validateServiceClass(Class<T> paramClass) { if (!paramClass.isInterface()) throw new IllegalArgumentException("Only interface endpoint definitions are supported."); if (paramClass.getInterfaces().length > 0) throw new IllegalArgumentException("Interface definitions must not extend other interfaces."); }
From source file:Main.java
@Nullable public static Class<?> getInterfaceOfClassExtendingGivenInterface(final Class<?> possibleExtendingClass, final Class<?> givenInterface) { if (!givenInterface.isAssignableFrom(possibleExtendingClass)) { // not possible return null; }//from w w w .j ava 2 s. com // assignable, find the interface Class<?> viewClass = possibleExtendingClass; while (viewClass != null) { final Class<?>[] interfaces = viewClass.getInterfaces(); for (final Class<?> clazz : interfaces) { if (givenInterface.isAssignableFrom(clazz)) { return clazz; } } // check super viewClass = viewClass.getSuperclass(); } // should never happen return null; }
From source file:com.examples.with.different.packagename.ClassWithPrivateInterfaces.java
private static void getAllInterfaces(Class<?> cls, final HashSet<Class<?>> interfacesFound) { while (cls != null) { final Class<?>[] interfaces = cls.getInterfaces(); for (final Class<?> i : interfaces) { if (interfacesFound.add(i)) { getAllInterfaces(i, interfacesFound); }/*from w w w . jav a 2 s.c o m*/ } cls = cls.getSuperclass(); } }
From source file:Main.java
static <T> void validateInterface(Class<T> clientInterface) { if (!clientInterface.isInterface()) { throw new IllegalArgumentException("Monkey, debe ser una interfaz"); }// w w w . j a v a2 s . co m if (clientInterface.getInterfaces().length > 0) { throw new IllegalArgumentException("Monkey, no debe implementar de otra interfaz"); } }
From source file:Main.java
/** * Get the interfaces for the specified class. * * @param cls the class to look up, may be {@code null} * @param interfacesFound the {@code Set} of interfaces for the class *///w w w .ja v a 2 s .co m private static void getAllInterfaces(Class<?> cls, HashSet<Class<?>> interfacesFound) { while (cls != null) { Class<?>[] interfaces = cls.getInterfaces(); for (Class<?> i : interfaces) { if (interfacesFound.add(i)) { getAllInterfaces(i, interfacesFound); } } cls = cls.getSuperclass(); } }
From source file:org.apache.sling.models.impl.ReflectionUtil.java
private static void addAnnotatedMethodsFromInterfaces(Class<?> type, List<Method> result) { for (Class<?> iface : type.getInterfaces()) { Method[] methods = iface.getDeclaredMethods(); addAnnotated(methods, result);//from w ww . j av a 2 s.c o m addAnnotatedMethodsFromInterfaces(iface, result); } }
From source file:Main.java
public static Set<Class<?>> getAllImplementedInterfaceNames(Class<?> klass) { Set<Class<?>> interfaces = new HashSet<Class<?>>(); while (klass != null) { Class<?>[] localInterfaces = klass.getInterfaces(); for (Class<?> intf : localInterfaces) { interfaces.add(intf);/* w w w. ja v a2s . co m*/ exploreSuperInterfaces(intf, interfaces); } klass = klass.getSuperclass(); } return interfaces; }
From source file:Main.java
private static void addAssignableClasses(Set<Class<?>> classes, Class<?> clazz) { if (notAssignableClasses.contains(clazz)) { return;//from w w w .j a v a 2 s. c om } classes.add(clazz); final Class<?>[] interfaces = clazz.getInterfaces(); for (int i = 0; i < interfaces.length; ++i) { addAssignableClasses(classes, interfaces[i]); } }