Prevent redundant modifiers

This commit is contained in:
Benedikt Ritter 2017-06-06 16:11:45 +02:00
parent 8a8b8ec8d2
commit 3a818ed6a8
No known key found for this signature in database
GPG Key ID: 9DAADC1C9FCC82D0
54 changed files with 236 additions and 246 deletions

View File

@ -21,4 +21,5 @@ limitations under the License.
<suppress checks="JavadocPackage" files=".*[/\\]test[/\\].*"/> <suppress checks="JavadocPackage" files=".*[/\\]test[/\\].*"/>
<!-- exclude generated JMH classes from all checks --> <!-- exclude generated JMH classes from all checks -->
<suppress checks="[a-zA-Z0-9]*" files=".*[/\\]generated-test-sources[/\\].*"/> <suppress checks="[a-zA-Z0-9]*" files=".*[/\\]generated-test-sources[/\\].*"/>
<suppress checks="RedundantModifier" files="ConstructorUtilsTest" lines="0-99999"/>
</suppressions> </suppressions>

View File

@ -47,6 +47,7 @@ limitations under the License.
<property name="scope" value="public" /> <property name="scope" value="public" />
</module> </module>
<module name="ModifierOrder"/> <module name="ModifierOrder"/>
<module name="RedundantModifier"/>
<module name="UpperEll" /> <module name="UpperEll" />
</module> </module>
</module> </module>

View File

@ -39,7 +39,7 @@ public class ArchUtils {
init(); init();
} }
private static final void init() { private static void init() {
init_X86_32Bit(); init_X86_32Bit();
init_X86_64Bit(); init_X86_64Bit();
init_IA64_32Bit(); init_IA64_32Bit();
@ -48,32 +48,32 @@ public class ArchUtils {
init_PPC_64Bit(); 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); Processor processor = new Processor(Processor.Arch.BIT_32, Processor.Type.X86);
addProcessors(processor, "x86", "i386", "i486", "i586", "i686", "pentium"); 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); Processor processor = new Processor(Processor.Arch.BIT_64, Processor.Type.X86);
addProcessors(processor, "x86_64", "amd64", "em64t", "universal"); 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); Processor processor = new Processor(Processor.Arch.BIT_32, Processor.Type.IA_64);
addProcessors(processor, "ia64_32", "ia64n"); 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); Processor processor = new Processor(Processor.Arch.BIT_64, Processor.Type.IA_64);
addProcessors(processor, "ia64", "ia64w"); 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); Processor processor = new Processor(Processor.Arch.BIT_32, Processor.Type.PPC);
addProcessors(processor, "ppc", "power", "powerpc", "power_pc", "power_rs"); 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); Processor processor = new Processor(Processor.Arch.BIT_64, Processor.Type.PPC);
addProcessors(processor, "ppc64", "power64", "powerpc64", "power_pc64", "power_rs64"); addProcessors(processor, "ppc64", "power64", "powerpc64", "power_pc64", "power_rs64");
} }
@ -85,7 +85,7 @@ public class ArchUtils {
* @param processor The {@link Processor} to add. * @param processor The {@link Processor} to add.
* @throws IllegalStateException If the key already exists. * @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)) { if (!ARCH_TO_PROCESSOR.containsKey(key)) {
ARCH_TO_PROCESSOR.put(key, processor); ARCH_TO_PROCESSOR.put(key, processor);
} else { } else {
@ -101,7 +101,7 @@ public class ArchUtils {
* @param processor The {@link Processor} to add. * @param processor The {@link Processor} to add.
* @throws IllegalStateException If the key already exists. * @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) { for (String key : keys) {
addProcessor(key, processor); addProcessor(key, processor);
} }
@ -117,7 +117,7 @@ public class ArchUtils {
* *
* @return A {@link Processor} when supported, else <code>null</code>. * @return A {@link Processor} when supported, else <code>null</code>.
*/ */
public static final Processor getProcessor() { public static Processor getProcessor() {
return getProcessor(SystemUtils.OS_ARCH); 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. * @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>. * @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); return ARCH_TO_PROCESSOR.get(value);
} }

View File

@ -201,7 +201,7 @@ public class EnumUtils {
@SafeVarargs @SafeVarargs
public static <E extends Enum<E>> long generateBitVector(final Class<E> enumClass, final E... values) { public static <E extends Enum<E>> long generateBitVector(final Class<E> enumClass, final E... values) {
Validate.noNullElements(values); Validate.noNullElements(values);
return generateBitVector(enumClass, Arrays.<E> asList(values)); return generateBitVector(enumClass, Arrays.asList(values));
} }
/** /**

View File

@ -220,7 +220,7 @@ public class SerializationUtils {
*/ */
public static <T> T deserialize(final byte[] objectData) { public static <T> T deserialize(final byte[] objectData) {
Validate.isTrue(objectData != null, "The byte[] must not be null"); 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. * @throws IOException if an I/O error occurs while reading stream header.
* @see java.io.ObjectInputStream * @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); super(in);
this.classLoader = classLoader; this.classLoader = classLoader;
} }

View File

@ -34,7 +34,7 @@ final class IDKey {
* Constructor for IDKey * Constructor for IDKey
* @param _value The value * @param _value The value
*/ */
public IDKey(final Object _value) { IDKey(final Object _value) {
// This is the Object hash code // This is the Object hash code
id = System.identityHashCode(_value); id = System.identityHashCode(_value);
// There have been some cases (LANG-459) that return the // There have been some cases (LANG-459) that return the

View File

@ -131,10 +131,7 @@ public class ReflectionDiffBuilder implements Builder<DiffResult> {
if (Modifier.isTransient(field.getModifiers())) { if (Modifier.isTransient(field.getModifiers())) {
return false; return false;
} }
if (Modifier.isStatic(field.getModifiers())) { return !Modifier.isStatic(field.getModifiers());
return false;
}
return true;
} }
} }

View File

@ -608,10 +608,7 @@ public class ReflectionToStringBuilder extends ToStringBuilder {
// Reject fields from the getExcludeFieldNames list. // Reject fields from the getExcludeFieldNames list.
return false; return false;
} }
if(field.isAnnotationPresent(ToStringExclude.class)) { return !field.isAnnotationPresent(ToStringExclude.class);
return false;
}
return true;
} }
/** /**

View File

@ -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 * transitions. This is done to avoid complex if-conditions in the code of
* {@code CircuitBreaker}. * {@code CircuitBreaker}.
*/ */
protected static enum State { protected enum State {
CLOSED { CLOSED {
/** /**
* {@inheritDoc} * {@inheritDoc}

View File

@ -310,7 +310,7 @@ public abstract class BackgroundInitializer<T> implements
* *
* @param exec the {@code ExecutorService} * @param exec the {@code ExecutorService}
*/ */
public InitializationTask(final ExecutorService exec) { InitializationTask(final ExecutorService exec) {
execFinally = exec; execFinally = exec;
} }

View File

@ -440,7 +440,7 @@ public class EventCountCircuitBreaker extends AbstractCircuitBreaker<Integer> {
* @param count the current count value * @param count the current count value
* @param intervalStart the start time of the check interval * @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; eventCount = count;
checkIntervalStart = intervalStart; checkIntervalStart = intervalStart;
} }

View File

@ -1365,7 +1365,7 @@ public class TypeUtils {
*/ */
public static Type unrollVariables(Map<TypeVariable<?>, Type> typeArguments, final Type type) { public static Type unrollVariables(Map<TypeVariable<?>, Type> typeArguments, final Type type) {
if (typeArguments == null) { if (typeArguments == null) {
typeArguments = Collections.<TypeVariable<?>, Type> emptyMap(); typeArguments = Collections.emptyMap();
} }
if (containsTypeVariables(type)) { if (containsTypeVariables(type)) {
if (type instanceof TypeVariable<?>) { if (type instanceof TypeVariable<?>) {
@ -1732,7 +1732,7 @@ public class TypeUtils {
* @since 3.2 * @since 3.2
*/ */
public static <T> Typed<T> wrap(final Class<T> type) { public static <T> Typed<T> wrap(final Class<T> type) {
return TypeUtils.<T> wrap((Type) type); return TypeUtils.wrap((Type) type);
} }
/** /**

View File

@ -280,10 +280,7 @@ public class ExtendedMessageFormat extends MessageFormat {
if (ObjectUtils.notEqual(toPattern, rhs.toPattern)) { if (ObjectUtils.notEqual(toPattern, rhs.toPattern)) {
return false; return false;
} }
if (ObjectUtils.notEqual(registry, rhs.registry)) { return !ObjectUtils.notEqual(registry, rhs.registry);
return false;
}
return true;
} }
/** /**

View File

@ -35,7 +35,7 @@ import java.util.EnumSet;
@Deprecated @Deprecated
public class NumericEntityUnescaper extends CharSequenceTranslator { 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 // TODO?: Create an OptionsSet class to hide some of the conditional logic below
private final EnumSet<OPTION> options; private final EnumSet<OPTION> options;
@ -71,7 +71,7 @@ public class NumericEntityUnescaper extends CharSequenceTranslator {
* @return whether the option is set * @return whether the option is set
*/ */
public boolean isSet(final OPTION option) { public boolean isSet(final OPTION option) {
return options == null ? false : options.contains(option); return options != null && options.contains(option);
} }
/** /**

View File

@ -230,7 +230,7 @@ abstract class FormatCache<F extends Format> {
* Constructs an instance of <code>MultipartKey</code> to hold the specified objects. * 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. * @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; this.keys = keys;
} }

View File

@ -377,7 +377,7 @@ public class AnnotationUtilsTest {
Stooge[] stooges(); Stooge[] stooges();
} }
public static enum Stooge { public enum Stooge {
MOE, LARRY, CURLY, JOE, SHEMP MOE, LARRY, CURLY, JOE, SHEMP
} }

View File

@ -285,7 +285,7 @@ public class ArrayUtilsAddTest {
// boolean // boolean
assertTrue( Arrays.equals( new boolean[] { true, false, false, true }, 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 }, assertTrue( Arrays.equals( new boolean[] { false, true },
ArrayUtils.addAll( null, new boolean[] { false, true } ) ) ); ArrayUtils.addAll( null, new boolean[] { false, true } ) ) );
@ -295,7 +295,7 @@ public class ArrayUtilsAddTest {
// char // char
assertTrue( Arrays.equals( new char[] { 'a', 'b', 'c', 'd' }, 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' }, assertTrue( Arrays.equals( new char[] { 'c', 'd' },
ArrayUtils.addAll( null, new char[] { 'c', 'd' } ) ) ); ArrayUtils.addAll( null, new char[] { 'c', 'd' } ) ) );
@ -305,7 +305,7 @@ public class ArrayUtilsAddTest {
// byte // byte
assertTrue( Arrays.equals( new byte[] { (byte) 0, (byte) 1, (byte) 2, (byte) 3 }, 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 }, assertTrue( Arrays.equals( new byte[] { (byte) 2, (byte) 3 },
ArrayUtils.addAll( null, new byte[] { (byte) 2, (byte) 3 } ) ) ); ArrayUtils.addAll( null, new byte[] { (byte) 2, (byte) 3 } ) ) );
@ -315,7 +315,7 @@ public class ArrayUtilsAddTest {
// short // short
assertTrue( Arrays.equals( new short[] { (short) 10, (short) 20, (short) 30, (short) 40 }, 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 }, assertTrue( Arrays.equals( new short[] { (short) 30, (short) 40 },
ArrayUtils.addAll( null, new short[] { (short) 30, (short) 40 } ) ) ); ArrayUtils.addAll( null, new short[] { (short) 30, (short) 40 } ) ) );
@ -325,7 +325,7 @@ public class ArrayUtilsAddTest {
// int // int
assertTrue( Arrays.equals( new int[] { 1, 1000, -1000, -1 }, 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 }, assertTrue( Arrays.equals( new int[] { -1000, -1 },
ArrayUtils.addAll( null, new int[] { -1000, -1 } ) ) ); ArrayUtils.addAll( null, new int[] { -1000, -1 } ) ) );
@ -335,7 +335,7 @@ public class ArrayUtilsAddTest {
// long // long
assertTrue( Arrays.equals( new long[] { 1L, -1L, 1000L, -1000L }, 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 }, assertTrue( Arrays.equals( new long[] { 1000L, -1000L },
ArrayUtils.addAll( null, new long[] { 1000L, -1000L } ) ) ); ArrayUtils.addAll( null, new long[] { 1000L, -1000L } ) ) );
@ -345,7 +345,7 @@ public class ArrayUtilsAddTest {
// float // float
assertTrue( Arrays.equals( new float[] { 10.5f, 10.1f, 1.6f, 0.01f }, 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 }, assertTrue( Arrays.equals( new float[] { 1.6f, 0.01f },
ArrayUtils.addAll( null, new float[] { 1.6f, 0.01f } ) ) ); ArrayUtils.addAll( null, new float[] { 1.6f, 0.01f } ) ) );
@ -355,7 +355,7 @@ public class ArrayUtilsAddTest {
// double // double
assertTrue( Arrays.equals( new double[] { Math.PI, -Math.PI, 0, 9.99 }, 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 }, assertTrue( Arrays.equals( new double[] { 0, 9.99 },
ArrayUtils.addAll( null, new double[] { 0, 9.99 } ) ) ); ArrayUtils.addAll( null, new double[] { 0, 9.99 } ) ) );

View File

@ -4740,49 +4740,49 @@ public class ArrayUtilsTest {
final Object[] emptyObjectArray = new Object[0]; final Object[] emptyObjectArray = new Object[0];
final Object[] notEmptyObjectArray = new Object[] {"aValue"}; final Object[] notEmptyObjectArray = new Object[] {"aValue"};
assertEquals(0, ArrayUtils.getLength((Object[]) null)); assertEquals(0, ArrayUtils.getLength(null));
assertEquals(0, ArrayUtils.getLength(emptyObjectArray)); assertEquals(0, ArrayUtils.getLength(emptyObjectArray));
assertEquals(1, ArrayUtils.getLength(notEmptyObjectArray)); assertEquals(1, ArrayUtils.getLength(notEmptyObjectArray));
final int[] emptyIntArray = new int[] {}; final int[] emptyIntArray = new int[] {};
final int[] notEmptyIntArray = new int[] { 1 }; final int[] notEmptyIntArray = new int[] { 1 };
assertEquals(0, ArrayUtils.getLength((int[]) null)); assertEquals(0, ArrayUtils.getLength(null));
assertEquals(0, ArrayUtils.getLength(emptyIntArray)); assertEquals(0, ArrayUtils.getLength(emptyIntArray));
assertEquals(1, ArrayUtils.getLength(notEmptyIntArray)); assertEquals(1, ArrayUtils.getLength(notEmptyIntArray));
final short[] emptyShortArray = new short[] {}; final short[] emptyShortArray = new short[] {};
final short[] notEmptyShortArray = new short[] { 1 }; final short[] notEmptyShortArray = new short[] { 1 };
assertEquals(0, ArrayUtils.getLength((short[]) null)); assertEquals(0, ArrayUtils.getLength(null));
assertEquals(0, ArrayUtils.getLength(emptyShortArray)); assertEquals(0, ArrayUtils.getLength(emptyShortArray));
assertEquals(1, ArrayUtils.getLength(notEmptyShortArray)); assertEquals(1, ArrayUtils.getLength(notEmptyShortArray));
final char[] emptyCharArray = new char[] {}; final char[] emptyCharArray = new char[] {};
final char[] notEmptyCharArray = new char[] { 1 }; final char[] notEmptyCharArray = new char[] { 1 };
assertEquals(0, ArrayUtils.getLength((char[]) null)); assertEquals(0, ArrayUtils.getLength(null));
assertEquals(0, ArrayUtils.getLength(emptyCharArray)); assertEquals(0, ArrayUtils.getLength(emptyCharArray));
assertEquals(1, ArrayUtils.getLength(notEmptyCharArray)); assertEquals(1, ArrayUtils.getLength(notEmptyCharArray));
final byte[] emptyByteArray = new byte[] {}; final byte[] emptyByteArray = new byte[] {};
final byte[] notEmptyByteArray = new byte[] { 1 }; final byte[] notEmptyByteArray = new byte[] { 1 };
assertEquals(0, ArrayUtils.getLength((byte[]) null)); assertEquals(0, ArrayUtils.getLength(null));
assertEquals(0, ArrayUtils.getLength(emptyByteArray)); assertEquals(0, ArrayUtils.getLength(emptyByteArray));
assertEquals(1, ArrayUtils.getLength(notEmptyByteArray)); assertEquals(1, ArrayUtils.getLength(notEmptyByteArray));
final double[] emptyDoubleArray = new double[] {}; final double[] emptyDoubleArray = new double[] {};
final double[] notEmptyDoubleArray = new double[] { 1.0 }; final double[] notEmptyDoubleArray = new double[] { 1.0 };
assertEquals(0, ArrayUtils.getLength((double[]) null)); assertEquals(0, ArrayUtils.getLength(null));
assertEquals(0, ArrayUtils.getLength(emptyDoubleArray)); assertEquals(0, ArrayUtils.getLength(emptyDoubleArray));
assertEquals(1, ArrayUtils.getLength(notEmptyDoubleArray)); assertEquals(1, ArrayUtils.getLength(notEmptyDoubleArray));
final float[] emptyFloatArray = new float[] {}; final float[] emptyFloatArray = new float[] {};
final float[] notEmptyFloatArray = new float[] { 1.0F }; final float[] notEmptyFloatArray = new float[] { 1.0F };
assertEquals(0, ArrayUtils.getLength((float[]) null)); assertEquals(0, ArrayUtils.getLength(null));
assertEquals(0, ArrayUtils.getLength(emptyFloatArray)); assertEquals(0, ArrayUtils.getLength(emptyFloatArray));
assertEquals(1, ArrayUtils.getLength(notEmptyFloatArray)); assertEquals(1, ArrayUtils.getLength(notEmptyFloatArray));
final boolean[] emptyBooleanArray = new boolean[] {}; final boolean[] emptyBooleanArray = new boolean[] {};
final boolean[] notEmptyBooleanArray = new boolean[] { true }; final boolean[] notEmptyBooleanArray = new boolean[] { true };
assertEquals(0, ArrayUtils.getLength((boolean[]) null)); assertEquals(0, ArrayUtils.getLength(null));
assertEquals(0, ArrayUtils.getLength(emptyBooleanArray)); assertEquals(0, ArrayUtils.getLength(emptyBooleanArray));
assertEquals(1, ArrayUtils.getLength(notEmptyBooleanArray)); assertEquals(1, ArrayUtils.getLength(notEmptyBooleanArray));

View File

@ -68,19 +68,19 @@ public class CharSetUtilsTest {
assertEquals(null, CharSetUtils.squeeze(null, new String[] {"el"})); assertEquals(null, CharSetUtils.squeeze(null, new String[] {"el"}));
assertEquals("", CharSetUtils.squeeze("", (String[]) null)); 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[] {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", (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[] {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("helo", CharSetUtils.squeeze("hello", "el"));
assertEquals("hello", CharSetUtils.squeeze("hello", new String[] { "e" })); assertEquals("hello", CharSetUtils.squeeze("hello", "e"));
assertEquals("fofof", CharSetUtils.squeeze("fooffooff", new String[] { "of" })); assertEquals("fofof", CharSetUtils.squeeze("fooffooff", "of"));
assertEquals("fof", CharSetUtils.squeeze("fooooff", new String[] { "fo" })); assertEquals("fof", CharSetUtils.squeeze("fooooff", "fo"));
} }
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
@ -102,25 +102,25 @@ public class CharSetUtilsTest {
@Test @Test
public void testContainsAny_StringStringarray() { public void testContainsAny_StringStringarray() {
assertFalse(CharSetUtils.containsAny(null, (String[]) null)); 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[] {null}));
assertFalse(CharSetUtils.containsAny(null, new String[] {"a-e"})); assertFalse(CharSetUtils.containsAny(null, "a-e"));
assertFalse(CharSetUtils.containsAny("", (String[]) null)); 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[] {null}));
assertFalse(CharSetUtils.containsAny("", new String[] {"a-e"})); assertFalse(CharSetUtils.containsAny("", "a-e"));
assertFalse(CharSetUtils.containsAny("hello", (String[]) null)); assertFalse(CharSetUtils.containsAny("hello", (String[]) null));
assertFalse(CharSetUtils.containsAny("hello", new String[0])); assertFalse(CharSetUtils.containsAny("hello"));
assertFalse(CharSetUtils.containsAny("hello", new String[] {null})); 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" })); assertTrue(CharSetUtils.containsAny("hello", "el"));
assertFalse(CharSetUtils.containsAny("hello", new String[] { "x" })); assertFalse(CharSetUtils.containsAny("hello", "x"));
assertTrue(CharSetUtils.containsAny("hello", new String[] { "e-i" })); assertTrue(CharSetUtils.containsAny("hello", "e-i"));
assertTrue(CharSetUtils.containsAny("hello", new String[] { "a-z" })); assertTrue(CharSetUtils.containsAny("hello", "a-z"));
assertFalse(CharSetUtils.containsAny("hello", new String[] { "" })); assertFalse(CharSetUtils.containsAny("hello", ""));
} }
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
@ -142,25 +142,25 @@ public class CharSetUtilsTest {
@Test @Test
public void testCount_StringStringarray() { public void testCount_StringStringarray() {
assertEquals(0, CharSetUtils.count(null, (String[]) null)); 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[] {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("", (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[] {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", (String[]) null));
assertEquals(0, CharSetUtils.count("hello", new String[0])); assertEquals(0, CharSetUtils.count("hello"));
assertEquals(0, CharSetUtils.count("hello", new String[] {null})); 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(3, CharSetUtils.count("hello", "el"));
assertEquals(0, CharSetUtils.count("hello", new String[] { "x" })); assertEquals(0, CharSetUtils.count("hello", "x"));
assertEquals(2, CharSetUtils.count("hello", new String[] { "e-i" })); assertEquals(2, CharSetUtils.count("hello", "e-i"));
assertEquals(5, CharSetUtils.count("hello", new String[] { "a-z" })); assertEquals(5, CharSetUtils.count("hello", "a-z"));
assertEquals(0, CharSetUtils.count("hello", new String[] { "" })); assertEquals(0, CharSetUtils.count("hello", ""));
} }
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
@ -189,21 +189,21 @@ public class CharSetUtilsTest {
assertEquals(null, CharSetUtils.keep(null, new String[] {"a-e"})); assertEquals(null, CharSetUtils.keep(null, new String[] {"a-e"}));
assertEquals("", CharSetUtils.keep("", (String[]) null)); 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[] {null}));
assertEquals("", CharSetUtils.keep("", new String[] {"a-e"})); assertEquals("", CharSetUtils.keep("", "a-e"));
assertEquals("", CharSetUtils.keep("hello", (String[]) null)); 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("", CharSetUtils.keep("hello", new String[] {null}));
assertEquals("e", CharSetUtils.keep("hello", new String[] {"a-e"})); assertEquals("e", CharSetUtils.keep("hello", "a-e"));
assertEquals("e", CharSetUtils.keep("hello", new String[] { "a-e" })); assertEquals("e", CharSetUtils.keep("hello", "a-e"));
assertEquals("ell", CharSetUtils.keep("hello", new String[] { "el" })); assertEquals("ell", CharSetUtils.keep("hello", "el"));
assertEquals("hello", CharSetUtils.keep("hello", new String[] { "elho" })); assertEquals("hello", CharSetUtils.keep("hello", "elho"));
assertEquals("hello", CharSetUtils.keep("hello", new String[] { "a-z" })); assertEquals("hello", CharSetUtils.keep("hello", "a-z"));
assertEquals("----", CharSetUtils.keep("----", new String[] { "-" })); assertEquals("----", CharSetUtils.keep("----", "-"));
assertEquals("ll", CharSetUtils.keep("hello", new String[] { "l" })); assertEquals("ll", CharSetUtils.keep("hello", "l"));
} }
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
@ -231,22 +231,22 @@ public class CharSetUtilsTest {
assertEquals(null, CharSetUtils.delete(null, new String[] {"el"})); assertEquals(null, CharSetUtils.delete(null, new String[] {"el"}));
assertEquals("", CharSetUtils.delete("", (String[]) null)); 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[] {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", (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[] {null}));
assertEquals("hello", CharSetUtils.delete("hello", new String[] {"xyz"})); assertEquals("hello", CharSetUtils.delete("hello", "xyz"));
assertEquals("ho", CharSetUtils.delete("hello", new String[] { "el" })); assertEquals("ho", CharSetUtils.delete("hello", "el"));
assertEquals("", CharSetUtils.delete("hello", new String[] { "elho" })); assertEquals("", CharSetUtils.delete("hello", "elho"));
assertEquals("hello", CharSetUtils.delete("hello", new String[] { "" }));
assertEquals("hello", CharSetUtils.delete("hello", "")); assertEquals("hello", CharSetUtils.delete("hello", ""));
assertEquals("", CharSetUtils.delete("hello", new String[] { "a-z" })); assertEquals("hello", CharSetUtils.delete("hello", ""));
assertEquals("", CharSetUtils.delete("----", new String[] { "-" })); assertEquals("", CharSetUtils.delete("hello", "a-z"));
assertEquals("heo", CharSetUtils.delete("hello", new String[] { "l" })); assertEquals("", CharSetUtils.delete("----", "-"));
assertEquals("heo", CharSetUtils.delete("hello", "l"));
} }
} }

View File

@ -281,17 +281,17 @@ public class ClassUtilsTest {
assertEquals(null, ClassUtils.getAllInterfaces(null)); 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 { private static class CX implements IB, IA, IE {
} }
@ -378,7 +378,7 @@ public class ClassUtilsTest {
assertTrue(ClassUtils.isAssignable(null, array0)); assertTrue(ClassUtils.isAssignable(null, array0));
assertTrue(ClassUtils.isAssignable(array0, array0)); assertTrue(ClassUtils.isAssignable(array0, array0));
assertTrue(ClassUtils.isAssignable(array0, (Class<?>[]) null)); // explicit cast to avoid warning 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)); assertFalse(ClassUtils.isAssignable(array1, array1s));
assertTrue(ClassUtils.isAssignable(array1s, array1s)); assertTrue(ClassUtils.isAssignable(array1s, array1s));
@ -1096,9 +1096,9 @@ public class ClassUtilsTest {
public void testShowJavaBug() throws Exception { public void testShowJavaBug() throws Exception {
// Tests with Collections$UnmodifiableSet // Tests with Collections$UnmodifiableSet
final Set<?> set = Collections.unmodifiableSet(new HashSet<>()); 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 { try {
isEmptyMethod.invoke(set, new Object[0]); isEmptyMethod.invoke(set);
fail("Failed to throw IllegalAccessException as expected"); fail("Failed to throw IllegalAccessException as expected");
} catch(final IllegalAccessException iae) { } catch(final IllegalAccessException iae) {
// expected // expected
@ -1109,17 +1109,17 @@ public class ClassUtilsTest {
public void testGetPublicMethod() throws Exception { public void testGetPublicMethod() throws Exception {
// Tests with Collections$UnmodifiableSet // Tests with Collections$UnmodifiableSet
final Set<?> set = Collections.unmodifiableSet(new HashSet<>()); 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())); assertTrue(Modifier.isPublic(isEmptyMethod.getDeclaringClass().getModifiers()));
try { try {
isEmptyMethod.invoke(set, new Object[0]); isEmptyMethod.invoke(set);
} catch(final java.lang.IllegalAccessException iae) { } catch(final java.lang.IllegalAccessException iae) {
fail("Should not have thrown IllegalAccessException"); fail("Should not have thrown IllegalAccessException");
} }
// Tests with a public Class // 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); 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)); assertSame(ArrayUtils.EMPTY_CLASS_ARRAY, ClassUtils.toClass(ArrayUtils.EMPTY_OBJECT_ARRAY));
assertTrue(Arrays.equals(new Class[] { String.class, Integer.class, Double.class }, 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 }, 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 @Test

View File

@ -77,7 +77,7 @@ public class ObjectUtilsTest {
assertSame(Boolean.TRUE, ObjectUtils.firstNonNull(Boolean.TRUE)); 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 // 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 // Cast to Object in line below ensures compiler doesn't complain of unchecked generic array creation
assertNull(ObjectUtils.firstNonNull(null, null)); assertNull(ObjectUtils.firstNonNull(null, null));
@ -631,7 +631,7 @@ public class ObjectUtilsTest {
* *
* @param value * @param value
*/ */
public NonComparableCharSequence(final String value) { NonComparableCharSequence(final String value) {
super(); super();
Validate.notNull(value); Validate.notNull(value);
this.value = value; this.value = value;

View File

@ -59,7 +59,7 @@ public class StringUtilsEqualsIndexOfTest {
private static class CustomCharSequence implements CharSequence { private static class CustomCharSequence implements CharSequence {
private final CharSequence seq; private final CharSequence seq;
public CustomCharSequence(final CharSequence seq) { CustomCharSequence(final CharSequence seq) {
this.seq = seq; this.seq = seq;
} }

View File

@ -243,14 +243,14 @@ public class StringUtilsTest {
// assertNull(StringUtils.join(null)); // generates warning // assertNull(StringUtils.join(null)); // generates warning
assertNull(StringUtils.join((Object[]) null)); // equivalent explicit cast assertNull(StringUtils.join((Object[]) null)); // equivalent explicit cast
// test additional varargs calls // 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((Object) null)); // => new Object[]{null}
assertEquals("", StringUtils.join(EMPTY_ARRAY_LIST)); assertEquals("", StringUtils.join(EMPTY_ARRAY_LIST));
assertEquals("", StringUtils.join(NULL_ARRAY_LIST)); assertEquals("", StringUtils.join(NULL_ARRAY_LIST));
assertEquals("null", StringUtils.join(NULL_TO_STRING_LIST)); assertEquals("null", StringUtils.join(NULL_TO_STRING_LIST));
assertEquals("abc", StringUtils.join(new String[]{"a", "b", "c"})); assertEquals("abc", StringUtils.join("a", "b", "c"));
assertEquals("a", StringUtils.join(new String[]{null, "a", ""})); assertEquals("a", StringUtils.join(null, "a", ""));
assertEquals("foo", StringUtils.join(MIXED_ARRAY_LIST)); assertEquals("foo", StringUtils.join(MIXED_ARRAY_LIST));
assertEquals("foo2", StringUtils.join(MIXED_TYPE_LIST)); assertEquals("foo2", StringUtils.join(MIXED_TYPE_LIST));
} }
@ -422,12 +422,12 @@ public class StringUtilsTest {
@Test @Test
public void testJoinWith() { public void testJoinWith() {
assertEquals("", StringUtils.joinWith(",", new Object[0])); // empty array assertEquals("", StringUtils.joinWith(",")); // empty array
assertEquals("", StringUtils.joinWith(",", (Object[]) NULL_ARRAY_LIST)); assertEquals("", StringUtils.joinWith(",", (Object[]) NULL_ARRAY_LIST));
assertEquals("null", StringUtils.joinWith(",", NULL_TO_STRING_LIST)); //toString method prints 'null' 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,b,c", StringUtils.joinWith(",", "a", "b", "c"));
assertEquals(",a,", StringUtils.joinWith(",", new Object[]{null, "a", ""})); assertEquals(",a,", StringUtils.joinWith(",", null, "a", ""));
assertEquals("ab", StringUtils.joinWith(null, "a", "b")); assertEquals("ab", StringUtils.joinWith(null, "a", "b"));
} }
@ -1553,7 +1553,7 @@ public class StringUtilsTest {
assertEquals("abcabcabc", StringUtils.repeat("abc", 3)); assertEquals("abcabcabc", StringUtils.repeat("abc", 3));
final String str = StringUtils.repeat("a", 10000); // bigger than pad limit final String str = StringUtils.repeat("a", 10000); // bigger than pad limit
assertEquals(10000, str.length()); assertEquals(10000, str.length());
assertTrue(StringUtils.containsOnly(str, new char[]{'a'})); assertTrue(StringUtils.containsOnly(str, 'a'));
} }
@Test @Test
@ -1680,7 +1680,7 @@ public class StringUtilsTest {
assertEquals("abcxx", StringUtils.rightPad("abc", 5, 'x')); assertEquals("abcxx", StringUtils.rightPad("abc", 5, 'x'));
final String str = StringUtils.rightPad("aaa", 10000, 'a'); // bigger than pad length final String str = StringUtils.rightPad("aaa", 10000, 'a'); // bigger than pad length
assertEquals(10000, str.length()); assertEquals(10000, str.length());
assertTrue(StringUtils.containsOnly(str, new char[]{'a'})); assertTrue(StringUtils.containsOnly(str, 'a'));
} }
@Test @Test
@ -1716,7 +1716,7 @@ public class StringUtilsTest {
assertEquals("abc", StringUtils.leftPad("abc", 2, ' ')); assertEquals("abc", StringUtils.leftPad("abc", 2, ' '));
final String str = StringUtils.leftPad("aaa", 10000, 'a'); // bigger than pad length final String str = StringUtils.leftPad("aaa", 10000, 'a'); // bigger than pad length
assertEquals(10000, str.length()); assertEquals(10000, str.length());
assertTrue(StringUtils.containsOnly(str, new char[]{'a'})); assertTrue(StringUtils.containsOnly(str, 'a'));
} }
@Test @Test

View File

@ -337,11 +337,11 @@ public class ThreadUtilsTest {
private static class TestThread extends Thread { private static class TestThread extends Thread {
private final CountDownLatch latch = new CountDownLatch(1); private final CountDownLatch latch = new CountDownLatch(1);
public TestThread(final String name) { TestThread(final String name) {
super(name); super(name);
} }
public TestThread(final ThreadGroup group, final String name) { TestThread(final ThreadGroup group, final String name) {
super(group, name); super(group, name);
} }

View File

@ -721,7 +721,7 @@ public class ValidateTest {
assertEquals("Broken: ", ex.getMessage()); 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"); final List<String> test = Validate.validIndex(strColl, 0, "Message");
assertSame(strColl, test); assertSame(strColl, test);
} }
@ -746,7 +746,7 @@ public class ValidateTest {
assertEquals("The validated collection index is invalid: 2", ex.getMessage()); 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); final List<String> test = Validate.validIndex(strColl, 0);
assertSame(strColl, test); assertSame(strColl, test);
} }

View File

@ -32,7 +32,7 @@ public class CompareToBuilderTest {
static class TestObject implements Comparable<TestObject> { static class TestObject implements Comparable<TestObject> {
private int a; private int a;
public TestObject(final int a) { TestObject(final int a) {
this.a = a; this.a = a;
} }
@Override @Override
@ -67,10 +67,10 @@ public class CompareToBuilderTest {
static class TestSubObject extends TestObject { static class TestSubObject extends TestObject {
private int b; private int b;
public TestSubObject() { TestSubObject() {
super(0); super(0);
} }
public TestSubObject(final int a, final int b) { TestSubObject(final int a, final int b) {
super(a); super(a);
this.b = b; this.b = b;
} }
@ -90,7 +90,7 @@ public class CompareToBuilderTest {
static class TestTransientSubObject extends TestObject { static class TestTransientSubObject extends TestObject {
@SuppressWarnings("unused") @SuppressWarnings("unused")
private transient int t; private transient int t;
public TestTransientSubObject(final int a, final int t) { TestTransientSubObject(final int a, final int t) {
super(a); super(a);
this.t = t; this.t = t;
} }

View File

@ -36,11 +36,11 @@ public class DiffResultTest {
private static class SimpleClass implements Diffable<SimpleClass> { private static class SimpleClass implements Diffable<SimpleClass> {
private final boolean booleanField; private final boolean booleanField;
public SimpleClass(final boolean booleanField) { SimpleClass(final boolean booleanField) {
this.booleanField = booleanField; this.booleanField = booleanField;
} }
public static String getFieldName() { static String getFieldName() {
return "booleanField"; return "booleanField";
} }

View File

@ -34,9 +34,9 @@ public class EqualsBuilderTest {
static class TestObject { static class TestObject {
private int a; private int a;
public TestObject() { TestObject() {
} }
public TestObject(final int a) { TestObject(final int a) {
this.a = a; this.a = a;
} }
@Override @Override
@ -67,10 +67,10 @@ public class EqualsBuilderTest {
static class TestSubObject extends TestObject { static class TestSubObject extends TestObject {
private int b; private int b;
public TestSubObject() { TestSubObject() {
super(0); super(0);
} }
public TestSubObject(final int a, final int b) { TestSubObject(final int a, final int b) {
super(a); super(a);
this.b = b; this.b = b;
} }
@ -101,7 +101,7 @@ public class EqualsBuilderTest {
} }
static class TestEmptySubObject extends TestObject { static class TestEmptySubObject extends TestObject {
public TestEmptySubObject(final int a) { TestEmptySubObject(final int a) {
super(a); super(a);
} }
} }
@ -109,7 +109,7 @@ public class EqualsBuilderTest {
static class TestTSubObject extends TestObject { static class TestTSubObject extends TestObject {
@SuppressWarnings("unused") @SuppressWarnings("unused")
private transient int t; private transient int t;
public TestTSubObject(final int a, final int t) { TestTSubObject(final int a, final int t) {
super(a); super(a);
this.t = t; this.t = t;
} }
@ -118,7 +118,7 @@ public class EqualsBuilderTest {
static class TestTTSubObject extends TestTSubObject { static class TestTTSubObject extends TestTSubObject {
@SuppressWarnings("unused") @SuppressWarnings("unused")
private transient int tt; 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); super(a, t);
this.tt = tt; this.tt = tt;
} }
@ -127,7 +127,7 @@ public class EqualsBuilderTest {
static class TestTTLeafObject extends TestTTSubObject { static class TestTTLeafObject extends TestTTSubObject {
@SuppressWarnings("unused") @SuppressWarnings("unused")
private final int leafValue; 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); super(a, t, tt);
this.leafValue = leafValue; this.leafValue = leafValue;
} }
@ -135,7 +135,7 @@ public class EqualsBuilderTest {
static class TestTSubObject2 extends TestObject { static class TestTSubObject2 extends TestObject {
private transient int t; private transient int t;
public TestTSubObject2(final int a, final int t) { TestTSubObject2(final int a, final int t) {
super(a); super(a);
} }
public int getT() { public int getT() {
@ -151,7 +151,7 @@ public class EqualsBuilderTest {
private final TestRecursiveInnerObject b; private final TestRecursiveInnerObject b;
private int z; private int z;
public TestRecursiveObject(final TestRecursiveInnerObject a, TestRecursiveObject(final TestRecursiveInnerObject a,
final TestRecursiveInnerObject b, final int z) { final TestRecursiveInnerObject b, final int z) {
this.a = a; this.a = a;
this.b = b; this.b = b;
@ -173,7 +173,7 @@ public class EqualsBuilderTest {
static class TestRecursiveInnerObject { static class TestRecursiveInnerObject {
private final int n; private final int n;
public TestRecursiveInnerObject(final int n) { TestRecursiveInnerObject(final int n) {
this.n = n; this.n = n;
} }
@ -185,12 +185,12 @@ public class EqualsBuilderTest {
static class TestRecursiveCycleObject { static class TestRecursiveCycleObject {
private TestRecursiveCycleObject cycle; private TestRecursiveCycleObject cycle;
private final int n; private final int n;
public TestRecursiveCycleObject(final int n) { TestRecursiveCycleObject(final int n) {
this.n = n; this.n = n;
this.cycle = this; this.cycle = this;
} }
public TestRecursiveCycleObject(final TestRecursiveCycleObject cycle, final int n) { TestRecursiveCycleObject(final TestRecursiveCycleObject cycle, final int n) {
this.n = n; this.n = n;
this.cycle = cycle; 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 // 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, (String[]) null));
assertFalse(EqualsBuilder.reflectionEquals(x1, x2, new String[] {})); assertFalse(EqualsBuilder.reflectionEquals(x1, x2));
assertFalse(EqualsBuilder.reflectionEquals(x1, x2, new String[] {"xxx"})); assertFalse(EqualsBuilder.reflectionEquals(x1, x2, "xxx"));
// not equal if only one of the differing fields excluded // not equal if only one of the differing fields excluded
assertFalse(EqualsBuilder.reflectionEquals(x1, x2, new String[] {"two"})); assertFalse(EqualsBuilder.reflectionEquals(x1, x2, "two"));
assertFalse(EqualsBuilder.reflectionEquals(x1, x2, new String[] {"three"})); assertFalse(EqualsBuilder.reflectionEquals(x1, x2, "three"));
// equal if both differing fields excluded // 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 // 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, "one", "two", "three"));
assertTrue(EqualsBuilder.reflectionEquals(x1, x2, new String[] {"one", "two", "three", "xxx"})); assertTrue(EqualsBuilder.reflectionEquals(x1, x2, "one", "two", "three", "xxx"));
} }
static class TestObjectWithMultipleFields { static class TestObjectWithMultipleFields {
@ -1187,7 +1187,7 @@ public class EqualsBuilderTest {
@SuppressWarnings("unused") @SuppressWarnings("unused")
private final TestObject three; 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.one = new TestObject(one);
this.two = new TestObject(two); this.two = new TestObject(two);
this.three = new TestObject(three); this.three = new TestObject(three);
@ -1229,7 +1229,7 @@ public class EqualsBuilderTest {
@SuppressWarnings("unused") @SuppressWarnings("unused")
private final TestObject one; private final TestObject one;
public TestObjectReference(final int one) { TestObjectReference(final int one) {
this.one = new TestObject(one); this.one = new TestObject(one);
} }
@ -1271,7 +1271,7 @@ public class EqualsBuilderTest {
private final int a; private final int a;
private final int b; private final int b;
public TestObjectEqualsExclude(final int a, final int b) { TestObjectEqualsExclude(final int a, final int b) {
this.a = a; this.a = a;
this.b = b; this.b = b;
} }

View File

@ -75,7 +75,7 @@ public class HashCodeBuilderTest {
static class TestObject { static class TestObject {
private int a; private int a;
public TestObject(final int a) { TestObject(final int a) {
this.a = a; this.a = a;
} }
@ -111,11 +111,11 @@ public class HashCodeBuilderTest {
@SuppressWarnings("unused") @SuppressWarnings("unused")
private transient int t; private transient int t;
public TestSubObject() { TestSubObject() {
super(0); 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); super(a);
this.b = b; this.b = b;
this.t = t; 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));
assertEquals(((17 * 37 + 1) * 37 + 2) * 37 + 3, HashCodeBuilder.reflectionHashCode(x, (String[]) null)); 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));
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, "xxx"));
assertEquals((17 * 37 + 1) * 37 + 3, HashCodeBuilder.reflectionHashCode(x, new String[]{"two"})); assertEquals((17 * 37 + 1) * 37 + 3, HashCodeBuilder.reflectionHashCode(x, "two"));
assertEquals((17 * 37 + 1) * 37 + 2, HashCodeBuilder.reflectionHashCode(x, new String[]{"three"})); 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, "one", "two", "three"));
assertEquals(17, HashCodeBuilder.reflectionHashCode(x, new String[]{"one", "two", "three", "xxx"})); assertEquals(17, HashCodeBuilder.reflectionHashCode(x, "one", "two", "three", "xxx"));
} }
static class TestObjectWithMultipleFields { static class TestObjectWithMultipleFields {
@ -513,7 +513,7 @@ public class HashCodeBuilderTest {
@SuppressWarnings("unused") @SuppressWarnings("unused")
private int three = 0; 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.one = one;
this.two = two; this.two = two;
this.three = three; this.three = three;
@ -568,7 +568,7 @@ public class HashCodeBuilderTest {
private final int a; private final int a;
private final int b; private final int b;
public TestObjectHashCodeExclude(final int a, final int b) { TestObjectHashCodeExclude(final int a, final int b) {
this.a = a; this.a = a;
this.b = b; this.b = b;
} }
@ -588,7 +588,7 @@ public class HashCodeBuilderTest {
@HashCodeExclude @HashCodeExclude
private final int b; private final int b;
public TestObjectHashCodeExclude2(final int a, final int b) { TestObjectHashCodeExclude2(final int a, final int b) {
this.a = a; this.a = a;
this.b = b; this.b = b;
} }

View File

@ -235,7 +235,7 @@ public class MultilineRecursiveToStringStyleTest {
static class Bank { static class Bank {
String name; String name;
public Bank(final String name) { Bank(final String name) {
this.name = name; this.name = name;
} }
} }
@ -245,7 +245,7 @@ public class MultilineRecursiveToStringStyleTest {
Bank bank; Bank bank;
List<Account> accounts; List<Account> accounts;
public Customer(final String name) { Customer(final String name) {
this.name = name; this.name = name;
} }
} }
@ -267,7 +267,7 @@ public class MultilineRecursiveToStringStyleTest {
double amount; double amount;
String date; String date;
public Transaction(final String datum, final double betrag) { Transaction(final String datum, final double betrag) {
this.date = datum; this.date = datum;
this.amount = betrag; this.amount = betrag;
} }

View File

@ -30,7 +30,7 @@ public class ReflectionToStringBuilderExcludeNullValuesTest {
@SuppressWarnings("unused") @SuppressWarnings("unused")
private String testStringField; private String testStringField;
public TestFixture(Integer a, String b) { TestFixture(Integer a, String b) {
this.testIntegerField = a; this.testIntegerField = a;
this.testStringField = b; this.testStringField = b;
} }

View File

@ -54,7 +54,7 @@ public class ReflectionToStringBuilderExcludeTest {
@Test @Test
public void test_toStringExcludeArray() { 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); this.validateSecretFieldAbsent(toString);
} }
@ -66,7 +66,7 @@ public class ReflectionToStringBuilderExcludeTest {
@Test @Test
public void test_toStringExcludeArrayWithNulls() { 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); this.validateSecretFieldPresent(toString);
} }

View File

@ -41,7 +41,7 @@ public class ReflectionToStringBuilderMutateInspectConcurrencyTest {
private final Random random = new Random(); private final Random random = new Random();
private final int N = 100; private final int N = 100;
public TestFixture() { TestFixture() {
synchronized (this) { synchronized (this) {
for (int i = 0; i < N; i++) { for (int i = 0; i < N; i++) {
listField.add(Integer.valueOf(i)); listField.add(Integer.valueOf(i));
@ -62,7 +62,7 @@ public class ReflectionToStringBuilderMutateInspectConcurrencyTest {
private final TestFixture testFixture; private final TestFixture testFixture;
private final Random random = new Random(); private final Random random = new Random();
public MutatingClient(final TestFixture testFixture) { MutatingClient(final TestFixture testFixture) {
this.testFixture = testFixture; this.testFixture = testFixture;
} }
@ -79,7 +79,7 @@ public class ReflectionToStringBuilderMutateInspectConcurrencyTest {
class InspectingClient implements Runnable { class InspectingClient implements Runnable {
private final TestFixture testFixture; private final TestFixture testFixture;
public InspectingClient(final TestFixture testFixture) { InspectingClient(final TestFixture testFixture) {
this.testFixture = testFixture; this.testFixture = testFixture;
} }

View File

@ -472,10 +472,10 @@ public class ToStringBuilderTest {
static class SimpleReflectionTestFixture { static class SimpleReflectionTestFixture {
Object o; Object o;
public SimpleReflectionTestFixture() { SimpleReflectionTestFixture() {
} }
public SimpleReflectionTestFixture(final Object o) { SimpleReflectionTestFixture(final Object o) {
this.o = o; this.o = o;
} }
@ -489,7 +489,7 @@ public class ToStringBuilderTest {
@SuppressWarnings("unused") @SuppressWarnings("unused")
private final SelfInstanceVarReflectionTestFixture typeIsSelf; private final SelfInstanceVarReflectionTestFixture typeIsSelf;
public SelfInstanceVarReflectionTestFixture() { SelfInstanceVarReflectionTestFixture() {
this.typeIsSelf = this; this.typeIsSelf = this;
} }
@ -504,7 +504,7 @@ public class ToStringBuilderTest {
private final SelfInstanceTwoVarsReflectionTestFixture typeIsSelf; private final SelfInstanceTwoVarsReflectionTestFixture typeIsSelf;
private final String otherType = "The Other Type"; private final String otherType = "The Other Type";
public SelfInstanceTwoVarsReflectionTestFixture() { SelfInstanceTwoVarsReflectionTestFixture() {
this.typeIsSelf = this; this.typeIsSelf = this;
} }

View File

@ -297,11 +297,11 @@ public class BackgroundInitializerTest {
/** The number of invocations of initialize(). */ /** The number of invocations of initialize(). */
volatile int initializeCalls; volatile int initializeCalls;
public BackgroundInitializerTestImpl() { BackgroundInitializerTestImpl() {
super(); super();
} }
public BackgroundInitializerTestImpl(final ExecutorService exec) { BackgroundInitializerTestImpl(final ExecutorService exec) {
super(exec); super(exec);
} }

View File

@ -330,7 +330,7 @@ public class EventCountCircuitBreakerTest {
/** The current time in nanoseconds. */ /** The current time in nanoseconds. */
private long currentTime; 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 openingUnit, final int closingThreshold, final long closingInterval,
final TimeUnit closingUnit) { final TimeUnit closingUnit) {
super(openingThreshold, openingInterval, openingUnit, closingThreshold, super(openingThreshold, openingInterval, openingUnit, closingThreshold,
@ -374,7 +374,7 @@ public class EventCountCircuitBreakerTest {
* *
* @param source the expected event source * @param source the expected event source
*/ */
public ChangeListener(final Object source) { ChangeListener(final Object source) {
expectedSource = source; expectedSource = source;
changedValues = new ArrayList<>(); changedValues = new ArrayList<>();
} }

View File

@ -434,12 +434,12 @@ public class TimedSemaphoreTest {
/** Counter for the endOfPeriod() invocations. */ /** Counter for the endOfPeriod() invocations. */
private int periodEnds; private int periodEnds;
public TimedSemaphoreTestImpl(final long timePeriod, final TimeUnit timeUnit, TimedSemaphoreTestImpl(final long timePeriod, final TimeUnit timeUnit,
final int limit) { final int limit) {
super(timePeriod, timeUnit, limit); super(timePeriod, timeUnit, limit);
} }
public TimedSemaphoreTestImpl(final ScheduledExecutorService service, TimedSemaphoreTestImpl(final ScheduledExecutorService service,
final long timePeriod, final TimeUnit timeUnit, final int limit) { final long timePeriod, final TimeUnit timeUnit, final int limit) {
super(service, timePeriod, timeUnit, limit); super(service, timePeriod, timeUnit, limit);
} }
@ -449,7 +449,7 @@ public class TimedSemaphoreTest {
* *
* @return the endOfPeriod() invocations * @return the endOfPeriod() invocations
*/ */
public int getPeriodEnds() { int getPeriodEnds() {
synchronized (this) { synchronized (this) {
return periodEnds; return periodEnds;
} }
@ -504,7 +504,7 @@ public class TimedSemaphoreTest {
/** The number of invocations of the latch. */ /** The number of invocations of the latch. */
private final int latchCount; 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; semaphore = b;
latch = l; latch = l;
count = c; count = c;
@ -546,7 +546,7 @@ public class TimedSemaphoreTest {
/** Flag whether a permit could be acquired. */ /** Flag whether a permit could be acquired. */
private boolean acquired; private boolean acquired;
public TryAcquireThread(final TimedSemaphore s, final CountDownLatch l) { TryAcquireThread(final TimedSemaphore s, final CountDownLatch l) {
semaphore = s; semaphore = s;
latch = l; latch = l;
} }

View File

@ -160,11 +160,11 @@ public class EventUtilsTest
assertEquals(1, counter.getCount()); 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 public static class EventCounter

View File

@ -489,12 +489,12 @@ public class ExceptionUtilsTest {
private Throwable cause; private Throwable cause;
public ExceptionWithCause(final String str, final Throwable cause) { ExceptionWithCause(final String str, final Throwable cause) {
super(str); super(str);
setCause(cause); setCause(cause);
} }
public ExceptionWithCause(final Throwable cause) { ExceptionWithCause(final Throwable cause) {
super(); super();
setCause(cause); setCause(cause);
} }
@ -528,8 +528,8 @@ public class ExceptionUtilsTest {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@SuppressWarnings("unused") @SuppressWarnings("unused")
public NestableException() { super(); } NestableException() { super(); }
public NestableException(final Throwable t) { super(t); } NestableException(final Throwable t) { super(t); }
} }
@Test @Test

View File

@ -61,7 +61,7 @@ public class IEEE754rUtilsTest {
} catch(final IllegalArgumentException iae) { /* expected */ } } catch(final IllegalArgumentException iae) { /* expected */ }
try { try {
IEEE754rUtils.min(new float[0]); IEEE754rUtils.min();
fail("IllegalArgumentException expected for empty input"); fail("IllegalArgumentException expected for empty input");
} catch(final IllegalArgumentException iae) { /* expected */ } } catch(final IllegalArgumentException iae) { /* expected */ }
@ -71,7 +71,7 @@ public class IEEE754rUtilsTest {
} catch(final IllegalArgumentException iae) { /* expected */ } } catch(final IllegalArgumentException iae) { /* expected */ }
try { try {
IEEE754rUtils.max(new float[0]); IEEE754rUtils.max();
fail("IllegalArgumentException expected for empty input"); fail("IllegalArgumentException expected for empty input");
} catch(final IllegalArgumentException iae) { /* expected */ } } catch(final IllegalArgumentException iae) { /* expected */ }

View File

@ -565,15 +565,15 @@ public class NumberUtilsTest {
assertEquals( assertEquals(
"min(int[]) failed for array length 1", "min(int[]) failed for array length 1",
5, 5,
NumberUtils.min(new int[] { 5 })); NumberUtils.min(5));
assertEquals( assertEquals(
"min(int[]) failed for array length 2", "min(int[]) failed for array length 2",
6, 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(-10, -5, 0, 5, 10));
assertEquals(-10, NumberUtils.min(new int[] { -5, 0, -10, 5, 10 })); assertEquals(-10, NumberUtils.min(-5, 0, -10, 5, 10));
} }
@Test(expected = IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
@ -609,7 +609,7 @@ public class NumberUtilsTest {
@Test(expected = IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
public void testMinByte_emptyArray() { public void testMinByte_emptyArray() {
NumberUtils.min(new byte[0]); NumberUtils.min();
} }
@Test @Test
@ -643,19 +643,19 @@ public class NumberUtilsTest {
assertEquals( assertEquals(
"min(double[]) failed for array length 1", "min(double[]) failed for array length 1",
5.12, 5.12,
NumberUtils.min(new double[] { 5.12 }), NumberUtils.min(5.12),
0); 0);
assertEquals( assertEquals(
"min(double[]) failed for array length 2", "min(double[]) failed for array length 2",
6.23, 6.23,
NumberUtils.min(new double[] { 6.23, 9.34 }), NumberUtils.min(6.23, 9.34),
0); 0);
assertEquals( assertEquals(
"min(double[]) failed for array length 5", "min(double[]) failed for array length 5",
-10.45, -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); 0);
assertEquals(-10, NumberUtils.min(new double[] { -10, -5, 0, 5, 10 }), 0.0001); 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); assertEquals(-10, NumberUtils.min(new double[] { -5, 0, -10, 5, 10 }), 0.0001);
@ -676,19 +676,19 @@ public class NumberUtilsTest {
assertEquals( assertEquals(
"min(float[]) failed for array length 1", "min(float[]) failed for array length 1",
5.9f, 5.9f,
NumberUtils.min(new float[] { 5.9f }), NumberUtils.min(5.9f),
0); 0);
assertEquals( assertEquals(
"min(float[]) failed for array length 2", "min(float[]) failed for array length 2",
6.8f, 6.8f,
NumberUtils.min(new float[] { 6.8f, 9.7f }), NumberUtils.min(6.8f, 9.7f),
0); 0);
assertEquals( assertEquals(
"min(float[]) failed for array length 5", "min(float[]) failed for array length 5",
-10.6f, -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); 0);
assertEquals(-10, NumberUtils.min(new float[] { -10, -5, 0, 5, 10 }), 0.0001f); 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); assertEquals(-10, NumberUtils.min(new float[] { -5, 0, -10, 5, 10 }), 0.0001f);
@ -739,19 +739,19 @@ public class NumberUtilsTest {
assertEquals( assertEquals(
"max(int[]) failed for array length 1", "max(int[]) failed for array length 1",
5, 5,
NumberUtils.max(new int[] { 5 })); NumberUtils.max(5));
assertEquals( assertEquals(
"max(int[]) failed for array length 2", "max(int[]) failed for array length 2",
9, 9,
NumberUtils.max(new int[] { 6, 9 })); NumberUtils.max(6, 9));
assertEquals( assertEquals(
"max(int[]) failed for array length 5", "max(int[]) failed for array length 5",
10, 10,
NumberUtils.max(new int[] { -10, -5, 0, 5, 10 })); NumberUtils.max(-10, -5, 0, 5, 10));
assertEquals(10, NumberUtils.max(new int[] { -10, -5, 0, 5, 10 })); assertEquals(10, NumberUtils.max(-10, -5, 0, 5, 10));
assertEquals(10, NumberUtils.max(new int[] { -5, 0, 10, 5, -10 })); assertEquals(10, NumberUtils.max(-5, 0, 10, 5, -10));
} }
@Test(expected = IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
@ -791,7 +791,7 @@ public class NumberUtilsTest {
@Test(expected = IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
public void testMaxByte_emptyArray() { public void testMaxByte_emptyArray() {
NumberUtils.max(new byte[0]); NumberUtils.max();
} }
@Test @Test
@ -873,19 +873,19 @@ public class NumberUtilsTest {
assertEquals( assertEquals(
"max(float[]) failed for array length 1", "max(float[]) failed for array length 1",
5.1f, 5.1f,
NumberUtils.max(new float[] { 5.1f }), NumberUtils.max(5.1f),
0); 0);
assertEquals( assertEquals(
"max(float[]) failed for array length 2", "max(float[]) failed for array length 2",
9.2f, 9.2f,
NumberUtils.max(new float[] { 6.3f, 9.2f }), NumberUtils.max(6.3f, 9.2f),
0); 0);
assertEquals( assertEquals(
"max(float[]) failed for float length 5", "max(float[]) failed for float length 5",
10.4f, 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); 0);
assertEquals(10, NumberUtils.max(new float[] { -10, -5, 0, 5, 10 }), 0.0001f); 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); 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) { private boolean checkCreateNumber(final String val) {
try { try {
final Object obj = NumberUtils.createNumber(val); final Object obj = NumberUtils.createNumber(val);
if (obj == null) { return obj != null;
return false;
}
return true;
} catch (final NumberFormatException e) { } catch (final NumberFormatException e) {
return false; return false;
} }

View File

@ -101,7 +101,7 @@ public class ConstructorUtilsTest {
} }
} }
private static class PrivateClass { static class PrivateClass {
@SuppressWarnings("unused") @SuppressWarnings("unused")
public PrivateClass() { public PrivateClass() {
} }

View File

@ -59,7 +59,7 @@ import org.junit.Test;
*/ */
public class MethodUtilsTest { public class MethodUtilsTest {
private static interface PrivateInterface {} private interface PrivateInterface {}
static class TestBeanWithInterfaces implements PrivateInterface { static class TestBeanWithInterfaces implements PrivateInterface {
public String foo() { public String foo() {

View File

@ -811,7 +811,7 @@ class AAAClass extends AAClass<String> {
//raw types, where used, are used purposely //raw types, where used, are used purposely
class AClass extends AAClass<String>.BBClass<Number> { class AClass extends AAClass<String>.BBClass<Number> {
public AClass(final AAClass<String> enclosingInstance) { AClass(final AAClass<String> enclosingInstance) {
enclosingInstance.super(); enclosingInstance.super();
} }

View File

@ -19,7 +19,7 @@ package org.apache.commons.lang3.reflect.testbed;
/** /**
*/ */
public interface Bar { public interface Bar {
public static final String VALUE = "bar"; String VALUE = "bar";
void doIt(); void doIt();
} }

View File

@ -19,7 +19,7 @@ package org.apache.commons.lang3.reflect.testbed;
/** /**
*/ */
public interface Foo { public interface Foo {
public static final String VALUE = "foo"; String VALUE = "foo";
@Annotated @Annotated
void doIt(); void doIt();

View File

@ -467,7 +467,7 @@ public class ExtendedMessageFormatTest {
private static class OtherExtendedMessageFormat extends ExtendedMessageFormat { private static class OtherExtendedMessageFormat extends ExtendedMessageFormat {
private static final long serialVersionUID = 1L; 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) { final Map<String, ? extends FormatFactory> registry) {
super(pattern, locale, registry); super(pattern, locale, registry);
} }

View File

@ -1061,11 +1061,11 @@ public class StrBuilderAppendInsertTest {
assertEquals("", sb.toString()); assertEquals("", sb.toString());
sb.clear(); sb.clear();
sb.appendAll(new Object[0]); sb.appendAll();
assertEquals("", sb.toString()); assertEquals("", sb.toString());
sb.clear(); sb.clear();
sb.appendAll(new Object[]{"foo", "bar", "baz"}); sb.appendAll("foo", "bar", "baz");
assertEquals("foobarbaz", sb.toString()); assertEquals("foobarbaz", sb.toString());
sb.clear(); sb.clear();

View File

@ -170,7 +170,7 @@ public class StrBuilderTest {
private final CharBuffer src; private final CharBuffer src;
public MockReadable(final String src) { MockReadable(final String src) {
this.src = CharBuffer.wrap(src); this.src = CharBuffer.wrap(src);
} }

View File

@ -182,7 +182,7 @@ public class StrMatcherTest {
assertEquals(0, matcher.isMatch(BUFFER2, 3)); assertEquals(0, matcher.isMatch(BUFFER2, 3));
assertEquals(1, matcher.isMatch(BUFFER2, 4)); assertEquals(1, matcher.isMatch(BUFFER2, 4));
assertEquals(0, matcher.isMatch(BUFFER2, 5)); 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)); assertSame(StrMatcher.noneMatcher(), StrMatcher.charSetMatcher((char[]) null));
assertTrue(StrMatcher.charSetMatcher("a".toCharArray()) instanceof StrMatcher.CharMatcher); assertTrue(StrMatcher.charSetMatcher("a".toCharArray()) instanceof StrMatcher.CharMatcher);
} }

View File

@ -225,7 +225,7 @@ public class DateFormatUtilsTest {
public void testLang530() throws ParseException { public void testLang530() throws ParseException {
final Date d = new Date(); final Date d = new Date();
final String isoDateStr = DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT.format(d); 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 // 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); assertEquals("Date not equal to itself ISO formatted and parsed", d.getTime(), d2.getTime() + d.getTime() % 1000);
} }

View File

@ -1282,7 +1282,7 @@ public class DateUtilsTest {
public void testLang530() throws ParseException { public void testLang530() throws ParseException {
final Date d = new Date(); final Date d = new Date();
final String isoDateStr = DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT.format(d); 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 // 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); 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 @Test
public void testLANG799() throws ParseException { 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");
} }
} }

View File

@ -623,12 +623,12 @@ public class FastDateParserTest {
return cal; return cal;
} }
private static enum Expected1806 { private enum Expected1806 {
India(INDIA, "+05", "+0530", "+05:30", true), India(INDIA, "+05", "+0530", "+05:30", true),
Greenwich(GMT, "Z", "Z", "Z", false), Greenwich(GMT, "Z", "Z", "Z", false),
NewYork(NEW_YORK, "-05", "-0500", "-05:00", 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.zone = zone;
this.one = one; this.one = one;
this.two = two; this.two = two;

View File

@ -293,11 +293,11 @@ public class FastDatePrinterTest {
getInstance("XXXX"); getInstance("XXXX");
} }
private static enum Expected1806 { private enum Expected1806 {
India(INDIA, "+05", "+0530", "+05:30"), Greenwich(GMT, "Z", "Z", "Z"), NewYork( India(INDIA, "+05", "+0530", "+05:30"), Greenwich(GMT, "Z", "Z", "Z"), NewYork(
NEW_YORK, "-05", "-0500", "-05:00"); 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.zone = zone;
this.one = one; this.one = one;
this.two = two; this.two = two;