this.birthDay = profile.birthDay;
this.birthMonth = profile.birthMonth;
this.birthYear = profile.birthYear;
+ this.fields.addAll(profile.fields);
this.fieldValues.putAll(profile.fieldValues);
}
/**
* Sets the value of the field with the given name.
*
+ * @param fieldIndex
+ * The index of the field
+ * @param value
+ * The value of the field
+ */
+ public void setField(int fieldIndex, String value) {
+ Validation.begin().isGreaterOrEqual("Field Index", fieldIndex, 0).isLess("Field Index", fieldIndex, fields.size()).check();
+ setField(fields.get(fieldIndex), value);
+ }
+
+ /**
+ * Sets the value of the field with the given name.
+ *
* @param field
* The name of the field
* @param value
}
/**
+ * Renames a fields.
+ *
+ * @param fieldIndex
+ * The index of the field to rename
+ * @param fieldName
+ * The new name of the field
+ */
+ public void setFieldName(int fieldIndex, String fieldName) {
+ Validation.begin().isGreaterOrEqual("Field Index", fieldIndex, 0).isLess("Field Index", fieldIndex, fields.size()).isNotNull("Field Name", fieldName).isEqual("New Field Name Unique", !fields.contains(fieldName) || (getFieldIndex(fieldName) == fieldIndex), true).check();
+ String value = fieldValues.remove(fields.get(fieldIndex));
+ fields.set(fieldIndex, fieldName);
+ fieldValues.put(fieldName, value);
+ }
+
+ /**
* Returns all field names and their values, ordered the same way
* {@link #getFieldNames()} returns the names of the fields.
*