Skip to content

Commit

Permalink
tabs -> spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
Feuermagier authored Jul 14, 2024
1 parent e27ee7d commit 4247ee2
Showing 1 changed file with 28 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,49 +20,49 @@ static <T> Option<T> none() {
}

default T unwrap() {
if (this instanceof Some<T> someValue) {
return someValue.value;
} else if (this instanceof None<T>) {
throw new IllegalStateException("Expected Some value, but got None.");
}
throw new IllegalArgumentException();
}
if (this instanceof Some<T> someValue) {
return someValue.value;
} else if (this instanceof None<T>) {
throw new IllegalStateException("Expected Some value, but got None.");
}
throw new IllegalArgumentException();
}

default boolean isSome() {
return this instanceof Some;
}

default <U> Option<U> map(Function<T, U> function) {
if (this instanceof Some<T> someValue) {
return new Some<>(function.apply(someValue.value));
} else if (this instanceof None<T>) {
return new None<>();
}
throw new IllegalArgumentException();
}
if (this instanceof Some<T> someValue) {
return new Some<>(function.apply(someValue.value));
} else if (this instanceof None<T>) {
return new None<>();
}
throw new IllegalArgumentException();
}

/**
* Returns the value if it is present or null if it is not.
*
* @return the value or null
*/
default T nullable() {
if (this instanceof Some<T> someValue) {
return someValue.value;
} else if (this instanceof None<T>) {
return null;
}
throw new IllegalArgumentException();
}
if (this instanceof Some<T> someValue) {
return someValue.value;
} else if (this instanceof None<T>) {
return null;
}
throw new IllegalArgumentException();
}

default Stream<T> stream() {
if (this instanceof Some<T> someValue) {
return Stream.of(someValue.value);
} else if (this instanceof None<T>) {
return Stream.empty();
}
throw new IllegalArgumentException();
}
if (this instanceof Some<T> someValue) {
return Stream.of(someValue.value);
} else if (this instanceof None<T>) {
return Stream.empty();
}
throw new IllegalArgumentException();
}

@Override
default Iterator<T> iterator() {
Expand Down

0 comments on commit 4247ee2

Please sign in to comment.