Last active
May 21, 2019 21:47
-
-
Save flying3615/0c8e79f279f923f443c5cdc62506000a to your computer and use it in GitHub Desktop.
Some of something
This file contains 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