package se.citerus.dddsample.domain;

import org.apache.commons.lang.Validate;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;

/**
 * Identifies a particular cargo.
 * <p/>
 * Make sure to put a constraint in the database to make sure TrackingId is unique.
 */
public final class TrackingId {

  private String id;

  /**
   * Constructor.
   *
   * @param id Id string.
   */
  public TrackingId(final String id) {
    Validate.notNull(id);
    this.id = id;
  }

  /**
   * @return String representation of this tracking id.
   */
  public String idString() {
    return id;
  }

  @Override
  public boolean equals(final Object obj) {
    return EqualsBuilder.reflectionEquals(this, obj);
  }

  @Override
  public int hashCode() {
    return HashCodeBuilder.reflectionHashCode(this);
  }


  TrackingId() {
    // Needed by Hibernate
  }

}

@@ -190,17 +190,26 @@
 %0A/**%0A * 
-I
+Uniquely i
 dentifie
@@ -233,134 +233,126 @@
 rgo.
-%0A * %3Cp/%3E%0A * Make sure to put a constraint in the database to make sure TrackingId is unique.%0A */%0Apublic final class TrackingId
+ Automatically generated by the application.%0A *  %0A */%0Apublic final class TrackingId implements ValueObject%3CTrackingId%3E
  %7B%0A%0A
@@ -679,22 +679,16 @@
 als(
-final 
 Object o
 bj) 
@@ -687,18 +687,16 @@
 ct o
-bj
 ) %7B%0A    
 retu
@@ -695,55 +695,168 @@
     
-return EqualsBuilder.reflectionEqual
+if (this == o) return true;%0A    if (o == null %7C%7C getClass() != o.getClass()) return false;%0A%0A    TrackingId other = (TrackingId) o;%0A%0A    return sameValueA
 s(
+o
 th
-is, obj
+er
 );%0A 
@@ -955,16 +955,142 @@
 );%0A  %7D%0A%0A
+  public boolean sameValueAs(TrackingId other) %7B%0A    return other != null && EqualsBuilder.reflectionEquals(this, other);%0A  %7D%0A
 %0A  Track
@@ -1130,11 +1130,10 @@
 ate%0A  %7D%0A
-%0A
 %7D%0A

Implement ValueObject.sameValueAs(), and use that as delegate in equals()