Skip to content

Commit 3f15c5d

Browse files
committed
Make use of sequenced collections
1 parent e1189c6 commit 3f15c5d

File tree

38 files changed

+71
-69
lines changed

38 files changed

+71
-69
lines changed

annotation-processor/src/main/java/mekanism/MethodFactoryProcessor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ private void addHandlerToRegistry(TypeElement handledType, ClassName factoryClas
114114
}
115115
ClassName clazz = ClassName.get(superTypeElement);
116116
if (clazz.canonicalName().startsWith("mekanism")) {
117-
superClasses.add(0, clazz);
117+
superClasses.addFirst(clazz);
118118
}
119119
} while ((superClass = superTypeElement.getSuperclass()).getKind() != TypeKind.NONE);
120120

annotation-processor/src/main/java/mekanism/visitors/AnnotationHelper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public TypeMirror getClassValue(String key) {
117117
}
118118

119119
/**
120-
* Get a list of Class (TypeMirror) values from the annotation. Non class values will be ignored
120+
* Get a list of Class (TypeMirror) values from the annotation. Non-class values will be ignored
121121
*
122122
* @param key the annotation member name
123123
*

annotation-processor/src/main/java/mekanism/visitors/ParamToHelperMapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public CodeBlock visitDeclared(DeclaredType t, Integer paramNum) {
5959
}
6060
//check for list or map. List not yet implemented
6161
return switch (className.canonicalName()) {
62-
case "java.util.List" -> CodeBlock.of("$N.getList($L /* $L */)", helperParam, paramNum, t.getTypeArguments().get(0).toString());
62+
case "java.util.List" -> CodeBlock.of("$N.getList($L /* $L */)", helperParam, paramNum, t.getTypeArguments().getFirst().toString());
6363
case "java.util.Map" -> CodeBlock.of("$N.getMap($L)", helperParam, paramNum);
6464
default -> CodeBlock.of("$N.get$L($L)", helperParam, className.simpleName(), paramNum);
6565
};

src/api/java/mekanism/api/chemical/ChemicalUtils.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public static <CHEMICAL extends Chemical<CHEMICAL>, STACK extends ChemicalStack<
8282
if (chemicalContainers.isEmpty()) {
8383
return stack;
8484
} else if (chemicalContainers.size() == 1) {
85-
return chemicalContainers.get(0).insert(stack, action, automationType);
85+
return chemicalContainers.getFirst().insert(stack, action, automationType);
8686
}
8787
STACK toInsert = stack;
8888
//Start by trying to insert into the tanks that have the same type
@@ -168,7 +168,7 @@ public static <CHEMICAL extends Chemical<CHEMICAL>, STACK extends ChemicalStack<
168168
if (chemicalTanks.isEmpty()) {
169169
return empty;
170170
} else if (chemicalTanks.size() == 1) {
171-
return chemicalTanks.get(0).extract(amount, action, automationType);
171+
return chemicalTanks.getFirst().extract(amount, action, automationType);
172172
}
173173
STACK extracted = empty;
174174
long toDrain = amount;
@@ -255,7 +255,7 @@ public static <CHEMICAL extends Chemical<CHEMICAL>, STACK extends ChemicalStack<
255255
if (chemicalTanks.isEmpty()) {
256256
return empty;
257257
} else if (chemicalTanks.size() == 1) {
258-
TANK tank = chemicalTanks.get(0);
258+
TANK tank = chemicalTanks.getFirst();
259259
if (tank.isEmpty() || !tank.isTypeEqual(stack)) {
260260
return empty;
261261
}

src/api/java/mekanism/api/fluid/ExtendedFluidHandlerUtils.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public static FluidStack insert(FluidStack stack, @Nullable Direction side, Func
9595
if (fluidContainers.isEmpty()) {
9696
return stack;
9797
} else if (fluidContainers.size() == 1) {
98-
return fluidContainers.get(0).insert(stack, action, automationType);
98+
return fluidContainers.getFirst().insert(stack, action, automationType);
9999
}
100100
FluidStack toInsert = stack;
101101
//Start by trying to insert into the tanks that have the same type
@@ -194,7 +194,7 @@ public static FluidStack extract(int amount, @Nullable Direction side, Function<
194194
if (fluidContainers.isEmpty()) {
195195
return FluidStack.EMPTY;
196196
} else if (fluidContainers.size() == 1) {
197-
return fluidContainers.get(0).extract(amount, action, automationType);
197+
return fluidContainers.getFirst().extract(amount, action, automationType);
198198
}
199199
FluidStack extracted = FluidStack.EMPTY;
200200
int toDrain = amount;
@@ -294,7 +294,7 @@ public static FluidStack extract(FluidStack stack, @Nullable Direction side, Fun
294294
if (fluidContainers.isEmpty()) {
295295
return FluidStack.EMPTY;
296296
} else if (fluidContainers.size() == 1) {
297-
IExtendedFluidTank tank = fluidContainers.get(0);
297+
IExtendedFluidTank tank = fluidContainers.getFirst();
298298
if (tank.isEmpty() || !tank.isFluidEqual(stack)) {
299299
return FluidStack.EMPTY;
300300
}

src/api/java/mekanism/api/heat/IMekanismHeatHandler.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ default double getTotalInverseInsulation(@Nullable Direction side) {
105105
if (heatCapacitors.isEmpty()) {
106106
return HeatAPI.DEFAULT_INVERSE_INSULATION;
107107
} else if (heatCapacitors.size() == 1) {
108-
return heatCapacitors.get(0).getInverseInsulation();
108+
return heatCapacitors.getFirst().getInverseInsulation();
109109
}
110110
double sum = 0;
111111
double totalCapacity = getTotalHeatCapacity(heatCapacitors);
@@ -121,7 +121,7 @@ default double getTotalTemperature(@Nullable Direction side) {
121121
if (heatCapacitors.isEmpty()) {
122122
return 0;
123123
} else if (heatCapacitors.size() == 1) {
124-
return heatCapacitors.get(0).getTemperature();
124+
return heatCapacitors.getFirst().getTemperature();
125125
}
126126
double sum = 0;
127127
double totalCapacity = getTotalHeatCapacity(heatCapacitors);
@@ -137,7 +137,7 @@ default double getTotalInverseConductionCoefficient(@Nullable Direction side) {
137137
if (heatCapacitors.isEmpty()) {
138138
return HeatAPI.DEFAULT_INVERSE_CONDUCTION;
139139
} else if (heatCapacitors.size() == 1) {
140-
return heatCapacitors.get(0).getInverseConduction();
140+
return heatCapacitors.getFirst().getInverseConduction();
141141
}
142142
double sum = 0;
143143
double totalCapacity = getTotalHeatCapacity(heatCapacitors);
@@ -154,7 +154,7 @@ default double getTotalHeatCapacity(@Nullable Direction side) {
154154

155155
private double getTotalHeatCapacity(List<IHeatCapacitor> capacitors) {
156156
if (capacitors.size() == 1) {
157-
return capacitors.get(0).getHeatCapacity();
157+
return capacitors.getFirst().getHeatCapacity();
158158
}
159159
double sum = 0;
160160
for (IHeatCapacitor capacitor : capacitors) {
@@ -167,7 +167,7 @@ private double getTotalHeatCapacity(List<IHeatCapacitor> capacitors) {
167167
default void handleHeat(double transfer, @Nullable Direction side) {
168168
List<IHeatCapacitor> heatCapacitors = getHeatCapacitors(side);
169169
if (heatCapacitors.size() == 1) {
170-
heatCapacitors.get(0).handleHeat(transfer);
170+
heatCapacitors.getFirst().handleHeat(transfer);
171171
} else if (!heatCapacitors.isEmpty()) {
172172
double totalHeatCapacity = getTotalHeatCapacity(heatCapacitors);
173173
for (IHeatCapacitor heatCapacitor : heatCapacitors) {

src/api/java/mekanism/api/math/FloatingLongTransferUtils.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public static FloatingLong insert(FloatingLong stack, @Nullable Direction side,
100100
if (energyContainers.isEmpty()) {
101101
return stack;
102102
} else if (energyContainers.size() == 1) {
103-
return energyContainers.get(0).insert(stack, action, automationType);
103+
return energyContainers.getFirst().insert(stack, action, automationType);
104104
}
105105
FloatingLong toInsert = stack;
106106
//Start by trying to insert into the containers that are not empty
@@ -199,7 +199,7 @@ public static FloatingLong extract(FloatingLong amount, @Nullable Direction side
199199
if (energyContainers.isEmpty()) {
200200
return FloatingLong.ZERO;
201201
} else if (energyContainers.size() == 1) {
202-
return energyContainers.get(0).extract(amount, action, automationType);
202+
return energyContainers.getFirst().extract(amount, action, automationType);
203203
}
204204
FloatingLong extracted = FloatingLong.ZERO;
205205
FloatingLong toExtract = amount.copy();

src/datagen/main/java/mekanism/common/integration/crafttweaker/example/component/CrTExampleRecipeComponentBuilder.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ private void examplesAndVariation(StringBuilder stringBuilder, String methodName
209209
List<String> representations = parameterRepresentations[i];
210210
int representationCount = representations.size();
211211
if (representationCount == 1) {
212-
appendToAll(combinedParameters, representations.get(0), addComma);
212+
appendToAll(combinedParameters, representations.getFirst(), addComma);
213213
} else {
214214
List<StringBuilder> currentCombinedParameters = copyCombined(combinedParameters);
215215
for (int j = 0; j < representationCount; j++) {
@@ -228,7 +228,7 @@ private void examplesAndVariation(StringBuilder stringBuilder, String methodName
228228
}
229229
}
230230
appendRecipeMethodStart(stringBuilder, methodName);
231-
stringBuilder.append(combinedParameters.get(0))
231+
stringBuilder.append(combinedParameters.getFirst())
232232
.append(");\n");
233233
int possibilities = combinedParameters.size();
234234
if (possibilities > 1) {

src/datagen/main/java/mekanism/common/recipe/builder/ExtendedShapedRecipeBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ protected void validate(ResourceLocation id) {
9494
}
9595
if (!set.isEmpty()) {
9696
throw new IllegalStateException("Ingredients are defined but not used in pattern for recipe " + id);
97-
} else if (pattern.size() == 1 && pattern.get(0).length() == 1) {
97+
} else if (pattern.size() == 1 && pattern.getFirst().length() == 1) {
9898
throw new IllegalStateException("Shaped recipe " + id + " only takes in a single item, and should probably be a shapeless recipe instead");
9999
}
100100
}

src/main/java/mekanism/client/gui/element/gauge/GuiGauge.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ public void updateTooltip(int mouseX, int mouseY) {
145145
} else {
146146
list = new ArrayList<>(getTooltipText());
147147
if (getLabel() != null) {
148-
list.add(0, getLabel());
148+
list.addFirst(getLabel());
149149
}
150150
}
151151
if (!list.equals(lastInfo)) {

0 commit comments

Comments
 (0)