Skip to content

Instantly share code, notes, and snippets.

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