From d10309ac6032961f0c1333e1362f7c7ae0439ac1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Chmielarz?= Date: Sat, 10 Feb 2024 17:40:52 +0100 Subject: [PATCH] Removes deprecated and not used code --- .../org/assertj/vavr/api/AbstractEitherAssert.java | 5 ----- .../org/assertj/vavr/api/AbstractMapAssert.java | 6 +++--- .../assertj/vavr/api/AbstractMultimapAssert.java | 6 +++--- .../org/assertj/vavr/api/AbstractSeqAssert.java | 13 ++++++------- 4 files changed, 12 insertions(+), 18 deletions(-) diff --git a/src/main/java/org/assertj/vavr/api/AbstractEitherAssert.java b/src/main/java/org/assertj/vavr/api/AbstractEitherAssert.java index f6ad84a..bb5ddd4 100644 --- a/src/main/java/org/assertj/vavr/api/AbstractEitherAssert.java +++ b/src/main/java/org/assertj/vavr/api/AbstractEitherAssert.java @@ -23,7 +23,6 @@ import java.util.Comparator; import java.util.function.Consumer; -import static org.assertj.core.util.Preconditions.checkArgument; import static org.assertj.vavr.api.EitherShouldBeLeft.shouldBeLeft; import static org.assertj.vavr.api.EitherShouldBeRight.shouldBeRight; import static org.assertj.vavr.api.EitherShouldContain.*; @@ -255,10 +254,6 @@ public SELF usingDefaultRightValueComparator() { return myself; } - private void checkNotNull(Object expectedValue) { - checkArgument(expectedValue != null, "The expected value should not be ."); - } - private void assertIsRight() { isNotNull(); if (actual.isLeft()) throwAssertionError(shouldBeRight(actual)); diff --git a/src/main/java/org/assertj/vavr/api/AbstractMapAssert.java b/src/main/java/org/assertj/vavr/api/AbstractMapAssert.java index 8e9ade4..7bdba1e 100644 --- a/src/main/java/org/assertj/vavr/api/AbstractMapAssert.java +++ b/src/main/java/org/assertj/vavr/api/AbstractMapAssert.java @@ -26,6 +26,7 @@ import java.util.function.BiConsumer; import java.util.stream.StreamSupport; +import static java.util.Objects.requireNonNull; import static org.assertj.core.error.ShouldBeEmpty.shouldBeEmpty; import static org.assertj.core.error.ShouldBeNullOrEmpty.shouldBeNullOrEmpty; import static org.assertj.core.error.ShouldHaveSameSizeAs.shouldHaveSameSizeAs; @@ -38,7 +39,6 @@ import static org.assertj.core.error.ShouldNotBeEmpty.shouldNotBeEmpty; import static org.assertj.core.util.Arrays.array; import static org.assertj.core.util.IterableUtil.sizeOf; -import static org.assertj.core.util.Preconditions.checkNotNull; /** * Assertions for {@link Map}. @@ -68,7 +68,7 @@ abstract class AbstractMapAssert entryRequirements) { - checkNotNull(entryRequirements, "The BiConsumer expressing the assertions requirements must not be null"); + requireNonNull(entryRequirements, "The BiConsumer expressing the assertions requirements must not be null"); isNotNull(); actual.forEach(entry -> entryRequirements.accept(entry._1, entry._2)); return myself; @@ -405,7 +405,7 @@ public SELF hasSizeBetween(int lowerBoundary, int higherBoundary) { @Override public SELF hasSameSizeAs(Iterable other) { isNotNull(); - checkNotNull(other, "The other Iterable to compare actual size with should not be null"); + requireNonNull(other, "The other Iterable to compare actual size with should not be null"); final long expectedSize = sizeOf(other); if (actual.size() != expectedSize) throwAssertionError(shouldHaveSameSizeAs(actual, other, actual.size(), expectedSize)); diff --git a/src/main/java/org/assertj/vavr/api/AbstractMultimapAssert.java b/src/main/java/org/assertj/vavr/api/AbstractMultimapAssert.java index ce6a71e..4aac71a 100644 --- a/src/main/java/org/assertj/vavr/api/AbstractMultimapAssert.java +++ b/src/main/java/org/assertj/vavr/api/AbstractMultimapAssert.java @@ -26,6 +26,7 @@ import java.util.function.BiConsumer; import java.util.stream.StreamSupport; +import static java.util.Objects.requireNonNull; import static org.assertj.core.error.ShouldBeEmpty.shouldBeEmpty; import static org.assertj.core.error.ShouldBeNullOrEmpty.shouldBeNullOrEmpty; import static org.assertj.core.error.ShouldHaveSameSizeAs.shouldHaveSameSizeAs; @@ -38,7 +39,6 @@ import static org.assertj.core.error.ShouldNotBeEmpty.shouldNotBeEmpty; import static org.assertj.core.util.Arrays.array; import static org.assertj.core.util.IterableUtil.sizeOf; -import static org.assertj.core.util.Preconditions.checkNotNull; abstract class AbstractMultimapAssert, ACTUAL extends Multimap, KEY, VALUE> extends AbstractValueAssert implements EnumerableAssert> { @@ -138,7 +138,7 @@ public SELF containsExactly(@SuppressWarnings("unchecked") Tuple2 entryRequirements) { - checkNotNull(entryRequirements, "The BiConsumer expressing the assertions requirements must not be null"); + requireNonNull(entryRequirements, "The BiConsumer expressing the assertions requirements must not be null"); isNotNull(); actual.forEach(entry -> entryRequirements.accept(entry._1, entry._2)); return myself; @@ -399,7 +399,7 @@ public SELF hasSizeBetween(int lowerBoundary, int higherBoundary) { @Override public SELF hasSameSizeAs(Iterable other) { isNotNull(); - checkNotNull(other, "The other Iterable to compare actual size with should not be null"); + requireNonNull(other, "The other Iterable to compare actual size with should not be null"); final long expectedSize = sizeOf(other); if (actual.size() != expectedSize) throwAssertionError(shouldHaveSameSizeAs(actual, other, actual.size(), expectedSize)); diff --git a/src/main/java/org/assertj/vavr/api/AbstractSeqAssert.java b/src/main/java/org/assertj/vavr/api/AbstractSeqAssert.java index 18c7696..d05148e 100644 --- a/src/main/java/org/assertj/vavr/api/AbstractSeqAssert.java +++ b/src/main/java/org/assertj/vavr/api/AbstractSeqAssert.java @@ -26,11 +26,11 @@ import java.util.function.Consumer; import static java.lang.String.format; +import static java.util.Objects.requireNonNull; import static org.assertj.core.error.ShouldBeSorted.shouldHaveComparableElementsAccordingToGivenComparator; import static org.assertj.core.error.ShouldContainAtIndex.shouldContainAtIndex; import static org.assertj.core.error.ShouldNotBeEmpty.shouldNotBeEmpty; import static org.assertj.core.error.ShouldNotContainAtIndex.shouldNotContainAtIndex; -import static org.assertj.core.util.Preconditions.checkNotNull; import static org.assertj.vavr.api.SeqShouldBeAtIndex.shouldBeAtIndex; import static org.assertj.vavr.api.SeqShouldBeSorted.*; import static org.assertj.vavr.api.SeqShouldHaveAtIndex.shouldHaveAtIndex; @@ -292,18 +292,18 @@ public SELF isSortedAccordingTo(Comparator comparator) { */ public SELF satisfies(Consumer requirements, Index index) { isNotNull(); - checkNotNull(requirements, "The Consumer expressing the assertions requirements must not be null"); + requireNonNull(requirements, "The Consumer expressing the assertions requirements must not be null"); assertIndexIsValid(index); requirements.accept(actual.get(index.value)); return myself; } private void assertIsSortedAccordingToComparator(Comparator comparator) { - checkNotNull(comparator, "The given comparator should not be null"); + requireNonNull(comparator, "The given comparator should not be null"); try { // Empty collections are considered sorted even if comparator can't be applied to their element type // We can't verify that point because of erasure type at runtime. - if (actual.size() == 0) return; + if (actual.isEmpty()) return; Comparator rawComparator = comparator; if (actual.size() == 1) { // Compare unique element with itself to verify that it is compatible with comparator (a ClassCastException is @@ -320,12 +320,11 @@ private void assertIsSortedAccordingToComparator(Comparator comparator) { throwAssertionError( shouldHaveComparableElementsAccordingToGivenComparator(actual, comparator)); } - return; } private void assertConditionIsMetAtIndex(Condition condition, Index index, Runnable errorProvider) { isNotNull(); - checkNotNull(condition, "The condition to evaluate should not be null"); + requireNonNull(condition, "The condition to evaluate should not be null"); assertNotEmpty(); assertIndexIsValid(index); @@ -336,7 +335,7 @@ private void assertConditionIsMetAtIndex(Condition condition, I } private void assertIndexIsValid(Index index) { - checkNotNull(index, "Index should not be null"); + requireNonNull(index, "Index should not be null"); final int maximum = actual.size() - 1; if (index.value > maximum) { String errorMessage = "Index should be between <0> and <%d> (inclusive) but was:%n <%d>";