@Override public boolean apply(TypeToken<?> type) { return type.getRawType().isInterface(); } }
/** * Set the interface of the service to access. * The interface must be suitable for the particular service and remoting strategy. * <p>Typically required to be able to create a suitable service proxy, * but can also be optional if the lookup returns a typed proxy. */ public void setServiceInterface(Class<?> serviceInterface) { Assert.notNull(serviceInterface, "'serviceInterface' must not be null"); Assert.isTrue(serviceInterface.isInterface(), "'serviceInterface' must be an interface"); this.serviceInterface = serviceInterface; }
/** * Set the interface of the service to access. * The interface must be suitable for the particular service and remoting tool. * <p>Typically required to be able to create a suitable service proxy, * but can also be optional if the lookup returns a typed stub. */ public void setServiceInterface(Class<?> serviceInterface) { Assert.notNull(serviceInterface, "'serviceInterface' must not be null"); Assert.isTrue(serviceInterface.isInterface(), "'serviceInterface' must be an interface"); this.serviceInterface = serviceInterface; }
/** * Set the interface that the proxy must implement. * @param serviceInterface the interface that the proxy must implement * @throws IllegalArgumentException if the supplied {@code serviceInterface} * is not an interface type */ public void setServiceInterface(Class<?> serviceInterface) { Assert.notNull(serviceInterface, "'serviceInterface' must not be null"); Assert.isTrue(serviceInterface.isInterface(), "'serviceInterface' must be an interface"); this.serviceInterface = serviceInterface; }
/** * Set the interface of the service to export. * The interface must be suitable for the particular service and remoting strategy. */ public void setServiceInterface(Class<?> serviceInterface) { Assert.notNull(serviceInterface, "'serviceInterface' must not be null"); Assert.isTrue(serviceInterface.isInterface(), "'serviceInterface' must be an interface"); this.serviceInterface = serviceInterface; }
/** * Set the interface of the service that this factory should create a proxy for. */ public void setServiceInterface(@Nullable Class<?> serviceInterface) { if (serviceInterface != null) { Assert.isTrue(serviceInterface.isInterface(), "'serviceInterface' must be an interface"); } this.serviceInterface = serviceInterface; }
private static void assertInterfaceArray(Class<?>[] ics) { for (int i = 0; i < ics.length; i++) { if (!ics[i].isInterface()) { throw new RuntimeException("Class " + ics[i].getName() + " is not a interface."); } } }
private static void assertInterfaceArray(Class<?>[] ics) { for (int i = 0; i < ics.length; i++) { if (!ics[i].isInterface()) { throw new RuntimeException("Class " + ics[i].getName() + " is not a interface."); } } }
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."); } }
public static Method findInterfaceMethod(Class iface) { if (!iface.isInterface()) { throw new IllegalArgumentException(iface + " is not an interface"); } Method[] methods = iface.getDeclaredMethods(); if (methods.length != 1) { throw new IllegalArgumentException("expecting exactly 1 method in " + iface); } return methods[0]; }
/** * Add the specified interface to the list of interfaces to introduce. * @param intf the interface to introduce */ public void addInterface(Class<?> intf) { Assert.notNull(intf, "Interface must not be null"); if (!intf.isInterface()) { throw new IllegalArgumentException("Specified class [" + intf.getName() + "] must be an interface"); } this.interfaces.add(intf); }
private ImmutableList<TypeToken<? super T>> boundsAsInterfaces(Type[] bounds) { ImmutableList.Builder<TypeToken<? super T>> builder = ImmutableList.builder(); for (Type bound : bounds) { @SuppressWarnings("unchecked") // upper bound of T TypeToken<? super T> boundType = (TypeToken<? super T>) of(bound); if (boundType.getRawType().isInterface()) { builder.add(boundType); } } return builder.build(); }
public ReflectiveElementFactory(Class<? extends E> elementClass) { Assert.notNull(elementClass, "Element class must not be null"); Assert.isTrue(!elementClass.isInterface(), "Element class must not be an interface type"); Assert.isTrue(!Modifier.isAbstract(elementClass.getModifiers()), "Element class cannot be an abstract class"); this.elementClass = elementClass; }
private @Nullable TypeToken<? super T> boundAsSuperclass(Type bound) { TypeToken<?> token = of(bound); if (token.getRawType().isInterface()) { return null; } @SuppressWarnings("unchecked") // only upper bound of T is passed in. TypeToken<? super T> superclass = (TypeToken<? super T>) token; return superclass; }
public void setInterface(Class<?> interfaceClass) { if (interfaceClass != null && !interfaceClass.isInterface()) { throw new IllegalStateException("The interface class " + interfaceClass + " is not a interface!"); } this.interfaceClass = interfaceClass; setInterface(interfaceClass == null ? null : interfaceClass.getName()); }
public void setInterface(Class<?> interfaceClass) { if (interfaceClass != null && !interfaceClass.isInterface()) { throw new IllegalStateException("The interface class " + interfaceClass + " is not a interface!"); } this.interfaceClass = interfaceClass; setInterface(interfaceClass == null ? null : interfaceClass.getName()); }
@Override ImmutableList<K> collectTypes(Iterable<? extends K> types) { ImmutableList.Builder<K> builder = ImmutableList.builder(); for (K type : types) { if (!getRawType(type).isInterface()) { builder.add(type); } } return super.collectTypes(builder.build()); } };
private <T> T defaultGenerate(Class<T> rawType) { if (rawType.isInterface()) { // always create a new proxy return newProxy(rawType); } return ArbitraryInstances.get(rawType); }
@Override public <T> T getExtension(Class<T> type, String name) { if (type.isInterface() && type.isAnnotationPresent(SPI.class)) { ExtensionLoader<T> loader = ExtensionLoader.getExtensionLoader(type); if (!loader.getSupportedExtensions().isEmpty()) { return loader.getAdaptiveExtension(); } } return null; }
@Override public <T> T getExtension(Class<T> type, String name) { if (type.isInterface() && type.isAnnotationPresent(SPI.class)) { ExtensionLoader<T> loader = ExtensionLoader.getExtensionLoader(type); if (!loader.getSupportedExtensions().isEmpty()) { return loader.getAdaptiveExtension(); } } return null; }