+
+ public Field(String name, String value) {
+ this(randomUUID().toString(), name, value);
+ }
+
+ public Field(String id, String name, String value) {
+ this.id = checkNotNull(id, "id must not be null");
+ this.name = name;
+ this.value = value;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof Field)) {
+ return false;
+ }
+ Field field = (Field) object;
+ return id.equals(field.id);
+ }
+
+ @Override
+ public int hashCode() {
+ return id.hashCode();
+ }
+
+ }
+
+ public static class Name implements Fingerprintable {
+
+ private final Optional<String> first;
+ private final Optional<String> middle;
+ private final Optional<String> last;
+
+ public Name() {
+ this(Optional.<String>absent(), Optional.<String>absent(), Optional.<String>absent());
+ }
+
+ public Name(Optional<String> first, Optional<String> middle, Optional<String> last) {
+ this.first = first;
+ this.middle = middle;
+ this.last = last;
+ }
+
+ public Optional<String> getFirst() {
+ return first;
+ }
+
+ public Optional<String> getMiddle() {
+ return middle;
+ }
+
+ public Optional<String> getLast() {
+ return last;
+ }
+
+ @Override
+ public String getFingerprint() {
+ Hasher hash = Hashing.sha256().newHasher();
+ hash.putString("Name(");
+ if (first.isPresent()) {
+ hash.putString("First(").putString(first.get()).putString(")");
+ }
+ if (middle.isPresent()) {
+ hash.putString("Middle(").putString(middle.get()).putString(")");
+ }
+ if (last.isPresent()) {
+ hash.putString("Last(").putString(last.get()).putString(")");
+ }
+ hash.putString(")");
+ return hash.hash().toString();
+ }
+
+ }
+
+ public static class BirthDate implements Fingerprintable {
+
+ private final Optional<Integer> year;
+ private final Optional<Integer> month;
+ private final Optional<Integer> day;
+
+ public BirthDate() {
+ this(Optional.<Integer>absent(), Optional.<Integer>absent(), Optional.<Integer>absent());