@Override public boolean equals(Object oth) { if (this == oth) return true; else if (!getClass().isInstance(oth)) return false; DirWrapper<?> other = (DirWrapper<?>) oth; if (!get().equals(other.get())) return false; if (hasDirection() && other.hasDirection()) return getDirection().equals(other.getDirection()); else if (!hasDirection() && !other.hasDirection()) return true; else return false; }