Skip to content

Commit

Permalink
Merge pull request #888 from uli-f/add_newreaction_to_ichemobjectbuilder
Browse files Browse the repository at this point in the history
added dedicated method newReaction() for instantiation of Reaction ob…
  • Loading branch information
johnmay committed Sep 5, 2022
2 parents 9e89820 + c780f42 commit 244a3a4
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,14 @@ public IAtomContainer newAtomContainer() {
return new AtomContainer2(0, 0, 0, 0);

}

/**
* {@inheritDoc}
*/
@Override
public IReaction newReaction() {
return new Reaction();
}
}

/**
Expand Down Expand Up @@ -294,4 +302,12 @@ public IBond newBond() {
public IAtomContainer newAtomContainer() {
return Holder.INSTANCE.newAtomContainer();
}

/**
* {@inheritDoc}
*/
@Override
public IReaction newReaction() {
return Holder.INSTANCE.newReaction();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
import org.openscience.cdk.test.AbstractChemObjectBuilderTest;

/**
* Checks the functionality of the {@link IChemObjectBuilder}
* {@link SilentChemObjectBuilder} implementation.
* Checks the functionality of the {@link IChemObjectBuilder} {@link DefaultChemObjectBuilder} implementation.
*
* @cdk.module test-data
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@
* implementation. The factory create debug objects which will log their
* behaviour when used.
*
*
* <pre>{@code
* IChemObjectBuilder builder = DebugChemObjectBuilder.getInstance();
*
Expand Down Expand Up @@ -197,6 +196,14 @@ public IBond newBond() {
public IAtomContainer newAtomContainer() {
return new DebugAtomContainer(0, 0, 0, 0);
}

/**
* {@inheritDoc}
*/
@Override
public IReaction newReaction() {
return new DebugReaction();
}
}

/**
Expand Down Expand Up @@ -252,4 +259,12 @@ public IBond newBond() {
public IAtomContainer newAtomContainer() {
return Holder.INSTANCE.newAtomContainer();
}

/**
* {@inheritDoc}
*/
@Override
public IReaction newReaction() {
return Holder.INSTANCE.newReaction();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
import org.openscience.cdk.interfaces.IChemObjectBuilder;

/**
* Checks the functionality of the {@link IChemObjectBuilder}
* {@link DebugChemObjectBuilder} implementation.
* Checks the functionality of the {@link IChemObjectBuilder} {@link DebugChemObjectBuilder} implementation.
*
* @cdk.module test-datadebug
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public interface IChemObjectBuilder {

/**
* Create a new bond using the default constructor. This method is considerably faster
* than the dynamic dispatch of {@code newInstance(IAtom.class)} and should be used for
* than the dynamic dispatch of {@code newInstance(IBond.class)} and should be used for
* high throughput applications (e.g. IO).
*
* @return new bond
Expand All @@ -63,10 +63,20 @@ public interface IChemObjectBuilder {

/**
* Create a new atom container using the default constructor. This method is considerably faster
* than the dynamic dispatch of {@code newInstance(IAtom.class)} and should be used for
* than the dynamic dispatch of {@code newInstance(IAtomContainer.class)} and should be used for
* high throughput applications (e.g. IO).
*
* @return the new atom container
*/
IAtomContainer newAtomContainer();

/**
* Create a new reaction using the default constructor. This method is considerably faster
* than the dynamic dispatch of {@code newInstance(IReaction.class)} and should be used for
* high throughput applications (e.g. IO).
*
* @return the new reaction
*/
IReaction newReaction();

}
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,14 @@ public IAtomContainer newAtomContainer() {
return new AtomContainer2(0, 0, 0, 0);

}

/**
* {@inheritDoc}
*/
@Override
public IReaction newReaction() {
return new Reaction();
}
}

/**
Expand Down Expand Up @@ -289,4 +297,12 @@ public IBond newBond() {
public IAtomContainer newAtomContainer() {
return Holder.INSTANCE.newAtomContainer();
}

/**
* {@inheritDoc}
*/
@Override
public IReaction newReaction() {
return Holder.INSTANCE.newReaction();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
import org.openscience.cdk.interfaces.IChemObjectBuilder;

/**
* Checks the functionality of the {@link IChemObjectBuilder}
* {@link SilentChemObjectBuilder} implementation.
* Checks the functionality of the {@link IChemObjectBuilder} {@link SilentChemObjectBuilder} implementation.
*
* @cdk.module test-silent
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public static void setRootObject(IChemObject rootObject) {
}

@Test(expected = IllegalArgumentException.class)
public void testNewInstance_Class_arrayObject() throws Exception {
public void testNewInstance_Class_arrayObject() {
// throw random stuff; it should fail
IChemObjectBuilder builder = rootObject.getBuilder();
builder.newInstance(IAtom.class, new Object[2]);
Expand Down Expand Up @@ -660,4 +660,11 @@ public void testSubstance() {
Assert.assertNotNull(substance);
}

@Test
public void testNewReaction_dedicatedMethod() {
IChemObjectBuilder builder = rootObject.getBuilder();
IReaction reaction = builder.newReaction();
Assert.assertNotNull(reaction);
}

}

0 comments on commit 244a3a4

Please sign in to comment.