Add method to rename a field.
[Sone.git] / src / main / java / net / pterodactylus / sone / data / Profile.java
index 3e287d7..1d7610e 100644 (file)
@@ -238,6 +238,14 @@ public class Profile implements Fingerprintable {
                return field;
        }
 
+       public void renameField(Field field, String newName) {
+               int indexOfField = fields.indexOf(field);
+               if (indexOfField == -1) {
+                       return;
+               }
+               fields.set(indexOfField, new Field(field.getId(), newName, field.getValue()));
+       }
+
        /**
         * Moves the given field up one position in the field list. The index of the
         * field to move must be greater than {@code 0} (because you obviously can
@@ -425,6 +433,12 @@ public class Profile implements Fingerprintable {
                        this.id = checkNotNull(id, "id must not be null");
                }
 
+               public Field(String id, String name, String value) {
+                       this.id = checkNotNull(id, "id must not be null");
+                       this.name = name;
+                       this.value = value;
+               }
+
                /**
                 * Returns the ID of this field.
                 *