/** * Get all interfaces the extends the type provided. */ public static <T> List<Class<? extends T>> getInterfaces( final Class<?> target, final Class<T> type) { List<Class<? extends T>> ret = new ArrayList<Class<? extends T>>(); Collection<Class<?>> interfs = getAllInterfaces(target); for (Class<?> clazz : interfs) { if (containsInterface(clazz, type)) { @SuppressWarnings("unchecked") Class<? extends T> o = (Class<? extends T>) clazz; ret.add(o); } } return ret; }
/** * Get all interfaces the extends the type provided. */ public static <T> List<Class<? extends T>> getInterfaces(final Class<?> target, final Class<T> type) { final List<Class<? extends T>> ret = new ArrayList<Class<? extends T>>(); final Collection<Class<?>> interfs = getAllInterfaces(target); for (Class<?> clazz : interfs) { if (containsInterface(clazz, type)) { @SuppressWarnings("unchecked") final Class<? extends T> o = (Class<? extends T>) clazz; ret.add(o); } } return ret; }
/** * Get all interfaces the extends the type provided. */ public static <T> List<Class<? extends T>> getInterfaces(final Class<?> target, final Class<T> type) { final List<Class<? extends T>> ret = new ArrayList<Class<? extends T>>(); final Collection<Class<?>> interfs = getAllInterfaces(target); for (Class<?> clazz : interfs) { if (containsInterface(clazz, type)) { @SuppressWarnings("unchecked") final Class<? extends T> o = (Class<? extends T>) clazz; ret.add(o); } } return ret; }
/** * Determines the default set of operations that a {@link Connector} * supports. */ public static Set<Class<? extends APIOperation>> getDefaultSupportedOperations( Class<? extends Connector> connector) { // determine all support operations.. Set<Class<? extends APIOperation>> ret; ret = new HashSet<Class<? extends APIOperation>>(); Set<Class<?>> itrfs = ReflectionUtil.getAllInterfaces(connector); for (Class<? extends SPIOperation> spi : allSPIOperations()) { // determine if the SPI is in the set of interfaces if (itrfs.contains(spi)) { // convert the SPI to API.. ret.addAll(spi2apis(spi)); } } //finally add unconditionally supported ops ret.addAll(getUnconditionallySupportedOperations()); return ret; }
/** * Determines the default set of operations that a {@link Connector} * supports. */ public static Set<Class<? extends APIOperation>> getDefaultSupportedOperations( Class<? extends Connector> connector) { // determine all support operations.. Set<Class<? extends APIOperation>> ret; ret = new HashSet<Class<? extends APIOperation>>(); Set<Class<?>> itrfs = ReflectionUtil.getAllInterfaces(connector); for (Class<? extends SPIOperation> spi : allSPIOperations()) { // determine if the SPI is in the set of interfaces if (itrfs.contains(spi)) { // convert the SPI to API.. ret.addAll(spi2apis(spi)); } } // finally add unconditionally supported ops ret.addAll(getUnconditionallySupportedOperations()); return ret; }
/** * Determines the default set of operations that a {@link Connector} * supports. */ public static Set<Class<? extends APIOperation>> getDefaultSupportedOperations( Class<? extends Connector> connector) { // determine all support operations.. Set<Class<? extends APIOperation>> ret; ret = new HashSet<Class<? extends APIOperation>>(); Set<Class<?>> itrfs = ReflectionUtil.getAllInterfaces(connector); for (Class<? extends SPIOperation> spi : allSPIOperations()) { // determine if the SPI is in the set of interfaces if (itrfs.contains(spi)) { // convert the SPI to API.. ret.addAll(spi2apis(spi)); } } // finally add unconditionally supported ops ret.addAll(getUnconditionallySupportedOperations()); return ret; }
for (Class<?> c : ReflectionUtil.getAllInterfaces(config)) { if (c.getName().equals(GROOVY_LANG_GROOVY_OBJECT)) {
for (Class<?> c : ReflectionUtil.getAllInterfaces(config)) { if (c.getName().equals(GROOVY_LANG_GROOVY_OBJECT)) {
@Test public void functional() { // getInterfaces Set<Class<?>> set = getAllInterfaces(C1.class); assertTrue(set.contains(I1.class)); assertTrue(set.contains(I2.class)); assertFalse(set.contains(I3.class)); // containsInterface assertTrue(containsInterface(C1.class, I1.class)); assertTrue(containsInterface(C1.class, I2.class)); assertFalse(containsInterface(C1.class, I3.class)); }