MCPcopy Create free account
hub / github.com/tomaszpolanski/Options / Some

Class Some

options/core/src/main/java/polanski/option/Some.java:24–228  ·  view source on GitHub ↗

Represent option of existing value. @param type of object that exists

Source from the content-addressed store, hash-verified

22 * @param <T> type of object that exists
23 */
24public final class Some<T> extends Option<T> {
25
26 @NotNull
27 private final T mValue;
28
29 Some(@NotNull final T value) {
30 mValue = value;
31 }
32
33 @Override
34 public boolean isSome() {
35 return true;
36 }
37
38 @Override
39 public boolean isNone() {
40 return false;
41 }
42
43 @Override
44 public Option<T> ifSome(@NotNull final Action1<T> action) {
45 action.call(mValue);
46 return this;
47 }
48
49 @Override
50 public Option<T> ifNone(@NotNull final Action0 action) {
51 // Do nothing
52 return this;
53 }
54
55 @NotNull
56 @Override
57 public <OUT> Option<OUT> map(@NotNull final Func1<T, OUT> f) {
58 return ofObj(f.call(mValue));
59 }
60
61 @NotNull
62 @Override
63 public <OUT> Option<OUT> flatMap(@NotNull final Func1<T, Option<OUT>> f) {
64 return f.call(mValue);
65 }
66
67 @NotNull
68 @Override
69 public Option<T> filter(@NotNull final Func1<T, Boolean> predicate) {
70 return predicate.call(mValue) ? this : Option.<T>none();
71 }
72
73 @NotNull
74 @Override
75 public Option<T> orOption(@NotNull final Func0<Option<T>> f) {
76 return this;
77 }
78
79 @NotNull
80 @Override
81 public T orDefault(@NotNull final Func0<T> def) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…