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