Skip to content

Commit e1abff2

Browse files
johnmayegonw
authored andcommitted
There is no replacement for checkArgument in recent JDK's - however the logic is simple enough that we can just expand out the conditions.
1 parent 5e46d9c commit e1abff2

File tree

3 files changed

+7
-11
lines changed

3 files changed

+7
-11
lines changed

base/core/src/main/java/org/openscience/cdk/graph/JumboPathGraph.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@
3131
import java.util.List;
3232
import java.util.Objects;
3333

34-
import static com.google.common.base.Preconditions.checkArgument;
35-
3634
/**
3735
* A path graph (<b>P-Graph</b>) for graphs with more than 64 vertices - the
3836
* P-Graph provides efficient generation of all simple cycles in a graph
@@ -87,8 +85,8 @@ final class JumboPathGraph extends PathGraph {
8785
int ord = graph.length;
8886

8987
// check configuration
90-
checkArgument(ord > 2, "graph was acyclic");
91-
checkArgument(limit >= 3 && limit <= ord, "limit should be from 3 to |V|");
88+
if (ord <= 2) throw new IllegalArgumentException("graph was acyclic");
89+
if (limit < 3 || limit > ord) throw new IllegalArgumentException("limit should be from 3 to |V|");
9290

9391
for (int v = 0; v < ord; v++)
9492
graph[v] = Lists.newArrayList();

base/core/src/main/java/org/openscience/cdk/graph/RegularPathGraph.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import java.util.List;
3131
import java.util.Objects;
3232

33-
import static com.google.common.base.Preconditions.checkArgument;
3433

3534
/**
3635
* A path graph (<b>P-Graph</b>) for graphs with less than 64 vertices - the
@@ -86,9 +85,9 @@ final class RegularPathGraph extends PathGraph {
8685
int ord = graph.length;
8786

8887
// check configuration
89-
checkArgument(ord > 2, "graph was acyclic");
90-
checkArgument(limit >= 3 && limit <= ord, "limit should be from 3 to |V|");
91-
checkArgument(ord < 64, "graph has 64 or more atoms, use JumboPathGraph");
88+
if (ord <= 2) throw new IllegalArgumentException("graph was acyclic");
89+
if (limit < 3 || limit > ord) throw new IllegalArgumentException("limit should be from 3 to |V|");
90+
if (ord >= 64) throw new IllegalArgumentException("graph has 64 or more atoms, use JumboPathGraph");
9291

9392
for (int v = 0; v < ord; v++)
9493
graph[v] = Lists.newArrayList();

storage/smiles/src/main/java/org/openscience/cdk/smiles/CDKToBeam.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@
5353
import java.util.Map;
5454
import java.util.Objects;
5555

56-
import static com.google.common.base.Preconditions.checkArgument;
5756
import static org.openscience.cdk.CDKConstants.ATOM_ATOM_MAPPING;
5857
import static org.openscience.cdk.interfaces.IDoubleBondStereochemistry.Conformation.TOGETHER;
5958
import static org.openscience.cdk.interfaces.ITetrahedralChirality.Stereo.CLOCKWISE;
@@ -112,7 +111,7 @@ Atom toBeamAtom(IAtom atom) throws CDKException {
112111

113112
Edge toBeamEdge(IBond b, Map<IAtom, Integer> indices) throws CDKException {
114113

115-
checkArgument(b.getAtomCount() == 2, "Invalid number of atoms on bond");
114+
if (b.getAtomCount() != 2) throw new IllegalArgumentException("Invalid number of atoms on bond");
116115

117116
int u = indices.get(b.getBegin());
118117
int v = indices.get(b.getEnd());
@@ -253,7 +252,7 @@ static Atom toBeamAtom(final IAtom a, final int flavour) {
253252
*/
254253
static Edge toBeamEdge(IBond b, int flavour, Map<IAtom, Integer> indices) throws CDKException {
255254

256-
checkArgument(b.getAtomCount() == 2, "Invalid number of atoms on bond");
255+
if (b.getAtomCount() != 2) throw new IllegalArgumentException("Invalid number of atoms on bond");
257256

258257
int u = indices.get(b.getBegin());
259258
int v = indices.get(b.getEnd());

0 commit comments

Comments
 (0)