Skip to content

Commit

Permalink
Minor code cleanup (closes #1972)
Browse files Browse the repository at this point in the history
  • Loading branch information
dfa1 authored and scordio committed Aug 27, 2020
1 parent 92f928e commit 8a9712c
Show file tree
Hide file tree
Showing 10 changed files with 16 additions and 15 deletions.
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
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 @@ -24,7 +24,7 @@

public class IgnoringFieldsComparator extends FieldByFieldComparator {

private String[] fields;
private final String[] fields;

public IgnoringFieldsComparator(Map<String, Comparator<?>> comparatorByPropertyOrField,
TypeComparators comparatorByType, String... fields) {
Expand All @@ -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 @@ -27,7 +27,7 @@

public class OnFieldsComparator extends FieldByFieldComparator {

private String[] fields;
private final String[] fields;

public OnFieldsComparator(Map<String, Comparator<?>> comparatorByPropertyOrField,
TypeComparators comparatorByType, String... fields) {
Expand All @@ -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 8a9712c

Please sign in to comment.