Use final, remove redundant call to super(), use valueOf(), lambdas.

This commit is contained in:
Gary Gregory 2022-06-15 15:25:10 -04:00
parent 6cdaa83614
commit 1967613528
10 changed files with 18 additions and 20 deletions

View File

@ -1269,7 +1269,7 @@ public class ClassUtilsTest {
assertEquals(Inner.DeeplyNested.class, ClassUtils.getClass("org.apache.commons.lang3.ClassUtilsTest$Inner$DeeplyNested", true));
assertEquals(Inner.DeeplyNested.class, ClassUtils.getClass("org.apache.commons.lang3.ClassUtilsTest$Inner.DeeplyNested", true));
//
ClassLoader classLoader = Inner.DeeplyNested.class.getClassLoader();
final ClassLoader classLoader = Inner.DeeplyNested.class.getClassLoader();
assertEquals(Inner.DeeplyNested.class, ClassUtils.getClass(classLoader, "org.apache.commons.lang3.ClassUtilsTest.Inner.DeeplyNested"));
assertEquals(Inner.DeeplyNested.class, ClassUtils.getClass(classLoader, "org.apache.commons.lang3.ClassUtilsTest.Inner$DeeplyNested"));
assertEquals(Inner.DeeplyNested.class, ClassUtils.getClass(classLoader, "org.apache.commons.lang3.ClassUtilsTest$Inner$DeeplyNested"));

View File

@ -437,7 +437,7 @@ public class ConversionTest {
@ParameterizedTest
@ValueSource(ints = {-1, 8, 99})
public void binaryBeMsb0ToHexDigitPosOutsideArray(int index) {
public void binaryBeMsb0ToHexDigitPosOutsideArray(final int index) {
assertThrows(IndexOutOfBoundsException.class,
() -> Conversion.binaryBeMsb0ToHexDigit(new boolean[8], index));
}

View File

@ -580,7 +580,7 @@ enum Month {
private final int id;
Month(int id) {
Month(final int id) {
this.id = id;
}

View File

@ -356,9 +356,9 @@ public class DiffBuilderTest {
@Test
public void testObjectsNotSameButEqual() {
final TypeTestClass left = new TypeTestClass();
left.objectField = new Integer(1);
left.objectField = Integer.valueOf(1000);
final TypeTestClass right = new TypeTestClass();
right.objectField = new Integer(1);
right.objectField = Integer.valueOf(1000);
assertNotSame(left.objectField, right.objectField);
assertEquals(left.objectField, right.objectField);

View File

@ -22,18 +22,17 @@ public class CustomCheckedException extends Exception {
private static final long serialVersionUID = 1L;
public CustomCheckedException() {
super();
}
public CustomCheckedException(String message) {
public CustomCheckedException(final String message) {
super(message);
}
public CustomCheckedException(String message, Throwable cause) {
public CustomCheckedException(final String message, final Throwable cause) {
super(message, cause);
}
public CustomCheckedException(Throwable cause) {
public CustomCheckedException(final Throwable cause) {
super(cause);
}

View File

@ -22,18 +22,17 @@ public class CustomUncheckedException extends RuntimeException {
private static final long serialVersionUID = 1L;
public CustomUncheckedException() {
super();
}
public CustomUncheckedException(String message) {
public CustomUncheckedException(final String message) {
super(message);
}
public CustomUncheckedException(String message, Throwable cause) {
public CustomUncheckedException(final String message, final Throwable cause) {
super(message, cause);
}
public CustomUncheckedException(Throwable cause) {
public CustomUncheckedException(final Throwable cause) {
super(cause);
}

View File

@ -34,11 +34,11 @@ public class ConsumersTest {
public void testNop() {
Stream.of("").forEach(Consumers.nop());
//
Consumer<?> c1 = Consumers.nop();
final Consumer<?> c1 = Consumers.nop();
c1.accept(null);
Consumer<Object> c2 = Consumers.nop();
final Consumer<Object> c2 = Consumers.nop();
c2.accept(null);
Consumer<String> c3 = Consumers.nop();
final Consumer<String> c3 = Consumers.nop();
c3.accept(null);
//
Consumers.nop().accept(null);

View File

@ -143,7 +143,7 @@ public class StreamsTest {
assertEquals(2, Streams.instancesOf(String.class, Arrays.asList(null, "A", null, "B", null)).collect(Collectors.toList()).size());
assertEquals(0, Streams.instancesOf(String.class, Arrays.asList(null, null)).collect(Collectors.toList()).size());
//
List<Object> objects = Arrays.asList("A", "B");
final List<Object> objects = Arrays.asList("A", "B");
assertEquals(2, Streams.instancesOf(String.class, objects).collect(Collectors.toList()).size());
}

View File

@ -152,8 +152,8 @@ public class DateFormatUtilsTest {
@Test
public void testLANG1462() {
TimeZone timeZone = TimeZone.getTimeZone("GMT-3");
Calendar calendar = createJuneTestDate(timeZone);
final TimeZone timeZone = TimeZone.getTimeZone("GMT-3");
final Calendar calendar = createJuneTestDate(timeZone);
assertEquals("20030608101112", DateFormatUtils.format(calendar, "yyyyMMddHHmmss"));
calendar.setTimeZone(TimeZone.getTimeZone("JST"));
assertEquals("20030608221112", DateFormatUtils.format(calendar, "yyyyMMddHHmmss"));

View File

@ -76,7 +76,7 @@ public class DurationUtilsTest {
@Test
public void testOfRunnble() {
assertTrue(DurationUtils.of(() -> testSince()).compareTo(Duration.ZERO) >= 0);
assertTrue(DurationUtils.of(this::testSince).compareTo(Duration.ZERO) >= 0);
}
@Test