From 08dc00941247f96cc4ef984f0927c5369e9c99e0 Mon Sep 17 00:00:00 2001 From: Sibo Van Gool Date: Fri, 10 Sep 2021 00:36:29 +0200 Subject: [PATCH] [code_cleanup-1] Clean up using IntelliJ's 'Silent Code Cleanup' --- core/src-extra/altimeter/Alt15K.java | 7 +-- core/src-extra/altimeter/RotationLogger.java | 4 +- core/src-extra/altimeter/SerialDownload.java | 4 +- core/src/de/congrace/exp4j/FunctionToken.java | 2 +- .../de/congrace/exp4j/PostfixExpression.java | 2 +- core/src/de/congrace/exp4j/Variable.java | 4 +- core/src/de/congrace/exp4j/VariableSet.java | 2 +- .../sf/openrocket/aerodynamics/Warning.java | 8 ++-- .../aerodynamics/barrowman/FinSetCalc.java | 4 +- .../aerodynamics/barrowman/LaunchLugCalc.java | 4 +- .../barrowman/TubeFinSetCalc.java | 2 +- .../defaults/DefaultAppearance.java | 30 ++++++------- .../defaults/ResourceDecalImage.java | 2 +- .../net/sf/openrocket/arch/SystemInfo.java | 4 +- .../openrocket/communication/BugReporter.java | 3 +- .../communication/Communicator.java | 9 ++-- .../database/ComponentPresetDatabase.java | 4 +- .../net/sf/openrocket/database/Database.java | 2 +- .../sf/openrocket/document/DecalRegistry.java | 2 +- .../document/OpenRocketDocument.java | 8 ++-- .../sf/openrocket/document/Simulation.java | 4 +- .../attachments/FileSystemAttachment.java | 2 +- .../attachments/ZipFileAttachment.java | 2 +- .../src/net/sf/openrocket/file/CSVExport.java | 4 +- .../openrocket/file/GeneralRocketLoader.java | 4 +- .../openrocket/file/GeneralRocketSaver.java | 4 +- .../configuration/XmlContainerElement.java | 2 +- .../openrocket/importt/ConfigHandler.java | 4 +- .../openrocket/importt/DocumentConfig.java | 44 +++++++++---------- .../openrocket/importt/FlightDataHandler.java | 6 +-- .../importt/PhotoStudioHandler.java | 2 +- .../importt/SimulationConditionsHandler.java | 2 +- .../savers/RocketComponentSaver.java | 2 +- .../file/rocksim/RocksimNoseConeCode.java | 2 +- .../file/rocksim/export/RocketDesignDTO.java | 30 ++++++------- .../file/rocksim/export/RocksimSaver.java | 3 +- .../file/rocksim/export/StageDTO.java | 2 +- .../rocksim/importt/MassObjectHandler.java | 2 +- .../importt/RockSimAppearanceBuilder.java | 5 +-- .../openrocket/l10n/ClassBasedTranslator.java | 2 +- .../openrocket/masscalc/MassCalculation.java | 2 +- .../openrocket/masscalc/MassCalculator.java | 2 +- .../models/atmosphere/ExtendedISAModel.java | 2 +- .../src/net/sf/openrocket/motor/CaseInfo.java | 6 +-- .../motor/DesignationComparator.java | 2 +- .../sf/openrocket/motor/IgnitionEvent.java | 10 ++--- .../net/sf/openrocket/motor/Manufacturer.java | 2 +- .../net/sf/openrocket/motor/MotorDigest.java | 12 ++--- .../sf/openrocket/motor/ThrustCurveMotor.java | 4 +- .../general/ParallelExecutorCache.java | 2 +- .../MultidirectionalSearchOptimizer.java | 6 +-- .../sf/openrocket/plugin/PluginModule.java | 4 +- .../sf/openrocket/preset/ComponentPreset.java | 10 ++--- .../InvalidComponentPresetException.java | 4 +- .../preset/loader/DoubleColumnParser.java | 2 +- .../preset/loader/DoubleUnitColumnParser.java | 2 +- .../preset/loader/IntegerColumnParser.java | 2 +- .../preset/loader/MaterialLoader.java | 2 +- .../loader/RocksimComponentFileLoader.java | 2 +- .../preset/loader/StringColumnParser.java | 2 +- .../preset/xml/BaseComponentDTO.java | 4 +- .../preset/xml/MaterialTypeDTO.java | 2 +- .../preset/xml/OpenRocketComponentSaver.java | 5 ++- .../sf/openrocket/preset/xml/ShapeDTO.java | 2 +- .../rocketcomponent/ComponentChangeEvent.java | 4 +- .../sf/openrocket/rocketcomponent/FinSet.java | 6 +-- .../FlightConfigurationId.java | 4 +- .../rocketcomponent/InstanceContext.java | 2 +- .../rocketcomponent/MassComponent.java | 2 +- .../rocketcomponent/RocketComponent.java | 2 +- .../BasicEventSimulationEngine.java | 8 ++-- .../DefaultSimulationOptionFactory.java | 2 +- .../sf/openrocket/simulation/FlightData.java | 2 +- .../simulation/FlightDataBranch.java | 2 +- .../sf/openrocket/simulation/FlightEvent.java | 12 ++--- .../simulation/SimulationStatus.java | 6 +-- .../simulation/SimulationStepper.java | 2 +- .../customexpression/CustomExpression.java | 4 +- .../customexpression/Functions.java | 2 +- .../impl/ScriptingSimulationListener.java | 2 +- .../extension/impl/ScriptingUtil.java | 10 ++--- .../sf/openrocket/startup/Application.java | 7 +-- .../sf/openrocket/startup/Preferences.java | 3 +- .../thrustcurve/DownloadRequest.java | 2 +- .../thrustcurve/DownloadResponse.java | 2 +- .../thrustcurve/DownloadResponseParser.java | 8 ++-- .../openrocket/thrustcurve/MotorBurnFile.java | 4 +- .../thrustcurve/SearchResponse.java | 2 +- .../thrustcurve/SearchResponseParser.java | 2 +- .../SerializeThrustcurveMotors.java | 6 +-- .../thrustcurve/ThrustCurveAPI.java | 6 +-- .../net/sf/openrocket/util/BoundingBox.java | 10 ++--- core/src/net/sf/openrocket/util/Config.java | 2 +- .../util/GeodeticComputationStrategy.java | 2 +- .../sf/openrocket/util/MemoryManagement.java | 4 +- .../sf/openrocket/util/MonitorableSet.java | 4 +- .../sf/openrocket/util/PolyInterpolator.java | 12 ++--- .../sf/openrocket/util/PrintProperties.java | 2 +- core/src/net/sf/openrocket/util/TextUtil.java | 4 +- core/src/net/sf/openrocket/util/UniqueID.java | 2 +- .../openrocket/utils/L10nPropertyReport.java | 2 +- .../utils/TestFunctionOptimizer.java | 5 +-- .../utils/TestFunctionOptimizerLoop.java | 5 +-- .../net/sf/openrocket/ServicesForTesting.java | 4 +- .../communication/HttpURLConnectionMock.java | 20 +++------ .../file/openrocket/OpenRocketSaverTest.java | 6 +-- .../file/rocksim/importt/RocksimTestBase.java | 6 +-- .../models/gravity/WGSGravityModelTest.java | 2 +- .../sf/openrocket/motor/MotorDigestTest.java | 3 +- .../motor/ThrustCurveMotorTest.java | 2 +- .../FlightConfigurationTest.java | 2 +- .../rocketcomponent/LaunchLugTest.java | 4 +- .../rocketcomponent/ParallelStageTest.java | 8 ++-- .../rocketcomponent/ParameterSetTest.java | 6 +-- .../rocketcomponent/RocketTest.java | 12 ++--- .../openrocket/util/ExpressionParserTest.java | 2 +- .../net/sf/openrocket/util/TestConfig.java | 6 +-- .../net/sf/openrocket/util/TextUtilTest.java | 3 +- 118 files changed, 274 insertions(+), 308 deletions(-) diff --git a/core/src-extra/altimeter/Alt15K.java b/core/src-extra/altimeter/Alt15K.java index 26ae08196..26cd2fff2 100644 --- a/core/src-extra/altimeter/Alt15K.java +++ b/core/src-extra/altimeter/Alt15K.java @@ -11,6 +11,7 @@ import java.io.InputStream; import java.io.OutputStream; import java.io.PrintStream; import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import java.text.DateFormat; import java.util.ArrayList; import java.util.Date; @@ -31,7 +32,7 @@ public class Alt15K { private static final boolean DEBUG = false; - private static final Charset CHARSET = Charset.forName("ISO-8859-1"); + private static final Charset CHARSET = StandardCharsets.ISO_8859_1; private final CommPortIdentifier portID; private SerialPort port = null; @@ -41,8 +42,8 @@ public class Alt15K { public static String[] getNames() { - ArrayList list = new ArrayList();; - + ArrayList list = new ArrayList(); + Enumeration pids = CommPortIdentifier.getPortIdentifiers(); while (pids.hasMoreElements()) { diff --git a/core/src-extra/altimeter/RotationLogger.java b/core/src-extra/altimeter/RotationLogger.java index d6fecb1b9..da7306e84 100644 --- a/core/src-extra/altimeter/RotationLogger.java +++ b/core/src-extra/altimeter/RotationLogger.java @@ -35,8 +35,8 @@ public class RotationLogger { public static String[] getNames() { - ArrayList list = new ArrayList();; - + ArrayList list = new ArrayList(); + Enumeration pids = CommPortIdentifier.getPortIdentifiers(); while (pids.hasMoreElements()) { diff --git a/core/src-extra/altimeter/SerialDownload.java b/core/src-extra/altimeter/SerialDownload.java index beaee1659..8c574abe8 100644 --- a/core/src-extra/altimeter/SerialDownload.java +++ b/core/src-extra/altimeter/SerialDownload.java @@ -30,8 +30,8 @@ public class SerialDownload { public static String[] getNames() { - ArrayList list = new ArrayList();; - + ArrayList list = new ArrayList(); + Enumeration pids = CommPortIdentifier.getPortIdentifiers(); while (pids.hasMoreElements()) { diff --git a/core/src/de/congrace/exp4j/FunctionToken.java b/core/src/de/congrace/exp4j/FunctionToken.java index 6bc620ce3..1d155048d 100644 --- a/core/src/de/congrace/exp4j/FunctionToken.java +++ b/core/src/de/congrace/exp4j/FunctionToken.java @@ -35,7 +35,7 @@ class FunctionToken extends CalculationToken { ABS, ACOS, ASIN, ATAN, CBRT, CEIL, COS, COSH, EXP, EXPM1, FLOOR, ROUND, RANDOM, LOG, SIN, SINH, SQRT, TAN, TANH, LOG10 } - private Function function; + private final Function function; /** * construct a new {@link FunctionToken} diff --git a/core/src/de/congrace/exp4j/PostfixExpression.java b/core/src/de/congrace/exp4j/PostfixExpression.java index ceb0784c0..e4ca42f9f 100644 --- a/core/src/de/congrace/exp4j/PostfixExpression.java +++ b/core/src/de/congrace/exp4j/PostfixExpression.java @@ -28,7 +28,7 @@ import java.util.Stack; */ public final class PostfixExpression extends AbstractExpression implements Calculable { - private VariableSet variables = new VariableSet(); + private final VariableSet variables = new VariableSet(); /** * Factory method for creating {@link PostfixExpression}s from human diff --git a/core/src/de/congrace/exp4j/Variable.java b/core/src/de/congrace/exp4j/Variable.java index f953b2087..8837c3842 100644 --- a/core/src/de/congrace/exp4j/Variable.java +++ b/core/src/de/congrace/exp4j/Variable.java @@ -9,8 +9,8 @@ package de.congrace.exp4j; public class Variable { // The primary or preferred representation - public enum Primary {DOUBLE, ARRAY, PLACEHOLDER}; - private final Primary primary; + public enum Primary {DOUBLE, ARRAY, PLACEHOLDER} + private final Primary primary; private final String name; diff --git a/core/src/de/congrace/exp4j/VariableSet.java b/core/src/de/congrace/exp4j/VariableSet.java index 674c51a62..1d46c68c6 100644 --- a/core/src/de/congrace/exp4j/VariableSet.java +++ b/core/src/de/congrace/exp4j/VariableSet.java @@ -27,7 +27,7 @@ public class VariableSet extends HashSet { if (this.size() == 0){ return null; } - String names[] = new String[this.size()]; + String[] names = new String[this.size()]; int i = 0; for (Variable var : this){ names[i] = var.getName(); diff --git a/core/src/net/sf/openrocket/aerodynamics/Warning.java b/core/src/net/sf/openrocket/aerodynamics/Warning.java index 211e555ac..92dd6e027 100644 --- a/core/src/net/sf/openrocket/aerodynamics/Warning.java +++ b/core/src/net/sf/openrocket/aerodynamics/Warning.java @@ -61,7 +61,7 @@ public abstract class Warning { * @author Sampo Niskanen */ public static class LargeAOA extends Warning { - private double aoa; + private final double aoa; /** * Sole constructor. The argument is the AOA that caused this warning. @@ -100,7 +100,7 @@ public abstract class Warning { * @author Craig Earls */ public static class HighSpeedDeployment extends Warning { - private double recoverySpeed; + private final double recoverySpeed; /** * Sole constructor. The argument is the speed that caused this warning. @@ -130,7 +130,7 @@ public abstract class Warning { * */ public static class EventAfterLanding extends Warning { - private FlightEvent event; + private final FlightEvent event; /** * Sole constructor. The argument is an event which has occurred after landing @@ -324,7 +324,7 @@ public abstract class Warning { * @author Sampo Niskanen */ public static class Other extends Warning { - private String description; + private final String description; public Other(String description) { this.description = description; diff --git a/core/src/net/sf/openrocket/aerodynamics/barrowman/FinSetCalc.java b/core/src/net/sf/openrocket/aerodynamics/barrowman/FinSetCalc.java index 8aef31d9f..bccffa1c4 100644 --- a/core/src/net/sf/openrocket/aerodynamics/barrowman/FinSetCalc.java +++ b/core/src/net/sf/openrocket/aerodynamics/barrowman/FinSetCalc.java @@ -45,7 +45,7 @@ public class FinSetCalc extends RocketComponentCalc { protected final WarningSet geometryWarnings = new WarningSet(); - private double[] poly = new double[6]; + private final double[] poly = new double[6]; private final double thickness; private final double bodyRadius; @@ -63,7 +63,7 @@ public class FinSetCalc extends RocketComponentCalc { public FinSetCalc(FinSet component) { super(component); - FinSet fin = (FinSet) component; + FinSet fin = component; thickness = fin.getThickness(); bodyLength = component.getParent().getLength(); diff --git a/core/src/net/sf/openrocket/aerodynamics/barrowman/LaunchLugCalc.java b/core/src/net/sf/openrocket/aerodynamics/barrowman/LaunchLugCalc.java index 99329280d..aeac39076 100644 --- a/core/src/net/sf/openrocket/aerodynamics/barrowman/LaunchLugCalc.java +++ b/core/src/net/sf/openrocket/aerodynamics/barrowman/LaunchLugCalc.java @@ -10,8 +10,8 @@ import net.sf.openrocket.util.Transformation; public class LaunchLugCalc extends RocketComponentCalc { - private double CDmul; - private double refArea; + private final double CDmul; + private final double refArea; public LaunchLugCalc(RocketComponent component) { super(component); diff --git a/core/src/net/sf/openrocket/aerodynamics/barrowman/TubeFinSetCalc.java b/core/src/net/sf/openrocket/aerodynamics/barrowman/TubeFinSetCalc.java index 4e045f2f0..4b3e3eb60 100644 --- a/core/src/net/sf/openrocket/aerodynamics/barrowman/TubeFinSetCalc.java +++ b/core/src/net/sf/openrocket/aerodynamics/barrowman/TubeFinSetCalc.java @@ -57,7 +57,7 @@ public class TubeFinSetCalc extends RocketComponentCalc { protected double[] chordTrail = new double[DIVISIONS]; protected double[] chordLength = new double[DIVISIONS]; - private double[] poly = new double[6]; + private final double[] poly = new double[6]; private final double thickness; private final double bodyRadius; diff --git a/core/src/net/sf/openrocket/appearance/defaults/DefaultAppearance.java b/core/src/net/sf/openrocket/appearance/defaults/DefaultAppearance.java index bd57cc94a..c364b6234 100644 --- a/core/src/net/sf/openrocket/appearance/defaults/DefaultAppearance.java +++ b/core/src/net/sf/openrocket/appearance/defaults/DefaultAppearance.java @@ -49,8 +49,8 @@ public class DefaultAppearance { new Coordinate(1, 1), 0, new ResourceDecalImage(resource), EdgeMode.REPEAT)); - }; - + } + /** * returns the image with custom color and shine * @@ -69,27 +69,27 @@ public class DefaultAppearance { new Coordinate(1, 1), 0, new ResourceDecalImage(resource), EdgeMode.REPEAT)); - }; - - private static Appearance BALSA = simple("/datafiles/textures/balsa.jpg"); - private static Appearance WOOD = simple("/datafiles/textures/wood.jpg"); + } + + private static final Appearance BALSA = simple("/datafiles/textures/balsa.jpg"); + private static final Appearance WOOD = simple("/datafiles/textures/wood.jpg"); @SuppressWarnings("unused") - private static Appearance CARDBOARD = simple("/datafiles/textures/cardboard.jpg"); - private static Appearance HARDBOARD = simple("/datafiles/textures/hardboard.jpg"); - private static Appearance WADDING = simple("/datafiles/textures/wadding.png"); - private static Appearance CHUTE = simple("/datafiles/textures/chute.jpg"); + private static final Appearance CARDBOARD = simple("/datafiles/textures/cardboard.jpg"); + private static final Appearance HARDBOARD = simple("/datafiles/textures/hardboard.jpg"); + private static final Appearance WADDING = simple("/datafiles/textures/wadding.png"); + private static final Appearance CHUTE = simple("/datafiles/textures/chute.jpg"); private static final Appearance ESTES_BT = simpleAlpha(new Color(212, 185, 145), .3f, "/datafiles/textures/spiral-wound-alpha.png"); private static final Appearance ESTES_IT = simpleAlpha(new Color(168, 146, 116), .1f, "/datafiles/textures/spiral-wound-alpha.png"); private static final Appearance WHITE_BT = simpleAlpha(new Color(240, 240, 240), .3f, "/datafiles/textures/spiral-wound-alpha.png"); - private static Appearance ESTES_MOTOR = simple("/datafiles/textures/motors/estes.jpg"); - private static Appearance AEROTECH_MOTOR = simple("/datafiles/textures/motors/aerotech.png"); - private static Appearance KLIMA_MOTOR = simple("/datafiles/textures/motors/klima.jpg"); - private static Appearance REUSABLE_MOTOR = simpleAlpha(new Color(195, 60, 50), .6f, "/datafiles/textures/motors/reusable.png"); + private static final Appearance ESTES_MOTOR = simple("/datafiles/textures/motors/estes.jpg"); + private static final Appearance AEROTECH_MOTOR = simple("/datafiles/textures/motors/aerotech.png"); + private static final Appearance KLIMA_MOTOR = simple("/datafiles/textures/motors/klima.jpg"); + private static final Appearance REUSABLE_MOTOR = simpleAlpha(new Color(195, 60, 50), .6f, "/datafiles/textures/motors/reusable.png"); - private static HashMap plastics = new HashMap(); + private static final HashMap plastics = new HashMap(); /** * gets the appearance correspondent to the plastic with the given color diff --git a/core/src/net/sf/openrocket/appearance/defaults/ResourceDecalImage.java b/core/src/net/sf/openrocket/appearance/defaults/ResourceDecalImage.java index 6c70470ce..85d24ebf6 100644 --- a/core/src/net/sf/openrocket/appearance/defaults/ResourceDecalImage.java +++ b/core/src/net/sf/openrocket/appearance/defaults/ResourceDecalImage.java @@ -37,7 +37,7 @@ public class ResourceDecalImage implements DecalImage { } @Override - public InputStream getBytes() throws FileNotFoundException, IOException { + public InputStream getBytes() throws IOException { return this.getClass().getResourceAsStream(resource); } diff --git a/core/src/net/sf/openrocket/arch/SystemInfo.java b/core/src/net/sf/openrocket/arch/SystemInfo.java index 27bf7d2bd..a6d441480 100644 --- a/core/src/net/sf/openrocket/arch/SystemInfo.java +++ b/core/src/net/sf/openrocket/arch/SystemInfo.java @@ -17,8 +17,8 @@ public class SystemInfo { public enum Platform { WINDOWS, MAC_OS, - UNIX; - } + UNIX + } /** diff --git a/core/src/net/sf/openrocket/communication/BugReporter.java b/core/src/net/sf/openrocket/communication/BugReporter.java index 7f081ba91..029452d04 100644 --- a/core/src/net/sf/openrocket/communication/BugReporter.java +++ b/core/src/net/sf/openrocket/communication/BugReporter.java @@ -3,6 +3,7 @@ package net.sf.openrocket.communication; import java.io.IOException; import java.io.OutputStreamWriter; import java.net.HttpURLConnection; +import java.nio.charset.StandardCharsets; import net.sf.openrocket.util.BuildProperties; @@ -40,7 +41,7 @@ public class BugReporter extends Communicator { try { // Send post information connection.setDoOutput(true); - wr = new OutputStreamWriter(connection.getOutputStream(), "UTF-8"); + wr = new OutputStreamWriter(connection.getOutputStream(), StandardCharsets.UTF_8); wr.write(post); wr.flush(); diff --git a/core/src/net/sf/openrocket/communication/Communicator.java b/core/src/net/sf/openrocket/communication/Communicator.java index 06c666b7f..ef31bc1c5 100644 --- a/core/src/net/sf/openrocket/communication/Communicator.java +++ b/core/src/net/sf/openrocket/communication/Communicator.java @@ -3,6 +3,7 @@ package net.sf.openrocket.communication; import java.io.UnsupportedEncodingException; import java.net.HttpURLConnection; import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; import net.sf.openrocket.util.BugException; @@ -64,11 +65,7 @@ public abstract class Communicator { public static String encode(String str) { if (str == null) return "null"; - try { - return URLEncoder.encode(str, "UTF-8"); - } catch (UnsupportedEncodingException e) { - throw new BugException("Unsupported encoding UTF-8", e); - } - } + return URLEncoder.encode(str, StandardCharsets.UTF_8); + } } diff --git a/core/src/net/sf/openrocket/database/ComponentPresetDatabase.java b/core/src/net/sf/openrocket/database/ComponentPresetDatabase.java index 1928e5144..5e54003cf 100644 --- a/core/src/net/sf/openrocket/database/ComponentPresetDatabase.java +++ b/core/src/net/sf/openrocket/database/ComponentPresetDatabase.java @@ -32,7 +32,7 @@ public class ComponentPresetDatabase extends Database implement @Override public List listForType( ComponentPreset.Type type ) { if ( type == null ) { - return Collections.emptyList(); + return Collections.emptyList(); } List result = new ArrayList(list.size()/6); @@ -75,7 +75,7 @@ public class ComponentPresetDatabase extends Database implement @Override public List listForTypes( ComponentPreset.Type ... type ) { if( type == null || type.length == 0 ) { - return Collections.emptyList(); + return Collections.emptyList(); } if (type.length == 1 ) { diff --git a/core/src/net/sf/openrocket/database/Database.java b/core/src/net/sf/openrocket/database/Database.java index df513ea21..a916c1df3 100644 --- a/core/src/net/sf/openrocket/database/Database.java +++ b/core/src/net/sf/openrocket/database/Database.java @@ -121,7 +121,7 @@ public class Database> extends AbstractSet { * Iterator class implementation that fires changes if remove() is called. */ private class DBIterator implements Iterator { - private Iterator iterator = list.iterator(); + private final Iterator iterator = list.iterator(); private T current = null; @Override diff --git a/core/src/net/sf/openrocket/document/DecalRegistry.java b/core/src/net/sf/openrocket/document/DecalRegistry.java index 591676cdf..9b523d066 100644 --- a/core/src/net/sf/openrocket/document/DecalRegistry.java +++ b/core/src/net/sf/openrocket/document/DecalRegistry.java @@ -39,7 +39,7 @@ public class DecalRegistry { } /** the decal usage map*/ - private Map registeredDecals = new HashMap(); + private final Map registeredDecals = new HashMap(); /** * returns a new decal with the same image but with unique names diff --git a/core/src/net/sf/openrocket/document/OpenRocketDocument.java b/core/src/net/sf/openrocket/document/OpenRocketDocument.java index eb0f26d7a..f019ea6c8 100644 --- a/core/src/net/sf/openrocket/document/OpenRocketDocument.java +++ b/core/src/net/sf/openrocket/document/OpenRocketDocument.java @@ -53,7 +53,7 @@ public class OpenRocketDocument implements ComponentChangeListener { private final Rocket rocket; private final ArrayList simulations = new ArrayList(); - private ArrayList customExpressions = new ArrayList(); + private final ArrayList customExpressions = new ArrayList(); // The Photo Settings will be saved in the core module as a map of key values with corresponding content private Map photoSettings = new HashMap<>(); @@ -66,8 +66,8 @@ public class OpenRocketDocument implements ComponentChangeListener { * The undo history of the rocket. Whenever a new undo position is created while the * rocket is in "dirty" state, the rocket is copied here. */ - private LinkedList undoHistory = new LinkedList(); - private LinkedList undoDescription = new LinkedList(); + private final LinkedList undoHistory = new LinkedList(); + private final LinkedList undoDescription = new LinkedList(); /** * The position in the undoHistory we are currently at. If modifications have been @@ -83,7 +83,7 @@ public class OpenRocketDocument implements ComponentChangeListener { private String storedDescription = null; - private ArrayList undoRedoListeners = new ArrayList(2); + private final ArrayList undoRedoListeners = new ArrayList(2); private File file = null; private int savedID = -1; diff --git a/core/src/net/sf/openrocket/document/Simulation.java b/core/src/net/sf/openrocket/document/Simulation.java index 23e3ea620..277431ed8 100644 --- a/core/src/net/sf/openrocket/document/Simulation.java +++ b/core/src/net/sf/openrocket/document/Simulation.java @@ -64,7 +64,7 @@ public class Simulation implements ChangeSource, Cloneable { CANT_RUN } - private RocketDescriptor descriptor = Application.getInjector().getInstance(RocketDescriptor.class); + private final RocketDescriptor descriptor = Application.getInjector().getInstance(RocketDescriptor.class); private SafetyMutex mutex = SafetyMutex.newInstance(); @@ -87,7 +87,7 @@ public class Simulation implements ChangeSource, Cloneable { private Class simulationStepperClass = RK4SimulationStepper.class; private Class aerodynamicCalculatorClass = BarrowmanCalculator.class; @SuppressWarnings("unused") - private Class massCalculatorClass = MassCalculator.class; + private final Class massCalculatorClass = MassCalculator.class; /** Listeners for this object */ private List listeners = new ArrayList(); diff --git a/core/src/net/sf/openrocket/document/attachments/FileSystemAttachment.java b/core/src/net/sf/openrocket/document/attachments/FileSystemAttachment.java index 763aa92e2..08ed7f7de 100644 --- a/core/src/net/sf/openrocket/document/attachments/FileSystemAttachment.java +++ b/core/src/net/sf/openrocket/document/attachments/FileSystemAttachment.java @@ -41,7 +41,7 @@ public class FileSystemAttachment extends Attachment { * creates the stream based on the location passed while building */ @Override - public InputStream getBytes() throws FileNotFoundException, IOException { + public InputStream getBytes() throws IOException { return new FileInputStream(location); } diff --git a/core/src/net/sf/openrocket/document/attachments/ZipFileAttachment.java b/core/src/net/sf/openrocket/document/attachments/ZipFileAttachment.java index 27d7d6423..d1baa9bfb 100644 --- a/core/src/net/sf/openrocket/document/attachments/ZipFileAttachment.java +++ b/core/src/net/sf/openrocket/document/attachments/ZipFileAttachment.java @@ -21,7 +21,7 @@ public class ZipFileAttachment extends Attachment { } @Override - public InputStream getBytes() throws FileNotFoundException, IOException { + public InputStream getBytes() throws IOException { String name = getName(); ZipInputStream zis = new ZipInputStream(zipFileLocation.openStream()); diff --git a/core/src/net/sf/openrocket/file/CSVExport.java b/core/src/net/sf/openrocket/file/CSVExport.java index 2c9c47a12..35e2d1608 100644 --- a/core/src/net/sf/openrocket/file/CSVExport.java +++ b/core/src/net/sf/openrocket/file/CSVExport.java @@ -3,7 +3,7 @@ package net.sf.openrocket.file; import java.io.IOException; import java.io.OutputStream; import java.io.PrintWriter; -import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -49,7 +49,7 @@ public class CSVExport { PrintWriter writer = null; try { - writer = new PrintWriter(stream, false, Charset.forName("UTF-8")); + writer = new PrintWriter(stream, false, StandardCharsets.UTF_8); // Write the initial comments if (simulationComments) { diff --git a/core/src/net/sf/openrocket/file/GeneralRocketLoader.java b/core/src/net/sf/openrocket/file/GeneralRocketLoader.java index f4e094328..43b6c5f72 100644 --- a/core/src/net/sf/openrocket/file/GeneralRocketLoader.java +++ b/core/src/net/sf/openrocket/file/GeneralRocketLoader.java @@ -43,8 +43,8 @@ public class GeneralRocketLoader { private final RocksimLoader rocksimLoader = new RocksimLoader(); - private File baseFile; - private URL jarURL; + private final File baseFile; + private final URL jarURL; private boolean isContainer; private final MotorFinder motorFinder; diff --git a/core/src/net/sf/openrocket/file/GeneralRocketSaver.java b/core/src/net/sf/openrocket/file/GeneralRocketSaver.java index 4a4ecbec6..9df2abf73 100644 --- a/core/src/net/sf/openrocket/file/GeneralRocketSaver.java +++ b/core/src/net/sf/openrocket/file/GeneralRocketSaver.java @@ -234,9 +234,9 @@ public class GeneralRocketSaver { private static class ProgressOutputStream extends FilterOutputStream { - private long estimatedSize; + private final long estimatedSize; private long bytesWritten = 0; - private SavingProgress progressCallback; + private final SavingProgress progressCallback; ProgressOutputStream(OutputStream ostream, long estimatedSize, SavingProgress progressCallback) { super(ostream); diff --git a/core/src/net/sf/openrocket/file/configuration/XmlContainerElement.java b/core/src/net/sf/openrocket/file/configuration/XmlContainerElement.java index c227f6d0b..7df74c004 100644 --- a/core/src/net/sf/openrocket/file/configuration/XmlContainerElement.java +++ b/core/src/net/sf/openrocket/file/configuration/XmlContainerElement.java @@ -5,7 +5,7 @@ import java.util.List; public class XmlContainerElement extends XmlElement { - private ArrayList subelements = new ArrayList(); + private final ArrayList subelements = new ArrayList(); public XmlContainerElement(String name) { super(name); diff --git a/core/src/net/sf/openrocket/file/openrocket/importt/ConfigHandler.java b/core/src/net/sf/openrocket/file/openrocket/importt/ConfigHandler.java index ec2f7b8f7..f9df591e7 100644 --- a/core/src/net/sf/openrocket/file/openrocket/importt/ConfigHandler.java +++ b/core/src/net/sf/openrocket/file/openrocket/importt/ConfigHandler.java @@ -17,8 +17,8 @@ import org.xml.sax.SAXException; public class ConfigHandler extends AbstractElementHandler { private ConfigHandler listHandler; - private Config config = new Config(); - private List list = new ArrayList(); + private final Config config = new Config(); + private final List list = new ArrayList(); @Override public ElementHandler openElement(String element, HashMap attributes, WarningSet warnings) throws SAXException { diff --git a/core/src/net/sf/openrocket/file/openrocket/importt/DocumentConfig.java b/core/src/net/sf/openrocket/file/openrocket/importt/DocumentConfig.java index d29068f6c..8a6ec3547 100644 --- a/core/src/net/sf/openrocket/file/openrocket/importt/DocumentConfig.java +++ b/core/src/net/sf/openrocket/file/openrocket/importt/DocumentConfig.java @@ -67,33 +67,33 @@ class DocumentConfig { static { try { // External components - constructors.put("bodytube", BodyTube.class.getConstructor(new Class[0])); - constructors.put("transition", Transition.class.getConstructor(new Class[0])); - constructors.put("nosecone", NoseCone.class.getConstructor(new Class[0])); - constructors.put("trapezoidfinset", TrapezoidFinSet.class.getConstructor(new Class[0])); - constructors.put("ellipticalfinset", EllipticalFinSet.class.getConstructor(new Class[0])); - constructors.put("freeformfinset", FreeformFinSet.class.getConstructor(new Class[0])); - constructors.put("tubefinset", TubeFinSet.class.getConstructor(new Class[0])); - constructors.put("launchlug", LaunchLug.class.getConstructor(new Class[0])); - constructors.put("railbutton", RailButton.class.getConstructor(new Class[0])); + constructors.put("bodytube", BodyTube.class.getConstructor()); + constructors.put("transition", Transition.class.getConstructor()); + constructors.put("nosecone", NoseCone.class.getConstructor()); + constructors.put("trapezoidfinset", TrapezoidFinSet.class.getConstructor()); + constructors.put("ellipticalfinset", EllipticalFinSet.class.getConstructor()); + constructors.put("freeformfinset", FreeformFinSet.class.getConstructor()); + constructors.put("tubefinset", TubeFinSet.class.getConstructor()); + constructors.put("launchlug", LaunchLug.class.getConstructor()); + constructors.put("railbutton", RailButton.class.getConstructor()); // Internal components - constructors.put("engineblock", EngineBlock.class.getConstructor(new Class[0])); - constructors.put("innertube", InnerTube.class.getConstructor(new Class[0])); - constructors.put("tubecoupler", TubeCoupler.class.getConstructor(new Class[0])); - constructors.put("bulkhead", Bulkhead.class.getConstructor(new Class[0])); - constructors.put("centeringring", CenteringRing.class.getConstructor(new Class[0])); + constructors.put("engineblock", EngineBlock.class.getConstructor()); + constructors.put("innertube", InnerTube.class.getConstructor()); + constructors.put("tubecoupler", TubeCoupler.class.getConstructor()); + constructors.put("bulkhead", Bulkhead.class.getConstructor()); + constructors.put("centeringring", CenteringRing.class.getConstructor()); - constructors.put("masscomponent", MassComponent.class.getConstructor(new Class[0])); - constructors.put("shockcord", ShockCord.class.getConstructor(new Class[0])); - constructors.put("parachute", Parachute.class.getConstructor(new Class[0])); - constructors.put("streamer", Streamer.class.getConstructor(new Class[0])); + constructors.put("masscomponent", MassComponent.class.getConstructor()); + constructors.put("shockcord", ShockCord.class.getConstructor()); + constructors.put("parachute", Parachute.class.getConstructor()); + constructors.put("streamer", Streamer.class.getConstructor()); // Other - constructors.put("stage", AxialStage.class.getConstructor(new Class[0])); - constructors.put("boosterset", ParallelStage.class.getConstructor(new Class[0])); - constructors.put("parallelstage", ParallelStage.class.getConstructor(new Class[0])); - constructors.put("podset", PodSet.class.getConstructor(new Class[0])); + constructors.put("stage", AxialStage.class.getConstructor()); + constructors.put("boosterset", ParallelStage.class.getConstructor()); + constructors.put("parallelstage", ParallelStage.class.getConstructor()); + constructors.put("podset", PodSet.class.getConstructor()); } catch (NoSuchMethodException e) { throw new BugException( diff --git a/core/src/net/sf/openrocket/file/openrocket/importt/FlightDataHandler.java b/core/src/net/sf/openrocket/file/openrocket/importt/FlightDataHandler.java index 5883ba17e..34c1d528d 100644 --- a/core/src/net/sf/openrocket/file/openrocket/importt/FlightDataHandler.java +++ b/core/src/net/sf/openrocket/file/openrocket/importt/FlightDataHandler.java @@ -17,10 +17,10 @@ class FlightDataHandler extends AbstractElementHandler { private final DocumentLoadingContext context; private FlightDataBranchHandler dataHandler; - private WarningSet warningSet = new WarningSet(); - private List branches = new ArrayList(); + private final WarningSet warningSet = new WarningSet(); + private final List branches = new ArrayList(); - private SingleSimulationHandler simHandler; + private final SingleSimulationHandler simHandler; private FlightData data; diff --git a/core/src/net/sf/openrocket/file/openrocket/importt/PhotoStudioHandler.java b/core/src/net/sf/openrocket/file/openrocket/importt/PhotoStudioHandler.java index 2d2584813..52f729be1 100644 --- a/core/src/net/sf/openrocket/file/openrocket/importt/PhotoStudioHandler.java +++ b/core/src/net/sf/openrocket/file/openrocket/importt/PhotoStudioHandler.java @@ -21,7 +21,7 @@ import java.util.*; */ public class PhotoStudioHandler extends AbstractElementHandler { // The Photo Settings will be saved in the core module as a map of key values with corresponding content - private Map p; + private final Map p; private static final Logger log = LoggerFactory.getLogger(OpenRocketHandler.class); public PhotoStudioHandler(Map p) { diff --git a/core/src/net/sf/openrocket/file/openrocket/importt/SimulationConditionsHandler.java b/core/src/net/sf/openrocket/file/openrocket/importt/SimulationConditionsHandler.java index 27b72c8db..941abd51f 100644 --- a/core/src/net/sf/openrocket/file/openrocket/importt/SimulationConditionsHandler.java +++ b/core/src/net/sf/openrocket/file/openrocket/importt/SimulationConditionsHandler.java @@ -15,7 +15,7 @@ import net.sf.openrocket.util.GeodeticComputationStrategy; class SimulationConditionsHandler extends AbstractElementHandler { private final DocumentLoadingContext context; public FlightConfigurationId idToSet = FlightConfigurationId.ERROR_FCID; - private SimulationOptions options; + private final SimulationOptions options; private AtmosphereHandler atmosphereHandler; public SimulationConditionsHandler(Rocket rocket, DocumentLoadingContext context) { diff --git a/core/src/net/sf/openrocket/file/openrocket/savers/RocketComponentSaver.java b/core/src/net/sf/openrocket/file/openrocket/savers/RocketComponentSaver.java index 449164970..176993f18 100644 --- a/core/src/net/sf/openrocket/file/openrocket/savers/RocketComponentSaver.java +++ b/core/src/net/sf/openrocket/file/openrocket/savers/RocketComponentSaver.java @@ -80,7 +80,7 @@ public class RocketComponentSaver { int instanceCount = c.getInstanceCount(); if (c instanceof Clusterable) { - ; // no-op. Instance counts are set via named cluster configurations + // no-op. Instance counts are set via named cluster configurations } else { emitInteger(elements, "instancecount", c.getInstanceCount()); } diff --git a/core/src/net/sf/openrocket/file/rocksim/RocksimNoseConeCode.java b/core/src/net/sf/openrocket/file/rocksim/RocksimNoseConeCode.java index 8d24e2444..f11292d0b 100644 --- a/core/src/net/sf/openrocket/file/rocksim/RocksimNoseConeCode.java +++ b/core/src/net/sf/openrocket/file/rocksim/RocksimNoseConeCode.java @@ -33,7 +33,7 @@ public enum RocksimNoseConeCode { /** * Names of the shape that are sometimes found in NCDATA.CSV */ - private Set shapeNames = new HashSet(); + private final Set shapeNames = new HashSet(); /** * Constructor. diff --git a/core/src/net/sf/openrocket/file/rocksim/export/RocketDesignDTO.java b/core/src/net/sf/openrocket/file/rocksim/export/RocketDesignDTO.java index 23adf20f7..dd74826e6 100644 --- a/core/src/net/sf/openrocket/file/rocksim/export/RocketDesignDTO.java +++ b/core/src/net/sf/openrocket/file/rocksim/export/RocketDesignDTO.java @@ -16,31 +16,31 @@ public class RocketDesignDTO { @XmlElement(name = "StageCount") private int stageCount = 1; @XmlElement(name = "DisplayFlags") - private int displayFlags = 7; + private final int displayFlags = 7; @XmlElement(name = "ViewType") - private int viewType = 0; + private final int viewType = 0; @XmlElement(name = "ViewStageCount") - private int viewStageCount = 3; + private final int viewStageCount = 3; @XmlElement(name = "ViewTypeEdit") - private int viewTypeEdit = 0; + private final int viewTypeEdit = 0; @XmlElement(name = "ViewStageCountEdit") - private int viewStageCountEdit = 3; + private final int viewStageCountEdit = 3; @XmlElement(name = "ZoomFactor") - private double zoomFactor = 0d; + private final double zoomFactor = 0d; @XmlElement (name = "ZoomFactorEdit") - private double zoomFactorEdit = 0d; + private final double zoomFactorEdit = 0d; @XmlElement(name = "ScrollPosX") - private int scrollPosX = 0; + private final int scrollPosX = 0; @XmlElement(name = "ScrollPosY") - private int scrollPosY = 0; + private final int scrollPosY = 0; @XmlElement(name = "ScrollPosXEdit") - private int scrollPosXEdit = 0; + private final int scrollPosXEdit = 0; @XmlElement(name = "ScrollPosYEdit") - private int scrollPosYEdit = 0; + private final int scrollPosYEdit = 0; @XmlElement(name = "ThreeDFlags") - private int threeDFlags = 0; + private final int threeDFlags = 0; @XmlElement(name = "ThreeDFlagsEdit") - private int threeDFlagsEdit = 0; + private final int threeDFlagsEdit = 0; @XmlElement(name = "LastSerialNumber") private int lastSerialNumber = -1; @XmlElement(name = "Stage3Mass") @@ -61,9 +61,9 @@ public class RocketDesignDTO { private double stage32CG = 0d; @XmlElement(name = "CPCalcFlags") - private int cpCalcFlags = 1; + private final int cpCalcFlags = 1; @XmlElement(name = "CPSimFlags") - private int cpSimFlags = 1; + private final int cpSimFlags = 1; @XmlElement(name = "UseKnownMass") private int useKnownMass = 0; @XmlElement(name = "Stage3Parts") diff --git a/core/src/net/sf/openrocket/file/rocksim/export/RocksimSaver.java b/core/src/net/sf/openrocket/file/rocksim/export/RocksimSaver.java index 175d7c246..82e7a1455 100644 --- a/core/src/net/sf/openrocket/file/rocksim/export/RocksimSaver.java +++ b/core/src/net/sf/openrocket/file/rocksim/export/RocksimSaver.java @@ -5,6 +5,7 @@ import java.io.IOException; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.StringWriter; +import java.nio.charset.StandardCharsets; import javax.xml.bind.JAXBContext; import javax.xml.bind.Marshaller; @@ -60,7 +61,7 @@ public class RocksimSaver extends RocketSaver { public void save(OutputStream dest, OpenRocketDocument doc, StorageOptions options) throws IOException { log.info("Saving .rkt file"); - BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(dest, "UTF-8")); + BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(dest, StandardCharsets.UTF_8)); writer.write(marshalToRocksim(doc)); writer.flush(); } diff --git a/core/src/net/sf/openrocket/file/rocksim/export/StageDTO.java b/core/src/net/sf/openrocket/file/rocksim/export/StageDTO.java index e6afdd355..2d859000e 100644 --- a/core/src/net/sf/openrocket/file/rocksim/export/StageDTO.java +++ b/core/src/net/sf/openrocket/file/rocksim/export/StageDTO.java @@ -25,7 +25,7 @@ public class StageDTO { @XmlElementRef(name = RocksimCommonConstants.NOSE_CONE, type = NoseConeDTO.class), @XmlElementRef(name = RocksimCommonConstants.TRANSITION, type = TransitionDTO.class) }) - private List externalPart = new ArrayList(); + private final List externalPart = new ArrayList(); /** * Default constructor. diff --git a/core/src/net/sf/openrocket/file/rocksim/importt/MassObjectHandler.java b/core/src/net/sf/openrocket/file/rocksim/importt/MassObjectHandler.java index 0668e81c6..5dfde9848 100644 --- a/core/src/net/sf/openrocket/file/rocksim/importt/MassObjectHandler.java +++ b/core/src/net/sf/openrocket/file/rocksim/importt/MassObjectHandler.java @@ -47,7 +47,7 @@ class MassObjectHandler extends PositionDependentHandler { /** * Parent. */ - private RocketComponent parent; + private final RocketComponent parent; /** * 0 == General, 1 == Shock Cord diff --git a/core/src/net/sf/openrocket/file/rocksim/importt/RockSimAppearanceBuilder.java b/core/src/net/sf/openrocket/file/rocksim/importt/RockSimAppearanceBuilder.java index 5ade83385..285f4d40f 100644 --- a/core/src/net/sf/openrocket/file/rocksim/importt/RockSimAppearanceBuilder.java +++ b/core/src/net/sf/openrocket/file/rocksim/importt/RockSimAppearanceBuilder.java @@ -121,8 +121,7 @@ public class RockSimAppearanceBuilder extends AppearanceBuilder { //TODO Make use of these values //System.out.println("Interpolate: " + interpolate); //System.out.println("FlipT: " + flipt); - ; - + } static Color weight(Color c, double w) { @@ -149,7 +148,7 @@ public class RockSimAppearanceBuilder extends AppearanceBuilder { } s = s.replace("rgb(", ""); s = s.replace(")", ""); - String ss[] = s.split(","); + String[] ss = s.split(","); return new Color(Integer.parseInt(ss[0]), Integer.parseInt(ss[1]), Integer.parseInt(ss[2])); } diff --git a/core/src/net/sf/openrocket/l10n/ClassBasedTranslator.java b/core/src/net/sf/openrocket/l10n/ClassBasedTranslator.java index 240281c4a..65589df06 100644 --- a/core/src/net/sf/openrocket/l10n/ClassBasedTranslator.java +++ b/core/src/net/sf/openrocket/l10n/ClassBasedTranslator.java @@ -83,7 +83,7 @@ public class ClassBasedTranslator implements Translator { private String findClassName() { Throwable trace = new Throwable(); - StackTraceElement stack[] = trace.getStackTrace(); + StackTraceElement[] stack = trace.getStackTrace(); final int index = 2 + levels; if (stack.length <= index) { throw new BugException("Stack trace is too short, length=" + stack.length + ", expected=" + index, trace); diff --git a/core/src/net/sf/openrocket/masscalc/MassCalculation.java b/core/src/net/sf/openrocket/masscalc/MassCalculation.java index 706d23558..3d4242dc8 100644 --- a/core/src/net/sf/openrocket/masscalc/MassCalculation.java +++ b/core/src/net/sf/openrocket/masscalc/MassCalculation.java @@ -106,7 +106,7 @@ public class MassCalculation { @Override public int hashCode() { - return (int) (this.centerOfMass.hashCode()); + return this.centerOfMass.hashCode(); } public MassCalculation( final Type _type, final FlightConfiguration _config, final double _time, diff --git a/core/src/net/sf/openrocket/masscalc/MassCalculator.java b/core/src/net/sf/openrocket/masscalc/MassCalculator.java index 820de4967..463ed7f4b 100644 --- a/core/src/net/sf/openrocket/masscalc/MassCalculator.java +++ b/core/src/net/sf/openrocket/masscalc/MassCalculator.java @@ -23,7 +23,7 @@ public class MassCalculator implements Monitorable { // private MassData rocketSpentMassCache; // private MassData motorMassCache; - private int modId = 0; + private final int modId = 0; ////////////////// Constructors /////////////////// public MassCalculator() { diff --git a/core/src/net/sf/openrocket/models/atmosphere/ExtendedISAModel.java b/core/src/net/sf/openrocket/models/atmosphere/ExtendedISAModel.java index eef78b005..b0153a03c 100644 --- a/core/src/net/sf/openrocket/models/atmosphere/ExtendedISAModel.java +++ b/core/src/net/sf/openrocket/models/atmosphere/ExtendedISAModel.java @@ -104,7 +104,7 @@ public class ExtendedISAModel extends InterpolatingAtmosphericModel { } - public static void main(String foo[]) { + public static void main(String[] foo) { ExtendedISAModel model1 = new ExtendedISAModel(); ExtendedISAModel model2 = new ExtendedISAModel(278.15, 100000); diff --git a/core/src/net/sf/openrocket/motor/CaseInfo.java b/core/src/net/sf/openrocket/motor/CaseInfo.java index cb7718c05..7acc2764c 100644 --- a/core/src/net/sf/openrocket/motor/CaseInfo.java +++ b/core/src/net/sf/openrocket/motor/CaseInfo.java @@ -21,7 +21,7 @@ public enum CaseInfo { PRO54_1("Pro54-1G"), PRO54_2("Pro54-2G"), PRO54_3("Pro54-3G"), PRO54_4("Pro54-4G"), PRO54_5("Pro54-5G"), PRO54_6("Pro54-6G"), PRO54_6XL("Pro54-6GXL"); - private String label; + private final String label; private CaseInfo(String label) { this.label = label; @@ -40,8 +40,8 @@ public enum CaseInfo { return compatibleCases.get(this); } - private static Map labelMapping; - private static Map compatibleCases; + private static final Map labelMapping; + private static final Map compatibleCases; static { labelMapping = new HashMap<>(); diff --git a/core/src/net/sf/openrocket/motor/DesignationComparator.java b/core/src/net/sf/openrocket/motor/DesignationComparator.java index 2c0e8f1f4..60f2984a0 100644 --- a/core/src/net/sf/openrocket/motor/DesignationComparator.java +++ b/core/src/net/sf/openrocket/motor/DesignationComparator.java @@ -36,7 +36,7 @@ public class DesignationComparator implements Comparator { * 4 = average thrust * 5 = stuff after thrust number */ - private Pattern pattern = + private final Pattern pattern = Pattern.compile("^([0-9]+-?|1/([1-8]))?([a-zA-Z])([0-9,]+)(.*?)$"); @Override diff --git a/core/src/net/sf/openrocket/motor/IgnitionEvent.java b/core/src/net/sf/openrocket/motor/IgnitionEvent.java index f932a6661..60a2bf2ea 100644 --- a/core/src/net/sf/openrocket/motor/IgnitionEvent.java +++ b/core/src/net/sf/openrocket/motor/IgnitionEvent.java @@ -14,7 +14,7 @@ public enum IgnitionEvent { AUTOMATIC( "AUTOMATIC", "MotorMount.IgnitionEvent.AUTOMATIC"){ @Override public boolean isActivationEvent(FlightEvent testEvent, RocketComponent targetComponent) { - AxialStage targetStage = (AxialStage)targetComponent.getStage(); + AxialStage targetStage = targetComponent.getStage(); if ( targetStage.isLaunchStage() ){ return LAUNCH.isActivationEvent(testEvent, targetComponent); @@ -36,8 +36,8 @@ public enum IgnitionEvent { return false; } - AxialStage targetStage = (AxialStage)targetComponent.getStage(); - AxialStage eventStage = (AxialStage)testEvent.getSource().getStage(); + AxialStage targetStage = targetComponent.getStage(); + AxialStage eventStage = testEvent.getSource().getStage(); AxialStage eventParentStage = eventStage.getUpperStage(); return ( targetStage.equals(eventParentStage)); } @@ -48,8 +48,8 @@ public enum IgnitionEvent { if (testEvent.getType() != FlightEvent.Type.BURNOUT) return false; - AxialStage targetStage = (AxialStage)targetComponent.getStage(); - AxialStage eventStage = (AxialStage)testEvent.getSource().getStage(); + AxialStage targetStage = targetComponent.getStage(); + AxialStage eventStage = testEvent.getSource().getStage(); AxialStage eventParentStage = eventStage.getUpperStage(); return ( targetStage.equals(eventParentStage)); } diff --git a/core/src/net/sf/openrocket/motor/Manufacturer.java b/core/src/net/sf/openrocket/motor/Manufacturer.java index ec26b308e..582733ad6 100644 --- a/core/src/net/sf/openrocket/motor/Manufacturer.java +++ b/core/src/net/sf/openrocket/motor/Manufacturer.java @@ -35,7 +35,7 @@ public class Manufacturer implements Serializable { } } - private static ManufacturerList manufacturers = new ManufacturerList(); + private static final ManufacturerList manufacturers = new ManufacturerList(); static { diff --git a/core/src/net/sf/openrocket/motor/MotorDigest.java b/core/src/net/sf/openrocket/motor/MotorDigest.java index 52593975e..ae8971189 100644 --- a/core/src/net/sf/openrocket/motor/MotorDigest.java +++ b/core/src/net/sf/openrocket/motor/MotorDigest.java @@ -1,6 +1,6 @@ package net.sf.openrocket.motor; -import java.io.UnsupportedEncodingException; +import java.nio.charset.StandardCharsets; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; @@ -167,13 +167,9 @@ public class MotorDigest { } catch (NoSuchAlgorithmException e) { throw new IllegalStateException("MD5 digest not supported by JRE", e); } - - try { - digest.update(comment.getBytes("UTF-8")); - } catch (UnsupportedEncodingException e) { - throw new IllegalStateException("UTF-8 encoding not supported by JRE", e); - } - + + digest.update(comment.getBytes(StandardCharsets.UTF_8)); + return TextUtil.hexString(digest.digest()); } diff --git a/core/src/net/sf/openrocket/motor/ThrustCurveMotor.java b/core/src/net/sf/openrocket/motor/ThrustCurveMotor.java index 8d269344c..4947676f3 100644 --- a/core/src/net/sf/openrocket/motor/ThrustCurveMotor.java +++ b/core/src/net/sf/openrocket/motor/ThrustCurveMotor.java @@ -560,7 +560,7 @@ public class ThrustCurveMotor implements Motor, Comparable, Se if( SNAP_TOLERANCE > (1-lowerFrac) ){ return cg[ (int) pseudoIndex ]; }else if( SNAP_TOLERANCE > upperFrac ){ - return cg[ (int)upperIndex ]; + return cg[upperIndex]; } // return simple linear interpolation @@ -749,7 +749,7 @@ public class ThrustCurveMotor implements Motor, Comparable, Se // 1. Manufacturer value = COLLATOR.compare(this.manufacturer.getDisplayName(), - ((ThrustCurveMotor) other).manufacturer.getDisplayName()); + other.manufacturer.getDisplayName()); if (value != 0) return value; diff --git a/core/src/net/sf/openrocket/optimization/general/ParallelExecutorCache.java b/core/src/net/sf/openrocket/optimization/general/ParallelExecutorCache.java index 67154da54..c1ad786c7 100644 --- a/core/src/net/sf/openrocket/optimization/general/ParallelExecutorCache.java +++ b/core/src/net/sf/openrocket/optimization/general/ParallelExecutorCache.java @@ -34,7 +34,7 @@ public class ParallelExecutorCache implements ParallelFunctionCache { private final Map functionCache = new HashMap(); private final Map> futureMap = new HashMap>(); - private ExecutorService executor; + private final ExecutorService executor; private Function function; diff --git a/core/src/net/sf/openrocket/optimization/general/multidim/MultidirectionalSearchOptimizer.java b/core/src/net/sf/openrocket/optimization/general/multidim/MultidirectionalSearchOptimizer.java index cc97f692c..9f3572dd9 100644 --- a/core/src/net/sf/openrocket/optimization/general/multidim/MultidirectionalSearchOptimizer.java +++ b/core/src/net/sf/openrocket/optimization/general/multidim/MultidirectionalSearchOptimizer.java @@ -28,12 +28,12 @@ import net.sf.openrocket.util.Statistics; public class MultidirectionalSearchOptimizer implements FunctionOptimizer, Statistics { private static final Logger log = LoggerFactory.getLogger(MultidirectionalSearchOptimizer.class); - private List simplex = new ArrayList(); + private final List simplex = new ArrayList(); private ParallelFunctionCache functionExecutor; - private boolean useExpansion = false; - private boolean useCoordinateSearch = false; + private final boolean useExpansion = false; + private final boolean useCoordinateSearch = false; private int stepCount = 0; private int reflectionAcceptance = 0; diff --git a/core/src/net/sf/openrocket/plugin/PluginModule.java b/core/src/net/sf/openrocket/plugin/PluginModule.java index 5985982a0..39bd94c13 100644 --- a/core/src/net/sf/openrocket/plugin/PluginModule.java +++ b/core/src/net/sf/openrocket/plugin/PluginModule.java @@ -17,8 +17,8 @@ import com.google.inject.multibindings.Multibinder; public class PluginModule extends AbstractModule { - private Map, Multibinder> binders = new HashMap, Multibinder>(); - private AnnotationFinder finder = new AnnotationFinderImpl(); + private final Map, Multibinder> binders = new HashMap, Multibinder>(); + private final AnnotationFinder finder = new AnnotationFinderImpl(); @SuppressWarnings("unchecked") diff --git a/core/src/net/sf/openrocket/preset/ComponentPreset.java b/core/src/net/sf/openrocket/preset/ComponentPreset.java index debd4bae3..c99833504 100644 --- a/core/src/net/sf/openrocket/preset/ComponentPreset.java +++ b/core/src/net/sf/openrocket/preset/ComponentPreset.java @@ -161,7 +161,7 @@ public class ComponentPreset implements Comparable, Serializabl return displayedColumns; } - private static Map> compatibleTypeMap = new HashMap>(); + private static final Map> compatibleTypeMap = new HashMap>(); static { compatibleTypeMap.put(BODY_TUBE, Arrays.asList(BODY_TUBE, TUBE_COUPLER, LAUNCH_LUG)); @@ -203,7 +203,7 @@ public class ComponentPreset implements Comparable, Serializabl public final static TypedKey STANDOFF_HEIGHT = new TypedKey("StandoffHeight", Double.class, UnitGroup.UNITS_LENGTH); public final static TypedKey FLANGE_HEIGHT = new TypedKey("FlangeHeight", Double.class, UnitGroup.UNITS_LENGTH); - public final static List> ORDERED_KEY_LIST = Collections.unmodifiableList(Arrays.> asList( + public final static List> ORDERED_KEY_LIST = Collections.unmodifiableList(Arrays.asList( MANUFACTURER, PARTNO, DESCRIPTION, @@ -328,11 +328,7 @@ public class ComponentPreset implements Comparable, Serializabl ComponentPreset that = (ComponentPreset) o; - if (digest != null ? !digest.equals(that.digest) : that.digest != null) { - return false; - } - - return true; + return digest != null ? digest.equals(that.digest) : that.digest == null; } @Override diff --git a/core/src/net/sf/openrocket/preset/InvalidComponentPresetException.java b/core/src/net/sf/openrocket/preset/InvalidComponentPresetException.java index c28fb0930..4d0b6a7a1 100644 --- a/core/src/net/sf/openrocket/preset/InvalidComponentPresetException.java +++ b/core/src/net/sf/openrocket/preset/InvalidComponentPresetException.java @@ -5,8 +5,8 @@ import java.util.List; public class InvalidComponentPresetException extends Exception { - private List errors = new ArrayList(); - private List> invalidParameters = new ArrayList>(); + private final List errors = new ArrayList(); + private final List> invalidParameters = new ArrayList>(); public InvalidComponentPresetException() { super(); diff --git a/core/src/net/sf/openrocket/preset/loader/DoubleColumnParser.java b/core/src/net/sf/openrocket/preset/loader/DoubleColumnParser.java index e4f541344..78b1376fd 100644 --- a/core/src/net/sf/openrocket/preset/loader/DoubleColumnParser.java +++ b/core/src/net/sf/openrocket/preset/loader/DoubleColumnParser.java @@ -5,7 +5,7 @@ import net.sf.openrocket.preset.TypedPropertyMap; public class DoubleColumnParser extends BaseColumnParser { - private TypedKey propKey; + private final TypedKey propKey; public DoubleColumnParser(String columnHeader, TypedKey propKey) { super(columnHeader); diff --git a/core/src/net/sf/openrocket/preset/loader/DoubleUnitColumnParser.java b/core/src/net/sf/openrocket/preset/loader/DoubleUnitColumnParser.java index 4dee25b54..00a0f4d61 100644 --- a/core/src/net/sf/openrocket/preset/loader/DoubleUnitColumnParser.java +++ b/core/src/net/sf/openrocket/preset/loader/DoubleUnitColumnParser.java @@ -8,7 +8,7 @@ import net.sf.openrocket.util.StringUtil; public class DoubleUnitColumnParser extends BaseUnitColumnParser { - private TypedKey propKey; + private final TypedKey propKey; public DoubleUnitColumnParser(String columnHeader, String unitHeader, TypedKey propKey) { diff --git a/core/src/net/sf/openrocket/preset/loader/IntegerColumnParser.java b/core/src/net/sf/openrocket/preset/loader/IntegerColumnParser.java index d871be1ce..92f0ec773 100644 --- a/core/src/net/sf/openrocket/preset/loader/IntegerColumnParser.java +++ b/core/src/net/sf/openrocket/preset/loader/IntegerColumnParser.java @@ -5,7 +5,7 @@ import net.sf.openrocket.preset.TypedPropertyMap; public class IntegerColumnParser extends BaseColumnParser { - private TypedKey propKey; + private final TypedKey propKey; public IntegerColumnParser(String columnHeader, TypedKey propKey) { super(columnHeader); diff --git a/core/src/net/sf/openrocket/preset/loader/MaterialLoader.java b/core/src/net/sf/openrocket/preset/loader/MaterialLoader.java index b7ef55b48..18915aef3 100644 --- a/core/src/net/sf/openrocket/preset/loader/MaterialLoader.java +++ b/core/src/net/sf/openrocket/preset/loader/MaterialLoader.java @@ -10,7 +10,7 @@ import net.sf.openrocket.util.BugException; public class MaterialLoader extends RocksimComponentFileLoader { - private MaterialHolder materialMap = new MaterialHolder(); + private final MaterialHolder materialMap = new MaterialHolder(); private final static TypedKey MATERIALNAME = new TypedKey("MaterialName", String.class); private final static TypedKey UNITS = new TypedKey("Units", String.class); diff --git a/core/src/net/sf/openrocket/preset/loader/RocksimComponentFileLoader.java b/core/src/net/sf/openrocket/preset/loader/RocksimComponentFileLoader.java index 375de7ac8..3126766c1 100644 --- a/core/src/net/sf/openrocket/preset/loader/RocksimComponentFileLoader.java +++ b/core/src/net/sf/openrocket/preset/loader/RocksimComponentFileLoader.java @@ -25,7 +25,7 @@ public abstract class RocksimComponentFileLoader { private String basePath = ""; - private File dir; + private final File dir; protected List fileColumns = new ArrayList(); diff --git a/core/src/net/sf/openrocket/preset/loader/StringColumnParser.java b/core/src/net/sf/openrocket/preset/loader/StringColumnParser.java index c4d96a70f..70949ba0c 100644 --- a/core/src/net/sf/openrocket/preset/loader/StringColumnParser.java +++ b/core/src/net/sf/openrocket/preset/loader/StringColumnParser.java @@ -5,7 +5,7 @@ import net.sf.openrocket.preset.TypedPropertyMap; public class StringColumnParser extends BaseColumnParser { - private TypedKey propKey; + private final TypedKey propKey; public StringColumnParser(String columnHeader, TypedKey propKey) { super(columnHeader); diff --git a/core/src/net/sf/openrocket/preset/xml/BaseComponentDTO.java b/core/src/net/sf/openrocket/preset/xml/BaseComponentDTO.java index ca8c18fde..3db31341c 100644 --- a/core/src/net/sf/openrocket/preset/xml/BaseComponentDTO.java +++ b/core/src/net/sf/openrocket/preset/xml/BaseComponentDTO.java @@ -228,7 +228,7 @@ public abstract class BaseComponentDTO { static class AnnotatedLengthDTO { @XmlAttribute(name = "Unit", required = false) - private String unitName = "m"; + private final String unitName = "m"; @XmlValue private double length; @@ -246,7 +246,7 @@ public abstract class BaseComponentDTO { static class AnnotatedMassDTO { @XmlAttribute(name = "Unit", required = false) - private String unitName = "kg"; + private final String unitName = "kg"; @XmlValue private double mass; diff --git a/core/src/net/sf/openrocket/preset/xml/MaterialTypeDTO.java b/core/src/net/sf/openrocket/preset/xml/MaterialTypeDTO.java index 93a83b35f..acc23d31f 100644 --- a/core/src/net/sf/openrocket/preset/xml/MaterialTypeDTO.java +++ b/core/src/net/sf/openrocket/preset/xml/MaterialTypeDTO.java @@ -12,7 +12,7 @@ public enum MaterialTypeDTO { SURFACE (Material.Type.SURFACE), BULK (Material.Type.BULK); - private Material.Type corollary; + private final Material.Type corollary; private MaterialTypeDTO(final Material.Type theCorollary) { corollary = theCorollary; diff --git a/core/src/net/sf/openrocket/preset/xml/OpenRocketComponentSaver.java b/core/src/net/sf/openrocket/preset/xml/OpenRocketComponentSaver.java index 191a69a6c..a1c5f835a 100644 --- a/core/src/net/sf/openrocket/preset/xml/OpenRocketComponentSaver.java +++ b/core/src/net/sf/openrocket/preset/xml/OpenRocketComponentSaver.java @@ -19,6 +19,7 @@ import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.Reader; import java.io.StringWriter; +import java.nio.charset.StandardCharsets; import java.util.Collections; import java.util.Comparator; import java.util.List; @@ -46,7 +47,7 @@ public class OpenRocketComponentSaver { public boolean save(File file, List theMaterialList, List thePresetList) throws JAXBException, IOException { - BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), "UTF-8")); + BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8)); writer.write(marshalToOpenRocketComponent(theMaterialList, thePresetList)); writer.flush(); writer.close(); @@ -130,7 +131,7 @@ public class OpenRocketComponentSaver { public void save(OutputStream dest, List theMaterialList, List thePresetList) throws IOException, JAXBException { - BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(dest, "UTF-8")); + BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(dest, StandardCharsets.UTF_8)); writer.write(marshalToOpenRocketComponent(theMaterialList, thePresetList)); writer.flush(); writer.close(); diff --git a/core/src/net/sf/openrocket/preset/xml/ShapeDTO.java b/core/src/net/sf/openrocket/preset/xml/ShapeDTO.java index d85fbcb0f..54f46da00 100644 --- a/core/src/net/sf/openrocket/preset/xml/ShapeDTO.java +++ b/core/src/net/sf/openrocket/preset/xml/ShapeDTO.java @@ -18,7 +18,7 @@ public enum ShapeDTO { PARABOLIC (Transition.Shape.PARABOLIC), HAACK (Transition.Shape.HAACK); - private Transition.Shape corollary; + private final Transition.Shape corollary; private ShapeDTO(Transition.Shape theShape) { corollary = theShape; diff --git a/core/src/net/sf/openrocket/rocketcomponent/ComponentChangeEvent.java b/core/src/net/sf/openrocket/rocketcomponent/ComponentChangeEvent.java index ffeab7f0c..f74798f6a 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/ComponentChangeEvent.java +++ b/core/src/net/sf/openrocket/rocketcomponent/ComponentChangeEvent.java @@ -30,8 +30,8 @@ public class ComponentChangeEvent extends EventObject { return (0 != (this.value & testValue )); } - }; - + } + /** A change that does not affect simulation results in any way (name, color, etc.) */ public static final int NONFUNCTIONAL_CHANGE = TYPE.NON_FUNCTIONAL.value; /** A change that affects the mass properties of the rocket */ diff --git a/core/src/net/sf/openrocket/rocketcomponent/FinSet.java b/core/src/net/sf/openrocket/rocketcomponent/FinSet.java index b298608bc..d6ebb28c1 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/FinSet.java +++ b/core/src/net/sf/openrocket/rocketcomponent/FinSet.java @@ -837,11 +837,7 @@ public abstract class FinSet extends ExternalComponent implements AxialPositiona public boolean isRootStraight( ){ if( getParent() instanceof Transition){ - if( ((Transition)getParent()).getType() == Transition.Shape.CONICAL ){ - return true; - }else{ - return false; - } + return ((Transition) getParent()).getType() == Shape.CONICAL; } // by default, assume a flat base diff --git a/core/src/net/sf/openrocket/rocketcomponent/FlightConfigurationId.java b/core/src/net/sf/openrocket/rocketcomponent/FlightConfigurationId.java index 258fd7fe5..bea02944f 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/FlightConfigurationId.java +++ b/core/src/net/sf/openrocket/rocketcomponent/FlightConfigurationId.java @@ -12,9 +12,9 @@ public final class FlightConfigurationId implements Comparable branches = new ArrayList(); diff --git a/core/src/net/sf/openrocket/simulation/FlightDataBranch.java b/core/src/net/sf/openrocket/simulation/FlightDataBranch.java index 533717832..c7f71f7fc 100644 --- a/core/src/net/sf/openrocket/simulation/FlightDataBranch.java +++ b/core/src/net/sf/openrocket/simulation/FlightDataBranch.java @@ -47,7 +47,7 @@ public class FlightDataBranch implements Monitorable { private final ArrayList events = new ArrayList(); - private Mutable mutable = new Mutable(); + private final Mutable mutable = new Mutable(); private int modID = 0; diff --git a/core/src/net/sf/openrocket/simulation/FlightEvent.java b/core/src/net/sf/openrocket/simulation/FlightEvent.java index a3eab8ef9..55ceaab36 100644 --- a/core/src/net/sf/openrocket/simulation/FlightEvent.java +++ b/core/src/net/sf/openrocket/simulation/FlightEvent.java @@ -79,12 +79,12 @@ public class FlightEvent implements Comparable { /** * The rocket begins to tumble. */ - TUMBLE(trans.get("FlightEvent.Type.TUMBLE")), - - /** - * Simulation aborted - */ - EXCEPTION(trans.get("FlightEvent.Type.EXCEPTION")); + TUMBLE(trans.get("FlightEvent.Type.TUMBLE")), + + /** + * Simulation aborted + */ + EXCEPTION(trans.get("FlightEvent.Type.EXCEPTION")); private final String name; diff --git a/core/src/net/sf/openrocket/simulation/SimulationStatus.java b/core/src/net/sf/openrocket/simulation/SimulationStatus.java index 88dcca17f..6618fefea 100644 --- a/core/src/net/sf/openrocket/simulation/SimulationStatus.java +++ b/core/src/net/sf/openrocket/simulation/SimulationStatus.java @@ -53,7 +53,7 @@ public class SimulationStatus implements Monitorable { private double effectiveLaunchRodLength; // Set of all motors - private List motorStateList = new ArrayList(); + private final List motorStateList = new ArrayList(); /** Nanosecond time when the simulation was started. */ @@ -79,7 +79,7 @@ public class SimulationStatus implements Monitorable { private boolean landed = false; /** Contains a list of deployed recovery devices. */ - private MonitorableSet deployedRecoveryDevices = new MonitorableSet(); + private final MonitorableSet deployedRecoveryDevices = new MonitorableSet(); /** The flight event queue */ private final EventQueue eventQueue = new EventQueue(); @@ -514,7 +514,7 @@ public class SimulationStatus implements Monitorable { } public String toEventDebug(){ - final StringBuilder buf = new StringBuilder(""); + final StringBuilder buf = new StringBuilder(); for ( FlightEvent event : this.eventQueue){ buf.append(" [t:"+event.getType()+" @"+ event.getTime()); if( null != event.getSource()){ diff --git a/core/src/net/sf/openrocket/simulation/SimulationStepper.java b/core/src/net/sf/openrocket/simulation/SimulationStepper.java index f218f387e..cdc16f049 100644 --- a/core/src/net/sf/openrocket/simulation/SimulationStepper.java +++ b/core/src/net/sf/openrocket/simulation/SimulationStepper.java @@ -11,7 +11,7 @@ public interface SimulationStepper { * @param status the current simulation status. * @return a SimulationStatus suitable for simulating with this simulation stepper. */ - public SimulationStatus initialize(SimulationStatus status); + public SimulationStatus initialize(SimulationStatus status); /** * Perform one simulation time step. diff --git a/core/src/net/sf/openrocket/simulation/customexpression/CustomExpression.java b/core/src/net/sf/openrocket/simulation/customexpression/CustomExpression.java index 0a7cf7ac7..17aad2229 100644 --- a/core/src/net/sf/openrocket/simulation/customexpression/CustomExpression.java +++ b/core/src/net/sf/openrocket/simulation/customexpression/CustomExpression.java @@ -31,12 +31,12 @@ public class CustomExpression implements Cloneable { private static final Logger log = LoggerFactory.getLogger(CustomExpression.class); - private OpenRocketDocument doc; + private final OpenRocketDocument doc; private String name, symbol, unit; protected String expression; private ExpressionBuilder builder; - private List subExpressions = new ArrayList(); + private final List subExpressions = new ArrayList(); public CustomExpression(OpenRocketDocument doc) { this.doc = doc; diff --git a/core/src/net/sf/openrocket/simulation/customexpression/Functions.java b/core/src/net/sf/openrocket/simulation/customexpression/Functions.java index 8c020b3b9..829ce82ed 100644 --- a/core/src/net/sf/openrocket/simulation/customexpression/Functions.java +++ b/core/src/net/sf/openrocket/simulation/customexpression/Functions.java @@ -25,7 +25,7 @@ public class Functions { private static final Logger log = LoggerFactory.getLogger(Functions.class); private static final Translator trans = Application.getTranslator(); - private List allFunctions = new ArrayList(); + private final List allFunctions = new ArrayList(); public static Functions getInstance() { if(instance == null) { diff --git a/core/src/net/sf/openrocket/simulation/extension/impl/ScriptingSimulationListener.java b/core/src/net/sf/openrocket/simulation/extension/impl/ScriptingSimulationListener.java index 6067378f4..976e53ff4 100644 --- a/core/src/net/sf/openrocket/simulation/extension/impl/ScriptingSimulationListener.java +++ b/core/src/net/sf/openrocket/simulation/extension/impl/ScriptingSimulationListener.java @@ -37,7 +37,7 @@ public class ScriptingSimulationListener implements SimulationListener, Simulati * so that unimplemented script methods are not called unnecessarily. */ - private Invocable invocable; + private final Invocable invocable; private Set missing = new HashSet(); diff --git a/core/src/net/sf/openrocket/simulation/extension/impl/ScriptingUtil.java b/core/src/net/sf/openrocket/simulation/extension/impl/ScriptingUtil.java index 6f0f76517..7259a9787 100644 --- a/core/src/net/sf/openrocket/simulation/extension/impl/ScriptingUtil.java +++ b/core/src/net/sf/openrocket/simulation/extension/impl/ScriptingUtil.java @@ -1,7 +1,7 @@ package net.sf.openrocket.simulation.extension.impl; -import java.io.UnsupportedEncodingException; import java.math.BigInteger; +import java.nio.charset.StandardCharsets; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.util.Arrays; @@ -138,9 +138,9 @@ public class ScriptingUtil { try { digest = MessageDigest.getInstance("SHA-256"); - digest.update(language.getBytes("UTF-8")); + digest.update(language.getBytes(StandardCharsets.UTF_8)); digest.update((byte) '|'); - byte[] hash = digest.digest(script.getBytes("UTF-8")); + byte[] hash = digest.digest(script.getBytes(StandardCharsets.UTF_8)); BigInteger bigInt = new BigInteger(1, hash); output = bigInt.toString(16); while (output.length() < 64) { @@ -148,10 +148,8 @@ public class ScriptingUtil { } } catch (NoSuchAlgorithmException e) { throw new BugException("JRE does not support SHA-256 hash algorithm", e); - } catch (UnsupportedEncodingException e) { - throw new BugException(e); } - + return digest.getAlgorithm() + ":" + output; } diff --git a/core/src/net/sf/openrocket/startup/Application.java b/core/src/net/sf/openrocket/startup/Application.java index 13e8fdedf..97d99f376 100644 --- a/core/src/net/sf/openrocket/startup/Application.java +++ b/core/src/net/sf/openrocket/startup/Application.java @@ -27,11 +27,8 @@ public final class Application { public static boolean useSafetyChecks() { // Currently default to false unless openrocket.debug.safetycheck is defined String s = System.getProperty("openrocket.debug.safetycheck"); - if (s != null && !(s.equalsIgnoreCase("false") || s.equalsIgnoreCase("off"))) { - return true; - } - return false; - } + return s != null && !(s.equalsIgnoreCase("false") || s.equalsIgnoreCase("off")); + } private static Translator getBaseTranslator() { if (injector == null) { diff --git a/core/src/net/sf/openrocket/startup/Preferences.java b/core/src/net/sf/openrocket/startup/Preferences.java index 157ca465d..3a9504858 100644 --- a/core/src/net/sf/openrocket/startup/Preferences.java +++ b/core/src/net/sf/openrocket/startup/Preferences.java @@ -221,7 +221,6 @@ public abstract class Preferences implements ChangeSource { if (MathUtil.equals(this.getDouble(LAUNCH_ROD_ANGLE, 0), launchRodAngle)) return; this.putDouble(LAUNCH_ROD_ANGLE, launchRodAngle); - ; fireChangeEvent(); } @@ -768,7 +767,7 @@ public abstract class Preferences implements ChangeSource { } } - private List listeners = new ArrayList(); + private final List listeners = new ArrayList(); private final EventObject event = new EventObject(this); @Override diff --git a/core/src/net/sf/openrocket/thrustcurve/DownloadRequest.java b/core/src/net/sf/openrocket/thrustcurve/DownloadRequest.java index d49d7d4a5..d0b7f4bd0 100644 --- a/core/src/net/sf/openrocket/thrustcurve/DownloadRequest.java +++ b/core/src/net/sf/openrocket/thrustcurve/DownloadRequest.java @@ -4,7 +4,7 @@ import java.util.ArrayList; class DownloadRequest { - private ArrayList motorIds = new ArrayList(); + private final ArrayList motorIds = new ArrayList(); private String format = null; diff --git a/core/src/net/sf/openrocket/thrustcurve/DownloadResponse.java b/core/src/net/sf/openrocket/thrustcurve/DownloadResponse.java index c7a49239e..69d0ef642 100644 --- a/core/src/net/sf/openrocket/thrustcurve/DownloadResponse.java +++ b/core/src/net/sf/openrocket/thrustcurve/DownloadResponse.java @@ -8,7 +8,7 @@ import java.util.Map; public class DownloadResponse { - private Map> data = new HashMap>(); + private final Map> data = new HashMap>(); private String error = null; diff --git a/core/src/net/sf/openrocket/thrustcurve/DownloadResponseParser.java b/core/src/net/sf/openrocket/thrustcurve/DownloadResponseParser.java index 42eb695cd..6a851b6a3 100644 --- a/core/src/net/sf/openrocket/thrustcurve/DownloadResponseParser.java +++ b/core/src/net/sf/openrocket/thrustcurve/DownloadResponseParser.java @@ -26,14 +26,14 @@ public class DownloadResponseParser implements ElementHandler { private static final String data_tag = "data"; private static final String error_tag = "error"; - private DownloadResponse response = new DownloadResponse(); + private final DownloadResponse response = new DownloadResponse(); private MotorBurnFile motorBurnFile; private DownloadResponseParser() { - }; - - public static DownloadResponse parse(InputStream in) throws IOException, SAXException { + } + + public static DownloadResponse parse(InputStream in) throws IOException, SAXException { DownloadResponseParser handler = new DownloadResponseParser(); WarningSet warnings = new WarningSet(); diff --git a/core/src/net/sf/openrocket/thrustcurve/MotorBurnFile.java b/core/src/net/sf/openrocket/thrustcurve/MotorBurnFile.java index 420553376..9c6c625e3 100644 --- a/core/src/net/sf/openrocket/thrustcurve/MotorBurnFile.java +++ b/core/src/net/sf/openrocket/thrustcurve/MotorBurnFile.java @@ -38,11 +38,11 @@ public class MotorBurnFile { if (SupportedFileTypes.RASP_FORMAT.equals(filetype)) { RASPMotorLoader loader = new RASPMotorLoader(); List motors = loader.load(new StringReader(data), "download"); - this.thrustCurveMotor = (ThrustCurveMotor.Builder)motors.get(0); + this.thrustCurveMotor = motors.get(0); } else if (SupportedFileTypes.ROCKSIM_FORMAT.equals(filetype)) { RockSimMotorLoader loader = new RockSimMotorLoader(); List motors = loader.load(new StringReader(data), "download"); - this.thrustCurveMotor = (ThrustCurveMotor.Builder)motors.get(0); + this.thrustCurveMotor = motors.get(0); } } catch (IOException ex) { this.thrustCurveMotor = null; diff --git a/core/src/net/sf/openrocket/thrustcurve/SearchResponse.java b/core/src/net/sf/openrocket/thrustcurve/SearchResponse.java index a15d06feb..5bc50e9fb 100644 --- a/core/src/net/sf/openrocket/thrustcurve/SearchResponse.java +++ b/core/src/net/sf/openrocket/thrustcurve/SearchResponse.java @@ -6,7 +6,7 @@ import java.util.List; public class SearchResponse { - private List results = new ArrayList(); + private final List results = new ArrayList(); private int matches; diff --git a/core/src/net/sf/openrocket/thrustcurve/SearchResponseParser.java b/core/src/net/sf/openrocket/thrustcurve/SearchResponseParser.java index 3c8b08fe7..137c9ec69 100644 --- a/core/src/net/sf/openrocket/thrustcurve/SearchResponseParser.java +++ b/core/src/net/sf/openrocket/thrustcurve/SearchResponseParser.java @@ -51,7 +51,7 @@ public class SearchResponseParser implements ElementHandler { private static final String updated_on = "updated-on"; private static final String availability = "availability"; - private SearchResponse response = new SearchResponse(); + private final SearchResponse response = new SearchResponse(); private TCMotor currentMotor; diff --git a/core/src/net/sf/openrocket/thrustcurve/SerializeThrustcurveMotors.java b/core/src/net/sf/openrocket/thrustcurve/SerializeThrustcurveMotors.java index 2299898dc..84842a6e1 100644 --- a/core/src/net/sf/openrocket/thrustcurve/SerializeThrustcurveMotors.java +++ b/core/src/net/sf/openrocket/thrustcurve/SerializeThrustcurveMotors.java @@ -21,7 +21,7 @@ import net.sf.openrocket.util.Pair; public class SerializeThrustcurveMotors { - private static String[] manufacturers = { + private static final String[] manufacturers = { "AeroTech", "Alpha", "AMW", @@ -75,7 +75,7 @@ public class SerializeThrustcurveMotors { } - public static void loadFromThrustCurve(List allMotors) throws SAXException, MalformedURLException, IOException { + public static void loadFromThrustCurve(List allMotors) throws SAXException, IOException { SearchRequest searchRequest = new SearchRequest(); for (String m : manufacturers) { @@ -164,7 +164,7 @@ public class SerializeThrustcurveMotors { } private static List getThrustCurvesForMotorId(int motorId) { - String formats[] = new String[] {"RASP", "RockSim"}; + String[] formats = new String[] {"RASP", "RockSim"}; List b = new ArrayList<>(); for (String format : formats) { try { diff --git a/core/src/net/sf/openrocket/thrustcurve/ThrustCurveAPI.java b/core/src/net/sf/openrocket/thrustcurve/ThrustCurveAPI.java index 8b810855c..94669143e 100644 --- a/core/src/net/sf/openrocket/thrustcurve/ThrustCurveAPI.java +++ b/core/src/net/sf/openrocket/thrustcurve/ThrustCurveAPI.java @@ -15,7 +15,7 @@ import org.xml.sax.SAXException; public abstract class ThrustCurveAPI { - public static SearchResponse doSearch(SearchRequest request) throws MalformedURLException, IOException, SAXException { + public static SearchResponse doSearch(SearchRequest request) throws IOException, SAXException { String requestString = request.toString(); @@ -42,7 +42,7 @@ public abstract class ThrustCurveAPI { return result; } - public static List downloadData(Integer motor_id, String format) throws MalformedURLException, IOException, SAXException { + public static List downloadData(Integer motor_id, String format) throws IOException, SAXException { if (motor_id == null) { return null; @@ -70,7 +70,7 @@ public abstract class ThrustCurveAPI { stream.write(requestString.getBytes()); if (conn.getResponseCode() == HttpURLConnection.HTTP_BAD_REQUEST) { - return Collections. emptyList(); + return Collections.emptyList(); } InputStream is = conn.getInputStream(); diff --git a/core/src/net/sf/openrocket/util/BoundingBox.java b/core/src/net/sf/openrocket/util/BoundingBox.java index a1f766837..4bb41e1e5 100644 --- a/core/src/net/sf/openrocket/util/BoundingBox.java +++ b/core/src/net/sf/openrocket/util/BoundingBox.java @@ -29,13 +29,9 @@ public class BoundingBox { } public boolean isEmpty(){ - if( (min.x > max.x) || - (min.y > max.y) || - (min.z > max.z)){ - return true; - }else{ - return false; - } + return (min.x > max.x) || + (min.y > max.y) || + (min.z > max.z); } /** diff --git a/core/src/net/sf/openrocket/util/Config.java b/core/src/net/sf/openrocket/util/Config.java index 64a87e833..e01412dc0 100644 --- a/core/src/net/sf/openrocket/util/Config.java +++ b/core/src/net/sf/openrocket/util/Config.java @@ -9,7 +9,7 @@ import java.util.Set; public class Config { - private LinkedHashMap map = new LinkedHashMap(); + private final LinkedHashMap map = new LinkedHashMap(); public void put(String key, String value) { diff --git a/core/src/net/sf/openrocket/util/GeodeticComputationStrategy.java b/core/src/net/sf/openrocket/util/GeodeticComputationStrategy.java index 661df2b1e..9ed7daf2d 100644 --- a/core/src/net/sf/openrocket/util/GeodeticComputationStrategy.java +++ b/core/src/net/sf/openrocket/util/GeodeticComputationStrategy.java @@ -115,7 +115,7 @@ public enum GeodeticComputationStrategy { // Calculate the new lat and lon double newLat, newLon; - double ret[] = dirct1(location.getLatitudeRad(), location.getLongitudeRad(), bearing, d, 6378137, 1.0 / 298.25722210088); + double[] ret = dirct1(location.getLatitudeRad(), location.getLongitudeRad(), bearing, d, 6378137, 1.0 / 298.25722210088); newLat = ret[0]; newLon = ret[1]; diff --git a/core/src/net/sf/openrocket/util/MemoryManagement.java b/core/src/net/sf/openrocket/util/MemoryManagement.java index 066ebb98b..4d8e63cb9 100644 --- a/core/src/net/sf/openrocket/util/MemoryManagement.java +++ b/core/src/net/sf/openrocket/util/MemoryManagement.java @@ -30,11 +30,11 @@ public final class MemoryManagement { * Storage of the objects. This is basically a mapping from the objects (using weak references) * to */ - private static List objects = new LinkedList(); + private static final List objects = new LinkedList(); private static int collectableCallCount = 0; - private static List>> listenerLists = new LinkedList>>(); + private static final List>> listenerLists = new LinkedList>>(); private static int listenerCallCount = 0; diff --git a/core/src/net/sf/openrocket/util/MonitorableSet.java b/core/src/net/sf/openrocket/util/MonitorableSet.java index a7601bdf4..48dc14626 100644 --- a/core/src/net/sf/openrocket/util/MonitorableSet.java +++ b/core/src/net/sf/openrocket/util/MonitorableSet.java @@ -17,8 +17,8 @@ public class MonitorableSet extends HashSet implements Monitorable { public boolean add(E e) { modID++; return super.add(e); - }; - + } + @Override public boolean addAll(Collection c) { modID++; diff --git a/core/src/net/sf/openrocket/util/PolyInterpolator.java b/core/src/net/sf/openrocket/util/PolyInterpolator.java index 8038f54b4..fd06d890e 100644 --- a/core/src/net/sf/openrocket/util/PolyInterpolator.java +++ b/core/src/net/sf/openrocket/util/PolyInterpolator.java @@ -151,9 +151,9 @@ public class PolyInterpolator { private static double[][] inverse(double[][] matrix) { int n = matrix.length; - double x[][] = new double[n][n]; - double b[][] = new double[n][n]; - int index[] = new int[n]; + double[][] x = new double[n][n]; + double[][] b = new double[n][n]; + int[] index = new int[n]; for (int i=0; i requestProperties = new HashMap(); + private final Map requestProperties = new HashMap(); private volatile int connectTimeout = -1; private volatile String contentEncoding = ""; @@ -214,12 +215,8 @@ public class HttpURLConnectionMock extends HttpURLConnection { } public void setContent(String content) { - try { - this.content = content.getBytes("UTF-8"); - } catch (UnsupportedEncodingException e) { - fail("UTF-8"); - } - } + this.content = content.getBytes(StandardCharsets.UTF_8); + } @Override @@ -285,13 +282,8 @@ public class HttpURLConnectionMock extends HttpURLConnection { } public String getOutputStreamString() { - try { - return outputStream.toString("UTF-8"); - } catch (UnsupportedEncodingException e) { - fail("UTF-8"); - return null; - } - } + return outputStream.toString(StandardCharsets.UTF_8); + } diff --git a/core/test/net/sf/openrocket/file/openrocket/OpenRocketSaverTest.java b/core/test/net/sf/openrocket/file/openrocket/OpenRocketSaverTest.java index 6e6cac7f4..0d5701d12 100644 --- a/core/test/net/sf/openrocket/file/openrocket/OpenRocketSaverTest.java +++ b/core/test/net/sf/openrocket/file/openrocket/OpenRocketSaverTest.java @@ -48,7 +48,7 @@ import com.google.inject.util.Modules; public class OpenRocketSaverTest { - private OpenRocketSaver saver = new OpenRocketSaver(); + private final OpenRocketSaver saver = new OpenRocketSaver(); private static final File TMP_DIR = new File("./tmp/"); public static final String SIMULATION_EXTENSION_SCRIPT = "// Test < &\n// >\n// testPairs[] = new TestPair[]{ + Pair[] testPairs = new TestPair[]{ new TestPair(0.512, 0.041), new TestPair(2.115, 0.084), new TestPair( 1.220, 0.060), diff --git a/core/test/net/sf/openrocket/rocketcomponent/FlightConfigurationTest.java b/core/test/net/sf/openrocket/rocketcomponent/FlightConfigurationTest.java index 1c55e2003..7b82c3a66 100644 --- a/core/test/net/sf/openrocket/rocketcomponent/FlightConfigurationTest.java +++ b/core/test/net/sf/openrocket/rocketcomponent/FlightConfigurationTest.java @@ -187,7 +187,7 @@ public class FlightConfigurationTest extends BaseTestCase { assertThat("number of loaded configuration counts doesn't actually match.", actualConfigCount, equalTo(expectedConfigCount)); // create with - rkt.createFlightConfiguration( (FlightConfigurationId)null); + rkt.createFlightConfiguration(null); expectedConfigCount = 6; actualConfigCount = rkt.getConfigurationCount(); assertThat("createFlightConfiguration with null: doesn't actually work.", actualConfigCount, equalTo(expectedConfigCount)); diff --git a/core/test/net/sf/openrocket/rocketcomponent/LaunchLugTest.java b/core/test/net/sf/openrocket/rocketcomponent/LaunchLugTest.java index 36c3d90bb..1df1864f3 100644 --- a/core/test/net/sf/openrocket/rocketcomponent/LaunchLugTest.java +++ b/core/test/net/sf/openrocket/rocketcomponent/LaunchLugTest.java @@ -24,7 +24,7 @@ public class LaunchLugTest extends BaseTestCase { double expX = 0.111 + body.getLocations()[0].x; double expR = -(body.getOuterRadius()+lug.getOuterRadius()); Coordinate expPos = new Coordinate( expX, expR, 0, 0); - Coordinate actPos[] = lug.getLocations(); + Coordinate[] actPos = lug.getLocations(); assertEquals(" LaunchLug has the wrong x value: ", expPos.x, actPos[0].x, EPSILON); assertEquals(" LaunchLug has the wrong y value: ", expPos.y, actPos[0].y, EPSILON); assertEquals(" LaunchLug has the wrong z value: ", expPos.z, actPos[0].z, EPSILON); @@ -51,7 +51,7 @@ public class LaunchLugTest extends BaseTestCase { double expY = Math.cos(startAngle)*expR ; double expZ = Math.sin(startAngle)*expR ; Coordinate expPos = new Coordinate( expX, expY, expZ, 0); - Coordinate actPos[] = lug.getLocations(); + Coordinate[] actPos = lug.getLocations(); assertEquals(" LaunchLug has the wrong x value: ", expPos.x, actPos[0].x, EPSILON); assertEquals(" LaunchLug has the wrong y value: ", expPos.y, actPos[0].y, EPSILON); assertEquals(" LaunchLug has the wrong z value: ", expPos.z, actPos[0].z, EPSILON); diff --git a/core/test/net/sf/openrocket/rocketcomponent/ParallelStageTest.java b/core/test/net/sf/openrocket/rocketcomponent/ParallelStageTest.java index 3d62a2071..ecc143ad3 100644 --- a/core/test/net/sf/openrocket/rocketcomponent/ParallelStageTest.java +++ b/core/test/net/sf/openrocket/rocketcomponent/ParallelStageTest.java @@ -220,7 +220,7 @@ public class ParallelStageTest extends BaseTestCase { final double expectedRadius = coreBody.getOuterRadius() + boosterBody.getOuterRadius(); { - final Coordinate actualInstanceOffsets[] = parallelBoosterStage.getInstanceOffsets(); + final Coordinate[] actualInstanceOffsets = parallelBoosterStage.getInstanceOffsets(); assertEquals(" error while setting radius offset: ", 0, actualInstanceOffsets[0].x, EPSILON); assertEquals(" error while setting radius offset: ", expectedRadius, actualInstanceOffsets[0].y, EPSILON); @@ -228,7 +228,7 @@ public class ParallelStageTest extends BaseTestCase { assertEquals(" error while setting radius offset: ", 0, actualInstanceOffsets[1].x, EPSILON); assertEquals(" error while setting radius offset: ", -expectedRadius, actualInstanceOffsets[1].y, EPSILON); }{ - final Coordinate actualLocations[] = parallelBoosterStage.getComponentLocations(); + final Coordinate[] actualLocations = parallelBoosterStage.getComponentLocations(); assertEquals(" error while setting radius offset: ", 0.484, actualLocations[0].x, EPSILON); assertEquals(" error while setting radius offset: ", expectedRadius, actualLocations[0].y, EPSILON); @@ -260,7 +260,7 @@ public class ParallelStageTest extends BaseTestCase { final double expectedRadius = targetRadiusOffset + coreBody.getOuterRadius() + boosterBody.getOuterRadius(); { - final Coordinate actualInstanceOffsets[] = parallelBoosterStage.getInstanceOffsets(); + final Coordinate[] actualInstanceOffsets = parallelBoosterStage.getInstanceOffsets(); assertEquals(" error while setting radius offset: ", 0, actualInstanceOffsets[0].x, EPSILON); assertEquals(" error while setting radius offset: ", expectedRadius, actualInstanceOffsets[0].y, EPSILON); @@ -268,7 +268,7 @@ public class ParallelStageTest extends BaseTestCase { assertEquals(" error while setting radius offset: ", 0, actualInstanceOffsets[1].x, EPSILON); assertEquals(" error while setting radius offset: ", -expectedRadius, actualInstanceOffsets[1].y, EPSILON); }{ - final Coordinate actualLocations[] = parallelBoosterStage.getComponentLocations(); + final Coordinate[] actualLocations = parallelBoosterStage.getComponentLocations(); assertEquals(" error while setting radius offset: ", 0.484, actualLocations[0].x, EPSILON); assertEquals(" error while setting radius offset: ", expectedRadius, actualLocations[0].y, EPSILON); diff --git a/core/test/net/sf/openrocket/rocketcomponent/ParameterSetTest.java b/core/test/net/sf/openrocket/rocketcomponent/ParameterSetTest.java index e6fbf9b1d..2879c0720 100644 --- a/core/test/net/sf/openrocket/rocketcomponent/ParameterSetTest.java +++ b/core/test/net/sf/openrocket/rocketcomponent/ParameterSetTest.java @@ -62,9 +62,9 @@ public class ParameterSetTest extends BaseTestCase { public TestParameter copy( final FlightConfigurationId copyId){ return new TestParameter(); } - }; - - @Before + } + + @Before public void localSetUp() { gid=0; TestParameter defaultParam = new TestParameter(); diff --git a/core/test/net/sf/openrocket/rocketcomponent/RocketTest.java b/core/test/net/sf/openrocket/rocketcomponent/RocketTest.java index 2cbe37116..0be44b63a 100644 --- a/core/test/net/sf/openrocket/rocketcomponent/RocketTest.java +++ b/core/test/net/sf/openrocket/rocketcomponent/RocketTest.java @@ -81,7 +81,7 @@ public class RocketTest extends BaseTestCase { { FinSet fins = (FinSet)body.getChild(0); - Coordinate actLocs[] = fins.getComponentLocations(); + Coordinate[] actLocs = fins.getComponentLocations(); assertThat(fins.getName()+" have incorrect count: ", fins.getInstanceCount(), equalTo(3)); { // fin #1 expLoc = new Coordinate(0.22,0.012,0); @@ -126,7 +126,7 @@ public class RocketTest extends BaseTestCase { assertThat(ring.getName()+" not positioned correctly: ", actLoc, equalTo(expLoc)); ring.setInstanceCount(2); - Coordinate actLocs[] = ring.getComponentLocations(); + Coordinate[] actLocs = ring.getComponentLocations(); { // first instance expLoc = new Coordinate(0.21, 0, 0); actLoc = actLocs[0]; @@ -176,7 +176,7 @@ public class RocketTest extends BaseTestCase { assertEquals("incorrect fin length:", 0.05, fins.getLength(), EPSILON); { // fin #1 final Coordinate expLoc = new Coordinate(0.22, 0.012, 0); - final Coordinate actLocs[] = fins.getComponentLocations(); + final Coordinate[] actLocs = fins.getComponentLocations(); assertThat(fins.getName() + " not positioned correctly: ", actLocs[0], equalTo(expLoc)); } } @@ -313,7 +313,7 @@ public class RocketTest extends BaseTestCase { Coordinate expLoc; Coordinate actLoc; - Coordinate actLocs[]; + Coordinate[] actLocs; { BodyTube body = (BodyTube)boosterStage.getChild(0); Coordinate[] bodyLocs = body.getComponentLocations(); @@ -429,14 +429,14 @@ public class RocketTest extends BaseTestCase { assertEquals( boosters.getName()+" position is incorrect: ", 0.0, boosterPosition.y, EPSILON); assertEquals( boosters.getName()+" position is incorrect: ", 0.0, boosterPosition.z, EPSILON); - Coordinate boosterInstanceOffsets[] = boosters.getInstanceOffsets(); + Coordinate[] boosterInstanceOffsets = boosters.getInstanceOffsets(); assertEquals( boosters.getName()+" location is incorrect: ", 0.0, boosterInstanceOffsets[0].x, EPSILON); assertEquals( boosters.getName()+" location is incorrect: ", 0.077, boosterInstanceOffsets[0].y, EPSILON); assertEquals( boosters.getName()+" location is incorrect: ", -0.077, boosterInstanceOffsets[1].y, EPSILON); assertEquals( boosters.getName()+" location is incorrect: ", 0.0, boosterInstanceOffsets[0].z, EPSILON); - Coordinate boosterLocations[] = boosters.getComponentLocations(); + Coordinate[] boosterLocations = boosters.getComponentLocations(); assertEquals( boosters.getName()+" location is incorrect: ", 0.484, boosterLocations[0].x, EPSILON); assertEquals( boosters.getName()+" location is incorrect: ", 0.077, boosterLocations[0].y, EPSILON); assertEquals( boosters.getName()+" location is incorrect: ", -0.077, boosterLocations[1].y, EPSILON); diff --git a/core/test/net/sf/openrocket/util/ExpressionParserTest.java b/core/test/net/sf/openrocket/util/ExpressionParserTest.java index efbabe9c4..d065a169d 100644 --- a/core/test/net/sf/openrocket/util/ExpressionParserTest.java +++ b/core/test/net/sf/openrocket/util/ExpressionParserTest.java @@ -8,7 +8,7 @@ public class ExpressionParserTest { private static final double EPS = 1e-10; - private ExpressionParser parser = new ExpressionParser(); + private final ExpressionParser parser = new ExpressionParser(); @Test public void testPlainNumber() throws InvalidExpressionException { diff --git a/core/test/net/sf/openrocket/util/TestConfig.java b/core/test/net/sf/openrocket/util/TestConfig.java index 5c10ca7a6..994fafd04 100644 --- a/core/test/net/sf/openrocket/util/TestConfig.java +++ b/core/test/net/sf/openrocket/util/TestConfig.java @@ -14,7 +14,7 @@ import org.junit.Test; public class TestConfig { - private Config config = new Config(); + private final Config config = new Config(); @Test public void testDoubles() { @@ -41,7 +41,7 @@ public class TestConfig { assertEquals(true, config.getBoolean("foo", true)); assertEquals(123, (int) config.getInt("foo", 123)); assertEquals(123L, (long) config.getLong("foo", 123L)); - assertEquals(1.23, (double) config.getDouble("foo", 1.23), 0); + assertEquals(1.23, config.getDouble("foo", 1.23), 0); assertEquals("bar", config.getString("foo", "bar")); assertEquals(Arrays.asList("foo"), config.getList("foo", Arrays.asList("foo"))); } @@ -110,7 +110,7 @@ public class TestConfig { assertEquals("foo", copy.getString("string", null)); assertEquals(123, (int) copy.getInt("int", null)); assertEquals(100, (int) copy.getInt("atomicinteger", null)); - assertEquals(Math.PI, (double) copy.getDouble("double", null), 0); + assertEquals(Math.PI, copy.getDouble("double", null), 0); assertEquals(Arrays.asList("Foo"), copy.getList("list", null)); } diff --git a/core/test/net/sf/openrocket/util/TextUtilTest.java b/core/test/net/sf/openrocket/util/TextUtilTest.java index e3b2558a3..d651aeed2 100644 --- a/core/test/net/sf/openrocket/util/TextUtilTest.java +++ b/core/test/net/sf/openrocket/util/TextUtilTest.java @@ -5,6 +5,7 @@ import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import java.util.Random; import org.junit.Test; @@ -14,7 +15,7 @@ public class TextUtilTest { @Test public void testConvertStringToBytes() { - Charset us_ascii = Charset.forName("US-ASCII"); + Charset us_ascii = StandardCharsets.US_ASCII; byte[] ZIP_SIGNATURE_CORRECT = "PK".getBytes(us_ascii); byte[] ZIP_SIGNATURE_TEST = TextUtil.asciiBytes("PK");