Skip to content

Commit 5e46d9c

Browse files
johnmayegonw
authored andcommitted
We can replace checkNotNull with requireNonNull (since JDK 1.7)
1 parent 6e62cac commit 5e46d9c

File tree

13 files changed

+36
-36
lines changed

13 files changed

+36
-36
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
import java.util.Collection;
3030
import java.util.LinkedList;
3131
import java.util.List;
32+
import java.util.Objects;
3233

33-
import static com.google.common.base.Preconditions.checkNotNull;
3434
import static org.openscience.cdk.graph.InitialCycles.Cycle;
3535

3636
/**
@@ -94,8 +94,8 @@ public EssentialCycles(final int[][] graph) {
9494
* @param initial a molecule graph
9595
*/
9696
EssentialCycles(final RelevantCycles relevant, final InitialCycles initial) {
97-
checkNotNull(relevant, "No RelevantCycles provided");
98-
this.initial = checkNotNull(initial, "No InitialCycles provided");
97+
Objects.requireNonNull(relevant, "No RelevantCycles provided");
98+
this.initial = Objects.requireNonNull(initial, "No InitialCycles provided");
9999
this.basis = new GreedyBasis(initial.numberOfCycles(), initial.numberOfEdges());
100100
this.essential = new ArrayList<Cycle>();
101101

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131

3232
import java.util.BitSet;
3333
import java.util.Collection;
34+
import java.util.Objects;
3435

35-
import static com.google.common.base.Preconditions.checkNotNull;
3636
import static java.util.Arrays.copyOf;
3737

3838
/**
@@ -113,7 +113,7 @@ final class InitialCycles {
113113
* @throws NullPointerException the graph was null
114114
*/
115115
private InitialCycles(final int[][] graph, final int limit, boolean biconnected) {
116-
this.graph = checkNotNull(graph, "no graph provided");
116+
this.graph = Objects.requireNonNull(graph, "no graph provided");
117117

118118
// ordering ensures the number of initial cycles is polynomial
119119
this.biconnected = biconnected;

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@
2929
import java.util.BitSet;
3030
import java.util.Collections;
3131
import java.util.List;
32+
import java.util.Objects;
3233

3334
import static com.google.common.base.Preconditions.checkArgument;
34-
import static com.google.common.base.Preconditions.checkNotNull;
3535

3636
/**
3737
* A path graph (<b>P-Graph</b>) for graphs with more than 64 vertices - the
@@ -78,8 +78,8 @@ final class JumboPathGraph extends PathGraph {
7878
@SuppressWarnings("unchecked")
7979
JumboPathGraph(final int[][] mGraph, final int[] rank, final int limit) {
8080

81-
checkNotNull(mGraph, "no molecule graph");
82-
checkNotNull(rank, "no rank provided");
81+
Objects.requireNonNull(mGraph, "no molecule graph");
82+
Objects.requireNonNull(rank, "no rank provided");
8383

8484
this.graph = new List[mGraph.length];
8585
this.rank = rank;

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
*/
2424
package org.openscience.cdk.graph;
2525

26-
import static com.google.common.base.Preconditions.checkNotNull;
26+
import java.util.Objects;
27+
2728
import static org.openscience.cdk.graph.InitialCycles.Cycle;
2829

2930
/**
@@ -85,7 +86,7 @@ public final class MinimumCycleBasis {
8586
* @see GraphUtil#subgraph(int[][], int[])
8687
*/
8788
public MinimumCycleBasis(final int[][] graph) {
88-
this(new InitialCycles(checkNotNull(graph, "No graph provided")));
89+
this(new InitialCycles(Objects.requireNonNull(graph, "No graph provided")));
8990
}
9091

9192
/**
@@ -111,7 +112,7 @@ public MinimumCycleBasis(final int[][] graph) {
111112
*/
112113
MinimumCycleBasis(final InitialCycles initial, boolean connected) {
113114

114-
checkNotNull(initial, "No InitialCycles provided");
115+
Objects.requireNonNull(initial, "No InitialCycles provided");
115116

116117
this.graph = initial.graph();
117118
this.basis = new GreedyBasis(initial.numberOfCycles(), initial.numberOfEdges());

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@
2828
import java.util.ArrayList;
2929
import java.util.Collections;
3030
import java.util.List;
31+
import java.util.Objects;
3132

3233
import static com.google.common.base.Preconditions.checkArgument;
33-
import static com.google.common.base.Preconditions.checkNotNull;
3434

3535
/**
3636
* A path graph (<b>P-Graph</b>) for graphs with less than 64 vertices - the
@@ -77,8 +77,8 @@ final class RegularPathGraph extends PathGraph {
7777
@SuppressWarnings("unchecked")
7878
RegularPathGraph(final int[][] mGraph, final int[] rank, final int limit) {
7979

80-
checkNotNull(mGraph, "no molecule graph");
81-
checkNotNull(rank, "no rank provided");
80+
Objects.requireNonNull(mGraph, "no molecule graph");
81+
Objects.requireNonNull(rank, "no rank provided");
8282

8383
this.graph = new List[mGraph.length];
8484
this.rank = rank;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
import java.util.ArrayList;
2828
import java.util.Collection;
2929
import java.util.List;
30+
import java.util.Objects;
3031

31-
import static com.google.common.base.Preconditions.checkNotNull;
3232
import static org.openscience.cdk.graph.InitialCycles.Cycle;
3333

3434
/**
@@ -111,7 +111,7 @@ public RelevantCycles(final int[][] graph) {
111111
*/
112112
RelevantCycles(final InitialCycles initial) {
113113

114-
checkNotNull(initial, "No InitialCycles provided");
114+
Objects.requireNonNull(initial, "No InitialCycles provided");
115115

116116
this.basis = new GreedyBasis(initial.numberOfCycles(), initial.numberOfEdges());
117117

base/standard/src/main/java/org/openscience/cdk/aromaticity/Aromaticity.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@
3535
import org.openscience.cdk.ringsearch.RingSearch;
3636

3737
import java.util.Arrays;
38+
import java.util.Objects;
3839
import java.util.Set;
3940

40-
import static com.google.common.base.Preconditions.checkNotNull;
4141
import static org.openscience.cdk.CDKConstants.ISAROMATIC;
4242
import static org.openscience.cdk.graph.GraphUtil.EdgeToBondMap;
4343

@@ -151,8 +151,8 @@ public final class Aromaticity {
151151
* @see org.openscience.cdk.graph.Cycles
152152
*/
153153
public Aromaticity(ElectronDonation model, CycleFinder cycles) {
154-
this.model = checkNotNull(model);
155-
this.cycles = checkNotNull(cycles);
154+
this.model = Objects.requireNonNull(model);
155+
this.cycles = Objects.requireNonNull(cycles);
156156
}
157157

158158
/**

base/standard/src/main/java/org/openscience/cdk/aromaticity/AtomTypeModel.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@
3737

3838
import java.util.Arrays;
3939
import java.util.Map;
40+
import java.util.Objects;
4041

41-
import static com.google.common.base.Preconditions.checkNotNull;
4242
import static org.openscience.cdk.interfaces.IAtomType.Hybridization;
4343

4444
/**
@@ -98,7 +98,7 @@ int[] contribution(IAtomContainer container, RingSearch ringSearch) {
9898

9999
Hybridization hyb = atom.getHybridization();
100100

101-
checkNotNull(atom.getAtomTypeName(), "atom has unset atom type");
101+
Objects.requireNonNull(atom.getAtomTypeName(), "atom has unset atom type");
102102

103103
// atom has been assigned an atom type but we don't know the hybrid state,
104104
// typically for atom type 'X' (unknown)

base/standard/src/main/java/org/openscience/cdk/aromaticity/DaylightModel.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@
3333

3434
import java.util.Arrays;
3535
import java.util.Map;
36-
37-
import static com.google.common.base.Preconditions.checkNotNull;
36+
import java.util.Objects;
3837

3938
/**
4039
* Electron donation model closely mirroring the Daylight model for use in
@@ -98,8 +97,8 @@ int[] contribution(IAtomContainer container, RingSearch ringSearch) {
9897
for (int i = 0; i < n; i++) {
9998
IAtom a = container.getAtom(i);
10099
atomIndex.put(a, i);
101-
int implH = checkNotNull(a.getImplicitHydrogenCount(),
102-
"Aromaticity model requires implicit hydrogen count is set.");
100+
int implH = Objects.requireNonNull(a.getImplicitHydrogenCount(),
101+
"Aromaticity model requires implicit hydrogen count is set.");
103102
degree[i] = implH;
104103
valence[i] = implH;
105104
}
@@ -114,7 +113,7 @@ int[] contribution(IAtomContainer container, RingSearch ringSearch) {
114113
degree[u]++;
115114
degree[v]++;
116115

117-
IBond.Order order = checkNotNull(bond.getOrder(), "Aromaticity model requires that bond orders must be set");
116+
IBond.Order order = Objects.requireNonNull(bond.getOrder(), "Aromaticity model requires that bond orders must be set");
118117

119118
switch (order) {
120119
case UNSET:

legacy/src/main/java/org/openscience/cdk/isomorphism/matchers/smarts/AtomicNumberAtom.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,11 @@
2323
*/
2424
package org.openscience.cdk.isomorphism.matchers.smarts;
2525

26-
import com.google.common.base.Preconditions;
2726
import org.openscience.cdk.interfaces.IAtom;
2827
import org.openscience.cdk.interfaces.IChemObjectBuilder;
2928

29+
import java.util.Objects;
30+
3031
/**
3132
* This matches an atom using the atomic number.
3233
*
@@ -55,7 +56,7 @@ public AtomicNumberAtom(int atomicNumber, IChemObjectBuilder builder) {
5556
*/
5657
@Override
5758
public boolean matches(IAtom atom) {
58-
return Preconditions.checkNotNull(atom.getAtomicNumber(), "Atomic number is not set.").equals(
59+
return Objects.requireNonNull(atom.getAtomicNumber(), "Atomic number is not set.").equals(
5960
this.getAtomicNumber());
6061
}
6162
}

0 commit comments

Comments
 (0)