Entity.java
1 package hlt; 2 3 public class Entity { 4 public final PlayerId owner; 5 public final EntityId id; 6 public final Position position; 7 8 public Entity(final PlayerId owner, final EntityId id, final Position position) { 9 this.owner = owner; 10 this.id = id; 11 this.position = position; 12 } 13 14 @Override 15 public boolean equals(Object o) { 16 if (this == o) return true; 17 if (o == null || getClass() != o.getClass()) return false; 18 19 Entity entity = (Entity) o; 20 21 if (!owner.equals(entity.owner)) return false; 22 if (!id.equals(entity.id)) return false; 23 return position.equals(entity.position); 24 } 25 26 @Override 27 public int hashCode() { 28 int result = owner.hashCode(); 29 result = 31 * result + id.hashCode(); 30 result = 31 * result + position.hashCode(); 31 return result; 32 } 33 }