Skip to content

Commit

Permalink
Meaningful generic names master only (#931)
Browse files Browse the repository at this point in the history
* meaningful generic names: optional

* meaningful generic names: CompletableFuture
  • Loading branch information
epeee authored and joel-costigliola committed Feb 23, 2017
1 parent a65dc3c commit 5316f8c
Show file tree
Hide file tree
Showing 12 changed files with 59 additions and 59 deletions.
Expand Up @@ -50,13 +50,13 @@ public PathAssert then(Path actual) {
* Create assertion for {@link java.util.Optional}.
*
* @param actual the actual value.
* @param <T> the type of the value contained in the {@link java.util.Optional}.
* @param <VALUE> the type of the value contained in the {@link java.util.Optional}.
*
* @return the created assertion object.
*/
@SuppressWarnings("unchecked")
@CheckReturnValue
public <T> OptionalAssert<T> then(Optional<T> actual) {
public <VALUE> OptionalAssert<VALUE> then(Optional<VALUE> actual) {
return proxy(OptionalAssert.class, Optional.class, actual);
}

Expand Down Expand Up @@ -166,13 +166,13 @@ public OffsetDateTimeAssert then(OffsetDateTime actual) {
* Create assertion for {@link java.util.concurrent.CompletableFuture}.
*
* @param actual the actual value.
* @param <T> the type of the value contained in the {@link java.util.concurrent.CompletableFuture}.
* @param <RESULT> the type of the value contained in the {@link java.util.concurrent.CompletableFuture}.
*
* @return the created assertion object.
*/
@SuppressWarnings("unchecked")
@CheckReturnValue
public <T> CompletableFutureAssert<T> then(CompletableFuture<T> actual) {
public <RESULT> CompletableFutureAssert<RESULT> then(CompletableFuture<RESULT> actual) {
return proxy(CompletableFutureAssert.class, CompletableFuture.class, actual);
}

Expand Down
Expand Up @@ -37,12 +37,12 @@
/**
* Assertions for {@link CompletableFuture}.
*
* @param <T> type of the value contained in the {@link CompletableFuture}.
* @param <RESULT> type of the value contained in the {@link CompletableFuture}.
*/
public abstract class AbstractCompletableFutureAssert<SELF extends AbstractCompletableFutureAssert<SELF, T>, T> extends
AbstractAssert<SELF, CompletableFuture<T>> {
public abstract class AbstractCompletableFutureAssert<SELF extends AbstractCompletableFutureAssert<SELF, RESULT>, RESULT> extends
AbstractAssert<SELF, CompletableFuture<RESULT>> {

protected AbstractCompletableFutureAssert(CompletableFuture<T> actual, Class<?> selfType) {
protected AbstractCompletableFutureAssert(CompletableFuture<RESULT> actual, Class<?> selfType) {
super(actual, selfType);
}

Expand Down Expand Up @@ -219,10 +219,10 @@ public SELF isNotCompleted() {
*
* @return this assertion object.
*/
public SELF isCompletedWithValue(T expected) {
public SELF isCompletedWithValue(RESULT expected) {
isCompleted();

T actualResult = actual.join();
RESULT actualResult = actual.join();
if (!Objects.equals(actualResult, expected))
throw Failures.instance().failure(info, shouldBeEqual(actualResult, expected, info.representation()));

Expand All @@ -242,7 +242,7 @@ public SELF isCompletedWithValue(T expected) {
*
* @return this assertion object.
*/
public SELF isCompletedWithValueMatching(Predicate<? super T> predicate) {
public SELF isCompletedWithValueMatching(Predicate<? super RESULT> predicate) {
return isCompletedWithValueMatching(predicate, PredicateDescription.GIVEN);
}

Expand All @@ -264,14 +264,14 @@ public SELF isCompletedWithValueMatching(Predicate<? super T> predicate) {
*
* @return this assertion object.
*/
public SELF isCompletedWithValueMatching(Predicate<? super T> predicate, String description) {
public SELF isCompletedWithValueMatching(Predicate<? super RESULT> predicate, String description) {
return isCompletedWithValueMatching(predicate, new PredicateDescription(description));
}

private SELF isCompletedWithValueMatching(Predicate<? super T> predicate, PredicateDescription description) {
private SELF isCompletedWithValueMatching(Predicate<? super RESULT> predicate, PredicateDescription description) {
isCompleted();

T actualResult = actual.join();
RESULT actualResult = actual.join();
if (!predicate.test(actualResult))
throw Failures.instance().failure(info, shouldMatch(actualResult, predicate, description));

Expand Down
24 changes: 12 additions & 12 deletions src/main/java/org/assertj/core/api/AbstractOptionalAssert.java
Expand Up @@ -35,18 +35,18 @@
* Assertions for {@link java.util.Optional}.
*
* @param <SELF> the "self" type of this assertion class.
* @param <T> type of the value contained in the {@link java.util.Optional}.
* @param <VALUE> type of the value contained in the {@link java.util.Optional}.
*
* @author Jean-Christophe Gay
* @author Nicolai Parlog
* @author Grzegorz Piwowarek
*/
public abstract class AbstractOptionalAssert<SELF extends AbstractOptionalAssert<SELF, T>, T> extends
AbstractAssert<SELF, Optional<T>> {
public abstract class AbstractOptionalAssert<SELF extends AbstractOptionalAssert<SELF, VALUE>, VALUE> extends
AbstractAssert<SELF, Optional<VALUE>> {

private ComparisonStrategy optionalValueComparisonStrategy;

protected AbstractOptionalAssert(Optional<T> actual, Class<?> selfType) {
protected AbstractOptionalAssert(Optional<VALUE> actual, Class<?> selfType) {
super(actual, selfType);
this.optionalValueComparisonStrategy = StandardComparisonStrategy.instance();
}
Expand Down Expand Up @@ -128,7 +128,7 @@ public SELF isNotPresent() {
* @param expectedValue the expected value inside the {@link java.util.Optional}.
* @return this assertion object.
*/
public SELF contains(T expectedValue) {
public SELF contains(VALUE expectedValue) {
isNotNull();
checkNotNull(expectedValue);
if (!actual.isPresent()) throwAssertionError(shouldContain(expectedValue));
Expand Down Expand Up @@ -164,7 +164,7 @@ public SELF contains(T expectedValue) {
* @param requirement to further assert on the object contained inside the {@link java.util.Optional}.
* @return this assertion object.
*/
public SELF hasValueSatisfying(Consumer<T> requirement) {
public SELF hasValueSatisfying(Consumer<VALUE> requirement) {
assertValueIsPresent();
requirement.accept(actual.get());
return myself;
Expand Down Expand Up @@ -192,7 +192,7 @@ public SELF hasValueSatisfying(Consumer<T> requirement) {
* @throws AssertionError if the actual value does not satisfy the given condition.
* @since 3.6.0
*/
public SELF hasValueSatisfying(Condition<? super T> condition) {
public SELF hasValueSatisfying(Condition<? super VALUE> condition) {
assertValueIsPresent();
conditions.assertIs(info, actual.get(), condition);
return myself;
Expand All @@ -212,7 +212,7 @@ public SELF hasValueSatisfying(Condition<? super T> condition) {
* @param expectedValue the expected value inside the {@link java.util.Optional}.
* @return this assertion object.
*/
public SELF hasValue(T expectedValue) {
public SELF hasValue(VALUE expectedValue) {
return contains(expectedValue);
}

Expand Down Expand Up @@ -292,7 +292,7 @@ public SELF usingFieldByFieldValueComparator() {
* @return {@code this} assertion object.
*/
@CheckReturnValue
public SELF usingValueComparator(Comparator<? super T> customComparator) {
public SELF usingValueComparator(Comparator<? super VALUE> customComparator) {
optionalValueComparisonStrategy = new ComparatorBasedComparisonStrategy(customComparator);
return myself;
}
Expand Down Expand Up @@ -337,7 +337,7 @@ public SELF usingDefaultValueComparator() {
* @param expectedValue the expected value inside the {@link java.util.Optional}.
* @return this assertion object.
*/
public SELF containsSame(T expectedValue) {
public SELF containsSame(VALUE expectedValue) {
isNotNull();
checkNotNull(expectedValue);
if (!actual.isPresent()) throwAssertionError(shouldContain(expectedValue));
Expand Down Expand Up @@ -373,7 +373,7 @@ public SELF containsSame(T expectedValue) {
* @since 3.6.0
*/
@CheckReturnValue
public <U> AbstractOptionalAssert<?, U> flatMap(Function<? super T, Optional<U>> mapper) {
public <U> AbstractOptionalAssert<?, U> flatMap(Function<? super VALUE, Optional<U>> mapper) {
isNotNull();
return assertThat(actual.flatMap(mapper));
}
Expand All @@ -400,7 +400,7 @@ public <U> AbstractOptionalAssert<?, U> flatMap(Function<? super T, Optional<U>>
* @since 3.6.0
*/
@CheckReturnValue
public <U> AbstractOptionalAssert<?, U> map(Function<? super T, ? extends U> mapper) {
public <U> AbstractOptionalAssert<?, U> map(Function<? super VALUE, ? extends U> mapper) {
isNotNull();
return assertThat(actual.map(mapper));
}
Expand Down
Expand Up @@ -50,13 +50,13 @@ public PathAssert assertThat(Path actual) {
* Create assertion for {@link java.util.Optional}.
*
* @param actual the actual value.
* @param <T> the type of the value contained in the {@link java.util.Optional}.
* @param <VALUE> the type of the value contained in the {@link java.util.Optional}.
*
* @return the created assertion object.
*/
@SuppressWarnings("unchecked")
@CheckReturnValue
public <T> OptionalAssert<T> assertThat(Optional<T> actual) {
public <VALUE> OptionalAssert<VALUE> assertThat(Optional<VALUE> actual) {
return proxy(OptionalAssert.class, Optional.class, actual);
}

Expand Down Expand Up @@ -166,13 +166,13 @@ public OffsetDateTimeAssert assertThat(OffsetDateTime actual) {
* Create assertion for {@link java.util.concurrent.CompletableFuture}.
*
* @param actual the actual value.
* @param <T> the type of the value contained in the {@link java.util.concurrent.CompletableFuture}.
* @param <RESULT> the type of the value contained in the {@link java.util.concurrent.CompletableFuture}.
*
* @return the created assertion object.
*/
@SuppressWarnings("unchecked")
@CheckReturnValue
public <T> CompletableFutureAssert<T> assertThat(CompletableFuture<T> actual) {
public <RESULT> CompletableFutureAssert<RESULT> assertThat(CompletableFuture<RESULT> actual) {
return proxy(CompletableFutureAssert.class, CompletableFuture.class, actual);
}

Expand Down
8 changes: 4 additions & 4 deletions src/main/java/org/assertj/core/api/Assertions.java
Expand Up @@ -182,25 +182,25 @@ public static DoublePredicateAssert assertThat(DoublePredicate actual) {
* Create assertion for {@link java.util.concurrent.CompletableFuture}.
*
* @param actual the actual value.
* @param <T> the type of the value contained in the {@link java.util.concurrent.CompletableFuture}.
* @param <RESULT> the type of the value contained in the {@link java.util.concurrent.CompletableFuture}.
*
* @return the created assertion object.
*/
@CheckReturnValue
public static <T> CompletableFutureAssert<T> assertThat(CompletableFuture<T> actual) {
public static <RESULT> CompletableFutureAssert<RESULT> assertThat(CompletableFuture<RESULT> actual) {
return AssertionsForClassTypes.assertThat(actual);
}

/**
* Create assertion for {@link java.util.Optional}.
*
* @param actual the actual value.
* @param <T> the type of the value contained in the {@link java.util.Optional}.
* @param <VALUE> the type of the value contained in the {@link java.util.Optional}.
*
* @return the created assertion object.
*/
@CheckReturnValue
public static <T> OptionalAssert<T> assertThat(Optional<T> actual) {
public static <VALUE> OptionalAssert<VALUE> assertThat(Optional<VALUE> actual) {
return AssertionsForClassTypes.assertThat(actual);
}

Expand Down
12 changes: 6 additions & 6 deletions src/main/java/org/assertj/core/api/AssertionsForClassTypes.java
Expand Up @@ -60,7 +60,7 @@

/**
* Java 8 is picky when choosing the right <code>assertThat</code> method if the object under test is generic and bounded,
* for example if foo is instance of T that extends Exception, java 8 will complain that it can't resolve
* for example if foo is instance of T that extends Exception, java 8 will complain that it can't resolve
* the proper <code>assertThat</code> method (normally <code>assertThat(Throwable)</code> as foo might implement an interface like List,
* if that occurred <code>assertThat(List)</code> would also be a possible choice - thus confusing java 8.
* <p>
Expand All @@ -73,25 +73,25 @@ public class AssertionsForClassTypes {
* Create assertion for {@link java.util.concurrent.CompletableFuture}.
*
* @param actual the actual value.
* @param <T> the type of the value contained in the {@link java.util.concurrent.CompletableFuture}.
* @param <RESULT> the type of the value contained in the {@link java.util.concurrent.CompletableFuture}.
*
* @return the created assertion object.
*/
@CheckReturnValue
public static <T> CompletableFutureAssert<T> assertThat(CompletableFuture<T> actual) {
public static <RESULT> CompletableFutureAssert<RESULT> assertThat(CompletableFuture<RESULT> actual) {
return new CompletableFutureAssert<>(actual);
}

/**
* Create assertion for {@link java.util.Optional}.
*
* @param actual the actual value.
* @param <T> the type of the value contained in the {@link java.util.Optional}.
* @param <VALUE> the type of the value contained in the {@link java.util.Optional}.
*
* @return the created assertion object.
*/
@CheckReturnValue
public static <T> OptionalAssert<T> assertThat(Optional<T> actual) {
public static <VALUE> OptionalAssert<VALUE> assertThat(Optional<VALUE> actual) {
return new OptionalAssert<>(actual);
}

Expand Down Expand Up @@ -606,7 +606,7 @@ public static AbstractLocalDateAssert<?> assertThat(LocalDate localDate) {
}

/**
* Entry point to check that an exception of type T is thrown by a given {@code throwingCallable}
* Entry point to check that an exception of type T is thrown by a given {@code throwingCallable}
* which allows to chain assertions on the thrown exception.
* <p>
* Example:
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/org/assertj/core/api/BDDAssertions.java
Expand Up @@ -143,12 +143,12 @@ public static DoublePredicateAssert then(DoublePredicate actual) {
* Create assertion for {@link java.util.Optional}.
*
* @param optional the actual value.
* @param <T> the type of the value contained in the {@link java.util.Optional}.
* @param <VALUE> the type of the value contained in the {@link java.util.Optional}.
*
* @return the created assertion object.
*/
@CheckReturnValue
public static <T> OptionalAssert<T> then(Optional<T> optional) {
public static <VALUE> OptionalAssert<VALUE> then(Optional<VALUE> optional) {
return assertThat(optional);
}

Expand Down Expand Up @@ -1103,12 +1103,12 @@ public static AbstractOffsetDateTimeAssert<?> then(OffsetDateTime actual) {
* Create assertion for {@link java.util.concurrent.CompletableFuture}.
*
* @param future the actual value.
* @param <T> the type of the value contained in the {@link java.util.concurrent.CompletableFuture}.
* @param <RESULT> the type of the value contained in the {@link java.util.concurrent.CompletableFuture}.
*
* @return the created assertion object.
*/
@CheckReturnValue
public static <T> CompletableFutureAssert<T> then(CompletableFuture<T> future) {
public static <RESULT> CompletableFutureAssert<RESULT> then(CompletableFuture<RESULT> future) {
return assertThat(future);
}

Expand Down
Expand Up @@ -17,11 +17,11 @@
/**
* Assertions for {@link CompletableFuture}.
*
* @param <T> type of the value contained in the {@link CompletableFuture}.
* @param <RESULT> type of the value contained in the {@link CompletableFuture}.
*/
public class CompletableFutureAssert<T> extends AbstractCompletableFutureAssert<CompletableFutureAssert<T>, T> {
public class CompletableFutureAssert<RESULT> extends AbstractCompletableFutureAssert<CompletableFutureAssert<RESULT>, RESULT> {

protected CompletableFutureAssert(CompletableFuture<T> actual) {
protected CompletableFutureAssert(CompletableFuture<RESULT> actual) {
super(actual, CompletableFutureAssert.class);
}

Expand Down
6 changes: 3 additions & 3 deletions src/main/java/org/assertj/core/api/OptionalAssert.java
Expand Up @@ -17,12 +17,12 @@
/**
* Assertions for {@link java.util.Optional}.
*
* @param <T> type of the value contained in the {@link java.util.Optional}.
* @param <VALUE> type of the value contained in the {@link java.util.Optional}.
* @author Jean-Christophe Gay
*/
public class OptionalAssert<T> extends AbstractOptionalAssert<OptionalAssert<T>, T> {
public class OptionalAssert<VALUE> extends AbstractOptionalAssert<OptionalAssert<VALUE>, VALUE> {

protected OptionalAssert(Optional<T> actual) {
protected OptionalAssert(Optional<VALUE> actual) {
super(actual, OptionalAssert.class);
}

Expand Down
6 changes: 3 additions & 3 deletions src/main/java/org/assertj/core/api/WithAssertions.java
Expand Up @@ -840,14 +840,14 @@ default AbstractZonedDateTimeAssert<?> assertThat(final ZonedDateTime actual) {
/**
* Delegate call to {@link org.assertj.core.api.Assertions#assertThat(CompletableFuture)}
*/
default <T> CompletableFutureAssert<T> assertThat(final CompletableFuture<T> future) {
default <RESULT> CompletableFutureAssert<RESULT> assertThat(final CompletableFuture<RESULT> future) {
return Assertions.assertThat(future);
}

/**
* Delegate call to {@link org.assertj.core.api.Assertions#assertThat(Optional)}
*/
default <T> OptionalAssert<T> assertThat(final Optional<T> optional) {
default <VALUE> OptionalAssert<VALUE> assertThat(final Optional<VALUE> optional) {
return Assertions.assertThat(optional);
}

Expand Down Expand Up @@ -969,7 +969,7 @@ default Throwable catchThrowable(final ThrowingCallable shouldRaiseThrowable) {
}

/**
* Entry point to check that an exception of type T is thrown by a given {@code throwingCallable}
* Entry point to check that an exception of type T is thrown by a given {@code throwingCallable}
* which allows to chain assertions on the thrown exception.
* <p>
* Example:
Expand Down
Expand Up @@ -32,10 +32,10 @@ private OptionalShouldBeEmpty(Class<?> optionalClass, Object optionalValue) {
* Indicates that the provided {@link java.util.Optional} should be empty.
*
* @param optional the actual {@link Optional} to test.
* @param <T> the type of the value contained in the {@link java.util.Optional}.
* @param <VALUE> the type of the value contained in the {@link java.util.Optional}.
* @return a error message factory.
*/
public static <T> OptionalShouldBeEmpty shouldBeEmpty(Optional<T> optional) {
public static <VALUE> OptionalShouldBeEmpty shouldBeEmpty(Optional<VALUE> optional) {
return new OptionalShouldBeEmpty(optional.getClass(), optional.get());
}

Expand Down

0 comments on commit 5316f8c

Please sign in to comment.