Skip to content

Commit fd0b13f

Browse files
committed
Change components array in FormData to an unmodifiable list
1 parent e2a54ab commit fd0b13f

File tree

1 file changed

+9
-6
lines changed
  • src/main/java/net/discordjug/javabot/systems/staff_commands/forms/model

1 file changed

+9
-6
lines changed

src/main/java/net/discordjug/javabot/systems/staff_commands/forms/model/FormData.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package net.discordjug.javabot.systems.staff_commands.forms.model;
22

33
import java.time.Instant;
4+
import java.util.ArrayList;
5+
import java.util.Collections;
46
import java.util.Date;
57
import java.util.List;
68
import java.util.Objects;
@@ -54,15 +56,16 @@ public boolean isAttached() {
5456
/**
5557
* Creates text components for use in the submission modal.
5658
*
57-
* @return List of layout components for use in the submission modal.
59+
* @return An unmodifiable list of layout components for use in the submission
60+
* modal.
5861
*/
59-
public Label[] createComponents() {
60-
Label[] array = new Label[fields.size()];
61-
for (int i = 0; i < array.length; i++) {
62+
public List<Label> createComponents() {
63+
List<Label> list = new ArrayList<>(fields.size());
64+
for (int i = 0; i < list.size(); i++) {
6265
FormField field = fields.get(i);
63-
array[i] = Label.of(fields.get(i).label(), field.createTextInput("text" + i));
66+
list.add(Label.of(fields.get(i).label(), field.createTextInput("text" + i)));
6467
}
65-
return array;
68+
return Collections.unmodifiableList(list);
6669
}
6770

6871
/**

0 commit comments

Comments
 (0)