Package org.openscience.cdk.silent
Class SilentChemObjectBuilder
- java.lang.Object
-
- org.openscience.cdk.silent.SilentChemObjectBuilder
-
- All Implemented Interfaces:
IChemObjectBuilder
public class SilentChemObjectBuilder extends Object implements IChemObjectBuilder
A factory class to provide implementation independentICDKObject
s.IChemObjectBuilder builder = SilentChemObjectBuilder.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
- See Also:
DynamicFactory
- Source code:
- main
- Belongs to CDK module:
- silent
-
-
Constructor Summary
Constructors Constructor Description SilentChemObjectBuilder()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static IChemObjectBuilder
getInstance()
Access the singleton instance of this SilentChemObjectBuilder.IAtom
newAtom()
Create a new atom using the default constructor.IAtomContainer
newAtomContainer()
Create a new atom container using the default constructor.IBond
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.IReaction
newReaction()
Create a new reaction using the default constructor.
-
-
-
Method Detail
-
getInstance
public static IChemObjectBuilder getInstance()
Access the singleton instance of this SilentChemObjectBuilder.// get the builder instance IChemObjectBuilder builder = SilentChemObjectBuilder.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 SilentChemObjectBuilder 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:
newInstance
in interfaceIChemObjectBuilder
- Type Parameters:
T
- Class of an interface extendingICDKObject
orICDKObject
itself.- 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 theIChemObjectBuilder
builder cannot instantiate theclazz
with the given parameters.
-
newAtom
public IAtom 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:
newAtom
in interfaceIChemObjectBuilder
- Returns:
- new atom
-
newBond
public IBond 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:
newBond
in interfaceIChemObjectBuilder
- Returns:
- new bond
-
newAtomContainer
public IAtomContainer 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:
newAtomContainer
in interfaceIChemObjectBuilder
- Returns:
- the new atom container
-
newReaction
public IReaction 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:
newReaction
in interfaceIChemObjectBuilder
- Returns:
- the new reaction
-
-