Skip to content

Commit

Permalink
minor code cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
dfa1 committed Aug 23, 2020
1 parent 70d6073 commit b5a8b2c
Show file tree
Hide file tree
Showing 12 changed files with 17 additions and 16 deletions.
4 changes: 2 additions & 2 deletions src/main/java/org/assertj/core/api/AbstractDateAssert.java
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ public SELF isIn(String... datesAsString) {
for (int i = 0; i < datesAsString.length; i++) {
dates[i] = parse(datesAsString[i]);
}
return isIn((Object[]) dates);
return isIn(dates);
}

/**
Expand Down Expand Up @@ -654,7 +654,7 @@ public SELF isNotIn(String... datesAsString) {
for (int i = 0; i < datesAsString.length; i++) {
dates[i] = parse(datesAsString[i]);
}
return isNotIn((Object[]) dates);
return isNotIn(dates);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/assertj/core/api/AbstractDoubleAssert.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@
public abstract class AbstractDoubleAssert<SELF extends AbstractDoubleAssert<SELF>> extends
AbstractComparableAssert<SELF, Double> implements FloatingPointNumberAssert<SELF, Double> {

private static final Double NEGATIVE_ZERO = Double.valueOf(-0.0);
private static final Double NEGATIVE_ZERO = -0.0;

@VisibleForTesting
Doubles doubles = Doubles.instance();

private boolean isPrimitive;
private final boolean isPrimitive;

public AbstractDoubleAssert(Double actual, Class<?> selfType) {
super(actual, selfType);
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/assertj/core/api/AbstractFloatAssert.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@
public abstract class AbstractFloatAssert<SELF extends AbstractFloatAssert<SELF>> extends AbstractComparableAssert<SELF, Float>
implements FloatingPointNumberAssert<SELF, Float> {

private static final Float NEGATIVE_ZERO = Float.valueOf(-0.0f);
private static final Float NEGATIVE_ZERO = -0.0f;

@VisibleForTesting
Floats floats = Floats.instance();

private boolean isPrimitive;
private final boolean isPrimitive;

public AbstractFloatAssert(Float actual, Class<?> selfType) {
super(actual, selfType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2826,7 +2826,7 @@ private ELEMENT_ASSERT internalElement(int index) {
isNotEmpty();
assertThat(index).describedAs(navigationDescription("check index validity"))
.isBetween(0, IterableUtil.sizeOf(actual) - 1);
ELEMENT elementAtIndex = null;
ELEMENT elementAtIndex;
if (actual instanceof List) {
@SuppressWarnings("unchecked")
List<? extends ELEMENT> list = (List<? extends ELEMENT>) actual;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/assertj/core/api/AbstractMapAssert.java
Original file line number Diff line number Diff line change
Expand Up @@ -1609,7 +1609,7 @@ public AbstractListAssert<?, List<?>, Object, ObjectAssert<Object>> extracting(O
public AbstractListAssert<?, List<? extends V>, V, ObjectAssert<V>> extractingByKeys(@SuppressWarnings("unchecked") K... keys) {
isNotNull();
List<V> extractedValues = Stream.of(keys).map(actual::get).collect(toList());
String extractedPropertiesOrFieldsDescription = extractedDescriptionOf((Object[]) keys);
String extractedPropertiesOrFieldsDescription = extractedDescriptionOf(keys);
String description = mostRelevantDescription(info.description(), extractedPropertiesOrFieldsDescription);
return newListAssertInstance(extractedValues).withAssertionState(myself).as(description);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import static org.assertj.core.util.Strings.quote;

import java.util.Arrays;
import java.util.Objects;

import org.assertj.core.description.Description;
import org.assertj.core.presentation.Representation;
Expand Down Expand Up @@ -85,7 +86,7 @@ public boolean equals(Object obj) {
if (obj == null) return false;
if (getClass() != obj.getClass()) return false;
UnquotedString other = (UnquotedString) obj;
return string == null ? other.string == null : string.equals(other.string);
return Objects.equals(string, other.string);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/assertj/core/internal/Comparables.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public boolean equals(Object obj) {
if (comparisonStrategy == null) {
if (other.comparisonStrategy != null) return false;
} else if (!comparisonStrategy.equals(other.comparisonStrategy)) return false;
return failures == null ? other.failures == null : failures.equals(other.failures);
return java.util.Objects.equals(failures, other.failures);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public FieldByFieldComparator(Map<String, Comparator<?>> comparatorsByPropertyOr
}

public FieldByFieldComparator() {
this(new TreeMap<String, Comparator<?>>(), defaultTypeComparators());
this(new TreeMap<>(), defaultTypeComparators());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public IgnoringFieldsComparator(Map<String, Comparator<?>> comparatorByPropertyO
}

public IgnoringFieldsComparator(String... fields) {
this(new HashMap<String, Comparator<?>>(), defaultTypeComparators(), fields);
this(new HashMap<>(), defaultTypeComparators(), fields);
}

@VisibleForTesting
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public OnFieldsComparator(Map<String, Comparator<?>> comparatorByPropertyOrField
}

public OnFieldsComparator(String... fields) {
this(new HashMap<String, Comparator<?>>(), defaultTypeComparators(), fields);
this(new HashMap<>(), defaultTypeComparators(), fields);
}

@VisibleForTesting
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/assertj/core/util/Throwables.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public static List<String> describeErrors(List<? extends Throwable> errors) {
public static void appendStackTraceInCurrentThreadToThrowable(Throwable t, String methodToStartFrom) {
List<StackTraceElement> stackTrace = newArrayList(t.getStackTrace());
stackTrace.addAll(stackTraceInCurrentThread(methodToStartFrom));
t.setStackTrace(stackTrace.toArray(new StackTraceElement[stackTrace.size()]));
t.setStackTrace(stackTrace.toArray(new StackTraceElement[0]));
}

private static List<StackTraceElement> stackTraceInCurrentThread(String methodToStartFrom) {
Expand Down Expand Up @@ -130,7 +130,7 @@ public static void removeAssertJRelatedElementsFromStackTrace(Throwable throwabl
}
previous = element;
}
StackTraceElement[] newStackTrace = filtered.toArray(new StackTraceElement[filtered.size()]);
StackTraceElement[] newStackTrace = filtered.toArray(new StackTraceElement[0]);
throwable.setStackTrace(newStackTrace);
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/assertj/core/util/diff/DiffUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public class DiffUtils {
* revised sequences. Never {@code null}.
*/
public static <T> Patch<T> diff(List<T> original, List<T> revised) {
return DiffUtils.diff(original, revised, new MyersDiff<T>());
return DiffUtils.diff(original, revised, new MyersDiff<>());
}

/**
Expand Down

0 comments on commit b5a8b2c

Please sign in to comment.