+ hash.putString("BirthYear(", UTF_8).putInt(birthYear).putString(")", UTF_8);
+ }
+ if (avatar != null) {
+ hash.putString("Avatar(", UTF_8).putString(avatar, UTF_8).putString(")", UTF_8);
+ }
+ hash.putString("ContactInformation(", UTF_8);
+ for (Field field : fields) {
+ hash.putString(field.getName(), UTF_8).putString("(", UTF_8).putString(field.getValue(), UTF_8).putString(")", UTF_8);
+ }
+ hash.putString(")", UTF_8);
+ hash.putString(")", UTF_8);
+
+ return hash.hash().toString();
+ }
+
+ /**
+ * Container for a profile field.
+ */
+ public class Field {
+
+ /** The ID of the field. */
+ private final String id;
+
+ /** The name of the field. */
+ private String name;
+
+ /** The value of the field. */
+ private String value;
+
+ /**
+ * Creates a new field with a random ID.
+ */
+ private Field() {
+ this(UUID.randomUUID().toString());
+ }
+
+ /**
+ * Creates a new field with the given ID.
+ *
+ * @param id
+ * The ID of the field
+ */
+ private Field(@Nonnull String id) {
+ this.id = checkNotNull(id, "id must not be null");
+ }
+
+ /**
+ * Returns the ID of this field.
+ *
+ * @return The ID of this field
+ */
+ @Nonnull
+ public String getId() {
+ return id;