Simplify map operations
This commit is contained in:
parent
f28cf9acb8
commit
71d1c02070
@ -107,13 +107,9 @@ public class DefaultSimulationModifierService implements SimulationModifierServi
|
||||
Class<? extends RocketComponent> componentClass, String methodName, String autoMethod) {
|
||||
|
||||
String modifierDescriptionKey = modifierNameKey + ".desc";
|
||||
|
||||
List<ModifierDefinition> list = definitions.get(componentClass);
|
||||
if (list == null) {
|
||||
list = new ArrayList<>();
|
||||
definitions.put(componentClass, list);
|
||||
}
|
||||
|
||||
|
||||
List<ModifierDefinition> list = definitions.computeIfAbsent(componentClass, k -> new ArrayList<>());
|
||||
|
||||
ModifierDefinition definition = new ModifierDefinition(modifierNameKey, modifierDescriptionKey, unitGroup,
|
||||
multiplier, componentClass, methodName, autoMethod);
|
||||
list.add(definition);
|
||||
|
@ -12,11 +12,7 @@ public class DownloadResponse {
|
||||
private String error = null;
|
||||
|
||||
public void add(MotorBurnFile mbd) {
|
||||
List<MotorBurnFile> currentData = data.get(mbd.getMotorId());
|
||||
if (currentData == null) {
|
||||
currentData = new ArrayList<>();
|
||||
data.put(mbd.getMotorId(), currentData);
|
||||
}
|
||||
List<MotorBurnFile> currentData = data.computeIfAbsent(mbd.getMotorId(), k -> new ArrayList<>());
|
||||
currentData.add(mbd);
|
||||
}
|
||||
|
||||
|
@ -205,11 +205,7 @@ public class ScaleDialog extends JDialog {
|
||||
|
||||
private static void addScaler(Class<? extends RocketComponent> componentClass, String methodName, String autoMethodName,
|
||||
Map<Class<? extends RocketComponent>, List<Scaler>> scaler) {
|
||||
List<Scaler> list = scaler.get(componentClass);
|
||||
if (list == null) {
|
||||
list = new ArrayList<>();
|
||||
scaler.put(componentClass, list);
|
||||
}
|
||||
List<Scaler> list = scaler.computeIfAbsent(componentClass, k -> new ArrayList<>());
|
||||
list.add(new GeneralScaler(componentClass, methodName, autoMethodName));
|
||||
}
|
||||
|
||||
|
@ -1017,11 +1017,7 @@ public class GeneralOptimizationDialog extends JDialog {
|
||||
|
||||
for (SimulationModifier m : OptimizationServiceHelper.getSimulationModifiers(documentCopy)) {
|
||||
Object key = m.getRelatedObject();
|
||||
List<SimulationModifier> list = simulationModifiers.get(key);
|
||||
if (list == null) {
|
||||
list = new ArrayList<>();
|
||||
simulationModifiers.put(key, list);
|
||||
}
|
||||
List<SimulationModifier> list = simulationModifiers.computeIfAbsent(key, k -> new ArrayList<>());
|
||||
list.add(m);
|
||||
}
|
||||
|
||||
|
@ -60,11 +60,7 @@ public class PrintableContext implements Comparable<PrintableContext>, Iterable<
|
||||
* @param thePrintable the printable to associate with the stage
|
||||
*/
|
||||
public void add(final Integer theStageNumber, final OpenRocketPrintable thePrintable) {
|
||||
Set<Integer> stages = previous.get(thePrintable);
|
||||
if (stages == null) {
|
||||
stages = new TreeSet<>();
|
||||
previous.put(thePrintable, stages);
|
||||
}
|
||||
Set<Integer> stages = previous.computeIfAbsent(thePrintable, k -> new TreeSet<>());
|
||||
if (theStageNumber != null) {
|
||||
stages.add(theStageNumber);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user