Skip to content

Commit

Permalink
Fields may be final
Browse files Browse the repository at this point in the history
  • Loading branch information
johnmay committed Feb 10, 2022
1 parent 3470a79 commit ef24841
Show file tree
Hide file tree
Showing 513 changed files with 877 additions and 856 deletions.
Expand Up @@ -213,7 +213,7 @@ public final class DepictionGenerator {
/**
* Object that should be highlighted
*/
private Map<IChemObject, Color> highlight = new HashMap<>();
private final Map<IChemObject, Color> highlight = new HashMap<>();

/**
* Create a depiction generator using the standard sans-serif
Expand Down
Expand Up @@ -71,7 +71,7 @@ final class SvgDrawVisitor implements IDrawVisitor {
private int indentLvl = 0;
private AffineTransform transform = null;
private RendererModel model = null;
private NumberFormat decimalFormat = new DecimalFormat(".##", new DecimalFormatSymbols(Locale.ROOT));
private final NumberFormat decimalFormat = new DecimalFormat(".##", new DecimalFormatSymbols(Locale.ROOT));

private boolean defaultsWritten = false;
private Color defaultStroke = null;
Expand Down
Expand Up @@ -40,7 +40,7 @@

public class AbbreviationsTest {

private static SmilesParser smipar = new SmilesParser(SilentChemObjectBuilder.getInstance());
private static final SmilesParser smipar = new SmilesParser(SilentChemObjectBuilder.getInstance());

static IAtomContainer smi(String smi) throws Exception {
return smipar.parseSmiles(smi);
Expand Down
Expand Up @@ -50,11 +50,11 @@ public class SybylAtomTypeMatcher implements IAtomTypeMatcher {
private final static String SYBYL_ATOM_TYPE_LIST = "org/openscience/cdk/dict/data/sybyl-atom-types.owl";
private final static String CDK_TO_SYBYL_MAP = "org/openscience/cdk/dict/data/cdk-sybyl-mappings.owl";

private AtomTypeFactory factory;
private CDKAtomTypeMatcher cdkMatcher;
private AtomTypeMapper mapper;
private final AtomTypeFactory factory;
private final CDKAtomTypeMatcher cdkMatcher;
private final AtomTypeMapper mapper;

private static Map<IChemObjectBuilder, SybylAtomTypeMatcher> factories = new Hashtable<>(
private static final Map<IChemObjectBuilder, SybylAtomTypeMatcher> factories = new Hashtable<>(
1);

private SybylAtomTypeMatcher(IChemObjectBuilder builder) {
Expand Down
Expand Up @@ -35,11 +35,11 @@
*/
public class AtomTypeMapper {

private static Map<String, AtomTypeMapper> mappers = new HashMap<>();
private static final Map<String, AtomTypeMapper> mappers = new HashMap<>();

private String mappingFile;
private final String mappingFile;

private Map<String, String> mappings;
private final Map<String, String> mappings;

private AtomTypeMapper(String mappingFile) {
this.mappingFile = mappingFile;
Expand Down
Expand Up @@ -46,8 +46,8 @@
public class OWLAtomTypeMappingReader {

private XMLReader parser;
private Reader input;
private static ILoggingTool logger = LoggingToolFactory.createLoggingTool(OWLAtomTypeReader.class);
private final Reader input;
private static final ILoggingTool logger = LoggingToolFactory.createLoggingTool(OWLAtomTypeReader.class);

/**
* Instantiates the XML based AtomTypeReader.
Expand Down
2 changes: 1 addition & 1 deletion base/core/src/main/java/org/openscience/cdk/CDK.java
Expand Up @@ -37,7 +37,7 @@
*/
public class CDK {

private static ILoggingTool logger = LoggingToolFactory.createLoggingTool(CDK.class);
private static final ILoggingTool logger = LoggingToolFactory.createLoggingTool(CDK.class);
private static final String RESOURCE_LOCATION = "/build.props";
private static volatile String version;

Expand Down
Expand Up @@ -60,12 +60,12 @@ public class CDKAtomTypeMatcher implements IAtomTypeMatcher {
public final static int REQUIRE_NOTHING = 1;
public final static int REQUIRE_EXPLICIT_HYDROGENS = 2;

private AtomTypeFactory factory;
private int mode;
private final AtomTypeFactory factory;
private final int mode;

private final static Object LOCK = new Object();

private static Map<Integer, Map<IChemObjectBuilder, CDKAtomTypeMatcher>> factories = new ConcurrentHashMap<>(5);
private static final Map<Integer, Map<IChemObjectBuilder, CDKAtomTypeMatcher>> factories = new ConcurrentHashMap<>(5);

private CDKAtomTypeMatcher(IChemObjectBuilder builder, int mode) {
factory = AtomTypeFactory.getInstance("org/openscience/cdk/dict/data/cdk-atom-types.owl", builder);
Expand Down
Expand Up @@ -92,7 +92,7 @@ public class AtomTypeFactory {
private final static String XML_EXTENSION = "xml";
private final static String OWL_EXTENSION = "owl";

private static ILoggingTool logger = LoggingToolFactory
private static final ILoggingTool logger = LoggingToolFactory
.createLoggingTool(AtomTypeFactory.class);
private static Map<String, AtomTypeFactory> tables = null;
private Map<String,IAtomType> atomTypes = null;
Expand Down
Expand Up @@ -40,11 +40,11 @@
*/
final class BODRIsotope implements IIsotope {

private String element;
private Integer atomicNumber;
private Double naturalAbundance;
private Double exactMass;
private Integer massNumber;
private final String element;
private final Integer atomicNumber;
private final Double naturalAbundance;
private final Double exactMass;
private final Integer massNumber;

protected BODRIsotope(String element, Integer atomicNumber, Integer massNumber, Double exactMass,
Double naturalAbundance) {
Expand Down
Expand Up @@ -39,10 +39,10 @@
*/
public class CDKBasedAtomTypeConfigurator implements IAtomTypeConfigurator {

private String configFile = "org.openscience.cdk.config.data.structgen_atomtypes.xml";
private final String configFile = "org.openscience.cdk.config.data.structgen_atomtypes.xml";
private InputStream ins = null;

private static ILoggingTool logger = LoggingToolFactory.createLoggingTool(CDKBasedAtomTypeConfigurator.class);
private static final ILoggingTool logger = LoggingToolFactory.createLoggingTool(CDKBasedAtomTypeConfigurator.class);

public CDKBasedAtomTypeConfigurator() {}

Expand Down
Expand Up @@ -44,9 +44,9 @@ public abstract class IsotopeFactory {

public static final IIsotope[] EMPTY_ISOTOPE_ARRAY = new IIsotope[0];
@SuppressWarnings("unchecked")
private List<IIsotope>[] isotopes = new List[256];
private final List<IIsotope>[] isotopes = new List[256];
@SuppressWarnings("unchecked")
private IIsotope[] majorIsotope = new IIsotope[256];
private final IIsotope[] majorIsotope = new IIsotope[256];
protected static ILoggingTool logger = LoggingToolFactory.createLoggingTool(IsotopeFactory.class);

/**
Expand Down
Expand Up @@ -38,7 +38,7 @@
public class OWLBasedAtomTypeConfigurator implements IAtomTypeConfigurator {

private InputStream ins = null;
private static ILoggingTool logger = LoggingToolFactory.createLoggingTool(OWLBasedAtomTypeConfigurator.class);
private static final ILoggingTool logger = LoggingToolFactory.createLoggingTool(OWLBasedAtomTypeConfigurator.class);

public OWLBasedAtomTypeConfigurator() {}

Expand Down
Expand Up @@ -44,7 +44,7 @@
*/
public class TXTBasedAtomTypeConfigurator implements IAtomTypeConfigurator {

private String configFile = "org/openscience/cdk/config/data/jmol_atomtypes.txt";
private final String configFile = "org/openscience/cdk/config/data/jmol_atomtypes.txt";
private InputStream ins = null;

public TXTBasedAtomTypeConfigurator() {}
Expand Down
Expand Up @@ -57,7 +57,7 @@ public class AtomTypeHandler extends DefaultHandler {
private final int SCALAR_PIBONDCOUNT = 13;
private final int SCALAR_LONEPAIRCOUNT = 14;

private static ILoggingTool logger = LoggingToolFactory
private static final ILoggingTool logger = LoggingToolFactory
.createLoggingTool(AtomTypeHandler.class);
private String currentChars;
private List<IAtomType> atomTypes;
Expand Down
Expand Up @@ -50,8 +50,8 @@
public class AtomTypeReader {

private XMLReader parser;
private Reader input;
private static ILoggingTool logger = LoggingToolFactory.createLoggingTool(AtomTypeReader.class);
private final Reader input;
private static final ILoggingTool logger = LoggingToolFactory.createLoggingTool(AtomTypeReader.class);

/**
* Instantiates the XML based AtomTypeReader.
Expand Down
Expand Up @@ -41,7 +41,7 @@ public class OWLAtomTypeHandler extends DefaultHandler {

private final String NS_ATOMTYPE = "http://cdk.sf.net/ontologies/atomtypes#";

private static ILoggingTool logger = LoggingToolFactory.createLoggingTool(OWLAtomTypeHandler.class);
private static final ILoggingTool logger = LoggingToolFactory.createLoggingTool(OWLAtomTypeHandler.class);
private String currentChars;
private List<IAtomType> atomTypes;
private IAtomType currentAtomType;
Expand Down
Expand Up @@ -48,8 +48,8 @@
public class OWLAtomTypeReader {

private XMLReader parser;
private Reader input;
private static ILoggingTool logger = LoggingToolFactory.createLoggingTool(OWLAtomTypeReader.class);
private final Reader input;
private static final ILoggingTool logger = LoggingToolFactory.createLoggingTool(OWLAtomTypeReader.class);

/**
* Instantiates the XML based AtomTypeReader.
Expand Down
5 changes: 3 additions & 2 deletions base/core/src/main/java/org/openscience/cdk/graph/Cycles.java
Expand Up @@ -1198,7 +1198,8 @@ private int[][] findInFused(int[][] g, int length) throws Intractable {
*/
private static final class Fallback implements CycleFinder {

private CycleFinder primary, auxiliary;
private final CycleFinder primary;
private final CycleFinder auxiliary;

/**
* Create a fallback for two cycle finders.
Expand Down Expand Up @@ -1240,7 +1241,7 @@ public Cycles find(IAtomContainer molecule, int[][] graph, int length) throws In
*/
private static final class Unchorded implements CycleFinder {

private CycleFinder primary;
private final CycleFinder primary;

/**
* Filter any cycles produced by the {@code primary} cycle finder and
Expand Down
Expand Up @@ -490,7 +490,7 @@ static InitialCycles ofBiconnectedComponent(int[][] graph, int limit) {
*/
static abstract class Cycle implements Comparable<Cycle> {

private int[] path;
private final int[] path;
ShortestPaths paths;
BitSet edgeVector;

Expand Down
Expand Up @@ -493,7 +493,7 @@ private static int[][] copy(final int[][] g) {
private static class Path implements Comparable<Path> {

/** Path of vertices. */
private int[] vertices;
private final int[] vertices;

/**
* Create a new path from the given vertices.
Expand Down
Expand Up @@ -50,8 +50,8 @@ public abstract class ChemObjectIO implements IChemObjectIO {
/**
* Holder of reader event listeners.
*/
private List<IChemObjectIOListener> listeners = new ArrayList<>(2);
private SettingManager<IOSetting> settings = new SettingManager<>();
private final List<IChemObjectIOListener> listeners = new ArrayList<>(2);
private final SettingManager<IOSetting> settings = new SettingManager<>();

/**
*{@inheritDoc}
Expand Down
Expand Up @@ -42,7 +42,7 @@ public abstract class DefaultRandomAccessChemObjectReader implements IRandomAcce
/**
* Holder of reader event listeners.
*/
private List<IChemObjectIOListener> listenerList = new ArrayList<>();
private final List<IChemObjectIOListener> listenerList = new ArrayList<>();

public void addChemObjectIOListener(IChemObjectIOListener listener) {
listenerList.add(listener);
Expand Down
Expand Up @@ -33,7 +33,7 @@
*/
public class OptionIOSetting extends IOSetting {

private List<String> settings;
private final List<String> settings;

/**
* OptionIOSetting is IOSetting for which the value must be
Expand Down
Expand Up @@ -81,7 +81,7 @@ public class SettingManager<T extends ISetting> {
/**
* Settings are stored in a map of name -> instance.
*/
private Map<String, T> settings = new HashMap<>(3);
private final Map<String, T> settings = new HashMap<>(3);

/**
* Generate a simple key for the given name. This method normalises the name by
Expand Down
Expand Up @@ -42,10 +42,10 @@ class JumboCyclicVertexSearch implements CyclicVertexSearch {
private final BitSet cyclic;

/* cycle systems as they are discovered */
private List<BitSet> cycles = new ArrayList<>(1);
private final List<BitSet> cycles = new ArrayList<>(1);

/* indicates if the 'cycle' at 'i' in 'cycles' is fused */
private List<Boolean> fused = new ArrayList<>(1);
private final List<Boolean> fused = new ArrayList<>(1);

/* set of visited vertices */
private BitSet visited;
Expand Down
Expand Up @@ -42,10 +42,10 @@ class RegularCyclicVertexSearch implements CyclicVertexSearch {
private long cyclic;

/* cycle systems as they are discovered */
private List<Long> cycles = new ArrayList<>(1);
private final List<Long> cycles = new ArrayList<>(1);

/* indicates if the 'cycle' at 'i' in 'cycles' is fused */
private List<Boolean> fused = new ArrayList<>(1);
private final List<Boolean> fused = new ArrayList<>(1);

/* set of visited vertices */
private long visited;
Expand Down
Expand Up @@ -39,8 +39,8 @@ abstract class AbstractStereo<F extends IChemObject, C extends IChemObject>
implements IStereoElement<F, C> {

private int value;
private F focus;
private List<C> carriers;
private final F focus;
private final List<C> carriers;
private IChemObjectBuilder builder;

protected static int numCarriers(int cfg) {
Expand Down
Expand Up @@ -37,7 +37,7 @@ public class SystemOutLoggingTool implements ILoggingTool {
private int level = ILoggingTool.WARN;

/** Name of the class for which this {@link ILoggingTool} is reporting. */
private String classname;
private final String classname;

/** Length of the stack to print for reported {@link Exception}s. */
private int stackLength;
Expand Down
Expand Up @@ -57,7 +57,7 @@ public class BioPolymer extends Polymer implements java.io.Serializable, IBioPol
*/
private static final long serialVersionUID = -5001873073769634393L;

private Map<String, IStrand> strands; // the list of all the contained Strands.
private final Map<String, IStrand> strands; // the list of all the contained Strands.

/**
* Constructs a new Polymer to store the Strands.
Expand Down
Expand Up @@ -61,7 +61,7 @@ public class ConformerContainer implements List<IAtomContainer> {

private IAtomContainer atomContainer = null;
private String title = null;
private List<Point3d[]> coordinates;
private final List<Point3d[]> coordinates;

private Point3d[] getCoordinateList(IAtomContainer atomContainer) {

Expand Down
Expand Up @@ -40,7 +40,7 @@
public class ReactionScheme extends ReactionSet implements IReactionScheme {

/** A List of reaction schemes*/
private List<IReactionScheme> reactionScheme;
private final List<IReactionScheme> reactionScheme;
/**
* Determines if a de-serialized object is compatible with this class.
*
Expand Down
2 changes: 1 addition & 1 deletion base/data/src/main/java/org/openscience/cdk/Strand.java
Expand Up @@ -54,7 +54,7 @@ public class Strand extends AtomContainer implements java.io.Serializable, IStra
private static final long serialVersionUID = 4200943086350928356L;

/** The list of all Monomers in the Strand.*/
private Map<String, IMonomer> monomers;
private final Map<String, IMonomer> monomers;
/** The name of this strand (e.g. A, B). */
private String strandName;
/** The type of this strand (e.g. PEPTIDE, DNA, RNA). */
Expand Down
Expand Up @@ -58,7 +58,7 @@ public class AdductFormula implements Iterable<IMolecularFormula>, IAdductFormul
private static final long serialVersionUID = -811384981700039389L;

/** Internal List of IMolecularFormula. */
private List<IMolecularFormula> components;
private final List<IMolecularFormula> components;

/**
* Constructs an empty AdductFormula.
Expand Down
Expand Up @@ -55,7 +55,7 @@ public class MolecularFormula implements IMolecularFormula {
*/
private static final long serialVersionUID = -2011407700837295287L;

private Map<IIsotope, Integer> isotopes;
private final Map<IIsotope, Integer> isotopes;
/**
* The partial charge of the molecularFormula. The default value is Double.NaN.
*/
Expand Down
Expand Up @@ -50,7 +50,7 @@ public class MolecularFormulaSet implements Iterable<IMolecularFormula>, IMolecu
private static final long serialVersionUID = -2043178712150212550L;

/** Internal List of IMolecularFormula. */
private List<IMolecularFormula> components;
private final List<IMolecularFormula> components;

/**
* Constructs an empty MolecularFormulaSet.
Expand Down
Expand Up @@ -44,7 +44,7 @@
*/
public class TestMoleculeFactory {

private static ILoggingTool logger = LoggingToolFactory.createLoggingTool(TestMoleculeFactory.class);
private static final ILoggingTool logger = LoggingToolFactory.createLoggingTool(TestMoleculeFactory.class);

private static IAtomContainer newAtomContainer() {
return DefaultChemObjectBuilder.getInstance().newAtomContainer();
Expand Down

0 comments on commit ef24841

Please sign in to comment.