Skip to content

Commit

Permalink
Removes deprecated and not used code
Browse files Browse the repository at this point in the history
  • Loading branch information
mchmielarz committed Feb 10, 2024
1 parent 0111c50 commit d10309a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 18 deletions.
5 changes: 0 additions & 5 deletions src/main/java/org/assertj/vavr/api/AbstractEitherAssert.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.*;
Expand Down Expand Up @@ -255,10 +254,6 @@ public SELF usingDefaultRightValueComparator() {
return myself;
}

private void checkNotNull(Object expectedValue) {
checkArgument(expectedValue != null, "The expected value should not be <null>.");
}

private void assertIsRight() {
isNotNull();
if (actual.isLeft()) throwAssertionError(shouldBeRight(actual));
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/org/assertj/vavr/api/AbstractMapAssert.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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}.
Expand Down Expand Up @@ -68,7 +68,7 @@ abstract class AbstractMapAssert<SELF extends AbstractMapAssert<SELF, ACTUAL, KE
* @throws AssertionError if one or more entries don't satisfy the given requirements.
*/
public SELF allSatisfy(BiConsumer<? super KEY, ? super VALUE> entryRequirements) {
checkNotNull(entryRequirements, "The BiConsumer<K, V> expressing the assertions requirements must not be null");
requireNonNull(entryRequirements, "The BiConsumer<K, V> expressing the assertions requirements must not be null");
isNotNull();
actual.forEach(entry -> entryRequirements.accept(entry._1, entry._2));
return myself;
Expand Down Expand Up @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<SELF extends AbstractMultimapAssert<SELF, ACTUAL, KEY, VALUE>, ACTUAL extends Multimap<KEY, VALUE>, KEY, VALUE>
extends AbstractValueAssert<SELF, ACTUAL> implements EnumerableAssert<SELF, Tuple2<? extends KEY, ? extends VALUE>> {
Expand Down Expand Up @@ -138,7 +138,7 @@ public SELF containsExactly(@SuppressWarnings("unchecked") Tuple2<? extends KEY,
* @throws AssertionError if one or more entries don't satisfy the given requirements.
*/
public SELF allSatisfy(BiConsumer<? super KEY, ? super VALUE> entryRequirements) {
checkNotNull(entryRequirements, "The BiConsumer<K, V> expressing the assertions requirements must not be null");
requireNonNull(entryRequirements, "The BiConsumer<K, V> expressing the assertions requirements must not be null");
isNotNull();
actual.forEach(entry -> entryRequirements.accept(entry._1, entry._2));
return myself;
Expand Down Expand Up @@ -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));
Expand Down
13 changes: 6 additions & 7 deletions src/main/java/org/assertj/vavr/api/AbstractSeqAssert.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -292,18 +292,18 @@ public SELF isSortedAccordingTo(Comparator<? super ELEMENT> comparator) {
*/
public SELF satisfies(Consumer<? super ELEMENT> 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
Expand All @@ -320,12 +320,11 @@ private void assertIsSortedAccordingToComparator(Comparator<?> comparator) {
throwAssertionError(
shouldHaveComparableElementsAccordingToGivenComparator(actual, comparator));
}
return;
}

private void assertConditionIsMetAtIndex(Condition<? super ELEMENT> 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);
Expand All @@ -336,7 +335,7 @@ private void assertConditionIsMetAtIndex(Condition<? super ELEMENT> 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>";
Expand Down

0 comments on commit d10309a

Please sign in to comment.