Skip to content

Commit fb175cd

Browse files
committed
Use List.copyOf
1 parent 1fdbf90 commit fb175cd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+30
-150
lines changed

codegen/templates/java.java.erb

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,9 @@ package io.cucumber.messages.types;
55
import org.jspecify.annotations.Nullable;
66

77
import java.util.List;
8-
import java.util.ArrayList;
98
import java.util.Objects;
109
import java.util.Optional;
1110

12-
import static java.util.Collections.unmodifiableList;
1311
import static java.util.Objects.requireNonNull;
1412

1513
/**
@@ -35,7 +33,7 @@ public final class <%= class_name(key) %> {
3533
<%- schema['properties'].each_with_index do |(property_name_2, _property_2), index| -%>
3634
<%- if property_name_2 == property_name -%>
3735
<%- if property['items'] -%>
38-
unmodifiableList(new ArrayList<>(requireNonNull(<%= property_name %>, "<%= class_name(key) %>.<%= property_name %> cannot be null")))<%= index < schema['properties'].length - 1 ? ',' : '' %>
36+
List.copyOf(requireNonNull(<%= property_name %>, "<%= class_name(key) %>.<%= property_name %> cannot be null"))<%= index < schema['properties'].length - 1 ? ',' : '' %>
3937
<%- else -%>
4038
requireNonNull(<%= property_name %>, "<%= class_name(key) %>.<%= property_name %> cannot be null")<%= index < schema['properties'].length - 1 ? ',' : '' %>
4139
<%- end -%>
@@ -60,13 +58,13 @@ public final class <%= class_name(key) %> {
6058
-%>
6159
<%- if required -%>
6260
<%- if property['items'] -%>
63-
this.<%= property_name %> = unmodifiableList(new ArrayList<>(requireNonNull(<%= property_name %>, "<%= class_name(key) %>.<%= property_name %> cannot be null")));
61+
this.<%= property_name %> = List.copyOf(requireNonNull(<%= property_name %>, "<%= class_name(key) %>.<%= property_name %> cannot be null"));
6462
<%- else -%>
6563
this.<%= property_name %> = requireNonNull(<%= property_name %>, "<%= class_name(key) %>.<%= property_name %> cannot be null");
6664
<%- end -%>
6765
<%- else -%>
6866
<%- if property['items'] -%>
69-
this.<%= property_name %> = <%= property_name %> == null ? null : unmodifiableList(new ArrayList<>(<%= property_name %>));
67+
this.<%= property_name %> = <%= property_name %> == null ? null : List.copyOf(<%= property_name %>);
7068
<%- else -%>
7169
this.<%= property_name %> = <%= property_name %>;
7270
<%- end -%>

java/src/generated/java/io/cucumber/messages/types/Attachment.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,9 @@
33
import org.jspecify.annotations.Nullable;
44

55
import java.util.List;
6-
import java.util.ArrayList;
76
import java.util.Objects;
87
import java.util.Optional;
98

10-
import static java.util.Collections.unmodifiableList;
119
import static java.util.Objects.requireNonNull;
1210

1311
/**

java/src/generated/java/io/cucumber/messages/types/Background.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,9 @@
33
import org.jspecify.annotations.Nullable;
44

55
import java.util.List;
6-
import java.util.ArrayList;
76
import java.util.Objects;
87
import java.util.Optional;
98

10-
import static java.util.Collections.unmodifiableList;
119
import static java.util.Objects.requireNonNull;
1210

1311
/**
@@ -35,7 +33,7 @@ public Background(
3533
this.keyword = requireNonNull(keyword, "Background.keyword cannot be null");
3634
this.name = requireNonNull(name, "Background.name cannot be null");
3735
this.description = requireNonNull(description, "Background.description cannot be null");
38-
this.steps = unmodifiableList(new ArrayList<>(requireNonNull(steps, "Background.steps cannot be null")));
36+
this.steps = List.copyOf(requireNonNull(steps, "Background.steps cannot be null"));
3937
this.id = requireNonNull(id, "Background.id cannot be null");
4038
}
4139

java/src/generated/java/io/cucumber/messages/types/Ci.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,9 @@
33
import org.jspecify.annotations.Nullable;
44

55
import java.util.List;
6-
import java.util.ArrayList;
76
import java.util.Objects;
87
import java.util.Optional;
98

10-
import static java.util.Collections.unmodifiableList;
119
import static java.util.Objects.requireNonNull;
1210

1311
/**

java/src/generated/java/io/cucumber/messages/types/Comment.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,9 @@
33
import org.jspecify.annotations.Nullable;
44

55
import java.util.List;
6-
import java.util.ArrayList;
76
import java.util.Objects;
87
import java.util.Optional;
98

10-
import static java.util.Collections.unmodifiableList;
119
import static java.util.Objects.requireNonNull;
1210

1311
/**

java/src/generated/java/io/cucumber/messages/types/DataTable.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,9 @@
33
import org.jspecify.annotations.Nullable;
44

55
import java.util.List;
6-
import java.util.ArrayList;
76
import java.util.Objects;
87
import java.util.Optional;
98

10-
import static java.util.Collections.unmodifiableList;
119
import static java.util.Objects.requireNonNull;
1210

1311
/**
@@ -24,7 +22,7 @@ public DataTable(
2422
List<TableRow> rows
2523
) {
2624
this.location = requireNonNull(location, "DataTable.location cannot be null");
27-
this.rows = unmodifiableList(new ArrayList<>(requireNonNull(rows, "DataTable.rows cannot be null")));
25+
this.rows = List.copyOf(requireNonNull(rows, "DataTable.rows cannot be null"));
2826
}
2927

3028
public Location getLocation() {

java/src/generated/java/io/cucumber/messages/types/DocString.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,9 @@
33
import org.jspecify.annotations.Nullable;
44

55
import java.util.List;
6-
import java.util.ArrayList;
76
import java.util.Objects;
87
import java.util.Optional;
98

10-
import static java.util.Collections.unmodifiableList;
119
import static java.util.Objects.requireNonNull;
1210

1311
/**

java/src/generated/java/io/cucumber/messages/types/Duration.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,9 @@
33
import org.jspecify.annotations.Nullable;
44

55
import java.util.List;
6-
import java.util.ArrayList;
76
import java.util.Objects;
87
import java.util.Optional;
98

10-
import static java.util.Collections.unmodifiableList;
119
import static java.util.Objects.requireNonNull;
1210

1311
/**

java/src/generated/java/io/cucumber/messages/types/Envelope.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,9 @@
33
import org.jspecify.annotations.Nullable;
44

55
import java.util.List;
6-
import java.util.ArrayList;
76
import java.util.Objects;
87
import java.util.Optional;
98

10-
import static java.util.Collections.unmodifiableList;
119
import static java.util.Objects.requireNonNull;
1210

1311
/**

java/src/generated/java/io/cucumber/messages/types/Examples.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,9 @@
33
import org.jspecify.annotations.Nullable;
44

55
import java.util.List;
6-
import java.util.ArrayList;
76
import java.util.Objects;
87
import java.util.Optional;
98

10-
import static java.util.Collections.unmodifiableList;
119
import static java.util.Objects.requireNonNull;
1210

1311
/**
@@ -36,12 +34,12 @@ public Examples(
3634
String id
3735
) {
3836
this.location = requireNonNull(location, "Examples.location cannot be null");
39-
this.tags = unmodifiableList(new ArrayList<>(requireNonNull(tags, "Examples.tags cannot be null")));
37+
this.tags = List.copyOf(requireNonNull(tags, "Examples.tags cannot be null"));
4038
this.keyword = requireNonNull(keyword, "Examples.keyword cannot be null");
4139
this.name = requireNonNull(name, "Examples.name cannot be null");
4240
this.description = requireNonNull(description, "Examples.description cannot be null");
4341
this.tableHeader = tableHeader;
44-
this.tableBody = unmodifiableList(new ArrayList<>(requireNonNull(tableBody, "Examples.tableBody cannot be null")));
42+
this.tableBody = List.copyOf(requireNonNull(tableBody, "Examples.tableBody cannot be null"));
4543
this.id = requireNonNull(id, "Examples.id cannot be null");
4644
}
4745

0 commit comments

Comments
 (0)