[code_cleanup-1] Clean up using IntelliJ's 'Silent Code Cleanup'

This commit is contained in:
Sibo Van Gool 2021-09-10 00:36:29 +02:00
parent 46b974cae7
commit 08dc009412
118 changed files with 274 additions and 308 deletions

View File

@ -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<String> list = new ArrayList<String>();;
ArrayList<String> list = new ArrayList<String>();
Enumeration<?> pids = CommPortIdentifier.getPortIdentifiers();
while (pids.hasMoreElements()) {

View File

@ -35,8 +35,8 @@ public class RotationLogger {
public static String[] getNames() {
ArrayList<String> list = new ArrayList<String>();;
ArrayList<String> list = new ArrayList<String>();
Enumeration<?> pids = CommPortIdentifier.getPortIdentifiers();
while (pids.hasMoreElements()) {

View File

@ -30,8 +30,8 @@ public class SerialDownload {
public static String[] getNames() {
ArrayList<String> list = new ArrayList<String>();;
ArrayList<String> list = new ArrayList<String>();
Enumeration<?> pids = CommPortIdentifier.getPortIdentifiers();
while (pids.hasMoreElements()) {

View File

@ -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}

View File

@ -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

View File

@ -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;

View File

@ -27,7 +27,7 @@ public class VariableSet extends HashSet<Variable> {
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();

View File

@ -61,7 +61,7 @@ public abstract class Warning {
* @author Sampo Niskanen <sampo.niskanen@iki.fi>
*/
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 <enderw88@gmail.com>
*/
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 <sampo.niskanen@iki.fi>
*/
public static class Other extends Warning {
private String description;
private final String description;
public Other(String description) {
this.description = description;

View File

@ -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();

View File

@ -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);

View File

@ -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;

View File

@ -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<Color, Appearance> plastics = new HashMap<Color, Appearance>();
private static final HashMap<Color, Appearance> plastics = new HashMap<Color, Appearance>();
/**
* gets the appearance correspondent to the plastic with the given color

View File

@ -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);
}

View File

@ -17,8 +17,8 @@ public class SystemInfo {
public enum Platform {
WINDOWS,
MAC_OS,
UNIX;
}
UNIX
}
/**

View File

@ -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();

View File

@ -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);
}
}

View File

@ -32,7 +32,7 @@ public class ComponentPresetDatabase extends Database<ComponentPreset> implement
@Override
public List<ComponentPreset> listForType( ComponentPreset.Type type ) {
if ( type == null ) {
return Collections.<ComponentPreset>emptyList();
return Collections.emptyList();
}
List<ComponentPreset> result = new ArrayList<ComponentPreset>(list.size()/6);
@ -75,7 +75,7 @@ public class ComponentPresetDatabase extends Database<ComponentPreset> implement
@Override
public List<ComponentPreset> listForTypes( ComponentPreset.Type ... type ) {
if( type == null || type.length == 0 ) {
return Collections.<ComponentPreset>emptyList();
return Collections.emptyList();
}
if (type.length == 1 ) {

View File

@ -121,7 +121,7 @@ public class Database<T extends Comparable<T>> extends AbstractSet<T> {
* Iterator class implementation that fires changes if remove() is called.
*/
private class DBIterator implements Iterator<T> {
private Iterator<T> iterator = list.iterator();
private final Iterator<T> iterator = list.iterator();
private T current = null;
@Override

View File

@ -39,7 +39,7 @@ public class DecalRegistry {
}
/** the decal usage map*/
private Map<String, DecalImageImpl> registeredDecals = new HashMap<String, DecalImageImpl>();
private final Map<String, DecalImageImpl> registeredDecals = new HashMap<String, DecalImageImpl>();
/**
* returns a new decal with the same image but with unique names

View File

@ -53,7 +53,7 @@ public class OpenRocketDocument implements ComponentChangeListener {
private final Rocket rocket;
private final ArrayList<Simulation> simulations = new ArrayList<Simulation>();
private ArrayList<CustomExpression> customExpressions = new ArrayList<CustomExpression>();
private final ArrayList<CustomExpression> customExpressions = new ArrayList<CustomExpression>();
// The Photo Settings will be saved in the core module as a map of key values with corresponding content
private Map<String, String> 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<Rocket> undoHistory = new LinkedList<Rocket>();
private LinkedList<String> undoDescription = new LinkedList<String>();
private final LinkedList<Rocket> undoHistory = new LinkedList<Rocket>();
private final LinkedList<String> undoDescription = new LinkedList<String>();
/**
* 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<UndoRedoListener> undoRedoListeners = new ArrayList<UndoRedoListener>(2);
private final ArrayList<UndoRedoListener> undoRedoListeners = new ArrayList<UndoRedoListener>(2);
private File file = null;
private int savedID = -1;

View File

@ -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<? extends SimulationStepper> simulationStepperClass = RK4SimulationStepper.class;
private Class<? extends AerodynamicCalculator> aerodynamicCalculatorClass = BarrowmanCalculator.class;
@SuppressWarnings("unused")
private Class<? extends MassCalculator> massCalculatorClass = MassCalculator.class;
private final Class<? extends MassCalculator> massCalculatorClass = MassCalculator.class;
/** Listeners for this object */
private List<EventListener> listeners = new ArrayList<EventListener>();

View File

@ -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);
}

View File

@ -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());

View File

@ -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) {

View File

@ -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;

View File

@ -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);

View File

@ -5,7 +5,7 @@ import java.util.List;
public class XmlContainerElement extends XmlElement {
private ArrayList<XmlElement> subelements = new ArrayList<XmlElement>();
private final ArrayList<XmlElement> subelements = new ArrayList<XmlElement>();
public XmlContainerElement(String name) {
super(name);

View File

@ -17,8 +17,8 @@ import org.xml.sax.SAXException;
public class ConfigHandler extends AbstractElementHandler {
private ConfigHandler listHandler;
private Config config = new Config();
private List<Object> list = new ArrayList<Object>();
private final Config config = new Config();
private final List<Object> list = new ArrayList<Object>();
@Override
public ElementHandler openElement(String element, HashMap<String, String> attributes, WarningSet warnings) throws SAXException {

View File

@ -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(

View File

@ -17,10 +17,10 @@ class FlightDataHandler extends AbstractElementHandler {
private final DocumentLoadingContext context;
private FlightDataBranchHandler dataHandler;
private WarningSet warningSet = new WarningSet();
private List<FlightDataBranch> branches = new ArrayList<FlightDataBranch>();
private final WarningSet warningSet = new WarningSet();
private final List<FlightDataBranch> branches = new ArrayList<FlightDataBranch>();
private SingleSimulationHandler simHandler;
private final SingleSimulationHandler simHandler;
private FlightData data;

View File

@ -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<String, String> p;
private final Map<String, String> p;
private static final Logger log = LoggerFactory.getLogger(OpenRocketHandler.class);
public PhotoStudioHandler(Map<String, String> p) {

View File

@ -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) {

View File

@ -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());
}

View File

@ -33,7 +33,7 @@ public enum RocksimNoseConeCode {
/**
* Names of the shape that are sometimes found in NCDATA.CSV
*/
private Set<String> shapeNames = new HashSet<String>();
private final Set<String> shapeNames = new HashSet<String>();
/**
* Constructor.

View File

@ -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")

View File

@ -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();
}

View File

@ -25,7 +25,7 @@ public class StageDTO {
@XmlElementRef(name = RocksimCommonConstants.NOSE_CONE, type = NoseConeDTO.class),
@XmlElementRef(name = RocksimCommonConstants.TRANSITION, type = TransitionDTO.class)
})
private List<BasePartDTO> externalPart = new ArrayList<BasePartDTO>();
private final List<BasePartDTO> externalPart = new ArrayList<BasePartDTO>();
/**
* Default constructor.

View File

@ -47,7 +47,7 @@ class MassObjectHandler extends PositionDependentHandler<MassObject> {
/**
* Parent.
*/
private RocketComponent parent;
private final RocketComponent parent;
/**
* 0 == General, 1 == Shock Cord

View File

@ -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]));
}

View File

@ -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);

View File

@ -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,

View File

@ -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() {

View File

@ -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);

View File

@ -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<String, CaseInfo> labelMapping;
private static Map<CaseInfo, CaseInfo[]> compatibleCases;
private static final Map<String, CaseInfo> labelMapping;
private static final Map<CaseInfo, CaseInfo[]> compatibleCases;
static {
labelMapping = new HashMap<>();

View File

@ -36,7 +36,7 @@ public class DesignationComparator implements Comparator<String> {
* 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

View File

@ -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));
}

View File

@ -35,7 +35,7 @@ public class Manufacturer implements Serializable {
}
}
private static ManufacturerList manufacturers = new ManufacturerList();
private static final ManufacturerList manufacturers = new ManufacturerList();
static {

View File

@ -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());
}

View File

@ -560,7 +560,7 @@ public class ThrustCurveMotor implements Motor, Comparable<ThrustCurveMotor>, 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<ThrustCurveMotor>, Se
// 1. Manufacturer
value = COLLATOR.compare(this.manufacturer.getDisplayName(),
((ThrustCurveMotor) other).manufacturer.getDisplayName());
other.manufacturer.getDisplayName());
if (value != 0)
return value;

View File

@ -34,7 +34,7 @@ public class ParallelExecutorCache implements ParallelFunctionCache {
private final Map<Point, Double> functionCache = new HashMap<Point, Double>();
private final Map<Point, Future<Double>> futureMap = new HashMap<Point, Future<Double>>();
private ExecutorService executor;
private final ExecutorService executor;
private Function function;

View File

@ -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<Point> simplex = new ArrayList<Point>();
private final List<Point> simplex = new ArrayList<Point>();
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;

View File

@ -17,8 +17,8 @@ import com.google.inject.multibindings.Multibinder;
public class PluginModule extends AbstractModule {
private Map<Class<?>, Multibinder<?>> binders = new HashMap<Class<?>, Multibinder<?>>();
private AnnotationFinder finder = new AnnotationFinderImpl();
private final Map<Class<?>, Multibinder<?>> binders = new HashMap<Class<?>, Multibinder<?>>();
private final AnnotationFinder finder = new AnnotationFinderImpl();
@SuppressWarnings("unchecked")

View File

@ -161,7 +161,7 @@ public class ComponentPreset implements Comparable<ComponentPreset>, Serializabl
return displayedColumns;
}
private static Map<Type, List<Type>> compatibleTypeMap = new HashMap<Type, List<Type>>();
private static final Map<Type, List<Type>> compatibleTypeMap = new HashMap<Type, List<Type>>();
static {
compatibleTypeMap.put(BODY_TUBE, Arrays.asList(BODY_TUBE, TUBE_COUPLER, LAUNCH_LUG));
@ -203,7 +203,7 @@ public class ComponentPreset implements Comparable<ComponentPreset>, Serializabl
public final static TypedKey<Double> STANDOFF_HEIGHT = new TypedKey<Double>("StandoffHeight", Double.class, UnitGroup.UNITS_LENGTH);
public final static TypedKey<Double> FLANGE_HEIGHT = new TypedKey<Double>("FlangeHeight", Double.class, UnitGroup.UNITS_LENGTH);
public final static List<TypedKey<?>> ORDERED_KEY_LIST = Collections.unmodifiableList(Arrays.<TypedKey<?>> asList(
public final static List<TypedKey<?>> ORDERED_KEY_LIST = Collections.unmodifiableList(Arrays.asList(
MANUFACTURER,
PARTNO,
DESCRIPTION,
@ -328,11 +328,7 @@ public class ComponentPreset implements Comparable<ComponentPreset>, 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

View File

@ -5,8 +5,8 @@ import java.util.List;
public class InvalidComponentPresetException extends Exception {
private List<String> errors = new ArrayList<String>();
private List<TypedKey<?>> invalidParameters = new ArrayList<TypedKey<?>>();
private final List<String> errors = new ArrayList<String>();
private final List<TypedKey<?>> invalidParameters = new ArrayList<TypedKey<?>>();
public InvalidComponentPresetException() {
super();

View File

@ -5,7 +5,7 @@ import net.sf.openrocket.preset.TypedPropertyMap;
public class DoubleColumnParser extends BaseColumnParser {
private TypedKey<Double> propKey;
private final TypedKey<Double> propKey;
public DoubleColumnParser(String columnHeader, TypedKey<Double> propKey) {
super(columnHeader);

View File

@ -8,7 +8,7 @@ import net.sf.openrocket.util.StringUtil;
public class DoubleUnitColumnParser extends BaseUnitColumnParser {
private TypedKey<Double> propKey;
private final TypedKey<Double> propKey;
public DoubleUnitColumnParser(String columnHeader, String unitHeader,
TypedKey<Double> propKey) {

View File

@ -5,7 +5,7 @@ import net.sf.openrocket.preset.TypedPropertyMap;
public class IntegerColumnParser extends BaseColumnParser {
private TypedKey<Integer> propKey;
private final TypedKey<Integer> propKey;
public IntegerColumnParser(String columnHeader, TypedKey<Integer> propKey) {
super(columnHeader);

View File

@ -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<String> MATERIALNAME = new TypedKey<String>("MaterialName", String.class);
private final static TypedKey<String> UNITS = new TypedKey<String>("Units", String.class);

View File

@ -25,7 +25,7 @@ public abstract class RocksimComponentFileLoader {
private String basePath = "";
private File dir;
private final File dir;
protected List<RocksimComponentFileColumnParser> fileColumns = new ArrayList<RocksimComponentFileColumnParser>();

View File

@ -5,7 +5,7 @@ import net.sf.openrocket.preset.TypedPropertyMap;
public class StringColumnParser extends BaseColumnParser {
private TypedKey<String> propKey;
private final TypedKey<String> propKey;
public StringColumnParser(String columnHeader, TypedKey<String> propKey) {
super(columnHeader);

View File

@ -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;

View File

@ -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;

View File

@ -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<Material> theMaterialList, List<ComponentPreset> 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<Material> theMaterialList, List<ComponentPreset> 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();

View File

@ -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;

View File

@ -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 */

View File

@ -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

View File

@ -12,9 +12,9 @@ public final class FlightConfigurationId implements Comparable<FlightConfigurati
private final static long DEFAULT_MOST_SIG_BITS = 0xF4F2F1F0;
private final static UUID ERROR_UUID = new UUID( DEFAULT_MOST_SIG_BITS, 2489);
private final static String ERROR_KEY_NAME = "ErrorKey".intern();
private final static String ERROR_KEY_NAME = "ErrorKey";
private final static UUID DEFAULT_VALUE_UUID = new UUID( DEFAULT_MOST_SIG_BITS, 5676);
private final static String DEFAULT_VALUE_NAME = "DefaultKey".intern();
private final static String DEFAULT_VALUE_NAME = "DefaultKey";
public final static FlightConfigurationId ERROR_FCID = new FlightConfigurationId( FlightConfigurationId.ERROR_UUID);
public final static FlightConfigurationId DEFAULT_VALUE_FCID = new FlightConfigurationId( FlightConfigurationId.DEFAULT_VALUE_UUID );

View File

@ -23,7 +23,7 @@ public class InstanceContext {
@Override
public int hashCode() {
return (int) (component.hashCode());
return component.hashCode();
}
public InstanceContext(final RocketComponent _component, final boolean _active, final int _instanceNumber, final Transformation _transform) {

View File

@ -25,7 +25,7 @@ public class MassComponent extends MassObject {
RECOVERYHARDWARE(Application.getTranslator().get("MassComponent.RecoveryHardware")),
BATTERY(Application.getTranslator().get("MassComponent.Battery"));
private String title;
private final String title;
MassComponentType(String title) {
this.title = title;

View File

@ -125,7 +125,7 @@ public abstract class RocketComponent implements ChangeSource, Cloneable, Iterab
/**
* Used to invalidate the component after calling {@link #copyFrom(RocketComponent)}.
*/
private Invalidator invalidator = new Invalidator(this);
private final Invalidator invalidator = new Invalidator(this);
/**

View File

@ -35,10 +35,10 @@ public class BasicEventSimulationEngine implements SimulationEngine {
private static final Logger log = LoggerFactory.getLogger(BasicEventSimulationEngine.class);
// TODO: MEDIUM: Allow selecting steppers
private SimulationStepper flightStepper = new RK4SimulationStepper();
private SimulationStepper landingStepper = new BasicLandingStepper();
private SimulationStepper tumbleStepper = new BasicTumbleStepper();
private SimulationStepper groundStepper = new GroundStepper();
private final SimulationStepper flightStepper = new RK4SimulationStepper();
private final SimulationStepper landingStepper = new BasicLandingStepper();
private final SimulationStepper tumbleStepper = new BasicTumbleStepper();
private final SimulationStepper groundStepper = new GroundStepper();
// Constant holding 20 degrees in radians. This is the AOA condition
// necessary to transition to tumbling.

View File

@ -8,7 +8,7 @@ import com.google.inject.Inject;
public class DefaultSimulationOptionFactory {
@Inject
private Preferences prefs;
private final Preferences prefs;
public static final String SIMCONDITION_WIND_SPEED = "SimConditionWindSpeed";
public static final String SIMCONDITION_WIND_STDDEV = "SimConditionWindStdDev";

View File

@ -36,7 +36,7 @@ public class FlightData {
NaN_DATA = data;
}
private Mutable mutable = new Mutable();
private final Mutable mutable = new Mutable();
private final ArrayList<FlightDataBranch> branches = new ArrayList<FlightDataBranch>();

View File

@ -47,7 +47,7 @@ public class FlightDataBranch implements Monitorable {
private final ArrayList<FlightEvent> events = new ArrayList<FlightEvent>();
private Mutable mutable = new Mutable();
private final Mutable mutable = new Mutable();
private int modID = 0;

View File

@ -79,12 +79,12 @@ public class FlightEvent implements Comparable<FlightEvent> {
/**
* 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;

View File

@ -53,7 +53,7 @@ public class SimulationStatus implements Monitorable {
private double effectiveLaunchRodLength;
// Set of all motors
private List<MotorClusterState> motorStateList = new ArrayList<MotorClusterState>();
private final List<MotorClusterState> motorStateList = new ArrayList<MotorClusterState>();
/** 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<RecoveryDevice> deployedRecoveryDevices = new MonitorableSet<RecoveryDevice>();
private final MonitorableSet<RecoveryDevice> deployedRecoveryDevices = new MonitorableSet<RecoveryDevice>();
/** 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()){

View File

@ -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.

View File

@ -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<CustomExpression> subExpressions = new ArrayList<CustomExpression>();
private final List<CustomExpression> subExpressions = new ArrayList<CustomExpression>();
public CustomExpression(OpenRocketDocument doc) {
this.doc = doc;

View File

@ -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<CustomFunction> allFunctions = new ArrayList<CustomFunction>();
private final List<CustomFunction> allFunctions = new ArrayList<CustomFunction>();
public static Functions getInstance() {
if(instance == null) {

View File

@ -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<String> missing = new HashSet<String>();

View File

@ -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;
}

View File

@ -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) {

View File

@ -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<EventListener> listeners = new ArrayList<EventListener>();
private final List<EventListener> listeners = new ArrayList<EventListener>();
private final EventObject event = new EventObject(this);
@Override

View File

@ -4,7 +4,7 @@ import java.util.ArrayList;
class DownloadRequest {
private ArrayList<Integer> motorIds = new ArrayList<Integer>();
private final ArrayList<Integer> motorIds = new ArrayList<Integer>();
private String format = null;

View File

@ -8,7 +8,7 @@ import java.util.Map;
public class DownloadResponse {
private Map<Integer,List<MotorBurnFile>> data = new HashMap<Integer,List<MotorBurnFile>>();
private final Map<Integer,List<MotorBurnFile>> data = new HashMap<Integer,List<MotorBurnFile>>();
private String error = null;

View File

@ -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();

View File

@ -38,11 +38,11 @@ public class MotorBurnFile {
if (SupportedFileTypes.RASP_FORMAT.equals(filetype)) {
RASPMotorLoader loader = new RASPMotorLoader();
List<ThrustCurveMotor.Builder> 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<ThrustCurveMotor.Builder> 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;

View File

@ -6,7 +6,7 @@ import java.util.List;
public class SearchResponse {
private List<TCMotor> results = new ArrayList<TCMotor>();
private final List<TCMotor> results = new ArrayList<TCMotor>();
private int matches;

View File

@ -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;

View File

@ -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<Motor> allMotors) throws SAXException, MalformedURLException, IOException {
public static void loadFromThrustCurve(List<Motor> allMotors) throws SAXException, IOException {
SearchRequest searchRequest = new SearchRequest();
for (String m : manufacturers) {
@ -164,7 +164,7 @@ public class SerializeThrustcurveMotors {
}
private static List<MotorBurnFile> getThrustCurvesForMotorId(int motorId) {
String formats[] = new String[] {"RASP", "RockSim"};
String[] formats = new String[] {"RASP", "RockSim"};
List<MotorBurnFile> b = new ArrayList<>();
for (String format : formats) {
try {

View File

@ -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<MotorBurnFile> downloadData(Integer motor_id, String format) throws MalformedURLException, IOException, SAXException {
public static List<MotorBurnFile> 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.<MotorBurnFile> emptyList();
return Collections.emptyList();
}
InputStream is = conn.getInputStream();

View File

@ -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);
}
/**

View File

@ -9,7 +9,7 @@ import java.util.Set;
public class Config {
private LinkedHashMap<String, Object> map = new LinkedHashMap<String, Object>();
private final LinkedHashMap<String, Object> map = new LinkedHashMap<String, Object>();
public void put(String key, String value) {

View File

@ -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];

View File

@ -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<MemoryData> objects = new LinkedList<MemoryData>();
private static final List<MemoryData> objects = new LinkedList<MemoryData>();
private static int collectableCallCount = 0;
private static List<WeakReference<ListenerList<?>>> listenerLists = new LinkedList<WeakReference<ListenerList<?>>>();
private static final List<WeakReference<ListenerList<?>>> listenerLists = new LinkedList<WeakReference<ListenerList<?>>>();
private static int listenerCallCount = 0;

View File

@ -17,8 +17,8 @@ public class MonitorableSet<E> extends HashSet<E> implements Monitorable {
public boolean add(E e) {
modID++;
return super.add(e);
};
}
@Override
public boolean addAll(Collection<? extends E> c) {
modID++;

View File

@ -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<n; ++i)
b[i][i] = 1;
@ -180,10 +180,10 @@ public class PolyInterpolator {
return x;
}
private static void gaussian(double a[][],
int index[]) {
private static void gaussian(double[][] a,
int[] index) {
int n = index.length;
double c[] = new double[n];
double[] c = new double[n];
// Initialize the index
for (int i=0; i<n; ++i) index[i] = i;

View File

@ -14,7 +14,7 @@ public class PrintProperties {
}
for (String key: keys) {
System.out.println(key + "=" + System.getProperty((String)key));
System.out.println(key + "=" + System.getProperty(key));
}
}

View File

@ -1,7 +1,7 @@
package net.sf.openrocket.util;
import java.nio.ByteBuffer;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
public class TextUtil {
@ -19,7 +19,7 @@ public class TextUtil {
* String.getBytes(Charset)
*/
public static byte[] asciiBytes(String string) {
ByteBuffer encoded = Charset.forName("US-ASCII").encode(string);
ByteBuffer encoded = StandardCharsets.US_ASCII.encode(string);
return encoded.array();
}

View File

@ -5,7 +5,7 @@ import java.util.concurrent.atomic.AtomicInteger;
public class UniqueID {
private static AtomicInteger nextId = new AtomicInteger(1);
private static final AtomicInteger nextId = new AtomicInteger(1);
/**
* Return a positive integer ID unique during this program execution.

Some files were not shown because too many files have changed in this diff Show More