Move Maybe into maybe package
This commit is contained in:
parent
95d5837e31
commit
bf8e383229
5 changed files with 41 additions and 9 deletions
|
@ -19,7 +19,7 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package net.kemitix.mon;
|
||||
package net.kemitix.mon.maybe;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
@ -39,7 +39,7 @@ import java.util.function.Supplier;
|
|||
* @author Paul Campbell (pcampbell@kemitix.net)
|
||||
*/
|
||||
@RequiredArgsConstructor(access = AccessLevel.PROTECTED)
|
||||
public final class Just<T> implements Maybe<T> {
|
||||
final class Just<T> implements Maybe<T> {
|
||||
|
||||
private final T value;
|
||||
|
|
@ -19,9 +19,10 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package net.kemitix.mon;
|
||||
package net.kemitix.mon.maybe;
|
||||
|
||||
import lombok.NonNull;
|
||||
import net.kemitix.mon.Functor;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.function.Consumer;
|
|
@ -19,7 +19,7 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package net.kemitix.mon;
|
||||
package net.kemitix.mon.maybe;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.function.Consumer;
|
||||
|
@ -34,9 +34,9 @@ import java.util.function.Supplier;
|
|||
*
|
||||
* @author Paul Campbell (pcampbell@kemitix.net)
|
||||
*/
|
||||
public final class Nothing<T> implements Maybe<T> {
|
||||
final class Nothing<T> implements Maybe<T> {
|
||||
|
||||
protected static final Maybe<?> INSTANCE = new Nothing<>();
|
||||
static final Maybe<?> INSTANCE = new Nothing<>();
|
||||
|
||||
@Override
|
||||
public <R> Maybe<?> map(final Function<T, R> f) {
|
30
src/main/java/net/kemitix/mon/maybe/package-info.java
Normal file
30
src/main/java/net/kemitix/mon/maybe/package-info.java
Normal file
|
@ -0,0 +1,30 @@
|
|||
/**
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2017 Paul Campbell
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
||||
* and associated documentation files (the "Software"), to deal in the Software without restriction,
|
||||
* including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies
|
||||
* or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
|
||||
* AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* An experiment in creating something similar to a Type-Alias in Java.
|
||||
*
|
||||
* <p>Ideas initially lifted from the Design with Types series at https://fsharpforfunandprofit.com/</p>
|
||||
*
|
||||
* @author Paul Campbell (pcampbell@kemitix.net)
|
||||
*/
|
||||
|
||||
package net.kemitix.mon.maybe;
|
|
@ -1,5 +1,6 @@
|
|||
package net.kemitix.mon;
|
||||
|
||||
import net.kemitix.mon.maybe.Maybe;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Objects;
|
||||
|
@ -7,9 +8,9 @@ import java.util.Optional;
|
|||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import static net.kemitix.mon.Maybe.just;
|
||||
import static net.kemitix.mon.Maybe.maybe;
|
||||
import static net.kemitix.mon.Maybe.nothing;
|
||||
import static net.kemitix.mon.maybe.Maybe.just;
|
||||
import static net.kemitix.mon.maybe.Maybe.maybe;
|
||||
import static net.kemitix.mon.maybe.Maybe.nothing;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatCode;
|
||||
import static org.assertj.core.api.Assertions.assertThatNullPointerException;
|
||||
|
|
Loading…
Reference in a new issue