The Some type, representing an existence of some value @param The type of value
| 91 | * @param <T> The type of value |
| 92 | */ |
| 93 | public static class Some<T> extends Option<T> { |
| 94 | private final T value; |
| 95 | |
| 96 | public Some(T value) { |
| 97 | this.value = value; |
| 98 | } |
| 99 | |
| 100 | public boolean isDefined() { |
| 101 | return true; |
| 102 | } |
| 103 | |
| 104 | public T get() { |
| 105 | return value; |
| 106 | } |
| 107 | |
| 108 | public String toString() { |
| 109 | return "Some(" + value + ")"; |
| 110 | } |
| 111 | } |
| 112 | |
| 113 | /** |
| 114 | * Wraps value in an Option type, depending on whether or not value is null |
no outgoing calls