Use enhanced for

This commit is contained in:
Andrea Cavalli 2023-03-02 22:46:54 +01:00
parent 1a1a696c53
commit 9d7264891c
3 changed files with 6 additions and 6 deletions

View File

@ -77,9 +77,9 @@ public class GenSerializerArrayX extends ClassGenerator {
method.addStatement("final int sz = data.size()");
method.addStatement("out.writeInt(sz)");
method.addCode("\n");
method.beginControlFlow("for (int i = 0; i < sz; ++i)");
method.beginControlFlow("for (var item : data)");
var baseSerializerInstance = typeArray.getBase().getJSerializerInstance(basePackageName);
method.addStatement("$T.$N.serialize(out, ($T) data.get(i))",
method.addStatement("$T.$N.serialize(out, ($T) item)",
baseSerializerInstance.className(),
baseSerializerInstance.fieldName(),
typeArray.getBase().getJTypeName(basePackageName)

View File

@ -12,8 +12,8 @@ public class ArrayInt52Serializer implements DataSerializer< List<Int52>> {
@Override
public void serialize(DataOutput dataOutput, List<Int52> data) throws IOException {
dataOutput.writeInt(data.size());
for (Int52 datum : data) {
Int52Serializer.INSTANCE.serialize(dataOutput, datum);
for (Int52 item : data) {
Int52Serializer.INSTANCE.serialize(dataOutput, item);
}
}

View File

@ -12,8 +12,8 @@ public class ArrayStringSerializer implements DataSerializer<List<String>> {
@Override
public void serialize(DataOutput dataOutput, @NotNull List<String> data) throws IOException {
dataOutput.writeInt(data.size());
for (int i = 0; i < data.size(); i++) {
dataOutput.writeUTF(data.get(i));
for (String item : data) {
dataOutput.writeUTF(item);
}
}