package com.forerunnergames.tools.common.id;

import com.forerunnergames.tools.common.Arguments;

import java.util.UUID;

public final class Id implements Comparable <Id>
{
  private final UUID value;

  public Id (final UUID value)
  {
    Arguments.checkIsNotNull (value, "value");
    
    this.value = value;
  }

  public UUID value ()
  {
    return value;
  }

  @Override
  public int hashCode ()
  {
    return value.hashCode ();
  }

  @Override
  public boolean equals (final Object o)
  {
    Arguments.checkIsNotNull (o, "o");
    
    if (this == o) return true;

    if (o == null || getClass () != o.getClass ()) return false;

    final Id that = (Id) o;

    return value.equals (that.value);
  }

  @Override
  public String toString ()
  {
    return String.valueOf (value);
  }

  @Override
  public int compareTo (final Id id)
  {
    Arguments.checkIsNotNull (id, "id");

    return this.value.compareTo (id.value);
  }

  public boolean is (final Id id)
  {
    Arguments.checkIsNotNull (id, "id");
    
    return equals (id);
  }

  public boolean isNot (final Id id)
  {
    Arguments.checkIsNotNull (id, "id");
    
    return !is (id);
  }

  public boolean hasValue (final UUID value)
  {
    Arguments.checkIsNotNull (value, "value");
    
    return this.value.equals (value);
  }
}

@@ -273,29 +273,25 @@
 , %22value%22);%0A
-    
 %0A
+
     this.val
@@ -494,52 +494,8 @@
   %7B%0A
-    Arguments.checkIsNotNull (o, %22o%22);%0A    %0A
     
@@ -960,37 +960,33 @@
 ull (id, %22id%22);%0A
-    
 %0A
+
     return equal
@@ -1076,29 +1076,25 @@
 (id, %22id%22);%0A
-    
 %0A
+
     return !
@@ -1203,20 +1203,16 @@
 alue%22);%0A
-    
 %0A    ret

Fix Id.equals throwing exception on null argument.