1 package au.gov.amsa.navigation; 2 3 public class Mmsi implements Identifier { 4 5 private final int mmsi; 6 private final int hashCode; 7 8 public Mmsi(int mmsi) { 9 this.mmsi = mmsi; 10 this.hashCode = calculateHashCode(); 11 } 12 13 public int value() { 14 return mmsi; 15 } 16 17 @Override 18 public long uniqueId() { 19 return mmsi; 20 } 21 22 private int calculateHashCode() { 23 final int prime = 31; 24 int result = 1; 25 result = prime * result + (mmsi ^ (mmsi >>> 32)); 26 return result; 27 } 28 29 @Override 30 public int hashCode() { 31 return hashCode; 32 } 33 34 @Override 35 public boolean equals(Object obj) { 36 if (this == obj) 37 return true; 38 if (obj == null) 39 return false; 40 if (getClass() != obj.getClass()) 41 return false; 42 Mmsi other = (Mmsi) obj; 43 if (mmsi != other.mmsi) 44 return false; 45 return true; 46 } 47 48 @Override 49 public String toString() { 50 return "Mmsi [mmsi=" + mmsi + "]"; 51 } 52 53 }