Created
August 30, 2013 13:09
-
-
Save renanreismartins/6389672 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public final class Some<T> extends Option<T> { | |
private final T value; | |
public Some(T value) { this.value = value; } | |
public boolean hasValue() { return true; } | |
public T get() { return value; } | |
@Override | |
public String toString() { return "Some("+value+")"; } | |
@Override | |
public boolean equals(Object other) { | |
if (other == null || other.getClass() != Some.class) | |
return false; | |
Some<?> that = (Some<?>) other; | |
Object thatValue = that.get(); | |
return value.equals(thatValue); | |
} | |
@Override | |
public int hashCode() { return 37 * value.hashCode(); } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment