Package org.openscience.cdk
Class DefaultChemObjectBuilder
java.lang.Object
org.openscience.cdk.DefaultChemObjectBuilder
- All Implemented Interfaces:
IChemObjectBuilder
A factory class to provide implementation independent
ICDKObjects.
IChemObjectBuilder builder = DefaultChemObjectBuilder.getInstance();
IAtom a = builder.newInstance(IAtom.class);
IAtom c12 = builder.newInstance(IAtom.class, "C");
IAtom c13 = builder.newInstance(IAtom.class,
builder.newInstance(IIsotope.class,
"C", 13));
- Author:
- egonw, john may
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic IChemObjectBuilderAccess the singleton instance of this DefaultChemObjectBuilder.newAtom()Create a new atom using the default constructor.Create a new atom container using the default constructor.newBond()Create a new bond using the default constructor.<T extends ICDKObject>
TnewInstance(Class<T> clazz, Object... params) Creates a new instance of anICDKObject, using the constructor defined by the given parameters.Create a new reaction using the default constructor.
-
Constructor Details
-
DefaultChemObjectBuilder
public DefaultChemObjectBuilder()
-
-
Method Details
-
getInstance
Access the singleton instance of this DefaultChemObjectBuilder.// get the builder instance IChemObjectBuilder builder = DefaultChemObjectBuilder.getInstance(); // using the builder... // create an IAtom using the default constructor IAtom atom = builder.newInstance(IAtom.class); // create a carbon atom IAtom c1 = builder.newInstance(IAtom.class, "C");- Returns:
- a DefaultChemObjectBuilder instance
-
newInstance
public <T extends ICDKObject> T newInstance(Class<T> clazz, Object... params) throws IllegalArgumentException Creates a new instance of anICDKObject, using the constructor defined by the given parameters.- Specified by:
newInstancein interfaceIChemObjectBuilder- Type Parameters:
T- Class of an interface extendingICDKObjectorICDKObjectitself.- Parameters:
clazz- Interface class to instantiate an instance for.params- Parameters passed to the constructor of the created instance.- Returns:
- Instance created.
- Throws:
IllegalArgumentException- Exception thrown when theIChemObjectBuilderbuilder cannot instantiate theclazzwith the given parameters.
-
newAtom
Create a new atom using the default constructor. This method is considerably faster than the dynamic dispatch ofnewInstance(IAtom.class)and should be used for high throughput applications (e.g. IO).- Specified by:
newAtomin interfaceIChemObjectBuilder- Returns:
- new atom
-
newBond
Create a new bond using the default constructor. This method is considerably faster than the dynamic dispatch ofnewInstance(IBond.class)and should be used for high throughput applications (e.g. IO).- Specified by:
newBondin interfaceIChemObjectBuilder- Returns:
- new bond
-
newAtomContainer
Create a new atom container using the default constructor. This method is considerably faster than the dynamic dispatch ofnewInstance(IAtomContainer.class)and should be used for high throughput applications (e.g. IO).- Specified by:
newAtomContainerin interfaceIChemObjectBuilder- Returns:
- the new atom container
-
newReaction
Create a new reaction using the default constructor. This method is considerably faster than the dynamic dispatch ofnewInstance(IReaction.class)and should be used for high throughput applications (e.g. IO).- Specified by:
newReactionin interfaceIChemObjectBuilder- Returns:
- the new reaction
-