Skip to content

Commit

Permalink
Create equals(), hashCode(), and toString() for LocationHint
Browse files Browse the repository at this point in the history
  • Loading branch information
mattbdean committed Mar 21, 2015
1 parent bf8e82a commit 92d9138
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/main/java/net/dean/jraw/models/LocationHint.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ public final class LocationHint {
private static final EnumMap<TraversalMethod, LocationHint> instances = new EnumMap<>(TraversalMethod.class);

private LocationHint(TraversalMethod method) {
if (method == null)
throw new NullPointerException("Traversal method cannot be null");
this.method = method;
}

Expand Down Expand Up @@ -44,4 +46,26 @@ public static LocationHint anywhere() {
TraversalMethod getTraversalMethod() {
return method;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;

LocationHint that = (LocationHint) o;

return method == that.method;
}

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

@Override
public String toString() {
return "LocationHint {" +
"method=" + method +
'}';
}
}

0 comments on commit 92d9138

Please sign in to comment.