From 2f5b01f460e29b4dd56f6e8538f19e30016ae49c Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Tue, 26 Jun 2018 07:22:32 +0100 Subject: [PATCH] Remove Identity --- CHANGELOG | 3 +- src/main/java/net/kemitix/mon/Identity.java | 45 ------------------- .../java/net/kemitix/mon/IdentityTest.java | 41 ----------------- 3 files changed, 2 insertions(+), 87 deletions(-) delete mode 100644 src/main/java/net/kemitix/mon/Identity.java delete mode 100644 src/test/java/net/kemitix/mon/IdentityTest.java diff --git a/CHANGELOG b/CHANGELOG index 354d099..8de5837 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -4,10 +4,11 @@ CHANGELOG 0.7.0 ----- +* Remove `Identity` * Add `Result` * Moved `Maybe` to `net.kemitix.mon.maybe.Maybe` +* `Maybe` is now a Monad * Add `Maybe.stream()` -* Deprecate `Maybe.fromOptional(Optional)` 0.6.0 ----- diff --git a/src/main/java/net/kemitix/mon/Identity.java b/src/main/java/net/kemitix/mon/Identity.java deleted file mode 100644 index 4b4df37..0000000 --- a/src/main/java/net/kemitix/mon/Identity.java +++ /dev/null @@ -1,45 +0,0 @@ -/** - * 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. - */ - -package net.kemitix.mon; - -import lombok.RequiredArgsConstructor; - -import java.util.function.Function; - -/** - * Identity. - * - * @param the type of the identity content - * - * @author Paul Campbell (pcampbell@kemitix.net) - */ -@RequiredArgsConstructor -class Identity implements Functor> { - - private final T value; - - @Override - public Identity map(final Function f) { - return new Identity<>(f.apply(value)); - } - -} diff --git a/src/test/java/net/kemitix/mon/IdentityTest.java b/src/test/java/net/kemitix/mon/IdentityTest.java deleted file mode 100644 index db95452..0000000 --- a/src/test/java/net/kemitix/mon/IdentityTest.java +++ /dev/null @@ -1,41 +0,0 @@ -package net.kemitix.mon; - -import org.assertj.core.api.WithAssertions; -import org.junit.Test; - -/** - * Tests for {@link Identity}. - * - * @author Paul Campbell (pcampbell@kemitix.net) - */ -public class IdentityTest implements WithAssertions { - - @Test - public void canMapIdentityFromStringToInteger() { - //given - final Identity idString = new Identity<>("abc"); - //when - final Identity idInt = idString.map(String::length); - //then - assertIdentityContains(idInt, 3); - } - - private void assertIdentityContains(final Identity identity, final T expected) { - identity.map(id -> assertThat(id).isEqualTo(expected)); - } - - @Test - public void canFluentlyComposeFunctions() { - //given - final Customer customer = new Customer(new Address("Park Place")); - //when - final Identity idBytes = new Identity<>(customer).map(Customer::getAddress) - .map(Address::getStreet) - .map((String s) -> s.substring(0, 3)) - .map(String::toLowerCase) - .map(String::getBytes); - //then - assertIdentityContains(idBytes, "par".getBytes()); - } - -}