diff options
author | Benedikt Ritter <britter@apache.org> | 2017-06-06 16:11:45 +0200 |
---|---|---|
committer | Benedikt Ritter <britter@apache.org> | 2017-06-06 16:11:45 +0200 |
commit | 3a818ed6a833f083a2db9bb6804c1bdb43b9b0ec (patch) | |
tree | 680a77d6103b45639dcb878fc4c059db6b282c06 | |
parent | 8a8b8ec8d244b18eeaf651d0ea6e84db579e7d92 (diff) | |
download | apache-commons-lang-3a818ed6a833f083a2db9bb6804c1bdb43b9b0ec.tar.gz |
Prevent redundant modifiers
54 files changed, 237 insertions, 247 deletions
diff --git a/checkstyle-suppressions.xml b/checkstyle-suppressions.xml index 359c8ddfe..e4746a570 100644 --- a/checkstyle-suppressions.xml +++ b/checkstyle-suppressions.xml @@ -21,4 +21,5 @@ limitations under the License. <suppress checks="JavadocPackage" files=".*[/\\]test[/\\].*"/> <!-- exclude generated JMH classes from all checks --> <suppress checks="[a-zA-Z0-9]*" files=".*[/\\]generated-test-sources[/\\].*"/> + <suppress checks="RedundantModifier" files="ConstructorUtilsTest" lines="0-99999"/> </suppressions> diff --git a/checkstyle.xml b/checkstyle.xml index 2b76eb688..7d3d3a653 100644 --- a/checkstyle.xml +++ b/checkstyle.xml @@ -47,6 +47,7 @@ limitations under the License. <property name="scope" value="public" /> </module> <module name="ModifierOrder"/> + <module name="RedundantModifier"/> <module name="UpperEll" /> </module> </module> diff --git a/src/main/java/org/apache/commons/lang3/ArchUtils.java b/src/main/java/org/apache/commons/lang3/ArchUtils.java index c7e28d9fb..6895b68ef 100644 --- a/src/main/java/org/apache/commons/lang3/ArchUtils.java +++ b/src/main/java/org/apache/commons/lang3/ArchUtils.java @@ -39,7 +39,7 @@ public class ArchUtils { init(); } - private static final void init() { + private static void init() { init_X86_32Bit(); init_X86_64Bit(); init_IA64_32Bit(); @@ -48,32 +48,32 @@ public class ArchUtils { init_PPC_64Bit(); } - private static final void init_X86_32Bit() { + private static void init_X86_32Bit() { Processor processor = new Processor(Processor.Arch.BIT_32, Processor.Type.X86); addProcessors(processor, "x86", "i386", "i486", "i586", "i686", "pentium"); } - private static final void init_X86_64Bit() { + private static void init_X86_64Bit() { Processor processor = new Processor(Processor.Arch.BIT_64, Processor.Type.X86); addProcessors(processor, "x86_64", "amd64", "em64t", "universal"); } - private static final void init_IA64_32Bit() { + private static void init_IA64_32Bit() { Processor processor = new Processor(Processor.Arch.BIT_32, Processor.Type.IA_64); addProcessors(processor, "ia64_32", "ia64n"); } - private static final void init_IA64_64Bit() { + private static void init_IA64_64Bit() { Processor processor = new Processor(Processor.Arch.BIT_64, Processor.Type.IA_64); addProcessors(processor, "ia64", "ia64w"); } - private static final void init_PPC_32Bit() { + private static void init_PPC_32Bit() { Processor processor = new Processor(Processor.Arch.BIT_32, Processor.Type.PPC); addProcessors(processor, "ppc", "power", "powerpc", "power_pc", "power_rs"); } - private static final void init_PPC_64Bit() { + private static void init_PPC_64Bit() { Processor processor = new Processor(Processor.Arch.BIT_64, Processor.Type.PPC); addProcessors(processor, "ppc64", "power64", "powerpc64", "power_pc64", "power_rs64"); } @@ -85,7 +85,7 @@ public class ArchUtils { * @param processor The {@link Processor} to add. * @throws IllegalStateException If the key already exists. */ - private static final void addProcessor(String key, Processor processor) throws IllegalStateException { + private static void addProcessor(String key, Processor processor) throws IllegalStateException { if (!ARCH_TO_PROCESSOR.containsKey(key)) { ARCH_TO_PROCESSOR.put(key, processor); } else { @@ -101,7 +101,7 @@ public class ArchUtils { * @param processor The {@link Processor} to add. * @throws IllegalStateException If the key already exists. */ - private static final void addProcessors(Processor processor, String... keys) throws IllegalStateException { + private static void addProcessors(Processor processor, String... keys) throws IllegalStateException { for (String key : keys) { addProcessor(key, processor); } @@ -117,7 +117,7 @@ public class ArchUtils { * * @return A {@link Processor} when supported, else <code>null</code>. */ - public static final Processor getProcessor() { + public static Processor getProcessor() { return getProcessor(SystemUtils.OS_ARCH); } @@ -128,7 +128,7 @@ public class ArchUtils { * @param value A {@link String} like a value returned by the os.arch System Property. * @return A {@link Processor} when it exists, else <code>null</code>. */ - public static final Processor getProcessor(String value) { + public static Processor getProcessor(String value) { return ARCH_TO_PROCESSOR.get(value); } diff --git a/src/main/java/org/apache/commons/lang3/EnumUtils.java b/src/main/java/org/apache/commons/lang3/EnumUtils.java index 84e93e221..ab062ad05 100644 --- a/src/main/java/org/apache/commons/lang3/EnumUtils.java +++ b/src/main/java/org/apache/commons/lang3/EnumUtils.java @@ -201,7 +201,7 @@ public class EnumUtils { @SafeVarargs public static <E extends Enum<E>> long generateBitVector(final Class<E> enumClass, final E... values) { Validate.noNullElements(values); - return generateBitVector(enumClass, Arrays.<E> asList(values)); + return generateBitVector(enumClass, Arrays.asList(values)); } /** diff --git a/src/main/java/org/apache/commons/lang3/SerializationUtils.java b/src/main/java/org/apache/commons/lang3/SerializationUtils.java index 5fca908a4..e62827a57 100644 --- a/src/main/java/org/apache/commons/lang3/SerializationUtils.java +++ b/src/main/java/org/apache/commons/lang3/SerializationUtils.java @@ -220,7 +220,7 @@ public class SerializationUtils { */ public static <T> T deserialize(final byte[] objectData) { Validate.isTrue(objectData != null, "The byte[] must not be null"); - return SerializationUtils.<T>deserialize(new ByteArrayInputStream(objectData)); + return SerializationUtils.deserialize(new ByteArrayInputStream(objectData)); } /** @@ -261,7 +261,7 @@ public class SerializationUtils { * @throws IOException if an I/O error occurs while reading stream header. * @see java.io.ObjectInputStream */ - public ClassLoaderAwareObjectInputStream(final InputStream in, final ClassLoader classLoader) throws IOException { + ClassLoaderAwareObjectInputStream(final InputStream in, final ClassLoader classLoader) throws IOException { super(in); this.classLoader = classLoader; } diff --git a/src/main/java/org/apache/commons/lang3/builder/IDKey.java b/src/main/java/org/apache/commons/lang3/builder/IDKey.java index 8eab0ea6c..426848a31 100644 --- a/src/main/java/org/apache/commons/lang3/builder/IDKey.java +++ b/src/main/java/org/apache/commons/lang3/builder/IDKey.java @@ -34,7 +34,7 @@ final class IDKey { * Constructor for IDKey * @param _value The value */ - public IDKey(final Object _value) { + IDKey(final Object _value) { // This is the Object hash code id = System.identityHashCode(_value); // There have been some cases (LANG-459) that return the diff --git a/src/main/java/org/apache/commons/lang3/builder/ReflectionDiffBuilder.java b/src/main/java/org/apache/commons/lang3/builder/ReflectionDiffBuilder.java index 887368ee4..e45360f10 100644 --- a/src/main/java/org/apache/commons/lang3/builder/ReflectionDiffBuilder.java +++ b/src/main/java/org/apache/commons/lang3/builder/ReflectionDiffBuilder.java @@ -131,10 +131,7 @@ public class ReflectionDiffBuilder implements Builder<DiffResult> { if (Modifier.isTransient(field.getModifiers())) { return false; } - if (Modifier.isStatic(field.getModifiers())) { - return false; - } - return true; + return !Modifier.isStatic(field.getModifiers()); } } diff --git a/src/main/java/org/apache/commons/lang3/builder/ReflectionToStringBuilder.java b/src/main/java/org/apache/commons/lang3/builder/ReflectionToStringBuilder.java index 3716bc17e..12e410df9 100644 --- a/src/main/java/org/apache/commons/lang3/builder/ReflectionToStringBuilder.java +++ b/src/main/java/org/apache/commons/lang3/builder/ReflectionToStringBuilder.java @@ -608,10 +608,7 @@ public class ReflectionToStringBuilder extends ToStringBuilder { // Reject fields from the getExcludeFieldNames list. return false; } - if(field.isAnnotationPresent(ToStringExclude.class)) { - return false; - } - return true; + return !field.isAnnotationPresent(ToStringExclude.class); } /** diff --git a/src/main/java/org/apache/commons/lang3/concurrent/AbstractCircuitBreaker.java b/src/main/java/org/apache/commons/lang3/concurrent/AbstractCircuitBreaker.java index 6eeade070..010792475 100644 --- a/src/main/java/org/apache/commons/lang3/concurrent/AbstractCircuitBreaker.java +++ b/src/main/java/org/apache/commons/lang3/concurrent/AbstractCircuitBreaker.java @@ -138,7 +138,7 @@ public abstract class AbstractCircuitBreaker<T> implements CircuitBreaker<T> { * transitions. This is done to avoid complex if-conditions in the code of * {@code CircuitBreaker}. */ - protected static enum State { + protected enum State { CLOSED { /** * {@inheritDoc} diff --git a/src/main/java/org/apache/commons/lang3/concurrent/BackgroundInitializer.java b/src/main/java/org/apache/commons/lang3/concurrent/BackgroundInitializer.java index 25e5625a8..d424c2159 100644 --- a/src/main/java/org/apache/commons/lang3/concurrent/BackgroundInitializer.java +++ b/src/main/java/org/apache/commons/lang3/concurrent/BackgroundInitializer.java @@ -310,7 +310,7 @@ public abstract class BackgroundInitializer<T> implements * * @param exec the {@code ExecutorService} */ - public InitializationTask(final ExecutorService exec) { + InitializationTask(final ExecutorService exec) { execFinally = exec; } diff --git a/src/main/java/org/apache/commons/lang3/concurrent/EventCountCircuitBreaker.java b/src/main/java/org/apache/commons/lang3/concurrent/EventCountCircuitBreaker.java index d33ff4868..1cc9eeb7a 100644 --- a/src/main/java/org/apache/commons/lang3/concurrent/EventCountCircuitBreaker.java +++ b/src/main/java/org/apache/commons/lang3/concurrent/EventCountCircuitBreaker.java @@ -440,7 +440,7 @@ public class EventCountCircuitBreaker extends AbstractCircuitBreaker<Integer> { * @param count the current count value * @param intervalStart the start time of the check interval */ - public CheckIntervalData(final int count, final long intervalStart) { + CheckIntervalData(final int count, final long intervalStart) { eventCount = count; checkIntervalStart = intervalStart; } diff --git a/src/main/java/org/apache/commons/lang3/reflect/TypeUtils.java b/src/main/java/org/apache/commons/lang3/reflect/TypeUtils.java index 3f568d1d6..54c810d04 100644 --- a/src/main/java/org/apache/commons/lang3/reflect/TypeUtils.java +++ b/src/main/java/org/apache/commons/lang3/reflect/TypeUtils.java @@ -1365,7 +1365,7 @@ public class TypeUtils { */ public static Type unrollVariables(Map<TypeVariable<?>, Type> typeArguments, final Type type) { if (typeArguments == null) { - typeArguments = Collections.<TypeVariable<?>, Type> emptyMap(); + typeArguments = Collections.emptyMap(); } if (containsTypeVariables(type)) { if (type instanceof TypeVariable<?>) { @@ -1732,7 +1732,7 @@ public class TypeUtils { * @since 3.2 */ public static <T> Typed<T> wrap(final Class<T> type) { - return TypeUtils.<T> wrap((Type) type); + return TypeUtils.wrap((Type) type); } /** diff --git a/src/main/java/org/apache/commons/lang3/text/ExtendedMessageFormat.java b/src/main/java/org/apache/commons/lang3/text/ExtendedMessageFormat.java index 6c9948b37..573b013c4 100644 --- a/src/main/java/org/apache/commons/lang3/text/ExtendedMessageFormat.java +++ b/src/main/java/org/apache/commons/lang3/text/ExtendedMessageFormat.java @@ -280,10 +280,7 @@ public class ExtendedMessageFormat extends MessageFormat { if (ObjectUtils.notEqual(toPattern, rhs.toPattern)) { return false; } - if (ObjectUtils.notEqual(registry, rhs.registry)) { - return false; - } - return true; + return !ObjectUtils.notEqual(registry, rhs.registry); } /** diff --git a/src/main/java/org/apache/commons/lang3/text/translate/NumericEntityUnescaper.java b/src/main/java/org/apache/commons/lang3/text/translate/NumericEntityUnescaper.java index d01a42041..71209ad2d 100644 --- a/src/main/java/org/apache/commons/lang3/text/translate/NumericEntityUnescaper.java +++ b/src/main/java/org/apache/commons/lang3/text/translate/NumericEntityUnescaper.java @@ -35,7 +35,7 @@ import java.util.EnumSet; @Deprecated public class NumericEntityUnescaper extends CharSequenceTranslator { - public static enum OPTION { semiColonRequired, semiColonOptional, errorIfNoSemiColon } + public enum OPTION { semiColonRequired, semiColonOptional, errorIfNoSemiColon } // TODO?: Create an OptionsSet class to hide some of the conditional logic below private final EnumSet<OPTION> options; @@ -71,7 +71,7 @@ public class NumericEntityUnescaper extends CharSequenceTranslator { * @return whether the option is set */ public boolean isSet(final OPTION option) { - return options == null ? false : options.contains(option); + return options != null && options.contains(option); } /** diff --git a/src/main/java/org/apache/commons/lang3/time/FormatCache.java b/src/main/java/org/apache/commons/lang3/time/FormatCache.java index db371d2ee..23c08e6ab 100644 --- a/src/main/java/org/apache/commons/lang3/time/FormatCache.java +++ b/src/main/java/org/apache/commons/lang3/time/FormatCache.java @@ -230,7 +230,7 @@ abstract class FormatCache<F extends Format> { * Constructs an instance of <code>MultipartKey</code> to hold the specified objects. * @param keys the set of objects that make up the key. Each key may be null. */ - public MultipartKey(final Object... keys) { + MultipartKey(final Object... keys) { this.keys = keys; } diff --git a/src/test/java/org/apache/commons/lang3/AnnotationUtilsTest.java b/src/test/java/org/apache/commons/lang3/AnnotationUtilsTest.java index 390b5f7e3..fc656aec4 100644 --- a/src/test/java/org/apache/commons/lang3/AnnotationUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/AnnotationUtilsTest.java @@ -377,7 +377,7 @@ public class AnnotationUtilsTest { Stooge[] stooges(); } - public static enum Stooge { + public enum Stooge { MOE, LARRY, CURLY, JOE, SHEMP } diff --git a/src/test/java/org/apache/commons/lang3/ArrayUtilsAddTest.java b/src/test/java/org/apache/commons/lang3/ArrayUtilsAddTest.java index dbbcdfd59..a05842774 100644 --- a/src/test/java/org/apache/commons/lang3/ArrayUtilsAddTest.java +++ b/src/test/java/org/apache/commons/lang3/ArrayUtilsAddTest.java @@ -285,7 +285,7 @@ public class ArrayUtilsAddTest { // boolean assertTrue( Arrays.equals( new boolean[] { true, false, false, true }, - ArrayUtils.addAll( new boolean[] { true, false }, new boolean[] { false, true } ) ) ); + ArrayUtils.addAll( new boolean[] { true, false }, false, true) ) ); assertTrue( Arrays.equals( new boolean[] { false, true }, ArrayUtils.addAll( null, new boolean[] { false, true } ) ) ); @@ -295,7 +295,7 @@ public class ArrayUtilsAddTest { // char assertTrue( Arrays.equals( new char[] { 'a', 'b', 'c', 'd' }, - ArrayUtils.addAll( new char[] { 'a', 'b' }, new char[] { 'c', 'd' } ) ) ); + ArrayUtils.addAll( new char[] { 'a', 'b' }, 'c', 'd') ) ); assertTrue( Arrays.equals( new char[] { 'c', 'd' }, ArrayUtils.addAll( null, new char[] { 'c', 'd' } ) ) ); @@ -305,7 +305,7 @@ public class ArrayUtilsAddTest { // byte assertTrue( Arrays.equals( new byte[] { (byte) 0, (byte) 1, (byte) 2, (byte) 3 }, - ArrayUtils.addAll( new byte[] { (byte) 0, (byte) 1 }, new byte[] { (byte) 2, (byte) 3 } ) ) ); + ArrayUtils.addAll( new byte[] { (byte) 0, (byte) 1 }, (byte) 2, (byte) 3) ) ); assertTrue( Arrays.equals( new byte[] { (byte) 2, (byte) 3 }, ArrayUtils.addAll( null, new byte[] { (byte) 2, (byte) 3 } ) ) ); @@ -315,7 +315,7 @@ public class ArrayUtilsAddTest { // short assertTrue( Arrays.equals( new short[] { (short) 10, (short) 20, (short) 30, (short) 40 }, - ArrayUtils.addAll( new short[] { (short) 10, (short) 20 }, new short[] { (short) 30, (short) 40 } ) ) ); + ArrayUtils.addAll( new short[] { (short) 10, (short) 20 }, (short) 30, (short) 40) ) ); assertTrue( Arrays.equals( new short[] { (short) 30, (short) 40 }, ArrayUtils.addAll( null, new short[] { (short) 30, (short) 40 } ) ) ); @@ -325,7 +325,7 @@ public class ArrayUtilsAddTest { // int assertTrue( Arrays.equals( new int[] { 1, 1000, -1000, -1 }, - ArrayUtils.addAll( new int[] { 1, 1000 }, new int[] { -1000, -1 } ) ) ); + ArrayUtils.addAll( new int[] { 1, 1000 }, -1000, -1) ) ); assertTrue( Arrays.equals( new int[] { -1000, -1 }, ArrayUtils.addAll( null, new int[] { -1000, -1 } ) ) ); @@ -335,7 +335,7 @@ public class ArrayUtilsAddTest { // long assertTrue( Arrays.equals( new long[] { 1L, -1L, 1000L, -1000L }, - ArrayUtils.addAll( new long[] { 1L, -1L }, new long[] { 1000L, -1000L } ) ) ); + ArrayUtils.addAll( new long[] { 1L, -1L }, 1000L, -1000L) ) ); assertTrue( Arrays.equals( new long[] { 1000L, -1000L }, ArrayUtils.addAll( null, new long[] { 1000L, -1000L } ) ) ); @@ -345,7 +345,7 @@ public class ArrayUtilsAddTest { // float assertTrue( Arrays.equals( new float[] { 10.5f, 10.1f, 1.6f, 0.01f }, - ArrayUtils.addAll( new float[] { 10.5f, 10.1f }, new float[] { 1.6f, 0.01f } ) ) ); + ArrayUtils.addAll( new float[] { 10.5f, 10.1f }, 1.6f, 0.01f) ) ); assertTrue( Arrays.equals( new float[] { 1.6f, 0.01f }, ArrayUtils.addAll( null, new float[] { 1.6f, 0.01f } ) ) ); @@ -355,7 +355,7 @@ public class ArrayUtilsAddTest { // double assertTrue( Arrays.equals( new double[] { Math.PI, -Math.PI, 0, 9.99 }, - ArrayUtils.addAll( new double[] { Math.PI, -Math.PI }, new double[] { 0, 9.99 } ) ) ); + ArrayUtils.addAll( new double[] { Math.PI, -Math.PI }, 0, 9.99) ) ); assertTrue( Arrays.equals( new double[] { 0, 9.99 }, ArrayUtils.addAll( null, new double[] { 0, 9.99 } ) ) ); diff --git a/src/test/java/org/apache/commons/lang3/ArrayUtilsTest.java b/src/test/java/org/apache/commons/lang3/ArrayUtilsTest.java index cffae29d9..bce957609 100644 --- a/src/test/java/org/apache/commons/lang3/ArrayUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/ArrayUtilsTest.java @@ -4740,49 +4740,49 @@ public class ArrayUtilsTest { final Object[] emptyObjectArray = new Object[0]; final Object[] notEmptyObjectArray = new Object[] {"aValue"}; - assertEquals(0, ArrayUtils.getLength((Object[]) null)); + assertEquals(0, ArrayUtils.getLength(null)); assertEquals(0, ArrayUtils.getLength(emptyObjectArray)); assertEquals(1, ArrayUtils.getLength(notEmptyObjectArray)); final int[] emptyIntArray = new int[] {}; final int[] notEmptyIntArray = new int[] { 1 }; - assertEquals(0, ArrayUtils.getLength((int[]) null)); + assertEquals(0, ArrayUtils.getLength(null)); assertEquals(0, ArrayUtils.getLength(emptyIntArray)); assertEquals(1, ArrayUtils.getLength(notEmptyIntArray)); final short[] emptyShortArray = new short[] {}; final short[] notEmptyShortArray = new short[] { 1 }; - assertEquals(0, ArrayUtils.getLength((short[]) null)); + assertEquals(0, ArrayUtils.getLength(null)); assertEquals(0, ArrayUtils.getLength(emptyShortArray)); assertEquals(1, ArrayUtils.getLength(notEmptyShortArray)); final char[] emptyCharArray = new char[] {}; final char[] notEmptyCharArray = new char[] { 1 }; - assertEquals(0, ArrayUtils.getLength((char[]) null)); + assertEquals(0, ArrayUtils.getLength(null)); assertEquals(0, ArrayUtils.getLength(emptyCharArray)); assertEquals(1, ArrayUtils.getLength(notEmptyCharArray)); final byte[] emptyByteArray = new byte[] {}; final byte[] notEmptyByteArray = new byte[] { 1 }; - assertEquals(0, ArrayUtils.getLength((byte[]) null)); + assertEquals(0, ArrayUtils.getLength(null)); assertEquals(0, ArrayUtils.getLength(emptyByteArray)); assertEquals(1, ArrayUtils.getLength(notEmptyByteArray)); final double[] emptyDoubleArray = new double[] {}; final double[] notEmptyDoubleArray = new double[] { 1.0 }; - assertEquals(0, ArrayUtils.getLength((double[]) null)); + assertEquals(0, ArrayUtils.getLength(null)); assertEquals(0, ArrayUtils.getLength(emptyDoubleArray)); assertEquals(1, ArrayUtils.getLength(notEmptyDoubleArray)); final float[] emptyFloatArray = new float[] {}; final float[] notEmptyFloatArray = new float[] { 1.0F }; - assertEquals(0, ArrayUtils.getLength((float[]) null)); + assertEquals(0, ArrayUtils.getLength(null)); assertEquals(0, ArrayUtils.getLength(emptyFloatArray)); assertEquals(1, ArrayUtils.getLength(notEmptyFloatArray)); final boolean[] emptyBooleanArray = new boolean[] {}; final boolean[] notEmptyBooleanArray = new boolean[] { true }; - assertEquals(0, ArrayUtils.getLength((boolean[]) null)); + assertEquals(0, ArrayUtils.getLength(null)); assertEquals(0, ArrayUtils.getLength(emptyBooleanArray)); assertEquals(1, ArrayUtils.getLength(notEmptyBooleanArray)); diff --git a/src/test/java/org/apache/commons/lang3/CharSetUtilsTest.java b/src/test/java/org/apache/commons/lang3/CharSetUtilsTest.java index 829ff6c16..e07081619 100644 --- a/src/test/java/org/apache/commons/lang3/CharSetUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/CharSetUtilsTest.java @@ -68,19 +68,19 @@ public class CharSetUtilsTest { assertEquals(null, CharSetUtils.squeeze(null, new String[] {"el"})); assertEquals("", CharSetUtils.squeeze("", (String[]) null)); - assertEquals("", CharSetUtils.squeeze("", new String[0])); + assertEquals("", CharSetUtils.squeeze("")); assertEquals("", CharSetUtils.squeeze("", new String[] {null})); - assertEquals("", CharSetUtils.squeeze("", new String[] {"a-e"})); + assertEquals("", CharSetUtils.squeeze("", "a-e")); assertEquals("hello", CharSetUtils.squeeze("hello", (String[]) null)); - assertEquals("hello", CharSetUtils.squeeze("hello", new String[0])); + assertEquals("hello", CharSetUtils.squeeze("hello")); assertEquals("hello", CharSetUtils.squeeze("hello", new String[] {null})); - assertEquals("hello", CharSetUtils.squeeze("hello", new String[] {"a-e"})); + assertEquals("hello", CharSetUtils.squeeze("hello", "a-e")); - assertEquals("helo", CharSetUtils.squeeze("hello", new String[] { "el" })); - assertEquals("hello", CharSetUtils.squeeze("hello", new String[] { "e" })); - assertEquals("fofof", CharSetUtils.squeeze("fooffooff", new String[] { "of" })); - assertEquals("fof", CharSetUtils.squeeze("fooooff", new String[] { "fo" })); + assertEquals("helo", CharSetUtils.squeeze("hello", "el")); + assertEquals("hello", CharSetUtils.squeeze("hello", "e")); + assertEquals("fofof", CharSetUtils.squeeze("fooffooff", "of")); + assertEquals("fof", CharSetUtils.squeeze("fooooff", "fo")); } //----------------------------------------------------------------------- @@ -102,25 +102,25 @@ public class CharSetUtilsTest { @Test public void testContainsAny_StringStringarray() { assertFalse(CharSetUtils.containsAny(null, (String[]) null)); - assertFalse(CharSetUtils.containsAny(null, new String[0])); + assertFalse(CharSetUtils.containsAny(null)); assertFalse(CharSetUtils.containsAny(null, new String[] {null})); - assertFalse(CharSetUtils.containsAny(null, new String[] {"a-e"})); + assertFalse(CharSetUtils.containsAny(null, "a-e")); assertFalse(CharSetUtils.containsAny("", (String[]) null)); - assertFalse(CharSetUtils.containsAny("", new String[0])); + assertFalse(CharSetUtils.containsAny("")); assertFalse(CharSetUtils.containsAny("", new String[] {null})); - assertFalse(CharSetUtils.containsAny("", new String[] {"a-e"})); + assertFalse(CharSetUtils.containsAny("", "a-e")); assertFalse(CharSetUtils.containsAny("hello", (String[]) null)); - assertFalse(CharSetUtils.containsAny("hello", new String[0])); + assertFalse(CharSetUtils.containsAny("hello")); assertFalse(CharSetUtils.containsAny("hello", new String[] {null})); - assertTrue(CharSetUtils.containsAny("hello", new String[] {"a-e"})); + assertTrue(CharSetUtils.containsAny("hello", "a-e")); - assertTrue(CharSetUtils.containsAny("hello", new String[] { "el" })); - assertFalse(CharSetUtils.containsAny("hello", new String[] { "x" })); - assertTrue(CharSetUtils.containsAny("hello", new String[] { "e-i" })); - assertTrue(CharSetUtils.containsAny("hello", new String[] { "a-z" })); - assertFalse(CharSetUtils.containsAny("hello", new String[] { "" })); + assertTrue(CharSetUtils.containsAny("hello", "el")); + assertFalse(CharSetUtils.containsAny("hello", "x")); + assertTrue(CharSetUtils.containsAny("hello", "e-i")); + assertTrue(CharSetUtils.containsAny("hello", "a-z")); + assertFalse(CharSetUtils.containsAny("hello", "")); } //----------------------------------------------------------------------- @@ -142,25 +142,25 @@ public class CharSetUtilsTest { @Test public void testCount_StringStringarray() { assertEquals(0, CharSetUtils.count(null, (String[]) null)); - assertEquals(0, CharSetUtils.count(null, new String[0])); + assertEquals(0, CharSetUtils.count(null)); assertEquals(0, CharSetUtils.count(null, new String[] {null})); - assertEquals(0, CharSetUtils.count(null, new String[] {"a-e"})); + assertEquals(0, CharSetUtils.count(null, "a-e")); assertEquals(0, CharSetUtils.count("", (String[]) null)); - assertEquals(0, CharSetUtils.count("", new String[0])); + assertEquals(0, CharSetUtils.count("")); assertEquals(0, CharSetUtils.count("", new String[] {null})); - assertEquals(0, CharSetUtils.count("", new String[] {"a-e"})); + assertEquals(0, CharSetUtils.count("", "a-e")); assertEquals(0, CharSetUtils.count("hello", (String[]) null)); - assertEquals(0, CharSetUtils.count("hello", new String[0])); + assertEquals(0, CharSetUtils.count("hello")); assertEquals(0, CharSetUtils.count("hello", new String[] {null})); - assertEquals(1, CharSetUtils.count("hello", new String[] {"a-e"})); + assertEquals(1, CharSetUtils.count("hello", "a-e")); - assertEquals(3, CharSetUtils.count("hello", new String[] { "el" })); - assertEquals(0, CharSetUtils.count("hello", new String[] { "x" })); - assertEquals(2, CharSetUtils.count("hello", new String[] { "e-i" })); - assertEquals(5, CharSetUtils.count("hello", new String[] { "a-z" })); - assertEquals(0, CharSetUtils.count("hello", new String[] { "" })); + assertEquals(3, CharSetUtils.count("hello", "el")); + assertEquals(0, CharSetUtils.count("hello", "x")); + assertEquals(2, CharSetUtils.count("hello", "e-i")); + assertEquals(5, CharSetUtils.count("hello", "a-z")); + assertEquals(0, CharSetUtils.count("hello", "")); } //----------------------------------------------------------------------- @@ -189,21 +189,21 @@ public class CharSetUtilsTest { assertEquals(null, CharSetUtils.keep(null, new String[] {"a-e"})); assertEquals("", CharSetUtils.keep("", (String[]) null)); - assertEquals("", CharSetUtils.keep("", new String[0])); + assertEquals("", CharSetUtils.keep("")); assertEquals("", CharSetUtils.keep("", new String[] {null})); - assertEquals("", CharSetUtils.keep("", new String[] {"a-e"})); + assertEquals("", CharSetUtils.keep("", "a-e")); assertEquals("", CharSetUtils.keep("hello", (String[]) null)); - assertEquals("", CharSetUtils.keep("hello", new String[0])); + assertEquals("", CharSetUtils.keep("hello")); assertEquals("", CharSetUtils.keep("hello", new String[] {null})); - assertEquals("e", CharSetUtils.keep("hello", new String[] {"a-e"})); - - assertEquals("e", CharSetUtils.keep("hello", new String[] { "a-e" })); - assertEquals("ell", CharSetUtils.keep("hello", new String[] { "el" })); - assertEquals("hello", CharSetUtils.keep("hello", new String[] { "elho" })); - assertEquals("hello", CharSetUtils.keep("hello", new String[] { "a-z" })); - assertEquals("----", CharSetUtils.keep("----", new String[] { "-" })); - assertEquals("ll", CharSetUtils.keep("hello", new String[] { "l" })); + assertEquals("e", CharSetUtils.keep("hello", "a-e")); + + assertEquals("e", CharSetUtils.keep("hello", "a-e")); + assertEquals("ell", CharSetUtils.keep("hello", "el")); + assertEquals("hello", CharSetUtils.keep("hello", "elho")); + assertEquals("hello", CharSetUtils.keep("hello", "a-z")); + assertEquals("----", CharSetUtils.keep("----", "-")); + assertEquals("ll", CharSetUtils.keep("hello", "l")); } //----------------------------------------------------------------------- @@ -231,22 +231,22 @@ public class CharSetUtilsTest { assertEquals(null, CharSetUtils.delete(null, new String[] {"el"})); assertEquals("", CharSetUtils.delete("", (String[]) null)); - assertEquals("", CharSetUtils.delete("", new String[0])); + assertEquals("", CharSetUtils.delete("")); assertEquals("", CharSetUtils.delete("", new String[] {null})); - assertEquals("", CharSetUtils.delete("", new String[] {"a-e"})); + assertEquals("", CharSetUtils.delete("", "a-e")); assertEquals("hello", CharSetUtils.delete("hello", (String[]) null)); - assertEquals("hello", CharSetUtils.delete("hello", new String[0])); + assertEquals("hello", CharSetUtils.delete("hello")); assertEquals("hello", CharSetUtils.delete("hello", new String[] {null})); - assertEquals("hello", CharSetUtils.delete("hello", new String[] {"xyz"})); + assertEquals("hello", CharSetUtils.delete("hello", "xyz")); - assertEquals("ho", CharSetUtils.delete("hello", new String[] { "el" })); - assertEquals("", CharSetUtils.delete("hello", new String[] { "elho" })); - assertEquals("hello", CharSetUtils.delete("hello", new String[] { "" })); + assertEquals("ho", CharSetUtils.delete("hello", "el")); + assertEquals("", CharSetUtils.delete("hello", "elho")); + assertEquals("hello", CharSetUtils.delete("hello", "")); assertEquals("hello", CharSetUtils.delete("hello", "")); - assertEquals("", CharSetUtils.delete("hello", new String[] { "a-z" })); - assertEquals("", CharSetUtils.delete("----", new String[] { "-" })); - assertEquals("heo", CharSetUtils.delete("hello", new String[] { "l" })); + assertEquals("", CharSetUtils.delete("hello", "a-z")); + assertEquals("", CharSetUtils.delete("----", "-")); + assertEquals("heo", CharSetUtils.delete("hello", "l")); } } diff --git a/src/test/java/org/apache/commons/lang3/ClassUtilsTest.java b/src/test/java/org/apache/commons/lang3/ClassUtilsTest.java index a31c78ce2..524140f8a 100644 --- a/src/test/java/org/apache/commons/lang3/ClassUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/ClassUtilsTest.java @@ -281,17 +281,17 @@ public class ClassUtilsTest { assertEquals(null, ClassUtils.getAllInterfaces(null)); } - private static interface IA { + private interface IA { } - private static interface IB { + private interface IB { } - private static interface IC extends ID, IE { + private interface IC extends ID, IE { } - private static interface ID { + private interface ID { } - private static interface IE extends IF { + private interface IE extends IF { } - private static interface IF { + private interface IF { } private static class CX implements IB, IA, IE { } @@ -378,7 +378,7 @@ public class ClassUtilsTest { assertTrue(ClassUtils.isAssignable(null, array0)); assertTrue(ClassUtils.isAssignable(array0, array0)); assertTrue(ClassUtils.isAssignable(array0, (Class<?>[]) null)); // explicit cast to avoid warning - assertTrue(ClassUtils.isAssignable((Class[]) null, (Class<?>[]) null)); // explicit cast to avoid warning + assertTrue(ClassUtils.isAssignable(null, (Class<?>[]) null)); // explicit cast to avoid warning assertFalse(ClassUtils.isAssignable(array1, array1s)); assertTrue(ClassUtils.isAssignable(array1s, array1s)); @@ -1096,9 +1096,9 @@ public class ClassUtilsTest { public void testShowJavaBug() throws Exception { // Tests with Collections$UnmodifiableSet final Set<?> set = Collections.unmodifiableSet(new HashSet<>()); - final Method isEmptyMethod = set.getClass().getMethod("isEmpty", new Class[0]); + final Method isEmptyMethod = set.getClass().getMethod("isEmpty"); try { - isEmptyMethod.invoke(set, new Object[0]); + isEmptyMethod.invoke(set); fail("Failed to throw IllegalAccessException as expected"); } catch(final IllegalAccessException iae) { // expected @@ -1109,17 +1109,17 @@ public class ClassUtilsTest { public void testGetPublicMethod() throws Exception { // Tests with Collections$UnmodifiableSet final Set<?> set = Collections.unmodifiableSet(new HashSet<>()); - final Method isEmptyMethod = ClassUtils.getPublicMethod(set.getClass(), "isEmpty", new Class[0]); + final Method isEmptyMethod = ClassUtils.getPublicMethod(set.getClass(), "isEmpty"); assertTrue(Modifier.isPublic(isEmptyMethod.getDeclaringClass().getModifiers())); try { - isEmptyMethod.invoke(set, new Object[0]); + isEmptyMethod.invoke(set); } catch(final java.lang.IllegalAccessException iae) { fail("Should not have thrown IllegalAccessException"); } // Tests with a public Class - final Method toStringMethod = ClassUtils.getPublicMethod(Object.class, "toString", new Class[0]); + final Method toStringMethod = ClassUtils.getPublicMethod(Object.class, "toString"); assertEquals(Object.class.getMethod("toString", new Class[0]), toStringMethod); } @@ -1136,10 +1136,10 @@ public class ClassUtilsTest { assertSame(ArrayUtils.EMPTY_CLASS_ARRAY, ClassUtils.toClass(ArrayUtils.EMPTY_OBJECT_ARRAY)); assertTrue(Arrays.equals(new Class[] { String.class, Integer.class, Double.class }, - ClassUtils.toClass(new Object[] { "Test", Integer.valueOf(1), Double.valueOf(99d) }))); + ClassUtils.toClass("Test", Integer.valueOf(1), Double.valueOf(99d)))); assertTrue(Arrays.equals(new Class[] { String.class, null, Double.class }, - ClassUtils.toClass(new Object[] { "Test", null, Double.valueOf(99d) }))); + ClassUtils.toClass("Test", null, Double.valueOf(99d)))); } @Test diff --git a/src/test/java/org/apache/commons/lang3/ObjectUtilsTest.java b/src/test/java/org/apache/commons/lang3/ObjectUtilsTest.java index c1d6dcc0e..d6547f626 100644 --- a/src/test/java/org/apache/commons/lang3/ObjectUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/ObjectUtilsTest.java @@ -77,7 +77,7 @@ public class ObjectUtilsTest { assertSame(Boolean.TRUE, ObjectUtils.firstNonNull(Boolean.TRUE)); // Explicitly pass in an empty array of Object type to ensure compiler doesn't complain of unchecked generic array creation - assertNull(ObjectUtils.firstNonNull(new Object[0])); + assertNull(ObjectUtils.firstNonNull()); // Cast to Object in line below ensures compiler doesn't complain of unchecked generic array creation assertNull(ObjectUtils.firstNonNull(null, null)); @@ -631,7 +631,7 @@ public class ObjectUtilsTest { * * @param value */ - public NonComparableCharSequence(final String value) { + NonComparableCharSequence(final String value) { super(); Validate.notNull(value); this.value = value; diff --git a/src/test/java/org/apache/commons/lang3/StringUtilsEqualsIndexOfTest.java b/src/test/java/org/apache/commons/lang3/StringUtilsEqualsIndexOfTest.java index 22cf9aabb..a9904e759 100644 --- a/src/test/java/org/apache/commons/lang3/StringUtilsEqualsIndexOfTest.java +++ b/src/test/java/org/apache/commons/lang3/StringUtilsEqualsIndexOfTest.java @@ -59,7 +59,7 @@ public class StringUtilsEqualsIndexOfTest { private static class CustomCharSequence implements CharSequence { private final CharSequence seq; - public CustomCharSequence(final CharSequence seq) { + CustomCharSequence(final CharSequence seq) { this.seq = seq; } diff --git a/src/test/java/org/apache/commons/lang3/StringUtilsTest.java b/src/test/java/org/apache/commons/lang3/StringUtilsTest.java index 5cda0aff9..aa9ec73a1 100644 --- a/src/test/java/org/apache/commons/lang3/StringUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/StringUtilsTest.java @@ -243,14 +243,14 @@ public class StringUtilsTest { // assertNull(StringUtils.join(null)); // generates warning assertNull(StringUtils.join((Object[]) null)); // equivalent explicit cast // test additional varargs calls - assertEquals("", StringUtils.join(new Object[0])); // empty array + assertEquals("", StringUtils.join()); // empty array assertEquals("", StringUtils.join((Object) null)); // => new Object[]{null} assertEquals("", StringUtils.join(EMPTY_ARRAY_LIST)); assertEquals("", StringUtils.join(NULL_ARRAY_LIST)); assertEquals("null", StringUtils.join(NULL_TO_STRING_LIST)); - assertEquals("abc", StringUtils.join(new String[]{"a", "b", "c"})); - assertEquals("a", StringUtils.join(new String[]{null, "a", ""})); + assertEquals("abc", StringUtils.join("a", "b", "c")); + assertEquals("a", StringUtils.join(null, "a", "")); assertEquals("foo", StringUtils.join(MIXED_ARRAY_LIST)); assertEquals("foo2", StringUtils.join(MIXED_TYPE_LIST)); } @@ -422,12 +422,12 @@ public class StringUtilsTest { @Test public void testJoinWith() { - assertEquals("", StringUtils.joinWith(",", new Object[0])); // empty array + assertEquals("", StringUtils.joinWith(",")); // empty array assertEquals("", StringUtils.joinWith(",", (Object[]) NULL_ARRAY_LIST)); assertEquals("null", StringUtils.joinWith(",", NULL_TO_STRING_LIST)); //toString method prints 'null' - assertEquals("a,b,c", StringUtils.joinWith(",", new Object[]{"a", "b", "c"})); - assertEquals(",a,", StringUtils.joinWith(",", new Object[]{null, "a", ""})); + assertEquals("a,b,c", StringUtils.joinWith(",", "a", "b", "c")); + assertEquals(",a,", StringUtils.joinWith(",", null, "a", "")); assertEquals("ab", StringUtils.joinWith(null, "a", "b")); } @@ -1553,7 +1553,7 @@ public class StringUtilsTest { assertEquals("abcabcabc", StringUtils.repeat("abc", 3)); final String str = StringUtils.repeat("a", 10000); // bigger than pad limit assertEquals(10000, str.length()); - assertTrue(StringUtils.containsOnly(str, new char[]{'a'})); + assertTrue(StringUtils.containsOnly(str, 'a')); } @Test @@ -1680,7 +1680,7 @@ public class StringUtilsTest { assertEquals("abcxx", StringUtils.rightPad("abc", 5, 'x')); final String str = StringUtils.rightPad("aaa", 10000, 'a'); // bigger than pad length assertEquals(10000, str.length()); - assertTrue(StringUtils.containsOnly(str, new char[]{'a'})); + assertTrue(StringUtils.containsOnly(str, 'a')); } @Test @@ -1716,7 +1716,7 @@ public class StringUtilsTest { assertEquals("abc", StringUtils.leftPad("abc", 2, ' ')); final String str = StringUtils.leftPad("aaa", 10000, 'a'); // bigger than pad length assertEquals(10000, str.length()); - assertTrue(StringUtils.containsOnly(str, new char[]{'a'})); + assertTrue(StringUtils.containsOnly(str, 'a')); } @Test diff --git a/src/test/java/org/apache/commons/lang3/ThreadUtilsTest.java b/src/test/java/org/apache/commons/lang3/ThreadUtilsTest.java index b0ad31006..63b11652f 100644 --- a/src/test/java/org/apache/commons/lang3/ThreadUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/ThreadUtilsTest.java @@ -337,11 +337,11 @@ public class ThreadUtilsTest { private static class TestThread extends Thread { private final CountDownLatch latch = new CountDownLatch(1); - public TestThread(final String name) { + TestThread(final String name) { super(name); } - public TestThread(final ThreadGroup group, final String name) { + TestThread(final ThreadGroup group, final String name) { super(group, name); } diff --git a/src/test/java/org/apache/commons/lang3/ValidateTest.java b/src/test/java/org/apache/commons/lang3/ValidateTest.java index 33b4fff12..958c6d31e 100644 --- a/src/test/java/org/apache/commons/lang3/ValidateTest.java +++ b/src/test/java/org/apache/commons/lang3/ValidateTest.java @@ -721,7 +721,7 @@ public class ValidateTest { assertEquals("Broken: ", ex.getMessage()); } - final List<String> strColl = Arrays.asList(new String[] {"Hi"}); + final List<String> strColl = Arrays.asList("Hi"); final List<String> test = Validate.validIndex(strColl, 0, "Message"); assertSame(strColl, test); } @@ -746,7 +746,7 @@ public class ValidateTest { assertEquals("The validated collection index is invalid: 2", ex.getMessage()); } - final List<String> strColl = Arrays.asList(new String[] {"Hi"}); + final List<String> strColl = Arrays.asList("Hi"); final List<String> test = Validate.validIndex(strColl, 0); assertSame(strColl, test); } diff --git a/src/test/java/org/apache/commons/lang3/builder/CompareToBuilderTest.java b/src/test/java/org/apache/commons/lang3/builder/CompareToBuilderTest.java index 33deaa877..350b56775 100644 --- a/src/test/java/org/apache/commons/lang3/builder/CompareToBuilderTest.java +++ b/src/test/java/org/apache/commons/lang3/builder/CompareToBuilderTest.java @@ -32,7 +32,7 @@ public class CompareToBuilderTest { static class TestObject implements Comparable<TestObject> { private int a; - public TestObject(final int a) { + TestObject(final int a) { this.a = a; } @Override @@ -67,10 +67,10 @@ public class CompareToBuilderTest { static class TestSubObject extends TestObject { private int b; - public TestSubObject() { + TestSubObject() { super(0); } - public TestSubObject(final int a, final int b) { + TestSubObject(final int a, final int b) { super(a); this.b = b; } @@ -90,7 +90,7 @@ public class CompareToBuilderTest { static class TestTransientSubObject extends TestObject { @SuppressWarnings("unused") private transient int t; - public TestTransientSubObject(final int a, final int t) { + TestTransientSubObject(final int a, final int t) { super(a); this.t = t; } diff --git a/src/test/java/org/apache/commons/lang3/builder/DiffResultTest.java b/src/test/java/org/apache/commons/lang3/builder/DiffResultTest.java index e18a7da58..a267a1b44 100644 --- a/src/test/java/org/apache/commons/lang3/builder/DiffResultTest.java +++ b/src/test/java/org/apache/commons/lang3/builder/DiffResultTest.java @@ -36,11 +36,11 @@ public class DiffResultTest { private static class SimpleClass implements Diffable<SimpleClass> { private final boolean booleanField; - public SimpleClass(final boolean booleanField) { + SimpleClass(final boolean booleanField) { this.booleanField = booleanField; } - public static String getFieldName() { + static String getFieldName() { return "booleanField"; } diff --git a/src/test/java/org/apache/commons/lang3/builder/EqualsBuilderTest.java b/src/test/java/org/apache/commons/lang3/builder/EqualsBuilderTest.java index 0e0f5f452..8be9b9815 100644 --- a/src/test/java/org/apache/commons/lang3/builder/EqualsBuilderTest.java +++ b/src/test/java/org/apache/commons/lang3/builder/EqualsBuilderTest.java @@ -34,9 +34,9 @@ public class EqualsBuilderTest { static class TestObject { private int a; - public TestObject() { + TestObject() { } - public TestObject(final int a) { + TestObject(final int a) { this.a = a; } @Override @@ -67,10 +67,10 @@ public class EqualsBuilderTest { static class TestSubObject extends TestObject { private int b; - public TestSubObject() { + TestSubObject() { super(0); } - public TestSubObject(final int a, final int b) { + TestSubObject(final int a, final int b) { super(a); this.b = b; } @@ -101,7 +101,7 @@ public class EqualsBuilderTest { } static class TestEmptySubObject extends TestObject { - public TestEmptySubObject(final int a) { + TestEmptySubObject(final int a) { super(a); } } @@ -109,7 +109,7 @@ public class EqualsBuilderTest { static class TestTSubObject extends TestObject { @SuppressWarnings("unused") private transient int t; - public TestTSubObject(final int a, final int t) { + TestTSubObject(final int a, final int t) { super(a); this.t = t; } @@ -118,7 +118,7 @@ public class EqualsBuilderTest { static class TestTTSubObject extends TestTSubObject { @SuppressWarnings("unused") private transient int tt; - public TestTTSubObject(final int a, final int t, final int tt) { + TestTTSubObject(final int a, final int t, final int tt) { super(a, t); this.tt = tt; } @@ -127,7 +127,7 @@ public class EqualsBuilderTest { static class TestTTLeafObject extends TestTTSubObject { @SuppressWarnings("unused") private final int leafValue; - public TestTTLeafObject(final int a, final int t, final int tt, final int leafValue) { + TestTTLeafObject(final int a, final int t, final int tt, final int leafValue) { super(a, t, tt); this.leafValue = leafValue; } @@ -135,7 +135,7 @@ public class EqualsBuilderTest { static class TestTSubObject2 extends TestObject { private transient int t; - public TestTSubObject2(final int a, final int t) { + TestTSubObject2(final int a, final int t) { super(a); } public int getT() { @@ -151,7 +151,7 @@ public class EqualsBuilderTest { private final TestRecursiveInnerObject b; private int z; - public TestRecursiveObject(final TestRecursiveInnerObject a, + TestRecursiveObject(final TestRecursiveInnerObject a, final TestRecursiveInnerObject b, final int z) { this.a = a; this.b = b; @@ -173,7 +173,7 @@ public class EqualsBuilderTest { static class TestRecursiveInnerObject { private final int n; - public TestRecursiveInnerObject(final int n) { + TestRecursiveInnerObject(final int n) { this.n = n; } @@ -185,12 +185,12 @@ public class EqualsBuilderTest { static class TestRecursiveCycleObject { private TestRecursiveCycleObject cycle; private final int n; - public TestRecursiveCycleObject(final int n) { + TestRecursiveCycleObject(final int n) { this.n = n; this.cycle = this; } - public TestRecursiveCycleObject(final TestRecursiveCycleObject cycle, final int n) { + TestRecursiveCycleObject(final TestRecursiveCycleObject cycle, final int n) { this.n = n; this.cycle = cycle; } @@ -1164,19 +1164,19 @@ public class EqualsBuilderTest { // doesn't barf on null, empty array, or non-existent field, but still tests as not equal assertFalse(EqualsBuilder.reflectionEquals(x1, x2, (String[]) null)); - assertFalse(EqualsBuilder.reflectionEquals(x1, x2, new String[] {})); - assertFalse(EqualsBuilder.reflectionEquals(x1, x2, new String[] {"xxx"})); + assertFalse(EqualsBuilder.reflectionEquals(x1, x2)); + assertFalse(EqualsBuilder.reflectionEquals(x1, x2, "xxx")); // not equal if only one of the differing fields excluded - assertFalse(EqualsBuilder.reflectionEquals(x1, x2, new String[] {"two"})); - assertFalse(EqualsBuilder.reflectionEquals(x1, x2, new String[] {"three"})); + assertFalse(EqualsBuilder.reflectionEquals(x1, x2, "two")); + assertFalse(EqualsBuilder.reflectionEquals(x1, x2, "three")); // equal if both differing fields excluded - assertTrue(EqualsBuilder.reflectionEquals(x1, x2, new String[] {"two", "three"})); + assertTrue(EqualsBuilder.reflectionEquals(x1, x2, "two", "three")); // still equal as long as both differing fields are among excluded - assertTrue(EqualsBuilder.reflectionEquals(x1, x2, new String[] {"one", "two", "three"})); - assertTrue(EqualsBuilder.reflectionEquals(x1, x2, new String[] {"one", "two", "three", "xxx"})); + assertTrue(EqualsBuilder.reflectionEquals(x1, x2, "one", "two", "three")); + assertTrue(EqualsBuilder.reflectionEquals(x1, x2, "one", "two", "three", "xxx")); } static class TestObjectWithMultipleFields { @@ -1187,7 +1187,7 @@ public class EqualsBuilderTest { @SuppressWarnings("unused") private final TestObject three; - public TestObjectWithMultipleFields(final int one, final int two, final int three) { + TestObjectWithMultipleFields(final int one, final int two, final int three) { this.one = new TestObject(one); this.two = new TestObject(two); this.three = new TestObject(three); @@ -1229,7 +1229,7 @@ public class EqualsBuilderTest { @SuppressWarnings("unused") private final TestObject one; - public TestObjectReference(final int one) { + TestObjectReference(final int one) { this.one = new TestObject(one); } @@ -1271,7 +1271,7 @@ public class EqualsBuilderTest { private final int a; private final int b; - public TestObjectEqualsExclude(final int a, final int b) { + TestObjectEqualsExclude(final int a, final int b) { this.a = a; this.b = b; } diff --git a/src/test/java/org/apache/commons/lang3/builder/HashCodeBuilderTest.java b/src/test/java/org/apache/commons/lang3/builder/HashCodeBuilderTest.java index 03b166acc..3e00cd068 100644 --- a/src/test/java/org/apache/commons/lang3/builder/HashCodeBuilderTest.java +++ b/src/test/java/org/apache/commons/lang3/builder/HashCodeBuilderTest.java @@ -75,7 +75,7 @@ public class HashCodeBuilderTest { static class TestObject { private int a; - public TestObject(final int a) { + TestObject(final int a) { this.a = a; } @@ -111,11 +111,11 @@ public class HashCodeBuilderTest { @SuppressWarnings("unused") private transient int t; - public TestSubObject() { + TestSubObject() { super(0); } - public TestSubObject(final int a, final int b, final int t) { + TestSubObject(final int a, final int b, final int t) { super(a); this.b = b; this.t = t; @@ -491,16 +491,16 @@ public class HashCodeBuilderTest { assertEquals(((17 * 37 + 1) * 37 + 2) * 37 + 3, HashCodeBuilder.reflectionHashCode(x)); assertEquals(((17 * 37 + 1) * 37 + 2) * 37 + 3, HashCodeBuilder.reflectionHashCode(x, (String[]) null)); - assertEquals(((17 * 37 + 1) * 37 + 2) * 37 + 3, HashCodeBuilder.reflectionHashCode(x, new String[]{})); - assertEquals(((17 * 37 + 1) * 37 + 2) * 37 + 3, HashCodeBuilder.reflectionHashCode(x, new String[]{"xxx"})); + assertEquals(((17 * 37 + 1) * 37 + 2) * 37 + 3, HashCodeBuilder.reflectionHashCode(x)); + assertEquals(((17 * 37 + 1) * 37 + 2) * 37 + 3, HashCodeBuilder.reflectionHashCode(x, "xxx")); - assertEquals((17 * 37 + 1) * 37 + 3, HashCodeBuilder.reflectionHashCode(x, new String[]{"two"})); - assertEquals((17 * 37 + 1) * 37 + 2, HashCodeBuilder.reflectionHashCode(x, new String[]{"three"})); + assertEquals((17 * 37 + 1) * 37 + 3, HashCodeBuilder.reflectionHashCode(x, "two")); + assertEquals((17 * 37 + 1) * 37 + 2, HashCodeBuilder.reflectionHashCode(x, "three")); - assertEquals(17 * 37 + 1, HashCodeBuilder.reflectionHashCode(x, new String[]{"two", "three"})); + assertEquals(17 * 37 + 1, HashCodeBuilder.reflectionHashCode(x, "two", "three")); - assertEquals(17, HashCodeBuilder.reflectionHashCode(x, new String[]{"one", "two", "three"})); - assertEquals(17, HashCodeBuilder.reflectionHashCode(x, new String[]{"one", "two", "three", "xxx"})); + assertEquals(17, HashCodeBuilder.reflectionHashCode(x, "one", "two", "three")); + assertEquals(17, HashCodeBuilder.reflectionHashCode(x, "one", "two", "three", "xxx")); } static class TestObjectWithMultipleFields { @@ -513,7 +513,7 @@ public class HashCodeBuilderTest { @SuppressWarnings("unused") private int three = 0; - public TestObjectWithMultipleFields(final int one, final int two, final int three) { + TestObjectWithMultipleFields(final int one, final int two, final int three) { this.one = one; this.two = two; this.three = three; @@ -568,7 +568,7 @@ public class HashCodeBuilderTest { private final int a; private final int b; - public TestObjectHashCodeExclude(final int a, final int b) { + TestObjectHashCodeExclude(final int a, final int b) { this.a = a; this.b = b; } @@ -588,7 +588,7 @@ public class HashCodeBuilderTest { @HashCodeExclude private final int b; - public TestObjectHashCodeExclude2(final int a, final int b) { + TestObjectHashCodeExclude2(final int a, final int b) { this.a = a; this.b = b; } diff --git a/src/test/java/org/apache/commons/lang3/builder/MultilineRecursiveToStringStyleTest.java b/src/test/java/org/apache/commons/lang3/builder/MultilineRecursiveToStringStyleTest.java index cb08ae01e..372e2d849 100644 --- a/src/test/java/org/apache/commons/lang3/builder/MultilineRecursiveToStringStyleTest.java +++ b/src/test/java/org/apache/commons/lang3/builder/MultilineRecursiveToStringStyleTest.java @@ -235,7 +235,7 @@ public class MultilineRecursiveToStringStyleTest { static class Bank { String name; - public Bank(final String name) { + Bank(final String name) { this.name = name; } } @@ -245,7 +245,7 @@ public class MultilineRecursiveToStringStyleTest { Bank bank; List<Account> accounts; - public Customer(final String name) { + Customer(final String name) { this.name = name; } } @@ -267,7 +267,7 @@ public class MultilineRecursiveToStringStyleTest { double amount; String date; - public Transaction(final String datum, final double betrag) { + Transaction(final String datum, final double betrag) { this.date = datum; this.amount = betrag; } diff --git a/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderExcludeNullValuesTest.java b/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderExcludeNullValuesTest.java index 4250ddf18..914700a67 100644 --- a/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderExcludeNullValuesTest.java +++ b/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderExcludeNullValuesTest.java @@ -30,7 +30,7 @@ public class ReflectionToStringBuilderExcludeNullValuesTest { @SuppressWarnings("unused") private String testStringField; - public TestFixture(Integer a, String b) { + TestFixture(Integer a, String b) { this.testIntegerField = a; this.testStringField = b; } diff --git a/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderExcludeTest.java b/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderExcludeTest.java index aa8909e5b..005f4b855 100644 --- a/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderExcludeTest.java +++ b/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderExcludeTest.java @@ -54,7 +54,7 @@ public class ReflectionToStringBuilderExcludeTest { @Test public void test_toStringExcludeArray() { - final String toString = ReflectionToStringBuilder.toStringExclude(new TestFixture(), new String[]{SECRET_FIELD}); + final String toString = ReflectionToStringBuilder.toStringExclude(new TestFixture(), SECRET_FIELD); this.validateSecretFieldAbsent(toString); } @@ -66,7 +66,7 @@ public class ReflectionToStringBuilderExcludeTest { @Test public void test_toStringExcludeArrayWithNulls() { - final String toString = ReflectionToStringBuilder.toStringExclude(new TestFixture(), new String[]{null, null}); + final String toString = ReflectionToStringBuilder.toStringExclude(new TestFixture(), null, null); this.validateSecretFieldPresent(toString); } diff --git a/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderMutateInspectConcurrencyTest.java b/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderMutateInspectConcurrencyTest.java index 85ab700dc..34788e0ea 100644 --- a/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderMutateInspectConcurrencyTest.java +++ b/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderMutateInspectConcurrencyTest.java @@ -41,7 +41,7 @@ public class ReflectionToStringBuilderMutateInspectConcurrencyTest { private final Random random = new Random(); private final int N = 100; - public TestFixture() { + TestFixture() { synchronized (this) { for (int i = 0; i < N; i++) { listField.add(Integer.valueOf(i)); @@ -62,7 +62,7 @@ public class ReflectionToStringBuilderMutateInspectConcurrencyTest { private final TestFixture testFixture; private final Random random = new Random(); - public MutatingClient(final TestFixture testFixture) { + MutatingClient(final TestFixture testFixture) { this.testFixture = testFixture; } @@ -79,7 +79,7 @@ public class ReflectionToStringBuilderMutateInspectConcurrencyTest { class InspectingClient implements Runnable { private final TestFixture testFixture; - public InspectingClient(final TestFixture testFixture) { + InspectingClient(final TestFixture testFixture) { this.testFixture = testFixture; } diff --git a/src/test/java/org/apache/commons/lang3/builder/ToStringBuilderTest.java b/src/test/java/org/apache/commons/lang3/builder/ToStringBuilderTest.java index 619b9f255..1e805bec7 100644 --- a/src/test/java/org/apache/commons/lang3/builder/ToStringBuilderTest.java +++ b/src/test/java/org/apache/commons/lang3/builder/ToStringBuilderTest.java @@ -472,10 +472,10 @@ public class ToStringBuilderTest { static class SimpleReflectionTestFixture { Object o; - public SimpleReflectionTestFixture() { + SimpleReflectionTestFixture() { } - public SimpleReflectionTestFixture(final Object o) { + SimpleReflectionTestFixture(final Object o) { this.o = o; } @@ -489,7 +489,7 @@ public class ToStringBuilderTest { @SuppressWarnings("unused") private final SelfInstanceVarReflectionTestFixture typeIsSelf; - public SelfInstanceVarReflectionTestFixture() { + SelfInstanceVarReflectionTestFixture() { this.typeIsSelf = this; } @@ -504,7 +504,7 @@ public class ToStringBuilderTest { private final SelfInstanceTwoVarsReflectionTestFixture typeIsSelf; private final String otherType = "The Other Type"; - public SelfInstanceTwoVarsReflectionTestFixture() { + SelfInstanceTwoVarsReflectionTestFixture() { this.typeIsSelf = this; } diff --git a/src/test/java/org/apache/commons/lang3/concurrent/BackgroundInitializerTest.java b/src/test/java/org/apache/commons/lang3/concurrent/BackgroundInitializerTest.java index f7d3261fc..739ff51ce 100644 --- a/src/test/java/org/apache/commons/lang3/concurrent/BackgroundInitializerTest.java +++ b/src/test/java/org/apache/commons/lang3/concurrent/BackgroundInitializerTest.java @@ -297,11 +297,11 @@ public class BackgroundInitializerTest { /** The number of invocations of initialize(). */ volatile int initializeCalls; - public BackgroundInitializerTestImpl() { + BackgroundInitializerTestImpl() { super(); } - public BackgroundInitializerTestImpl(final ExecutorService exec) { + BackgroundInitializerTestImpl(final ExecutorService exec) { super(exec); } diff --git a/src/test/java/org/apache/commons/lang3/concurrent/EventCountCircuitBreakerTest.java b/src/test/java/org/apache/commons/lang3/concurrent/EventCountCircuitBreakerTest.java index ab80b13fe..5a92fd53a 100644 --- a/src/test/java/org/apache/commons/lang3/concurrent/EventCountCircuitBreakerTest.java +++ b/src/test/java/org/apache/commons/lang3/concurrent/EventCountCircuitBreakerTest.java @@ -330,7 +330,7 @@ public class EventCountCircuitBreakerTest { /** The current time in nanoseconds. */ private long currentTime; - public EventCountCircuitBreakerTestImpl(final int openingThreshold, final long openingInterval, + EventCountCircuitBreakerTestImpl(final int openingThreshold, final long openingInterval, final TimeUnit openingUnit, final int closingThreshold, final long closingInterval, final TimeUnit closingUnit) { super(openingThreshold, openingInterval, openingUnit, closingThreshold, @@ -374,7 +374,7 @@ public class EventCountCircuitBreakerTest { * * @param source the expected event source */ - public ChangeListener(final Object source) { + ChangeListener(final Object source) { expectedSource = source; changedValues = new ArrayList<>(); } diff --git a/src/test/java/org/apache/commons/lang3/concurrent/TimedSemaphoreTest.java b/src/test/java/org/apache/commons/lang3/concurrent/TimedSemaphoreTest.java index 272491083..37a8772fb 100644 --- a/src/test/java/org/apache/commons/lang3/concurrent/TimedSemaphoreTest.java +++ b/src/test/java/org/apache/commons/lang3/concurrent/TimedSemaphoreTest.java @@ -434,12 +434,12 @@ public class TimedSemaphoreTest { /** Counter for the endOfPeriod() invocations. */ private int periodEnds; - public TimedSemaphoreTestImpl(final long timePeriod, final TimeUnit timeUnit, + TimedSemaphoreTestImpl(final long timePeriod, final TimeUnit timeUnit, final int limit) { super(timePeriod, timeUnit, limit); } - public TimedSemaphoreTestImpl(final ScheduledExecutorService service, + TimedSemaphoreTestImpl(final ScheduledExecutorService service, final long timePeriod, final TimeUnit timeUnit, final int limit) { super(service, timePeriod, timeUnit, limit); } @@ -449,7 +449,7 @@ public class TimedSemaphoreTest { * * @return the endOfPeriod() invocations */ - public int getPeriodEnds() { + int getPeriodEnds() { synchronized (this) { return periodEnds; } @@ -504,7 +504,7 @@ public class TimedSemaphoreTest { /** The number of invocations of the latch. */ private final int latchCount; - public SemaphoreThread(final TimedSemaphore b, final CountDownLatch l, final int c, final int lc) { + SemaphoreThread(final TimedSemaphore b, final CountDownLatch l, final int c, final int lc) { semaphore = b; latch = l; count = c; @@ -546,7 +546,7 @@ public class TimedSemaphoreTest { /** Flag whether a permit could be acquired. */ private boolean acquired; - public TryAcquireThread(final TimedSemaphore s, final CountDownLatch l) { + TryAcquireThread(final TimedSemaphore s, final CountDownLatch l) { semaphore = s; latch = l; } diff --git a/src/test/java/org/apache/commons/lang3/event/EventUtilsTest.java b/src/test/java/org/apache/commons/lang3/event/EventUtilsTest.java index db54742cc..a6e255572 100644 --- a/src/test/java/org/apache/commons/lang3/event/EventUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/event/EventUtilsTest.java @@ -160,11 +160,11 @@ public class EventUtilsTest assertEquals(1, counter.getCount()); } - public static interface MultipleEventListener + public interface MultipleEventListener { - public void event1(PropertyChangeEvent e); + void event1(PropertyChangeEvent e); - public void event2(PropertyChangeEvent e); + void event2(PropertyChangeEvent e); } public static class EventCounter diff --git a/src/test/java/org/apache/commons/lang3/exception/ExceptionUtilsTest.java b/src/test/java/org/apache/commons/lang3/exception/ExceptionUtilsTest.java index 00ec843fd..d319e2ea1 100644 --- a/src/test/java/org/apache/commons/lang3/exception/ExceptionUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/exception/ExceptionUtilsTest.java @@ -489,12 +489,12 @@ public class ExceptionUtilsTest { private Throwable cause; - public ExceptionWithCause(final String str, final Throwable cause) { + ExceptionWithCause(final String str, final Throwable cause) { super(str); setCause(cause); } - public ExceptionWithCause(final Throwable cause) { + ExceptionWithCause(final Throwable cause) { super(); setCause(cause); } @@ -528,8 +528,8 @@ public class ExceptionUtilsTest { private static final long serialVersionUID = 1L; @SuppressWarnings("unused") - public NestableException() { super(); } - public NestableException(final Throwable t) { super(t); } + NestableException() { super(); } + NestableException(final Throwable t) { super(t); } } @Test diff --git a/src/test/java/org/apache/commons/lang3/math/IEEE754rUtilsTest.java b/src/test/java/org/apache/commons/lang3/math/IEEE754rUtilsTest.java index 026c0f72c..fcd79b66a 100644 --- a/src/test/java/org/apache/commons/lang3/math/IEEE754rUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/math/IEEE754rUtilsTest.java @@ -61,7 +61,7 @@ public class IEEE754rUtilsTest { } catch(final IllegalArgumentException iae) { /* expected */ } try { - IEEE754rUtils.min(new float[0]); + IEEE754rUtils.min(); fail("IllegalArgumentException expected for empty input"); } catch(final IllegalArgumentException iae) { /* expected */ } @@ -71,7 +71,7 @@ public class IEEE754rUtilsTest { } catch(final IllegalArgumentException iae) { /* expected */ } try { - IEEE754rUtils.max(new float[0]); + IEEE754rUtils.max(); fail("IllegalArgumentException expected for empty input"); } catch(final IllegalArgumentException iae) { /* expected */ } diff --git a/src/test/java/org/apache/commons/lang3/math/NumberUtilsTest.java b/src/test/java/org/apache/commons/lang3/math/NumberUtilsTest.java index 3a53c1ebb..31ca17435 100644 --- a/src/test/java/org/apache/commons/lang3/math/NumberUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/math/NumberUtilsTest.java @@ -565,15 +565,15 @@ public class NumberUtilsTest { assertEquals( "min(int[]) failed for array length 1", 5, - NumberUtils.min(new int[] { 5 })); + NumberUtils.min(5)); assertEquals( "min(int[]) failed for array length 2", 6, - NumberUtils.min(new int[] { 6, 9 })); + NumberUtils.min(6, 9)); - assertEquals(-10, NumberUtils.min(new int[] { -10, -5, 0, 5, 10 })); - assertEquals(-10, NumberUtils.min(new int[] { -5, 0, -10, 5, 10 })); + assertEquals(-10, NumberUtils.min(-10, -5, 0, 5, 10)); + assertEquals(-10, NumberUtils.min(-5, 0, -10, 5, 10)); } @Test(expected = IllegalArgumentException.class) @@ -609,7 +609,7 @@ public class NumberUtilsTest { @Test(expected = IllegalArgumentException.class) public void testMinByte_emptyArray() { - NumberUtils.min(new byte[0]); + NumberUtils.min(); } @Test @@ -643,19 +643,19 @@ public class NumberUtilsTest { assertEquals( "min(double[]) failed for array length 1", 5.12, - NumberUtils.min(new double[] { 5.12 }), + NumberUtils.min(5.12), 0); assertEquals( "min(double[]) failed for array length 2", 6.23, - NumberUtils.min(new double[] { 6.23, 9.34 }), + NumberUtils.min(6.23, 9.34), 0); assertEquals( "min(double[]) failed for array length 5", -10.45, - NumberUtils.min(new double[] { -10.45, -5.56, 0, 5.67, 10.78 }), + NumberUtils.min(-10.45, -5.56, 0, 5.67, 10.78), 0); assertEquals(-10, NumberUtils.min(new double[] { -10, -5, 0, 5, 10 }), 0.0001); assertEquals(-10, NumberUtils.min(new double[] { -5, 0, -10, 5, 10 }), 0.0001); @@ -676,19 +676,19 @@ public class NumberUtilsTest { assertEquals( "min(float[]) failed for array length 1", 5.9f, - NumberUtils.min(new float[] { 5.9f }), + NumberUtils.min(5.9f), 0); assertEquals( "min(float[]) failed for array length 2", 6.8f, - NumberUtils.min(new float[] { 6.8f, 9.7f }), + NumberUtils.min(6.8f, 9.7f), 0); assertEquals( "min(float[]) failed for array length 5", -10.6f, - NumberUtils.min(new float[] { -10.6f, -5.5f, 0, 5.4f, 10.3f }), + NumberUtils.min(-10.6f, -5.5f, 0, 5.4f, 10.3f), 0); assertEquals(-10, NumberUtils.min(new float[] { -10, -5, 0, 5, 10 }), 0.0001f); assertEquals(-10, NumberUtils.min(new float[] { -5, 0, -10, 5, 10 }), 0.0001f); @@ -739,19 +739,19 @@ public class NumberUtilsTest { assertEquals( "max(int[]) failed for array length 1", 5, - NumberUtils.max(new int[] { 5 })); + NumberUtils.max(5)); assertEquals( "max(int[]) failed for array length 2", 9, - NumberUtils.max(new int[] { 6, 9 })); + NumberUtils.max(6, 9)); assertEquals( "max(int[]) failed for array length 5", 10, - NumberUtils.max(new int[] { -10, -5, 0, 5, 10 })); - assertEquals(10, NumberUtils.max(new int[] { -10, -5, 0, 5, 10 })); - assertEquals(10, NumberUtils.max(new int[] { -5, 0, 10, 5, -10 })); + NumberUtils.max(-10, -5, 0, 5, 10)); + assertEquals(10, NumberUtils.max(-10, -5, 0, 5, 10)); + assertEquals(10, NumberUtils.max(-5, 0, 10, 5, -10)); } @Test(expected = IllegalArgumentException.class) @@ -791,7 +791,7 @@ public class NumberUtilsTest { @Test(expected = IllegalArgumentException.class) public void testMaxByte_emptyArray() { - NumberUtils.max(new byte[0]); + NumberUtils.max(); } @Test @@ -873,19 +873,19 @@ public class NumberUtilsTest { assertEquals( "max(float[]) failed for array length 1", 5.1f, - NumberUtils.max(new float[] { 5.1f }), + NumberUtils.max(5.1f), 0); assertEquals( "max(float[]) failed for array length 2", 9.2f, - NumberUtils.max(new float[] { 6.3f, 9.2f }), + NumberUtils.max(6.3f, 9.2f), 0); assertEquals( "max(float[]) failed for float length 5", 10.4f, - NumberUtils.max(new float[] { -10.5f, -5.6f, 0, 5.7f, 10.4f }), + NumberUtils.max(-10.5f, -5.6f, 0, 5.7f, 10.4f), 0); assertEquals(10, NumberUtils.max(new float[] { -10, -5, 0, 5, 10 }), 0.0001f); assertEquals(10, NumberUtils.max(new float[] { -5, 0, 10, 5, -10 }), 0.0001f); @@ -1445,10 +1445,7 @@ public class NumberUtilsTest { private boolean checkCreateNumber(final String val) { try { final Object obj = NumberUtils.createNumber(val); - if (obj == null) { - return false; - } - return true; + return obj != null; } catch (final NumberFormatException e) { return false; } diff --git a/src/test/java/org/apache/commons/lang3/reflect/ConstructorUtilsTest.java b/src/test/java/org/apache/commons/lang3/reflect/ConstructorUtilsTest.java index c14625d71..9cd39c4f3 100644 --- a/src/test/java/org/apache/commons/lang3/reflect/ConstructorUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/reflect/ConstructorUtilsTest.java @@ -101,7 +101,7 @@ public class ConstructorUtilsTest { } } - private static class PrivateClass { + static class PrivateClass { @SuppressWarnings("unused") public PrivateClass() { } diff --git a/src/test/java/org/apache/commons/lang3/reflect/MethodUtilsTest.java b/src/test/java/org/apache/commons/lang3/reflect/MethodUtilsTest.java index 15d7cd766..5c1989bd2 100644 --- a/src/test/java/org/apache/commons/lang3/reflect/MethodUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/reflect/MethodUtilsTest.java @@ -59,7 +59,7 @@ import org.junit.Test; */ public class MethodUtilsTest { - private static interface PrivateInterface {} + private interface PrivateInterface {} static class TestBeanWithInterfaces implements PrivateInterface { public String foo() { diff --git a/src/test/java/org/apache/commons/lang3/reflect/TypeUtilsTest.java b/src/test/java/org/apache/commons/lang3/reflect/TypeUtilsTest.java index b3cef7a54..1b88147a3 100644 --- a/src/test/java/org/apache/commons/lang3/reflect/TypeUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/reflect/TypeUtilsTest.java @@ -811,7 +811,7 @@ class AAAClass extends AAClass<String> { //raw types, where used, are used purposely class AClass extends AAClass<String>.BBClass<Number> { - public AClass(final AAClass<String> enclosingInstance) { + AClass(final AAClass<String> enclosingInstance) { enclosingInstance.super(); } diff --git a/src/test/java/org/apache/commons/lang3/reflect/testbed/Bar.java b/src/test/java/org/apache/commons/lang3/reflect/testbed/Bar.java index 105dd1def..8ac873d3a 100644 --- a/src/test/java/org/apache/commons/lang3/reflect/testbed/Bar.java +++ b/src/test/java/org/apache/commons/lang3/reflect/testbed/Bar.java @@ -19,7 +19,7 @@ package org.apache.commons.lang3.reflect.testbed; /** */ public interface Bar { - public static final String VALUE = "bar"; + String VALUE = "bar"; void doIt(); } diff --git a/src/test/java/org/apache/commons/lang3/reflect/testbed/Foo.java b/src/test/java/org/apache/commons/lang3/reflect/testbed/Foo.java index be24ac6ac..f07a43377 100644 --- a/src/test/java/org/apache/commons/lang3/reflect/testbed/Foo.java +++ b/src/test/java/org/apache/commons/lang3/reflect/testbed/Foo.java @@ -19,7 +19,7 @@ package org.apache.commons.lang3.reflect.testbed; /** */ public interface Foo { - public static final String VALUE = "foo"; + String VALUE = "foo"; @Annotated void doIt(); diff --git a/src/test/java/org/apache/commons/lang3/text/ExtendedMessageFormatTest.java b/src/test/java/org/apache/commons/lang3/text/ExtendedMessageFormatTest.java index 41468a9bb..cdc53f795 100644 --- a/src/test/java/org/apache/commons/lang3/text/ExtendedMessageFormatTest.java +++ b/src/test/java/org/apache/commons/lang3/text/ExtendedMessageFormatTest.java @@ -467,7 +467,7 @@ public class ExtendedMessageFormatTest { private static class OtherExtendedMessageFormat extends ExtendedMessageFormat { private static final long serialVersionUID = 1L; - public OtherExtendedMessageFormat(final String pattern, final Locale locale, + OtherExtendedMessageFormat(final String pattern, final Locale locale, final Map<String, ? extends FormatFactory> registry) { super(pattern, locale, registry); } diff --git a/src/test/java/org/apache/commons/lang3/text/StrBuilderAppendInsertTest.java b/src/test/java/org/apache/commons/lang3/text/StrBuilderAppendInsertTest.java index ed86721e1..60d99376f 100644 --- a/src/test/java/org/apache/commons/lang3/text/StrBuilderAppendInsertTest.java +++ b/src/test/java/org/apache/commons/lang3/text/StrBuilderAppendInsertTest.java @@ -1061,11 +1061,11 @@ public class StrBuilderAppendInsertTest { assertEquals("", sb.toString()); sb.clear(); - sb.appendAll(new Object[0]); + sb.appendAll(); assertEquals("", sb.toString()); sb.clear(); - sb.appendAll(new Object[]{"foo", "bar", "baz"}); + sb.appendAll("foo", "bar", "baz"); assertEquals("foobarbaz", sb.toString()); sb.clear(); diff --git a/src/test/java/org/apache/commons/lang3/text/StrBuilderTest.java b/src/test/java/org/apache/commons/lang3/text/StrBuilderTest.java index ea684b621..09486efd6 100644 --- a/src/test/java/org/apache/commons/lang3/text/StrBuilderTest.java +++ b/src/test/java/org/apache/commons/lang3/text/StrBuilderTest.java @@ -170,7 +170,7 @@ public class StrBuilderTest { private final CharBuffer src; - public MockReadable(final String src) { + MockReadable(final String src) { this.src = CharBuffer.wrap(src); } diff --git a/src/test/java/org/apache/commons/lang3/text/StrMatcherTest.java b/src/test/java/org/apache/commons/lang3/text/StrMatcherTest.java index c26f22e85..24dd953ab 100644 --- a/src/test/java/org/apache/commons/lang3/text/StrMatcherTest.java +++ b/src/test/java/org/apache/commons/lang3/text/StrMatcherTest.java @@ -182,7 +182,7 @@ public class StrMatcherTest { assertEquals(0, matcher.isMatch(BUFFER2, 3)); assertEquals(1, matcher.isMatch(BUFFER2, 4)); assertEquals(0, matcher.isMatch(BUFFER2, 5)); - assertSame(StrMatcher.noneMatcher(), StrMatcher.charSetMatcher(new char[0])); + assertSame(StrMatcher.noneMatcher(), StrMatcher.charSetMatcher()); assertSame(StrMatcher.noneMatcher(), StrMatcher.charSetMatcher((char[]) null)); assertTrue(StrMatcher.charSetMatcher("a".toCharArray()) instanceof StrMatcher.CharMatcher); } diff --git a/src/test/java/org/apache/commons/lang3/time/DateFormatUtilsTest.java b/src/test/java/org/apache/commons/lang3/time/DateFormatUtilsTest.java index f19797423..a938caad4 100644 --- a/src/test/java/org/apache/commons/lang3/time/DateFormatUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/time/DateFormatUtilsTest.java @@ -225,7 +225,7 @@ public class DateFormatUtilsTest { public void testLang530() throws ParseException { final Date d = new Date(); final String isoDateStr = DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT.format(d); - final Date d2 = DateUtils.parseDate(isoDateStr, new String[] { DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT.getPattern() }); + final Date d2 = DateUtils.parseDate(isoDateStr, DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT.getPattern()); // the format loses milliseconds so have to reintroduce them assertEquals("Date not equal to itself ISO formatted and parsed", d.getTime(), d2.getTime() + d.getTime() % 1000); } diff --git a/src/test/java/org/apache/commons/lang3/time/DateUtilsTest.java b/src/test/java/org/apache/commons/lang3/time/DateUtilsTest.java index 77e110110..686c1a622 100644 --- a/src/test/java/org/apache/commons/lang3/time/DateUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/time/DateUtilsTest.java @@ -1282,7 +1282,7 @@ public class DateUtilsTest { public void testLang530() throws ParseException { final Date d = new Date(); final String isoDateStr = DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT.format(d); - final Date d2 = DateUtils.parseDate(isoDateStr, new String[] { DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT.getPattern() }); + final Date d2 = DateUtils.parseDate(isoDateStr, DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT.getPattern()); // the format loses milliseconds so have to reintroduce them assertEquals("Date not equal to itself ISO formatted and parsed", d.getTime(), d2.getTime() + d.getTime() % 1000); } @@ -1736,7 +1736,7 @@ public class DateUtilsTest { @Test public void testLANG799() throws ParseException { - DateUtils.parseDateStrictly("09 abril 2008 23:55:38 GMT", new Locale("es"), new String[]{"dd MMM yyyy HH:mm:ss zzz"}); + DateUtils.parseDateStrictly("09 abril 2008 23:55:38 GMT", new Locale("es"), "dd MMM yyyy HH:mm:ss zzz"); } } diff --git a/src/test/java/org/apache/commons/lang3/time/FastDateParserTest.java b/src/test/java/org/apache/commons/lang3/time/FastDateParserTest.java index c637f79e6..3289e5bb8 100644 --- a/src/test/java/org/apache/commons/lang3/time/FastDateParserTest.java +++ b/src/test/java/org/apache/commons/lang3/time/FastDateParserTest.java @@ -623,12 +623,12 @@ public class FastDateParserTest { return cal; } - private static enum Expected1806 { + private enum Expected1806 { India(INDIA, "+05", "+0530", "+05:30", true), Greenwich(GMT, "Z", "Z", "Z", false), NewYork(NEW_YORK, "-05", "-0500", "-05:00", false); - private Expected1806(final TimeZone zone, final String one, final String two, final String three, final boolean hasHalfHourOffset) { + Expected1806(final TimeZone zone, final String one, final String two, final String three, final boolean hasHalfHourOffset) { this.zone = zone; this.one = one; this.two = two; diff --git a/src/test/java/org/apache/commons/lang3/time/FastDatePrinterTest.java b/src/test/java/org/apache/commons/lang3/time/FastDatePrinterTest.java index 8d8372677..ff9180ce5 100644 --- a/src/test/java/org/apache/commons/lang3/time/FastDatePrinterTest.java +++ b/src/test/java/org/apache/commons/lang3/time/FastDatePrinterTest.java @@ -293,11 +293,11 @@ public class FastDatePrinterTest { getInstance("XXXX"); } - private static enum Expected1806 { + private enum Expected1806 { India(INDIA, "+05", "+0530", "+05:30"), Greenwich(GMT, "Z", "Z", "Z"), NewYork( NEW_YORK, "-05", "-0500", "-05:00"); - private Expected1806(final TimeZone zone, final String one, final String two, final String three) { + Expected1806(final TimeZone zone, final String one, final String two, final String three) { this.zone = zone; this.one = one; this.two = two; |