1 4 package com.tc.util; 5 6 import java.io.Serializable ; 7 8 13 public abstract class AbstractIdentifier implements Serializable { 14 private static final long NULL_ID = -1; 15 private final long id; 16 17 public AbstractIdentifier(long id) { 18 this.id = id; 19 } 20 21 protected AbstractIdentifier() { 22 this.id = NULL_ID; 23 } 24 25 public boolean isNull() { 26 return (this.id == NULL_ID); 27 } 28 29 public final long toLong() { 30 return id; 31 } 32 33 public final String toString() { 34 return getIdentifierType() + "=" + "[" + id + "]"; 35 } 36 37 abstract public String getIdentifierType(); 38 39 public int hashCode() { 40 return (int) (this.id ^ (this.id >>> 32)); 41 } 42 43 public boolean equals(Object obj) { 44 if (obj instanceof AbstractIdentifier) { 45 AbstractIdentifier other = (AbstractIdentifier) obj; 46 return ((this.id == other.id) && this.getClass().equals(other.getClass())); 47 } 48 return false; 49 } 50 } | Popular Tags |