CreationModifier<T> modifier) { if (!isConcrete(impl)) throw new IllegalArgumentException("attempt to register non-concrete class");
CreationModifier<T> modifier) { if (!isConcrete(impl)) throw new IllegalArgumentException("attempt to register non-concrete class");
/** * Registers a class with the factory. The interfaces of the class will be * checked to see if they are CDK interfaces before they are registered. * This method is provided for utility but will register the implementation * with all valid interfaces. If a restricted registration is required then * the safer {@link #register(Class, Class)} can be used. * * @param impl a concrete class * @throws IllegalArgumentException thrown if a non-concrete class is * registered * @see #register(Class, Class) * @see #register(Class, java.lang.reflect.Constructor) * @see #register(org.openscience.cdk.DynamicFactory.ConstructorKey, * org.openscience.cdk.DynamicFactory.Creator) */ public <T extends ICDKObject> boolean register(Class<? extends T> impl) { if (!isConcrete(impl)) throw new IllegalArgumentException("non-concrete implementation provided"); boolean registered = Boolean.FALSE; // only check direct interfaces, // IPolymer -> Polymer not IAtomContainer -> Polymer for (Class<?> c : interfaceProvider.getInterfaces(impl)) { // register this implementation with it's direct interfaces if (isCDKInterface(c)) { @SuppressWarnings("unchecked") Class<T> intf = (Class<T>) c; registered = register(intf, impl) || registered; } } return registered; }
/** * Registers a class with the factory. The interfaces of the class will be * checked to see if they are CDK interfaces before they are registered. * This method is provided for utility but will register the implementation * with all valid interfaces. If a restricted registration is required then * the safer {@link #register(Class, Class)} can be used. * * @param impl a concrete class * @throws IllegalArgumentException thrown if a non-concrete class is * registered * @see #register(Class, Class) * @see #register(Class, java.lang.reflect.Constructor) * @see #register(org.openscience.cdk.DynamicFactory.ConstructorKey, * org.openscience.cdk.DynamicFactory.Creator) */ public <T extends ICDKObject> boolean register(Class<? extends T> impl) { if (!isConcrete(impl)) throw new IllegalArgumentException("non-concrete implementation provided"); boolean registered = Boolean.FALSE; // only check direct interfaces, // IPolymer -> Polymer not IAtomContainer -> Polymer for (Class<?> c : interfaceProvider.getInterfaces(impl)) { // register this implementation with it's direct interfaces if (isCDKInterface(c)) { @SuppressWarnings("unchecked") Class<T> intf = (Class<T>) c; registered = register(intf, impl) || registered; } } return registered; }