Use final

- Use method reference
- Remove noisy parens
- Format tweaks
- Remove noisy block nesting
This commit is contained in:
Gary Gregory 2024-01-24 22:38:24 -05:00
parent 62e8c58129
commit 6540edfdc0
56 changed files with 340 additions and 347 deletions

View File

@ -316,7 +316,7 @@ public class BitField {
* parameter replacing the old bits
*/
public int setValue(final int holder, final int value) {
return (holder & ~mask) | ((value << shiftCount) & mask);
return holder & ~mask | value << shiftCount & mask;
}
}

View File

@ -483,10 +483,10 @@ public class CharUtils {
*/
public static String unicodeEscaped(final char ch) {
return "\\u" +
HEX_DIGITS[(ch >> 12) & 15] +
HEX_DIGITS[(ch >> 8) & 15] +
HEX_DIGITS[(ch >> 4) & 15] +
HEX_DIGITS[(ch) & 15];
HEX_DIGITS[ch >> 12 & 15] +
HEX_DIGITS[ch >> 8 & 15] +
HEX_DIGITS[ch >> 4 & 15] +
HEX_DIGITS[ch & 15];
}
/**

View File

@ -528,7 +528,7 @@ public class ClassUtils {
*/
public static Class<?> getClass(final ClassLoader classLoader, final String className, final boolean initialize) throws ClassNotFoundException {
try {
Class<?> clazz = namePrimitiveMap.get(className);
final Class<?> clazz = namePrimitiveMap.get(className);
return clazz != null ? clazz : Class.forName(toCanonicalName(className), initialize, classLoader);
} catch (final ClassNotFoundException ex) {
// allow path separators (.) as inner class name separators

View File

@ -175,7 +175,7 @@ public class Conversion {
final int shift = i + dstPos;
final int bits = (src[i + srcPos] ? 1 : 0) << shift;
final int mask = 0x1 << shift;
out = (byte) ((out & ~mask) | bits);
out = (byte) (out & ~mask | bits);
}
return out;
}
@ -332,7 +332,7 @@ public class Conversion {
final int shift = i + dstPos;
final int bits = (src[i + srcPos] ? 1 : 0) << shift;
final int mask = 0x1 << shift;
out = (out & ~mask) | bits;
out = out & ~mask | bits;
}
return out;
}
@ -365,7 +365,7 @@ public class Conversion {
final int shift = i + dstPos;
final long bits = (src[i + srcPos] ? 1L : 0) << shift;
final long mask = 0x1L << shift;
out = (out & ~mask) | bits;
out = out & ~mask | bits;
}
return out;
}
@ -398,7 +398,7 @@ public class Conversion {
final int shift = i + dstPos;
final int bits = (src[i + srcPos] ? 1 : 0) << shift;
final int mask = 0x1 << shift;
out = (short) ((out & ~mask) | bits);
out = (short) (out & ~mask | bits);
}
return out;
}
@ -431,7 +431,7 @@ public class Conversion {
final int shift = i * 8 + dstPos;
final int bits = (0xff & src[i + srcPos]) << shift;
final int mask = 0xff << shift;
out = (out & ~mask) | bits;
out = out & ~mask | bits;
}
return out;
}
@ -464,7 +464,7 @@ public class Conversion {
final int shift = i * 8 + dstPos;
final long bits = (0xffL & src[i + srcPos]) << shift;
final long mask = 0xffL << shift;
out = (out & ~mask) | bits;
out = out & ~mask | bits;
}
return out;
}
@ -497,7 +497,7 @@ public class Conversion {
final int shift = i * 8 + dstPos;
final int bits = (0xff & src[i + srcPos]) << shift;
final int mask = 0xff << shift;
out = (short) ((out & ~mask) | bits);
out = (short) (out & ~mask | bits);
}
return out;
}
@ -545,7 +545,7 @@ public class Conversion {
}
for (int i = 0; i < nBools; i++) {
final int shift = i + srcPos;
dst[dstPos + i] = (0x1 & (src >> shift)) != 0;
dst[dstPos + i] = (0x1 & src >> shift) != 0;
}
return dst;
}
@ -576,7 +576,7 @@ public class Conversion {
int append = sb.length();
for (int i = 0; i < nHexs; i++) {
final int shift = i * 4 + srcPos;
final int bits = 0xF & (src >> shift);
final int bits = 0xF & src >> shift;
if (dstPos + i == append) {
++append;
sb.append(intToHexDigit(bits));
@ -802,7 +802,7 @@ public class Conversion {
final int shift = i * 4 + dstPos;
final int bits = (0xf & hexDigitToInt(src.charAt(i + srcPos))) << shift;
final int mask = 0xf << shift;
out = (byte) ((out & ~mask) | bits);
out = (byte) (out & ~mask | bits);
}
return out;
}
@ -832,7 +832,7 @@ public class Conversion {
final int shift = i * 4 + dstPos;
final int bits = (0xf & hexDigitToInt(src.charAt(i + srcPos))) << shift;
final int mask = 0xf << shift;
out = (out & ~mask) | bits;
out = out & ~mask | bits;
}
return out;
}
@ -863,7 +863,7 @@ public class Conversion {
final int shift = i * 4 + dstPos;
final long bits = (0xfL & hexDigitToInt(src.charAt(i + srcPos))) << shift;
final long mask = 0xfL << shift;
out = (out & ~mask) | bits;
out = out & ~mask | bits;
}
return out;
}
@ -894,7 +894,7 @@ public class Conversion {
final int shift = i * 4 + dstPos;
final int bits = (0xf & hexDigitToInt(src.charAt(i + srcPos))) << shift;
final int mask = 0xf << shift;
out = (short) ((out & ~mask) | bits);
out = (short) (out & ~mask | bits);
}
return out;
}
@ -927,7 +927,7 @@ public class Conversion {
final int shift = i * 32 + dstPos;
final long bits = (0xffffffffL & src[i + srcPos]) << shift;
final long mask = 0xffffffffL << shift;
out = (out & ~mask) | bits;
out = out & ~mask | bits;
}
return out;
}
@ -957,7 +957,7 @@ public class Conversion {
}
for (int i = 0; i < nBools; i++) {
final int shift = i + srcPos;
dst[dstPos + i] = (0x1 & (src >> shift)) != 0;
dst[dstPos + i] = (0x1 & src >> shift) != 0;
}
return dst;
}
@ -987,7 +987,7 @@ public class Conversion {
}
for (int i = 0; i < nBytes; i++) {
final int shift = i * 8 + srcPos;
dst[dstPos + i] = (byte) (0xff & (src >> shift));
dst[dstPos + i] = (byte) (0xff & src >> shift);
}
return dst;
}
@ -1018,7 +1018,7 @@ public class Conversion {
int append = sb.length();
for (int i = 0; i < nHexs; i++) {
final int shift = i * 4 + srcPos;
final int bits = 0xF & (src >> shift);
final int bits = 0xF & src >> shift;
if (dstPos + i == append) {
++append;
sb.append(intToHexDigit(bits));
@ -1135,7 +1135,7 @@ public class Conversion {
}
for (int i = 0; i < nShorts; i++) {
final int shift = i * 16 + srcPos;
dst[dstPos + i] = (short) (0xffff & (src >> shift));
dst[dstPos + i] = (short) (0xffff & src >> shift);
}
return dst;
}
@ -1165,7 +1165,7 @@ public class Conversion {
}
for (int i = 0; i < nBools; i++) {
final int shift = i + srcPos;
dst[dstPos + i] = (0x1 & (src >> shift)) != 0;
dst[dstPos + i] = (0x1 & src >> shift) != 0;
}
return dst;
}
@ -1195,7 +1195,7 @@ public class Conversion {
}
for (int i = 0; i < nBytes; i++) {
final int shift = i * 8 + srcPos;
dst[dstPos + i] = (byte) (0xff & (src >> shift));
dst[dstPos + i] = (byte) (0xff & src >> shift);
}
return dst;
}
@ -1226,7 +1226,7 @@ public class Conversion {
int append = sb.length();
for (int i = 0; i < nHexs; i++) {
final int shift = i * 4 + srcPos;
final int bits = (int) (0xF & (src >> shift));
final int bits = (int) (0xF & src >> shift);
if (dstPos + i == append) {
++append;
sb.append(intToHexDigit(bits));
@ -1262,7 +1262,7 @@ public class Conversion {
}
for (int i = 0; i < nInts; i++) {
final int shift = i * 32 + srcPos;
dst[dstPos + i] = (int) (0xffffffff & (src >> shift));
dst[dstPos + i] = (int) (0xffffffff & src >> shift);
}
return dst;
}
@ -1292,7 +1292,7 @@ public class Conversion {
}
for (int i = 0; i < nShorts; i++) {
final int shift = i * 16 + srcPos;
dst[dstPos + i] = (short) (0xffff & (src >> shift));
dst[dstPos + i] = (short) (0xffff & src >> shift);
}
return dst;
}
@ -1325,7 +1325,7 @@ public class Conversion {
final int shift = i * 16 + dstPos;
final int bits = (0xffff & src[i + srcPos]) << shift;
final int mask = 0xffff << shift;
out = (out & ~mask) | bits;
out = out & ~mask | bits;
}
return out;
}
@ -1358,7 +1358,7 @@ public class Conversion {
final int shift = i * 16 + dstPos;
final long bits = (0xffffL & src[i + srcPos]) << shift;
final long mask = 0xffffL << shift;
out = (out & ~mask) | bits;
out = out & ~mask | bits;
}
return out;
}
@ -1386,10 +1386,10 @@ public class Conversion {
if (nBools - 1 + srcPos >= 16) {
throw new IllegalArgumentException("nBools-1+srcPos is greater or equal to than 16");
}
assert (nBools - 1) < 16 - srcPos;
assert nBools - 1 < 16 - srcPos;
for (int i = 0; i < nBools; i++) {
final int shift = i + srcPos;
dst[dstPos + i] = (0x1 & (src >> shift)) != 0;
dst[dstPos + i] = (0x1 & src >> shift) != 0;
}
return dst;
}
@ -1419,7 +1419,7 @@ public class Conversion {
}
for (int i = 0; i < nBytes; i++) {
final int shift = i * 8 + srcPos;
dst[dstPos + i] = (byte) (0xff & (src >> shift));
dst[dstPos + i] = (byte) (0xff & src >> shift);
}
return dst;
}
@ -1450,7 +1450,7 @@ public class Conversion {
int append = sb.length();
for (int i = 0; i < nHexs; i++) {
final int shift = i * 4 + srcPos;
final int bits = 0xF & (src >> shift);
final int bits = 0xF & src >> shift;
if (dstPos + i == append) {
++append;
sb.append(intToHexDigit(bits));

View File

@ -149,7 +149,7 @@ public class EnumUtils {
Collections.addAll(condensed, values);
final long[] result = new long[(enumClass.getEnumConstants().length - 1) / Long.SIZE + 1];
for (final E value : condensed) {
result[value.ordinal() / Long.SIZE] |= 1L << (value.ordinal() % Long.SIZE);
result[value.ordinal() / Long.SIZE] |= 1L << value.ordinal() % Long.SIZE;
}
ArrayUtils.reverse(result);
return result;
@ -178,7 +178,7 @@ public class EnumUtils {
values.forEach(constant -> condensed.add(Objects.requireNonNull(constant, NULL_ELEMENTS_NOT_PERMITTED)));
final long[] result = new long[(enumClass.getEnumConstants().length - 1) / Long.SIZE + 1];
for (final E value : condensed) {
result[value.ordinal() / Long.SIZE] |= 1L << (value.ordinal() % Long.SIZE);
result[value.ordinal() / Long.SIZE] |= 1L << value.ordinal() % Long.SIZE;
}
ArrayUtils.reverse(result);
return result;
@ -412,7 +412,7 @@ public class EnumUtils {
ArrayUtils.reverse(lvalues);
for (final E constant : enumClass.getEnumConstants()) {
final int block = constant.ordinal() / Long.SIZE;
if (block < lvalues.length && (lvalues[block] & 1L << (constant.ordinal() % Long.SIZE)) != 0) {
if (block < lvalues.length && (lvalues[block] & 1L << constant.ordinal() % Long.SIZE) != 0) {
results.add(constant);
}
}

View File

@ -94,7 +94,7 @@ public class RandomUtils {
return startInclusive;
}
return startInclusive + ((endExclusive - startInclusive) * random().nextDouble());
return startInclusive + (endExclusive - startInclusive) * random().nextDouble();
}
/**
@ -129,7 +129,7 @@ public class RandomUtils {
return startInclusive;
}
return startInclusive + ((endExclusive - startInclusive) * random().nextFloat());
return startInclusive + (endExclusive - startInclusive) * random().nextFloat();
}
/**
@ -193,7 +193,7 @@ public class RandomUtils {
do {
bits = random().nextLong() >>> 1;
val = bits % n;
} while (bits - val + (n - 1) < 0);
} while (bits - val + n - 1 < 0);
return val;
}

View File

@ -36,7 +36,7 @@ final class Reflection {
static Object getUnchecked(final Field field, final Object obj) {
try {
return Objects.requireNonNull(field, "field").get(obj);
} catch (IllegalAccessException e) {
} catch (final IllegalAccessException e) {
throw new IllegalArgumentException(e);
}
}

View File

@ -151,7 +151,7 @@ public class AtomicInitializer<T> extends AbstractConcurrentInitializer<T, Concu
* {@inheritDoc}
*/
@Override
protected ConcurrentException getTypedException(Exception e) {
protected ConcurrentException getTypedException(final Exception e) {
return new ConcurrentException(e);
}

View File

@ -139,7 +139,7 @@ public class AtomicSafeInitializer<T> extends AbstractConcurrentInitializer<T, C
* {@inheritDoc}
*/
@Override
protected ConcurrentException getTypedException(Exception e) {
protected ConcurrentException getTypedException(final Exception e) {
return new ConcurrentException(e);
}

View File

@ -318,7 +318,7 @@ public class BackgroundInitializer<T> extends AbstractConcurrentInitializer<T, E
* {@inheritDoc}
*/
@Override
protected Exception getTypedException(Exception e) {
protected Exception getTypedException(final Exception e) {
//This Exception object will be used for type comparison in AbstractConcurrentInitializer.initialize but not thrown
return new Exception(e);
}

View File

@ -111,7 +111,7 @@ public class CallableBackgroundInitializer<T> extends BackgroundInitializer<T> {
* {@inheritDoc}
*/
@Override
protected Exception getTypedException(Exception e) {
protected Exception getTypedException(final Exception e) {
//This Exception object will be used for type comparison in AbstractConcurrentInitializer.initialize but not thrown
return new Exception(e);
}

View File

@ -152,7 +152,7 @@ public class LazyInitializer<T> extends AbstractConcurrentInitializer<T, Concurr
* {@inheritDoc}
*/
@Override
protected ConcurrentException getTypedException(Exception e) {
protected ConcurrentException getTypedException(final Exception e) {
return new ConcurrentException(e);
}

View File

@ -288,10 +288,10 @@ public class MultiBackgroundInitializer
public void close() throws ConcurrentException {
ConcurrentException exception = null;
for (BackgroundInitializer<?> child : childInitializers.values()) {
for (final BackgroundInitializer<?> child : childInitializers.values()) {
try {
child.close();
} catch (Exception e) {
} catch (final Exception e) {
if (exception == null) {
exception = new ConcurrentException();
}

View File

@ -263,7 +263,7 @@ public class MutableLong extends Number implements Comparable<MutableLong>, Muta
*/
@Override
public int hashCode() {
return (int) (value ^ (value >>> 32));
return (int) (value ^ value >>> 32);
}
/**

View File

@ -130,10 +130,10 @@ public class UnicodeEscaper extends CodePointTranslator {
out.write(toUtf16Escape(codePoint));
} else {
out.write("\\u");
out.write(HEX_DIGITS[(codePoint >> 12) & 15]);
out.write(HEX_DIGITS[(codePoint >> 8) & 15]);
out.write(HEX_DIGITS[(codePoint >> 4) & 15]);
out.write(HEX_DIGITS[(codePoint) & 15]);
out.write(HEX_DIGITS[codePoint >> 12 & 15]);
out.write(HEX_DIGITS[codePoint >> 8 & 15]);
out.write(HEX_DIGITS[codePoint >> 4 & 15]);
out.write(HEX_DIGITS[codePoint & 15]);
}
return true;
}

View File

@ -35,7 +35,7 @@ final class GmtTimeZone extends TimeZone {
static final long serialVersionUID = 1L;
private static StringBuilder twoDigits(final StringBuilder sb, final int n) {
return sb.append((char) ('0' + (n / 10))).append((char) ('0' + (n % 10)));
return sb.append((char) ('0' + n / 10)).append((char) ('0' + n % 10));
}
private final int offset;
@ -48,7 +48,7 @@ final class GmtTimeZone extends TimeZone {
if (minutes >= MINUTES_PER_HOUR) {
throw new IllegalArgumentException(minutes + " minutes out of range");
}
final int milliseconds = (minutes + (hours * MINUTES_PER_HOUR)) * MILLISECONDS_PER_MINUTE;
final int milliseconds = (minutes + hours * MINUTES_PER_HOUR) * MILLISECONDS_PER_MINUTE;
offset = negate ? -milliseconds : milliseconds;
// @formatter:off
zoneId = twoDigits(twoDigits(new StringBuilder(9)

View File

@ -434,7 +434,7 @@ public class StopWatch {
* @param nanos nanoseconds to convert.
* @return milliseconds conversion result.
*/
private long nanosToMillis(long nanos) {
private long nanosToMillis(final long nanos) {
return nanos / NANO_2_MILLIS;
}

View File

@ -550,16 +550,16 @@ public class ArrayUtilsRemoveTest extends AbstractLangTest {
double[] array;
array = ArrayUtils.removeElement(null, (double) 1);
assertNull(array);
array = ArrayUtils.removeElement(ArrayUtils.EMPTY_DOUBLE_ARRAY, (double) 1);
array = ArrayUtils.removeElement(ArrayUtils.EMPTY_DOUBLE_ARRAY, 1);
assertArrayEquals(ArrayUtils.EMPTY_DOUBLE_ARRAY, array);
assertEquals(Double.TYPE, array.getClass().getComponentType());
array = ArrayUtils.removeElement(new double[] {1}, (double) 1);
array = ArrayUtils.removeElement(new double[] {1}, 1);
assertArrayEquals(ArrayUtils.EMPTY_DOUBLE_ARRAY, array);
assertEquals(Double.TYPE, array.getClass().getComponentType());
array = ArrayUtils.removeElement(new double[] {1, 2}, (double) 1);
array = ArrayUtils.removeElement(new double[] {1, 2}, 1);
assertArrayEquals(new double[]{2}, array);
assertEquals(Double.TYPE, array.getClass().getComponentType());
array = ArrayUtils.removeElement(new double[] {1, 2, 1}, (double) 1);
array = ArrayUtils.removeElement(new double[] {1, 2, 1}, 1);
assertArrayEquals(new double[]{2, 1}, array);
assertEquals(Double.TYPE, array.getClass().getComponentType());
}
@ -568,18 +568,18 @@ public class ArrayUtilsRemoveTest extends AbstractLangTest {
@SuppressWarnings("cast")
public void testRemoveElementFloatArray() {
float[] array;
array = ArrayUtils.removeElement((float[]) null, (float) 1);
array = ArrayUtils.removeElement((float[]) null, 1);
assertNull(array);
array = ArrayUtils.removeElement(ArrayUtils.EMPTY_FLOAT_ARRAY, (float) 1);
array = ArrayUtils.removeElement(ArrayUtils.EMPTY_FLOAT_ARRAY, 1);
assertArrayEquals(ArrayUtils.EMPTY_FLOAT_ARRAY, array);
assertEquals(Float.TYPE, array.getClass().getComponentType());
array = ArrayUtils.removeElement(new float[] {1}, (float) 1);
array = ArrayUtils.removeElement(new float[] {1}, 1);
assertArrayEquals(ArrayUtils.EMPTY_FLOAT_ARRAY, array);
assertEquals(Float.TYPE, array.getClass().getComponentType());
array = ArrayUtils.removeElement(new float[] {1, 2}, (float) 1);
array = ArrayUtils.removeElement(new float[] {1, 2}, 1);
assertArrayEquals(new float[]{2}, array);
assertEquals(Float.TYPE, array.getClass().getComponentType());
array = ArrayUtils.removeElement(new float[] {1, 2, 1}, (float) 1);
array = ArrayUtils.removeElement(new float[] {1, 2, 1}, 1);
assertArrayEquals(new float[]{2, 1}, array);
assertEquals(Float.TYPE, array.getClass().getComponentType());
}

View File

@ -45,7 +45,7 @@ import org.junit.jupiter.api.Test;
@SuppressWarnings("deprecation") // deliberate use of deprecated code
public class ArrayUtilsTest extends AbstractLangTest {
private final class TestClass {
private static final class TestClass {
// empty
}
@ -284,13 +284,13 @@ public class ArrayUtilsTest extends AbstractLangTest {
@Test
public void testContainsDouble() {
double[] array = null;
assertFalse(ArrayUtils.contains(array, (double) 1));
assertFalse(ArrayUtils.contains(array, 1));
array = new double[]{0, 1, 2, 3, 0};
assertTrue(ArrayUtils.contains(array, (double) 0));
assertTrue(ArrayUtils.contains(array, (double) 1));
assertTrue(ArrayUtils.contains(array, (double) 2));
assertTrue(ArrayUtils.contains(array, (double) 3));
assertFalse(ArrayUtils.contains(array, (double) 99));
assertTrue(ArrayUtils.contains(array, 0));
assertTrue(ArrayUtils.contains(array, 1));
assertTrue(ArrayUtils.contains(array, 2));
assertTrue(ArrayUtils.contains(array, 3));
assertFalse(ArrayUtils.contains(array, 99));
}
@Test
@ -305,7 +305,7 @@ public class ArrayUtilsTest extends AbstractLangTest {
@Test
public void testContainsDoubleTolerance() {
double[] array = null;
assertFalse(ArrayUtils.contains(array, (double) 1, (double) 0));
assertFalse(ArrayUtils.contains(array, 1, 0));
array = new double[]{0, 1, 2, 3, 0};
assertFalse(ArrayUtils.contains(array, 4.0, 0.33));
assertFalse(ArrayUtils.contains(array, 2.5, 0.49));
@ -317,13 +317,13 @@ public class ArrayUtilsTest extends AbstractLangTest {
@Test
public void testContainsFloat() {
float[] array = null;
assertFalse(ArrayUtils.contains(array, (float) 1));
assertFalse(ArrayUtils.contains(array, 1));
array = new float[]{0, 1, 2, 3, 0};
assertTrue(ArrayUtils.contains(array, (float) 0));
assertTrue(ArrayUtils.contains(array, (float) 1));
assertTrue(ArrayUtils.contains(array, (float) 2));
assertTrue(ArrayUtils.contains(array, (float) 3));
assertFalse(ArrayUtils.contains(array, (float) 99));
assertTrue(ArrayUtils.contains(array, 0));
assertTrue(ArrayUtils.contains(array, 1));
assertTrue(ArrayUtils.contains(array, 2));
assertTrue(ArrayUtils.contains(array, 3));
assertFalse(ArrayUtils.contains(array, 99));
}
@Test
@ -716,7 +716,7 @@ public class ArrayUtilsTest extends AbstractLangTest {
array = new double[]{0, 1, 2, 3, 0};
testSet.set(0);
testSet.set(4);
assertEquals(testSet, ArrayUtils.indexesOf(array, (double) 0, 0.3));
assertEquals(testSet, ArrayUtils.indexesOf(array, 0, 0.3));
testSet.clear();
testSet.set(3);
assertEquals(testSet, ArrayUtils.indexesOf(array, 4.15, 2.0));
@ -755,14 +755,14 @@ public class ArrayUtilsTest extends AbstractLangTest {
double[] array = null;
final BitSet emptySet = new BitSet();
final BitSet testSet = new BitSet();
assertEquals(emptySet, ArrayUtils.indexesOf(array, (double) 0, 0, (double) 0));
assertEquals(emptySet, ArrayUtils.indexesOf(array, 0, 0, 0));
array = new double[0];
assertEquals(emptySet, ArrayUtils.indexesOf(array, (double) 0, 0, (double) 0));
assertEquals(emptySet, ArrayUtils.indexesOf(array, 0, 0, 0));
array = new double[]{0, 1, 2, 3, 0};
testSet.set(4);
assertEquals(testSet, ArrayUtils.indexesOf(array, (double) 0, 1, 0.3));
assertEquals(testSet, ArrayUtils.indexesOf(array, 0, 1, 0.3));
testSet.set(0);
assertEquals(testSet, ArrayUtils.indexesOf(array, (double) 0, 0, 0.3));
assertEquals(testSet, ArrayUtils.indexesOf(array, 0, 0, 0.3));
testSet.clear();
testSet.set(2);
assertEquals(testSet, ArrayUtils.indexesOf(array, 2, 0, 0.35));
@ -1070,16 +1070,16 @@ public class ArrayUtilsTest extends AbstractLangTest {
@Test
public void testIndexOfDouble() {
double[] array = null;
assertEquals(-1, ArrayUtils.indexOf(array, (double) 0));
assertEquals(-1, ArrayUtils.indexOf(array, 0));
array = new double[0];
assertEquals(-1, ArrayUtils.indexOf(array, (double) 0));
assertEquals(-1, ArrayUtils.indexOf(array, 0));
array = new double[]{0, 1, 2, 3, 0};
assertEquals(0, ArrayUtils.indexOf(array, (double) 0));
assertEquals(1, ArrayUtils.indexOf(array, (double) 1));
assertEquals(2, ArrayUtils.indexOf(array, (double) 2));
assertEquals(3, ArrayUtils.indexOf(array, (double) 3));
assertEquals(3, ArrayUtils.indexOf(array, (double) 3, -1));
assertEquals(-1, ArrayUtils.indexOf(array, (double) 99));
assertEquals(0, ArrayUtils.indexOf(array, 0));
assertEquals(1, ArrayUtils.indexOf(array, 1));
assertEquals(2, ArrayUtils.indexOf(array, 2));
assertEquals(3, ArrayUtils.indexOf(array, 3));
assertEquals(3, ArrayUtils.indexOf(array, 3, -1));
assertEquals(-1, ArrayUtils.indexOf(array, 99));
}
@Test
@ -1099,7 +1099,7 @@ public class ArrayUtilsTest extends AbstractLangTest {
array = new double[0];
assertEquals(-1, ArrayUtils.indexOf(array, (double) 0, (double) 0));
array = new double[]{0, 1, 2, 3, 0};
assertEquals(0, ArrayUtils.indexOf(array, (double) 0, 0.3));
assertEquals(0, ArrayUtils.indexOf(array, 0, 0.3));
assertEquals(2, ArrayUtils.indexOf(array, 2.2, 0.35));
assertEquals(3, ArrayUtils.indexOf(array, 4.15, 2.0));
assertEquals(1, ArrayUtils.indexOf(array, 1.00001324, 0.0001));
@ -1109,29 +1109,29 @@ public class ArrayUtilsTest extends AbstractLangTest {
@Test
public void testIndexOfDoubleWithStartIndex() {
double[] array = null;
assertEquals(-1, ArrayUtils.indexOf(array, (double) 0, 2));
assertEquals(-1, ArrayUtils.indexOf(array, 0, 2));
array = new double[0];
assertEquals(-1, ArrayUtils.indexOf(array, (double) 0, 2));
assertEquals(-1, ArrayUtils.indexOf(array, 0, 2));
array = new double[]{0, 1, 2, 3, 0};
assertEquals(4, ArrayUtils.indexOf(array, (double) 0, 2));
assertEquals(-1, ArrayUtils.indexOf(array, (double) 1, 2));
assertEquals(2, ArrayUtils.indexOf(array, (double) 2, 2));
assertEquals(3, ArrayUtils.indexOf(array, (double) 3, 2));
assertEquals(-1, ArrayUtils.indexOf(array, (double) 99, 0));
assertEquals(-1, ArrayUtils.indexOf(array, (double) 0, 6));
assertEquals(4, ArrayUtils.indexOf(array, 0, 2));
assertEquals(-1, ArrayUtils.indexOf(array, 1, 2));
assertEquals(2, ArrayUtils.indexOf(array, 2, 2));
assertEquals(3, ArrayUtils.indexOf(array, 3, 2));
assertEquals(-1, ArrayUtils.indexOf(array, 99, 0));
assertEquals(-1, ArrayUtils.indexOf(array, 0, 6));
}
@SuppressWarnings("cast")
@Test
public void testIndexOfDoubleWithStartIndexTolerance() {
double[] array = null;
assertEquals(-1, ArrayUtils.indexOf(array, (double) 0, 2, (double) 0));
assertEquals(-1, ArrayUtils.indexOf(array, 0, 2, 0));
array = new double[0];
assertEquals(-1, ArrayUtils.indexOf(array, (double) 0, 2, (double) 0));
assertEquals(-1, ArrayUtils.indexOf(array, 0, 2, 0));
array = new double[]{0, 1, 2, 3, 0};
assertEquals(-1, ArrayUtils.indexOf(array, (double) 0, 99, 0.3));
assertEquals(0, ArrayUtils.indexOf(array, (double) 0, 0, 0.3));
assertEquals(4, ArrayUtils.indexOf(array, (double) 0, 3, 0.3));
assertEquals(-1, ArrayUtils.indexOf(array, 0, 99, 0.3));
assertEquals(0, ArrayUtils.indexOf(array, 0, 0, 0.3));
assertEquals(4, ArrayUtils.indexOf(array, 0, 3, 0.3));
assertEquals(2, ArrayUtils.indexOf(array, 2.2, 0, 0.35));
assertEquals(3, ArrayUtils.indexOf(array, 4.15, 0, 2.0));
assertEquals(1, ArrayUtils.indexOf(array, 1.00001324, 0, 0.0001));
@ -1143,15 +1143,15 @@ public class ArrayUtilsTest extends AbstractLangTest {
@Test
public void testIndexOfFloat() {
float[] array = null;
assertEquals(-1, ArrayUtils.indexOf(array, (float) 0));
assertEquals(-1, ArrayUtils.indexOf(array, 0));
array = new float[0];
assertEquals(-1, ArrayUtils.indexOf(array, (float) 0));
assertEquals(-1, ArrayUtils.indexOf(array, 0));
array = new float[]{0, 1, 2, 3, 0};
assertEquals(0, ArrayUtils.indexOf(array, (float) 0));
assertEquals(1, ArrayUtils.indexOf(array, (float) 1));
assertEquals(2, ArrayUtils.indexOf(array, (float) 2));
assertEquals(3, ArrayUtils.indexOf(array, (float) 3));
assertEquals(-1, ArrayUtils.indexOf(array, (float) 99));
assertEquals(0, ArrayUtils.indexOf(array, 0));
assertEquals(1, ArrayUtils.indexOf(array, 1));
assertEquals(2, ArrayUtils.indexOf(array, 2));
assertEquals(3, ArrayUtils.indexOf(array, 3));
assertEquals(-1, ArrayUtils.indexOf(array, 99));
}
@Test
@ -1166,17 +1166,17 @@ public class ArrayUtilsTest extends AbstractLangTest {
@Test
public void testIndexOfFloatWithStartIndex() {
float[] array = null;
assertEquals(-1, ArrayUtils.indexOf(array, (float) 0, 2));
assertEquals(-1, ArrayUtils.indexOf(array, 0, 2));
array = new float[0];
assertEquals(-1, ArrayUtils.indexOf(array, (float) 0, 2));
assertEquals(-1, ArrayUtils.indexOf(array, 0, 2));
array = new float[]{0, 1, 2, 3, 0};
assertEquals(4, ArrayUtils.indexOf(array, (float) 0, 2));
assertEquals(-1, ArrayUtils.indexOf(array, (float) 1, 2));
assertEquals(2, ArrayUtils.indexOf(array, (float) 2, 2));
assertEquals(3, ArrayUtils.indexOf(array, (float) 3, 2));
assertEquals(3, ArrayUtils.indexOf(array, (float) 3, -1));
assertEquals(-1, ArrayUtils.indexOf(array, (float) 99, 0));
assertEquals(-1, ArrayUtils.indexOf(array, (float) 0, 6));
assertEquals(4, ArrayUtils.indexOf(array, 0, 2));
assertEquals(-1, ArrayUtils.indexOf(array, 1, 2));
assertEquals(2, ArrayUtils.indexOf(array, 2, 2));
assertEquals(3, ArrayUtils.indexOf(array, 3, 2));
assertEquals(3, ArrayUtils.indexOf(array, 3, -1));
assertEquals(-1, ArrayUtils.indexOf(array, 99, 0));
assertEquals(-1, ArrayUtils.indexOf(array, 0, 6));
}
@Test
@ -1762,15 +1762,15 @@ public class ArrayUtilsTest extends AbstractLangTest {
@Test
public void testLastIndexOfDouble() {
double[] array = null;
assertEquals(-1, ArrayUtils.lastIndexOf(array, (double) 0));
assertEquals(-1, ArrayUtils.lastIndexOf(array, 0));
array = new double[0];
assertEquals(-1, ArrayUtils.lastIndexOf(array, (double) 0));
assertEquals(-1, ArrayUtils.lastIndexOf(array, 0));
array = new double[]{0, 1, 2, 3, 0};
assertEquals(4, ArrayUtils.lastIndexOf(array, (double) 0));
assertEquals(1, ArrayUtils.lastIndexOf(array, (double) 1));
assertEquals(2, ArrayUtils.lastIndexOf(array, (double) 2));
assertEquals(3, ArrayUtils.lastIndexOf(array, (double) 3));
assertEquals(-1, ArrayUtils.lastIndexOf(array, (double) 99));
assertEquals(4, ArrayUtils.lastIndexOf(array, 0));
assertEquals(1, ArrayUtils.lastIndexOf(array, 1));
assertEquals(2, ArrayUtils.lastIndexOf(array, 2));
assertEquals(3, ArrayUtils.lastIndexOf(array, 3));
assertEquals(-1, ArrayUtils.lastIndexOf(array, 99));
}
@SuppressWarnings("cast")
@ -1781,7 +1781,7 @@ public class ArrayUtilsTest extends AbstractLangTest {
array = new double[0];
assertEquals(-1, ArrayUtils.lastIndexOf(array, (double) 0, (double) 0));
array = new double[]{0, 1, 2, 3, 0};
assertEquals(4, ArrayUtils.lastIndexOf(array, (double) 0, 0.3));
assertEquals(4, ArrayUtils.lastIndexOf(array, 0, 0.3));
assertEquals(2, ArrayUtils.lastIndexOf(array, 2.2, 0.35));
assertEquals(3, ArrayUtils.lastIndexOf(array, 4.15, 2.0));
assertEquals(1, ArrayUtils.lastIndexOf(array, 1.00001324, 0.0001));
@ -1791,31 +1791,31 @@ public class ArrayUtilsTest extends AbstractLangTest {
@Test
public void testLastIndexOfDoubleWithStartIndex() {
double[] array = null;
assertEquals(-1, ArrayUtils.lastIndexOf(array, (double) 0, 2));
assertEquals(-1, ArrayUtils.lastIndexOf(array, 0, 2));
array = new double[0];
assertEquals(-1, ArrayUtils.lastIndexOf(array, (double) 0, 2));
assertEquals(-1, ArrayUtils.lastIndexOf(array, 0, 2));
array = new double[]{0, 1, 2, 3, 0};
assertEquals(0, ArrayUtils.lastIndexOf(array, (double) 0, 2));
assertEquals(1, ArrayUtils.lastIndexOf(array, (double) 1, 2));
assertEquals(2, ArrayUtils.lastIndexOf(array, (double) 2, 2));
assertEquals(-1, ArrayUtils.lastIndexOf(array, (double) 3, 2));
assertEquals(-1, ArrayUtils.lastIndexOf(array, (double) 3, -1));
assertEquals(-1, ArrayUtils.lastIndexOf(array, (double) 99));
assertEquals(4, ArrayUtils.lastIndexOf(array, (double) 0, 88));
assertEquals(0, ArrayUtils.lastIndexOf(array, 0, 2));
assertEquals(1, ArrayUtils.lastIndexOf(array, 1, 2));
assertEquals(2, ArrayUtils.lastIndexOf(array, 2, 2));
assertEquals(-1, ArrayUtils.lastIndexOf(array, 3, 2));
assertEquals(-1, ArrayUtils.lastIndexOf(array, 3, -1));
assertEquals(-1, ArrayUtils.lastIndexOf(array, 99));
assertEquals(4, ArrayUtils.lastIndexOf(array, 0, 88));
}
@SuppressWarnings("cast")
@Test
public void testLastIndexOfDoubleWithStartIndexTolerance() {
double[] array = null;
assertEquals(-1, ArrayUtils.lastIndexOf(array, (double) 0, 2, (double) 0));
assertEquals(-1, ArrayUtils.lastIndexOf(array, 0, 2, 0));
array = new double[0];
assertEquals(-1, ArrayUtils.lastIndexOf(array, (double) 0, 2, (double) 0));
array = new double[]{(double) 3};
assertEquals(-1, ArrayUtils.lastIndexOf(array, (double) 1, 0, (double) 0));
assertEquals(-1, ArrayUtils.lastIndexOf(array, 0, 2, 0));
array = new double[]{3};
assertEquals(-1, ArrayUtils.lastIndexOf(array, 1, 0, 0));
array = new double[]{0, 1, 2, 3, 0};
assertEquals(4, ArrayUtils.lastIndexOf(array, (double) 0, 99, 0.3));
assertEquals(0, ArrayUtils.lastIndexOf(array, (double) 0, 3, 0.3));
assertEquals(4, ArrayUtils.lastIndexOf(array, 0, 99, 0.3));
assertEquals(0, ArrayUtils.lastIndexOf(array, 0, 3, 0.3));
assertEquals(2, ArrayUtils.lastIndexOf(array, 2.2, 3, 0.35));
assertEquals(3, ArrayUtils.lastIndexOf(array, 4.15, array.length, 2.0));
assertEquals(1, ArrayUtils.lastIndexOf(array, 1.00001324, array.length, 0.0001));
@ -1826,32 +1826,32 @@ public class ArrayUtilsTest extends AbstractLangTest {
@Test
public void testLastIndexOfFloat() {
float[] array = null;
assertEquals(-1, ArrayUtils.lastIndexOf(array, (float) 0));
assertEquals(-1, ArrayUtils.lastIndexOf(array, 0));
array = new float[0];
assertEquals(-1, ArrayUtils.lastIndexOf(array, (float) 0));
assertEquals(-1, ArrayUtils.lastIndexOf(array, 0));
array = new float[]{0, 1, 2, 3, 0};
assertEquals(4, ArrayUtils.lastIndexOf(array, (float) 0));
assertEquals(1, ArrayUtils.lastIndexOf(array, (float) 1));
assertEquals(2, ArrayUtils.lastIndexOf(array, (float) 2));
assertEquals(3, ArrayUtils.lastIndexOf(array, (float) 3));
assertEquals(-1, ArrayUtils.lastIndexOf(array, (float) 99));
assertEquals(4, ArrayUtils.lastIndexOf(array, 0));
assertEquals(1, ArrayUtils.lastIndexOf(array, 1));
assertEquals(2, ArrayUtils.lastIndexOf(array, 2));
assertEquals(3, ArrayUtils.lastIndexOf(array, 3));
assertEquals(-1, ArrayUtils.lastIndexOf(array, 99));
}
@SuppressWarnings("cast")
@Test
public void testLastIndexOfFloatWithStartIndex() {
float[] array = null;
assertEquals(-1, ArrayUtils.lastIndexOf(array, (float) 0, 2));
assertEquals(-1, ArrayUtils.lastIndexOf(array, 0, 2));
array = new float[0];
assertEquals(-1, ArrayUtils.lastIndexOf(array, (float) 0, 2));
assertEquals(-1, ArrayUtils.lastIndexOf(array, 0, 2));
array = new float[]{0, 1, 2, 3, 0};
assertEquals(0, ArrayUtils.lastIndexOf(array, (float) 0, 2));
assertEquals(1, ArrayUtils.lastIndexOf(array, (float) 1, 2));
assertEquals(2, ArrayUtils.lastIndexOf(array, (float) 2, 2));
assertEquals(-1, ArrayUtils.lastIndexOf(array, (float) 3, 2));
assertEquals(-1, ArrayUtils.lastIndexOf(array, (float) 3, -1));
assertEquals(-1, ArrayUtils.lastIndexOf(array, (float) 99));
assertEquals(4, ArrayUtils.lastIndexOf(array, (float) 0, 88));
assertEquals(0, ArrayUtils.lastIndexOf(array, 0, 2));
assertEquals(1, ArrayUtils.lastIndexOf(array, 1, 2));
assertEquals(2, ArrayUtils.lastIndexOf(array, 2, 2));
assertEquals(-1, ArrayUtils.lastIndexOf(array, 3, 2));
assertEquals(-1, ArrayUtils.lastIndexOf(array, 3, -1));
assertEquals(-1, ArrayUtils.lastIndexOf(array, 99));
assertEquals(4, ArrayUtils.lastIndexOf(array, 0, 88));
}
@Test

View File

@ -401,9 +401,9 @@ public class CharSetTest extends AbstractLangTest {
@Test
public void testGetInstance_Stringarray() {
assertNull(CharSet.getInstance((String[]) null));
assertEquals("[]", CharSet.getInstance(new String[0]).toString());
assertEquals("[]", CharSet.getInstance().toString());
assertEquals("[]", CharSet.getInstance(new String[] {null}).toString());
assertEquals("[a-e]", CharSet.getInstance(new String[] {"a-e"}).toString());
assertEquals("[a-e]", CharSet.getInstance("a-e").toString());
}
@Test

View File

@ -80,7 +80,7 @@ public class CharUtilsTest extends AbstractLangTest {
assertFalse(CharUtils.isAsciiAlpha(CHAR_COPY));
for (int i = 0; i < 196; i++) {
if ((i >= 'A' && i <= 'Z') || (i >= 'a' && i <= 'z')) {
if (i >= 'A' && i <= 'Z' || i >= 'a' && i <= 'z') {
assertTrue(CharUtils.isAsciiAlpha((char) i));
} else {
assertFalse(CharUtils.isAsciiAlpha((char) i));
@ -116,7 +116,7 @@ public class CharUtilsTest extends AbstractLangTest {
assertFalse(CharUtils.isAsciiAlphanumeric(CHAR_COPY));
for (int i = 0; i < 196; i++) {
if ((i >= 'A' && i <= 'Z') || (i >= 'a' && i <= 'z') || (i >= '0' && i <= '9')) {
if (i >= 'A' && i <= 'Z' || i >= 'a' && i <= 'z' || i >= '0' && i <= '9') {
assertTrue(CharUtils.isAsciiAlphanumeric((char) i));
} else {
assertFalse(CharUtils.isAsciiAlphanumeric((char) i));

View File

@ -86,7 +86,7 @@ public class ClassUtilsTest extends AbstractLangTest {
}
private static final class Inner {
private final class DeeplyNested {
private static final class DeeplyNested {
// empty
}
}

View File

@ -62,9 +62,9 @@ public class EnumUtilsTest extends AbstractLangTest {
EnumUtils.generateBitVector(Traffic.class, EnumSet.of(Traffic.RED, Traffic.AMBER, Traffic.GREEN)));
// 64 values Enum (to test whether no int<->long jdk conversion issue exists)
assertEquals((1L << 31), EnumUtils.generateBitVector(Enum64.class, EnumSet.of(Enum64.A31)));
assertEquals((1L << 32), EnumUtils.generateBitVector(Enum64.class, EnumSet.of(Enum64.A32)));
assertEquals((1L << 63), EnumUtils.generateBitVector(Enum64.class, EnumSet.of(Enum64.A63)));
assertEquals(1L << 31, EnumUtils.generateBitVector(Enum64.class, EnumSet.of(Enum64.A31)));
assertEquals(1L << 32, EnumUtils.generateBitVector(Enum64.class, EnumSet.of(Enum64.A32)));
assertEquals(1L << 63, EnumUtils.generateBitVector(Enum64.class, EnumSet.of(Enum64.A63)));
assertEquals(Long.MIN_VALUE, EnumUtils.generateBitVector(Enum64.class, EnumSet.of(Enum64.A63)));
}
@ -145,9 +145,9 @@ public class EnumUtilsTest extends AbstractLangTest {
EnumUtils.generateBitVector(Traffic.class, Traffic.RED, Traffic.AMBER, Traffic.GREEN, Traffic.GREEN));
// 64 values Enum (to test whether no int<->long jdk conversion issue exists)
assertEquals((1L << 31), EnumUtils.generateBitVector(Enum64.class, Enum64.A31));
assertEquals((1L << 32), EnumUtils.generateBitVector(Enum64.class, Enum64.A32));
assertEquals((1L << 63), EnumUtils.generateBitVector(Enum64.class, Enum64.A63));
assertEquals(1L << 31, EnumUtils.generateBitVector(Enum64.class, Enum64.A31));
assertEquals(1L << 32, EnumUtils.generateBitVector(Enum64.class, Enum64.A32));
assertEquals(1L << 63, EnumUtils.generateBitVector(Enum64.class, Enum64.A63));
assertEquals(Long.MIN_VALUE, EnumUtils.generateBitVector(Enum64.class, Enum64.A63));
}
@ -164,15 +164,15 @@ public class EnumUtilsTest extends AbstractLangTest {
EnumUtils.generateBitVectors(Traffic.class, EnumSet.of(Traffic.RED, Traffic.AMBER, Traffic.GREEN)), 7L);
// 64 values Enum (to test whether no int<->long jdk conversion issue exists)
assertArrayEquals(EnumUtils.generateBitVectors(Enum64.class, EnumSet.of(Enum64.A31)), (1L << 31));
assertArrayEquals(EnumUtils.generateBitVectors(Enum64.class, EnumSet.of(Enum64.A32)), (1L << 32));
assertArrayEquals(EnumUtils.generateBitVectors(Enum64.class, EnumSet.of(Enum64.A63)), (1L << 63));
assertArrayEquals(EnumUtils.generateBitVectors(Enum64.class, EnumSet.of(Enum64.A31)), 1L << 31);
assertArrayEquals(EnumUtils.generateBitVectors(Enum64.class, EnumSet.of(Enum64.A32)), 1L << 32);
assertArrayEquals(EnumUtils.generateBitVectors(Enum64.class, EnumSet.of(Enum64.A63)), 1L << 63);
assertArrayEquals(EnumUtils.generateBitVectors(Enum64.class, EnumSet.of(Enum64.A63)), Long.MIN_VALUE);
// More than 64 values Enum
assertArrayEquals(EnumUtils.generateBitVectors(TooMany.class, EnumSet.of(TooMany.M2)), 1L, 0L);
assertArrayEquals(EnumUtils.generateBitVectors(TooMany.class, EnumSet.of(TooMany.L2, TooMany.M2)), 1L,
(1L << 63));
1L << 63);
}
@SuppressWarnings("unchecked")
@ -240,14 +240,14 @@ public class EnumUtilsTest extends AbstractLangTest {
EnumUtils.generateBitVectors(Traffic.class, Traffic.RED, Traffic.AMBER, Traffic.GREEN, Traffic.GREEN), 7L);
// 64 values Enum (to test whether no int<->long jdk conversion issue exists)
assertArrayEquals(EnumUtils.generateBitVectors(Enum64.class, Enum64.A31), (1L << 31));
assertArrayEquals(EnumUtils.generateBitVectors(Enum64.class, Enum64.A32), (1L << 32));
assertArrayEquals(EnumUtils.generateBitVectors(Enum64.class, Enum64.A63), (1L << 63));
assertArrayEquals(EnumUtils.generateBitVectors(Enum64.class, Enum64.A31), 1L << 31);
assertArrayEquals(EnumUtils.generateBitVectors(Enum64.class, Enum64.A32), 1L << 32);
assertArrayEquals(EnumUtils.generateBitVectors(Enum64.class, Enum64.A63), 1L << 63);
assertArrayEquals(EnumUtils.generateBitVectors(Enum64.class, Enum64.A63), Long.MIN_VALUE);
// More than 64 values Enum
assertArrayEquals(EnumUtils.generateBitVectors(TooMany.class, TooMany.M2), 1L, 0L);
assertArrayEquals(EnumUtils.generateBitVectors(TooMany.class, TooMany.L2, TooMany.M2), 1L, (1L << 63));
assertArrayEquals(EnumUtils.generateBitVectors(TooMany.class, TooMany.L2, TooMany.M2), 1L, 1L << 63);
}
@ -473,9 +473,9 @@ public class EnumUtilsTest extends AbstractLangTest {
EnumUtils.processBitVector(Traffic.class, 7L));
// 64 values Enum (to test whether no int<->long jdk conversion issue exists)
assertEquals(EnumSet.of(Enum64.A31), EnumUtils.processBitVector(Enum64.class, (1L << 31)));
assertEquals(EnumSet.of(Enum64.A32), EnumUtils.processBitVector(Enum64.class, (1L << 32)));
assertEquals(EnumSet.of(Enum64.A63), EnumUtils.processBitVector(Enum64.class, (1L << 63)));
assertEquals(EnumSet.of(Enum64.A31), EnumUtils.processBitVector(Enum64.class, 1L << 31));
assertEquals(EnumSet.of(Enum64.A32), EnumUtils.processBitVector(Enum64.class, 1L << 32));
assertEquals(EnumSet.of(Enum64.A63), EnumUtils.processBitVector(Enum64.class, 1L << 63));
assertEquals(EnumSet.of(Enum64.A63), EnumUtils.processBitVector(Enum64.class, Long.MIN_VALUE));
}
@ -524,9 +524,9 @@ public class EnumUtilsTest extends AbstractLangTest {
EnumUtils.processBitVectors(Traffic.class, 666L, 7L));
// 64 values Enum (to test whether no int<->long jdk conversion issue exists)
assertEquals(EnumSet.of(Enum64.A31), EnumUtils.processBitVectors(Enum64.class, (1L << 31)));
assertEquals(EnumSet.of(Enum64.A32), EnumUtils.processBitVectors(Enum64.class, (1L << 32)));
assertEquals(EnumSet.of(Enum64.A63), EnumUtils.processBitVectors(Enum64.class, (1L << 63)));
assertEquals(EnumSet.of(Enum64.A31), EnumUtils.processBitVectors(Enum64.class, 1L << 31));
assertEquals(EnumSet.of(Enum64.A32), EnumUtils.processBitVectors(Enum64.class, 1L << 32));
assertEquals(EnumSet.of(Enum64.A63), EnumUtils.processBitVectors(Enum64.class, 1L << 63));
assertEquals(EnumSet.of(Enum64.A63), EnumUtils.processBitVectors(Enum64.class, Long.MIN_VALUE));
}

View File

@ -227,42 +227,42 @@ public class FunctionsTest extends AbstractLangTest {
public void testDouble(final double i) throws Throwable {
test(throwable);
acceptedPrimitiveObject1 = (P) ((Double) i);
acceptedPrimitiveObject1 = (P) (Double) i;
}
public double testDoubleDouble(final double i, final double j) throws Throwable {
test(throwable);
acceptedPrimitiveObject1 = (P) ((Double) i);
acceptedPrimitiveObject2 = (P) ((Double) j);
acceptedPrimitiveObject1 = (P) (Double) i;
acceptedPrimitiveObject2 = (P) (Double) j;
return 3d;
}
public void testInt(final int i) throws Throwable {
test(throwable);
acceptedPrimitiveObject1 = (P) ((Integer) i);
acceptedPrimitiveObject1 = (P) (Integer) i;
}
public void testLong(final long i) throws Throwable {
test(throwable);
acceptedPrimitiveObject1 = (P) ((Long) i);
acceptedPrimitiveObject1 = (P) (Long) i;
}
public void testObjDouble(final T object, final double i) throws Throwable {
test(throwable);
acceptedObject = object;
acceptedPrimitiveObject1 = (P) ((Double) i);
acceptedPrimitiveObject1 = (P) (Double) i;
}
public void testObjInt(final T object, final int i) throws Throwable {
test(throwable);
acceptedObject = object;
acceptedPrimitiveObject1 = (P) ((Integer) i);
acceptedPrimitiveObject1 = (P) (Integer) i;
}
public void testObjLong(final T object, final long i) throws Throwable {
test(throwable);
acceptedObject = object;
acceptedPrimitiveObject1 = (P) ((Long) i);
acceptedPrimitiveObject1 = (P) (Long) i;
}
}

View File

@ -63,7 +63,7 @@ public class JavaVersionTest extends AbstractLangTest {
assertEquals(JAVA_1_7, get("1.7"), "1.7 failed");
assertEquals(JAVA_1_8, get("1.8"), "1.8 failed");
int lastSupportedVersion = Integer.parseInt(JavaVersion.values()[JavaVersion.values().length - 2].toString());
final int lastSupportedVersion = Integer.parseInt(JavaVersion.values()[JavaVersion.values().length - 2].toString());
for (int i = 9; i <= lastSupportedVersion; i++) {
assertEquals(JavaVersion.class.getField("JAVA_" + i).get(null), get("" + i), i + " failed");
}

View File

@ -31,7 +31,6 @@ import java.lang.reflect.Modifier;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Set;
@ -71,11 +70,9 @@ public class LocaleUtilsTest extends AbstractLangTest {
assertSame(list, list2);
//search through languages
for (final String country : countries) {
final Iterator<Locale> iterator = list.iterator();
boolean found = false;
// see if it was returned by the set
while (iterator.hasNext()) {
final Locale locale = iterator.next();
for (Locale locale : list) {
// should have an en empty variant
assertTrue(StringUtils.isEmpty(locale.getVariant()));
assertEquals(language, locale.getLanguage());
@ -105,11 +102,9 @@ public class LocaleUtilsTest extends AbstractLangTest {
assertSame(list, list2);
//search through languages
for (final String language : languages) {
final Iterator<Locale> iterator = list.iterator();
boolean found = false;
// see if it was returned by the set
while (iterator.hasNext()) {
final Locale locale = iterator.next();
for (Locale locale : list) {
// should have an en empty variant
assertTrue(StringUtils.isEmpty(locale.getVariant()));
assertEquals(country, locale.getCountry());

View File

@ -563,7 +563,7 @@ public class ObjectUtilsTest extends AbstractLangTest {
assertThrows(
NullPointerException.class,
() -> ObjectUtils.identityToString((Appendable) (new StringBuilder()), null));
() -> ObjectUtils.identityToString((Appendable) new StringBuilder(), null));
}
@Test

View File

@ -52,7 +52,7 @@ public class RandomStringUtilsTest extends AbstractLangTest {
private double chiSquare(final int[] expected, final int[] observed) {
double sumSq = 0.0d;
for (int i = 0; i < observed.length; i++) {
double dev = observed[i] - expected[i];
final double dev = observed[i] - expected[i];
sumSq += dev * dev / expected[i];
}
return sumSq;
@ -416,7 +416,7 @@ public class RandomStringUtilsTest extends AbstractLangTest {
r1 = RandomStringUtils.randomAscii(50);
assertEquals(50, r1.length(), "randomAscii(50) length");
for (int i = 0; i < r1.length(); i++) {
assertThat("char >= 32 && <= 127", ((int) r1.charAt(i)), allOf(greaterThanOrEqualTo(32), lessThanOrEqualTo(127)));
assertThat("char >= 32 && <= 127", (int) r1.charAt(i), allOf(greaterThanOrEqualTo(32), lessThanOrEqualTo(127)));
}
r2 = RandomStringUtils.randomAscii(50);
assertFalse(r1.equals(r2), "!r1.equals(r2)");
@ -513,7 +513,7 @@ public class RandomStringUtilsTest extends AbstractLangTest {
final int[] counts = {0, 0, 0};
final int[] expected = {200, 200, 200};
for (int i = 0; i < 100; i++) {
String gen = RandomStringUtils.random(6, chars);
final String gen = RandomStringUtils.random(6, chars);
for (int j = 0; j < 6; j++) {
switch (gen.charAt(j)) {
case 'a': {

View File

@ -117,16 +117,16 @@ public class RangeTest extends AbstractLangTest {
final DerivedComparableA derivedComparableA = new DerivedComparableA();
final DerivedComparableB derivedComparableB = new DerivedComparableB();
Range<AbstractComparable> mixed = Range.between(derivedComparableA, derivedComparableB, null);
final Range<AbstractComparable> mixed = Range.between(derivedComparableA, derivedComparableB, null);
assertTrue(mixed.contains(derivedComparableA));
Range<AbstractComparable> same = Range.between(derivedComparableA, derivedComparableA, null);
final Range<AbstractComparable> same = Range.between(derivedComparableA, derivedComparableA, null);
assertTrue(same.contains(derivedComparableA));
Range<DerivedComparableA> rangeA = Range.between(derivedComparableA, derivedComparableA, null);
final Range<DerivedComparableA> rangeA = Range.between(derivedComparableA, derivedComparableA, null);
assertTrue(rangeA.contains(derivedComparableA));
Range<DerivedComparableB> rangeB = Range.is(derivedComparableB, null);
final Range<DerivedComparableB> rangeB = Range.is(derivedComparableB, null);
assertTrue(rangeB.contains(derivedComparableB));
}

View File

@ -63,7 +63,7 @@ public class StringEscapeUtilsTest extends AbstractLangTest {
private void assertEscapeJava(String message, final String expected, final String original) throws IOException {
final String converted = StringEscapeUtils.escapeJava(original);
message = "escapeJava(String) failed" + (message == null ? "" : (": " + message));
message = "escapeJava(String) failed" + (message == null ? "" : ": " + message);
assertEquals(expected, converted, message);
final StringWriter writer = new StringWriter();
@ -81,7 +81,7 @@ public class StringEscapeUtilsTest extends AbstractLangTest {
assertEquals(expected, actual,
"unescape(String) failed" +
(message == null ? "" : (": " + message)) +
(message == null ? "" : ": " + message) +
": expected '" + StringEscapeUtils.escapeJava(expected) +
// we escape this so we can see it in the error message
"' actual '" + StringEscapeUtils.escapeJava(actual) + "'");
@ -488,8 +488,8 @@ public class StringEscapeUtilsTest extends AbstractLangTest {
final Character c1 = Character.valueOf(i);
final Character c2 = Character.valueOf((char) (i+1));
final String expected = c1.toString() + c2;
final String escapedC1 = "&#x" + Integer.toHexString((c1.charValue())) + ";";
final String escapedC2 = "&#x" + Integer.toHexString((c2.charValue())) + ";";
final String escapedC1 = "&#x" + Integer.toHexString(c1.charValue()) + ";";
final String escapedC2 = "&#x" + Integer.toHexString(c2.charValue()) + ";";
assertEquals(expected, StringEscapeUtils.unescapeHtml4(escapedC1 + escapedC2), "hex number unescape index " + (int) i);
}
}

View File

@ -167,10 +167,10 @@ public class StringUtilsContainsTest extends AbstractLangTest {
assertFalse(StringUtils.containsAny("", new String[] { "hello" }));
assertFalse(StringUtils.containsAny("hello, goodbye", (String[]) null));
assertFalse(StringUtils.containsAny("hello, goodbye", new String[0]));
assertTrue(StringUtils.containsAny("hello, goodbye", new String[]{"hello", "goodbye"}));
assertTrue(StringUtils.containsAny("hello, goodbye", new String[]{"hello", "Goodbye"}));
assertFalse(StringUtils.containsAny("hello, goodbye", new String[]{"Hello", "Goodbye"}));
assertFalse(StringUtils.containsAny("hello, goodbye", new String[]{"Hello", null}));
assertTrue(StringUtils.containsAny("hello, goodbye", new String[] { "hello", "goodbye" }));
assertTrue(StringUtils.containsAny("hello, goodbye", new String[] { "hello", "Goodbye" }));
assertFalse(StringUtils.containsAny("hello, goodbye", new String[] { "Hello", "Goodbye" }));
assertFalse(StringUtils.containsAny("hello, goodbye", new String[] { "Hello", null }));
assertFalse(StringUtils.containsAny("hello, null", new String[] { "Hello", null }));
// Javadoc examples:
assertTrue(StringUtils.containsAny("abcd", "ab", null));

View File

@ -56,7 +56,7 @@ public class SystemUtilsTest extends AbstractLangTest {
/**
* Returns the value of the SystemUtils.IS_JAVA_X field for the versions >= 9.
*/
private boolean getIS_JAVA(int version) throws Exception {
private boolean getIS_JAVA(final int version) throws Exception {
return SystemUtils.class.getField("IS_JAVA_" + version).getBoolean(null);
}
@ -66,7 +66,7 @@ public class SystemUtilsTest extends AbstractLangTest {
public int getLastSupportedJavaVersion() {
int lastSupportedVersion = 0;
for (Field field : SystemUtils.class.getFields()) {
for (final Field field : SystemUtils.class.getFields()) {
if (field.getName().matches("IS_JAVA_\\d+")) {
lastSupportedVersion = Math.max(lastSupportedVersion, Integer.parseInt(field.getName().substring(8)));
}
@ -78,8 +78,8 @@ public class SystemUtilsTest extends AbstractLangTest {
@Test
@SuppressWarnings("deprecation")
public void test_IS_JAVA() throws Exception {
String javaVersion = SystemUtils.JAVA_VERSION;
int lastSupportedVersion = getLastSupportedJavaVersion();
final String javaVersion = SystemUtils.JAVA_VERSION;
final int lastSupportedVersion = getLastSupportedJavaVersion();
if (javaVersion == null) {
assertFalse(SystemUtils.IS_JAVA_1_1);

View File

@ -155,14 +155,14 @@ public class ThreadUtilsTest extends AbstractLangTest {
@Test
public void testGetAllThreadGroupsDoesNotReturnNull() {
// LANG-1706 getAllThreadGroups and findThreadGroups should not return null items
Collection<ThreadGroup> threads = ThreadUtils.getAllThreadGroups();
final Collection<ThreadGroup> threads = ThreadUtils.getAllThreadGroups();
assertEquals(0, threads.stream().filter(Objects::isNull).count());
}
@Test
public void testGetAllThreadsDoesNotReturnNull() {
// LANG-1706 getAllThreads and findThreads should not return null items
Collection<Thread> threads = ThreadUtils.getAllThreads();
final Collection<Thread> threads = ThreadUtils.getAllThreads();
assertEquals(0, threads.stream().filter(Objects::isNull).count());
}

View File

@ -837,7 +837,7 @@ public class ValidateTest extends AbstractLangTest {
@Test
void shouldReturnSameInstance() {
final String[] expected = new String[] {"a", "b"};
final String[] expected = {"a", "b"};
assertSame(expected, Validate.noNullElements(expected));
}
@ -1032,7 +1032,7 @@ public class ValidateTest extends AbstractLangTest {
@Test
void shouldReturnTheSameInstance() {
final String[] expected = new String[] {"hi"};
final String[] expected = {"hi"};
assertSame(expected, Validate.notEmpty(expected, "MSG"));
}
@ -1059,7 +1059,7 @@ public class ValidateTest extends AbstractLangTest {
@Test
void shouldReturnTheSameInstance() {
final String[] expected = new String[] {"hi"};
final String[] expected = {"hi"};
assertSame(expected, Validate.notEmpty(expected));
}

View File

@ -128,13 +128,13 @@ public class HashCodeBuilderTest extends AbstractLangTest {
static class TestObjectWithMultipleFields {
@SuppressWarnings("unused")
private int one;
private final int one;
@SuppressWarnings("unused")
private int two;
private final int two;
@SuppressWarnings("unused")
private int three;
private final int three;
TestObjectWithMultipleFields(final int one, final int two, final int three) {
this.one = one;

View File

@ -33,12 +33,12 @@ public class ReflectionToStringBuilderCustomImplementationTest extends AbstractL
private static final String CUSTOM_PREFIX = "prefix:";
public CustomReflectionToStringBuilder(Object object, ToStringStyle toStringStyle) {
public CustomReflectionToStringBuilder(final Object object, final ToStringStyle toStringStyle) {
super(object, toStringStyle);
}
@Override
protected Object getValue(Field field) throws IllegalAccessException {
protected Object getValue(final Field field) throws IllegalAccessException {
return CUSTOM_PREFIX + super.getValue(field);
}
}

View File

@ -136,7 +136,7 @@ public class ReflectionToStringBuilderIncludeTest extends AbstractLangTest {
@Test
public void test_toStringIncludeNullArrayMultiplesValues() {
final String toString = ReflectionToStringBuilder.toStringInclude(new TestFeature(), new String[] {null, null, null, null});
final String toString = ReflectionToStringBuilder.toStringInclude(new TestFeature(), null, null, null, null);
this.validateAllFieldsPresent(toString);
}
@ -193,8 +193,8 @@ public class ReflectionToStringBuilderIncludeTest extends AbstractLangTest {
@Test
public void test_toStringSetIncludeWithArrayWithMultipleNullFields() {
final ReflectionToStringBuilder builder = new ReflectionToStringBuilder(new TestFeature());
builder.setExcludeFieldNames(new String[] {FIELDS[1], FIELDS[4]});
builder.setIncludeFieldNames(new String[] {null, null, null});
builder.setExcludeFieldNames(FIELDS[1], FIELDS[4]);
builder.setIncludeFieldNames(null, null, null);
final String toString = builder.toString();
this.validateIncludeFieldsPresent(toString, new String[]{FIELDS[0], FIELDS[2], FIELDS[3]}, new String[]{VALUES[0], VALUES[2], VALUES[3]});
}

View File

@ -123,42 +123,42 @@ public class StandardToStringStyleTest extends AbstractLangTest {
@Test
public void testDefaultIsArrayContentDetail() {
assertTrue((new StandardToStringStyle()).isArrayContentDetail());
assertTrue(new StandardToStringStyle().isArrayContentDetail());
}
@Test
public void testDefaultIsFieldSeparatorAtEnd() {
assertFalse((new StandardToStringStyle()).isFieldSeparatorAtEnd());
assertFalse(new StandardToStringStyle().isFieldSeparatorAtEnd());
}
@Test
public void testDefaultIsFieldSeparatorAtStart() {
assertFalse((new StandardToStringStyle()).isFieldSeparatorAtStart());
assertFalse(new StandardToStringStyle().isFieldSeparatorAtStart());
}
@Test
public void testDefaultValueOfFullDetail() {
assertTrue((new StandardToStringStyle()).isDefaultFullDetail());
assertTrue(new StandardToStringStyle().isDefaultFullDetail());
}
@Test
public void testDefaultValueOfUseClassName() {
assertTrue((new StandardToStringStyle()).isUseClassName());
assertTrue(new StandardToStringStyle().isUseClassName());
}
@Test
public void testDefaultValueOfUseFieldNames() {
assertTrue((new StandardToStringStyle()).isUseFieldNames());
assertTrue(new StandardToStringStyle().isUseFieldNames());
}
@Test
public void testDefaultValueOfUseIdentityHashCode() {
assertTrue((new StandardToStringStyle()).isUseIdentityHashCode());
assertTrue(new StandardToStringStyle().isUseIdentityHashCode());
}
@Test
public void testDefaultValueOfUseShortClassName() {
assertFalse((new StandardToStringStyle()).isUseShortClassName());
assertFalse(new StandardToStringStyle().isUseShortClassName());
}
@Test

View File

@ -258,7 +258,7 @@ public class ToStringBuilderTest extends AbstractLangTest {
@Test
public void testAppendAsObjectToStringNullPointerException() {
ToStringBuilder builder = new ToStringBuilder(1);
final ToStringBuilder builder = new ToStringBuilder(1);
assertThrows(NullPointerException.class, () -> builder.appendAsObjectToString(null));
builder.toString();
}

View File

@ -61,7 +61,7 @@ public abstract class AbstractConcurrentInitializerCloseAndExceptionsTest extend
// The use of enums rather than accepting an Exception as the input means we can have
// multiple exception types on the method signature.
protected static CloseableObject methodThatThrowsException(ExceptionToThrow input) throws IOException, SQLException, ConcurrentException {
protected static CloseableObject methodThatThrowsException(final ExceptionToThrow input) throws IOException, SQLException, ConcurrentException {
switch (input) {
case IOException:
throw new IOException();
@ -87,12 +87,12 @@ public abstract class AbstractConcurrentInitializerCloseAndExceptionsTest extend
public void testCloserThrowsCheckedException() throws ConcurrentException {
final ConcurrentInitializer<CloseableObject> initializer = createInitializerThatThrowsException(
CloseableObject::new,
(CloseableObject) -> methodThatThrowsException(ExceptionToThrow.IOException));
CloseableObject -> methodThatThrowsException(ExceptionToThrow.IOException));
try {
initializer.get();
((AbstractConcurrentInitializer) initializer).close();
fail();
} catch (Exception e) {
} catch (final Exception e) {
assertThat(e, instanceOf(ConcurrentException.class));
assertThat(e.getCause(), instanceOf(IOException.class));
}
@ -107,7 +107,7 @@ public abstract class AbstractConcurrentInitializerCloseAndExceptionsTest extend
public void testCloserThrowsRuntimeException() throws ConcurrentException {
final ConcurrentInitializer<CloseableObject> initializer = createInitializerThatThrowsException(
CloseableObject::new,
(CloseableObject) -> methodThatThrowsException(ExceptionToThrow.NullPointerException));
CloseableObject -> methodThatThrowsException(ExceptionToThrow.NullPointerException));
initializer.get();
assertThrows(NullPointerException.class, () -> {
@ -148,7 +148,7 @@ public abstract class AbstractConcurrentInitializerCloseAndExceptionsTest extend
try {
initializer.get();
fail();
} catch (ConcurrentException e) {
} catch (final ConcurrentException e) {
assertEquals(concurrentException, e);
}
}
@ -176,7 +176,7 @@ public abstract class AbstractConcurrentInitializerCloseAndExceptionsTest extend
CloseableObject::new,
CloseableObject::close);
CloseableObject closeableObject = initializer.get();
final CloseableObject closeableObject = initializer.get();
assertFalse(closeableObject.isClosed());
((AbstractConcurrentInitializer) initializer).close();
assertTrue(closeableObject.isClosed());

View File

@ -128,7 +128,7 @@ public abstract class AbstractConcurrentInitializerTest extends AbstractLangTest
public void testisInitialized() throws Throwable {
final ConcurrentInitializer<Object> initializer = createInitializer();
if (initializer instanceof AbstractConcurrentInitializer) {
AbstractConcurrentInitializer castedInitializer = (AbstractConcurrentInitializer) initializer;
final AbstractConcurrentInitializer castedInitializer = (AbstractConcurrentInitializer) initializer;
assertFalse(castedInitializer.isInitialized(), "was initialized before get()");
assertNotNull(castedInitializer.get(), "No managed object");
assertTrue(castedInitializer.isInitialized(), "was not initialized after get()");

View File

@ -30,7 +30,7 @@ public class AtomicInitializerSupplierTest extends AbstractConcurrentInitializer
*/
@Override
protected ConcurrentInitializer<Object> createInitializer() {
return AtomicInitializer.<Object>builder().setInitializer(() -> new Object()).get();
return AtomicInitializer.<Object>builder().setInitializer(Object::new).get();
}
@Override

View File

@ -50,9 +50,8 @@ public class AtomicInitializerTest extends AbstractConcurrentInitializerTest {
protected Object initialize() {
if (firstRun.getAndSet(false)) {
return null;
} else {
return new Object();
}
return new Object();
}
};

View File

@ -72,9 +72,8 @@ public class AtomicSafeInitializerSupplierTest extends AbstractConcurrentInitial
protected Object initialize() {
if (firstRun.getAndSet(false)) {
return null;
} else {
return new Object();
}
return new Object();
}
};

View File

@ -74,9 +74,8 @@ public class AtomicSafeInitializerTest extends AbstractConcurrentInitializerTest
protected Object initialize() {
if (firstRun.getAndSet(false)) {
return null;
} else {
return new Object();
}
return new Object();
}
};

View File

@ -40,29 +40,27 @@ public class BackgroundInitializerSupplierTest extends BackgroundInitializerTest
protected static final class SupplierBackgroundInitializerTestImpl extends AbstractBackgroundInitializerTestImpl {
SupplierBackgroundInitializerTestImpl() {
super();
setSupplierAndCloser((CloseableCounter cc) -> cc.close());
setSupplierAndCloser((final CloseableCounter cc) -> cc.close());
}
SupplierBackgroundInitializerTestImpl(final ExecutorService exec) {
super(exec);
setSupplierAndCloser((CloseableCounter cc) -> cc.close());
setSupplierAndCloser((final CloseableCounter cc) -> cc.close());
}
SupplierBackgroundInitializerTestImpl(FailableConsumer<?, ?> consumer) {
super();
SupplierBackgroundInitializerTestImpl(final FailableConsumer<?, ?> consumer) {
setSupplierAndCloser(consumer);
}
private void setSupplierAndCloser(FailableConsumer<?, ?> consumer) {
private void setSupplierAndCloser(final FailableConsumer<?, ?> consumer) {
try {
// Use reflection here because the constructors we need are private
FailableSupplier<?, ?> supplier = () -> initializeInternal();
Field initializer = AbstractConcurrentInitializer.class.getDeclaredField("initializer");
final FailableSupplier<?, ?> supplier = this::initializeInternal;
final Field initializer = AbstractConcurrentInitializer.class.getDeclaredField("initializer");
initializer.setAccessible(true);
initializer.set(this, supplier);
Field closer = AbstractConcurrentInitializer.class.getDeclaredField("closer");
final Field closer = AbstractConcurrentInitializer.class.getDeclaredField("closer");
closer.setAccessible(true);
closer.set(this, consumer);
} catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) {
@ -71,10 +69,12 @@ public class BackgroundInitializerSupplierTest extends BackgroundInitializerTest
}
}
@Override
protected AbstractBackgroundInitializerTestImpl getBackgroundInitializerTestImpl() {
return new SupplierBackgroundInitializerTestImpl();
}
@Override
protected SupplierBackgroundInitializerTestImpl getBackgroundInitializerTestImpl(final ExecutorService exec) {
return new SupplierBackgroundInitializerTestImpl(exec);
}
@ -106,7 +106,7 @@ public class BackgroundInitializerSupplierTest extends BackgroundInitializerTest
public void testCloseWithCheckedException() throws Exception {
final IOException ioException = new IOException();
final FailableConsumer<?, ?> IOExceptionConsumer = (CloseableCounter cc) -> {
final FailableConsumer<?, ?> IOExceptionConsumer = (final CloseableCounter cc) -> {
throw ioException;
};
@ -116,7 +116,7 @@ public class BackgroundInitializerSupplierTest extends BackgroundInitializerTest
try {
init.close();
fail();
} catch (Exception e) {
} catch (final Exception e) {
assertThat(e, instanceOf(ConcurrentException.class));
assertSame(ioException, e.getCause());
}
@ -131,7 +131,7 @@ public class BackgroundInitializerSupplierTest extends BackgroundInitializerTest
public void testCloseWithRuntimeException() throws Exception {
final NullPointerException npe = new NullPointerException();
final FailableConsumer<?, ?> NullPointerExceptionConsumer = (CloseableCounter cc) -> {
final FailableConsumer<?, ?> NullPointerExceptionConsumer = (final CloseableCounter cc) -> {
throw npe;
};
@ -141,7 +141,7 @@ public class BackgroundInitializerSupplierTest extends BackgroundInitializerTest
try {
init.close();
fail();
} catch (Exception e) {
} catch (final Exception e) {
assertSame(npe, e);
}
}

View File

@ -31,7 +31,7 @@ public class LazyInitializerSupplierTest extends AbstractConcurrentInitializerCl
*/
@Override
protected ConcurrentInitializer<Object> createInitializer() {
return LazyInitializer.<Object>builder().setInitializer(() -> new Object()).get();
return LazyInitializer.<Object>builder().setInitializer(Object::new).get();
}
@Override

View File

@ -43,13 +43,13 @@ public class MultiBackgroundInitializerSupplierTest extends MultiBackgroundIniti
private static final class SupplierChildBackgroundInitializer extends AbstractChildBackgroundInitializer {
SupplierChildBackgroundInitializer() {
this((CloseableCounter cc) -> cc.close());
this((final CloseableCounter cc) -> cc.close());
}
SupplierChildBackgroundInitializer(FailableConsumer<?, ?> consumer) {
SupplierChildBackgroundInitializer(final FailableConsumer<?, ?> consumer) {
try {
// Use reflection here because the constructors we need are private
final FailableSupplier<?, ?> supplier = () -> initializeInternal();
final FailableSupplier<?, ?> supplier = this::initializeInternal;
final Field initializer = AbstractConcurrentInitializer.class.getDeclaredField("initializer");
initializer.setAccessible(true);
initializer.set(this, supplier);
@ -80,10 +80,10 @@ public class MultiBackgroundInitializerSupplierTest extends MultiBackgroundIniti
public void setUpException() throws Exception {
npe = new NullPointerException();
ioException = new IOException();
ioExceptionConsumer = (CloseableCounter cc) -> {
ioExceptionConsumer = (final CloseableCounter cc) -> {
throw ioException;
};
nullPointerExceptionConsumer = (CloseableCounter cc) -> {
nullPointerExceptionConsumer = (final CloseableCounter cc) -> {
throw npe;
};
}
@ -109,9 +109,9 @@ public class MultiBackgroundInitializerSupplierTest extends MultiBackgroundIniti
initializer.start();
long startTime = System.currentTimeMillis();
long waitTime = 3000;
long endTime = startTime + waitTime;
final long startTime = System.currentTimeMillis();
final long waitTime = 3000;
final long endTime = startTime + waitTime;
//wait for the children to start
while (!childOne.isStarted() || !childTwo.isStarted()) {
if (System.currentTimeMillis() > endTime) {
@ -131,7 +131,7 @@ public class MultiBackgroundInitializerSupplierTest extends MultiBackgroundIniti
try {
initializer.close();
} catch (Exception e) {
} catch (final Exception e) {
fail();
}
@ -151,9 +151,9 @@ public class MultiBackgroundInitializerSupplierTest extends MultiBackgroundIniti
initializer.addInitializer("child one", childOne);
initializer.start();
long startTime = System.currentTimeMillis();
long waitTime = 3000;
long endTime = startTime + waitTime;
final long startTime = System.currentTimeMillis();
final long waitTime = 3000;
final long endTime = startTime + waitTime;
//wait for the children to start
while (! childOne.isStarted()) {
if (System.currentTimeMillis() > endTime) {
@ -166,7 +166,7 @@ public class MultiBackgroundInitializerSupplierTest extends MultiBackgroundIniti
try {
initializer.close();
fail();
} catch (Exception e) {
} catch (final Exception e) {
assertThat(e, instanceOf(ConcurrentException.class));
assertSame(ioException, e.getSuppressed()[0]);
}
@ -184,9 +184,9 @@ public class MultiBackgroundInitializerSupplierTest extends MultiBackgroundIniti
initializer.addInitializer("child one", childOne);
initializer.start();
long startTime = System.currentTimeMillis();
long waitTime = 3000;
long endTime = startTime + waitTime;
final long startTime = System.currentTimeMillis();
final long waitTime = 3000;
final long endTime = startTime + waitTime;
//wait for the children to start
while (! childOne.isStarted()) {
if (System.currentTimeMillis() > endTime) {
@ -199,7 +199,7 @@ public class MultiBackgroundInitializerSupplierTest extends MultiBackgroundIniti
try {
initializer.close();
fail();
} catch (Exception e) {
} catch (final Exception e) {
assertThat(e, instanceOf(ConcurrentException.class));
assertSame(npe, e.getSuppressed()[0]);
}
@ -240,12 +240,12 @@ public class MultiBackgroundInitializerSupplierTest extends MultiBackgroundIniti
try {
initializer.close();
fail();
} catch (Exception e) {
} catch (final Exception e) {
// We don't actually know which order the children will be closed in
boolean foundChildOneException = false;
boolean foundChildTwoException = false;
for (Throwable t : e.getSuppressed()) {
for (final Throwable t : e.getSuppressed()) {
if (t.equals(ioException)) {
foundChildOneException = true;
}

View File

@ -95,7 +95,7 @@ public class MultiBackgroundInitializerTest extends AbstractLangTest {
protected static class CloseableCounter {
// A convenience for testing that a CloseableCounter typed as Object has a specific initializeCalls value
public static CloseableCounter wrapInteger(int i) {
public static CloseableCounter wrapInteger(final int i) {
return new CloseableCounter().setInitializeCalls(i);
}
@ -130,7 +130,7 @@ public class MultiBackgroundInitializerTest extends AbstractLangTest {
return closed;
}
public CloseableCounter setInitializeCalls(int i) {
public CloseableCounter setInitializeCalls(final int i) {
initializeCalls = i;
return this;
}
@ -437,9 +437,9 @@ public class MultiBackgroundInitializerTest extends AbstractLangTest {
initializer.addInitializer("child two", childTwo);
initializer.start();
long startTime = System.currentTimeMillis();
long waitTime = 3000;
long endTime = startTime + waitTime;
final long startTime = System.currentTimeMillis();
final long waitTime = 3000;
final long endTime = startTime + waitTime;
//wait for the children to start
while (! childOne.isStarted() || ! childTwo.isStarted()) {
if (System.currentTimeMillis() > endTime) {

View File

@ -644,7 +644,7 @@ public class NumberUtilsTest extends AbstractLangTest {
assertEquals(new BigDecimal("1.7976931348623159e+308"), NumberUtils.createNumber("1.7976931348623159e+308"));
// Requested type is parsed as zero but the value is not zero
final Double nonZero1 = Double.valueOf(((double) Float.MIN_VALUE) / 2);
final Double nonZero1 = Double.valueOf((double) Float.MIN_VALUE / 2);
assertEquals(nonZero1, NumberUtils.createNumber(nonZero1.toString()));
assertEquals(nonZero1, NumberUtils.createNumber(nonZero1 + "F"));
// Smallest double is 4.9e-324.

View File

@ -26,7 +26,7 @@ import org.apache.commons.lang3.time.DurationUtils;
*/
public class PrintAtomicVsMutable {
public static void main(String[] args) {
public static void main(final String[] args) {
final MutableInt mInt = new MutableInt();
final int max = 100_000_000;
System.out.println("MutableInt " + DurationUtils.of(() -> {

View File

@ -665,19 +665,19 @@ public class StrBuilderTest extends AbstractLangTest {
assertTrue(sb1.equals(sb2));
assertTrue(sb1.equals(sb1));
assertTrue(sb2.equals(sb2));
assertEquals(sb1, (Object) sb2);
assertEquals(sb1, sb2);
sb1.append("abc");
assertFalse(sb1.equals(sb2));
assertNotEquals(sb1, (Object) sb2);
assertNotEquals(sb1, sb2);
sb2.append("ABC");
assertFalse(sb1.equals(sb2));
assertNotEquals(sb1, (Object) sb2);
assertNotEquals(sb1, sb2);
sb2.clear().append("abc");
assertTrue(sb1.equals(sb2));
assertEquals(sb1, (Object) sb2);
assertEquals(sb1, sb2);
assertNotEquals(sb1, Integer.valueOf(1));
assertNotEquals("abc", sb1);

View File

@ -127,7 +127,7 @@ public class DateUtilsFragmentTest extends AbstractLangTest {
@Test
public void testHoursOfMonthWithCalendar() {
final long testResult = DateUtils.getFragmentInHours(aCalendar, Calendar.MONTH);
assertEquals( hours +(((days - 1) * DateUtils.MILLIS_PER_DAY))
assertEquals( hours +(days - 1) * DateUtils.MILLIS_PER_DAY
/ DateUtils.MILLIS_PER_HOUR,
testResult);
}
@ -135,7 +135,7 @@ public class DateUtilsFragmentTest extends AbstractLangTest {
@Test
public void testHoursOfMonthWithDate() {
final long testResult = DateUtils.getFragmentInHours(aDate, Calendar.MONTH);
assertEquals(hours + (((days - 1) * DateUtils.MILLIS_PER_DAY))
assertEquals(hours + (days - 1) * DateUtils.MILLIS_PER_DAY
/ DateUtils.MILLIS_PER_HOUR,
testResult);
}
@ -143,7 +143,7 @@ public class DateUtilsFragmentTest extends AbstractLangTest {
@Test
public void testHoursOfYearWithCalendar() {
final long testResult = DateUtils.getFragmentInHours(aCalendar, Calendar.YEAR);
assertEquals( hours +(((aCalendar.get(Calendar.DAY_OF_YEAR) - 1) * DateUtils.MILLIS_PER_DAY))
assertEquals( hours +(aCalendar.get(Calendar.DAY_OF_YEAR) - 1) * DateUtils.MILLIS_PER_DAY
/ DateUtils.MILLIS_PER_HOUR,
testResult);
}
@ -153,7 +153,7 @@ public class DateUtilsFragmentTest extends AbstractLangTest {
final long testResult = DateUtils.getFragmentInHours(aDate, Calendar.YEAR);
final Calendar cal = Calendar.getInstance();
cal.setTime(aDate);
assertEquals(hours + (((cal.get(Calendar.DAY_OF_YEAR) - 1) * DateUtils.MILLIS_PER_DAY))
assertEquals(hours + (cal.get(Calendar.DAY_OF_YEAR) - 1) * DateUtils.MILLIS_PER_DAY
/ DateUtils.MILLIS_PER_HOUR,
testResult);
}
@ -201,7 +201,7 @@ public class DateUtilsFragmentTest extends AbstractLangTest {
@Test
public void testMillisecondsOfDayWithCalendar() {
long testresult = DateUtils.getFragmentInMilliseconds(aCalendar, Calendar.DATE);
final long expectedValue = millis + (seconds * DateUtils.MILLIS_PER_SECOND) + (minutes * DateUtils.MILLIS_PER_MINUTE) + (hours * DateUtils.MILLIS_PER_HOUR);
final long expectedValue = millis + seconds * DateUtils.MILLIS_PER_SECOND + minutes * DateUtils.MILLIS_PER_MINUTE + hours * DateUtils.MILLIS_PER_HOUR;
assertEquals(expectedValue, testresult);
testresult = DateUtils.getFragmentInMilliseconds(aCalendar, Calendar.DAY_OF_YEAR);
assertEquals(expectedValue, testresult);
@ -211,7 +211,7 @@ public class DateUtilsFragmentTest extends AbstractLangTest {
@Test
public void testMillisecondsOfDayWithDate() {
long testresult = DateUtils.getFragmentInMilliseconds(aDate, Calendar.DATE);
final long expectedValue = millis + (seconds * DateUtils.MILLIS_PER_SECOND) + (minutes * DateUtils.MILLIS_PER_MINUTE) + (hours * DateUtils.MILLIS_PER_HOUR);
final long expectedValue = millis + seconds * DateUtils.MILLIS_PER_SECOND + minutes * DateUtils.MILLIS_PER_MINUTE + hours * DateUtils.MILLIS_PER_HOUR;
assertEquals(expectedValue, testresult);
testresult = DateUtils.getFragmentInMilliseconds(aDate, Calendar.DAY_OF_YEAR);
assertEquals(expectedValue, testresult);
@ -222,32 +222,32 @@ public class DateUtilsFragmentTest extends AbstractLangTest {
@Test
public void testMillisecondsOfHourWithCalendar() {
final long testResult = DateUtils.getFragmentInMilliseconds(aCalendar, Calendar.HOUR_OF_DAY);
assertEquals(millis + (seconds * DateUtils.MILLIS_PER_SECOND) + (minutes * DateUtils.MILLIS_PER_MINUTE), testResult);
assertEquals(millis + seconds * DateUtils.MILLIS_PER_SECOND + minutes * DateUtils.MILLIS_PER_MINUTE, testResult);
}
@Test
public void testMillisecondsOfHourWithDate() {
final long testResult = DateUtils.getFragmentInMilliseconds(aDate, Calendar.HOUR_OF_DAY);
assertEquals(millis + (seconds * DateUtils.MILLIS_PER_SECOND) + (minutes * DateUtils.MILLIS_PER_MINUTE), testResult);
assertEquals(millis + seconds * DateUtils.MILLIS_PER_SECOND + minutes * DateUtils.MILLIS_PER_MINUTE, testResult);
}
@Test
public void testMillisecondsOfMinuteWithCalender() {
final long testResult = DateUtils.getFragmentInMilliseconds(aCalendar, Calendar.MINUTE);
assertEquals(millis + (seconds * DateUtils.MILLIS_PER_SECOND), testResult);
assertEquals(millis + seconds * DateUtils.MILLIS_PER_SECOND, testResult);
}
@Test
public void testMillisecondsOfMinuteWithDate() {
final long testResult = DateUtils.getFragmentInMilliseconds(aDate, Calendar.MINUTE);
assertEquals(millis + (seconds * DateUtils.MILLIS_PER_SECOND), testResult);
assertEquals(millis + seconds * DateUtils.MILLIS_PER_SECOND, testResult);
}
@Test
public void testMillisecondsOfMonthWithCalendar() {
final long testResult = DateUtils.getFragmentInMilliseconds(aCalendar, Calendar.MONTH);
assertEquals(millis + (seconds * DateUtils.MILLIS_PER_SECOND) + (minutes * DateUtils.MILLIS_PER_MINUTE)
+ (hours * DateUtils.MILLIS_PER_HOUR) + ((days - 1) * DateUtils.MILLIS_PER_DAY),
assertEquals(millis + seconds * DateUtils.MILLIS_PER_SECOND + minutes * DateUtils.MILLIS_PER_MINUTE
+ hours * DateUtils.MILLIS_PER_HOUR + (days - 1) * DateUtils.MILLIS_PER_DAY,
testResult);
}
@ -255,8 +255,8 @@ testResult);
@Test
public void testMillisecondsOfMonthWithDate() {
final long testResult = DateUtils.getFragmentInMilliseconds(aDate, Calendar.MONTH);
assertEquals(millis + (seconds * DateUtils.MILLIS_PER_SECOND) + (minutes * DateUtils.MILLIS_PER_MINUTE)
+ (hours * DateUtils.MILLIS_PER_HOUR) + ((days - 1) * DateUtils.MILLIS_PER_DAY),
assertEquals(millis + seconds * DateUtils.MILLIS_PER_SECOND + minutes * DateUtils.MILLIS_PER_MINUTE
+ hours * DateUtils.MILLIS_PER_HOUR + (days - 1) * DateUtils.MILLIS_PER_DAY,
testResult);
}
@ -276,8 +276,8 @@ testResult);
@Test
public void testMillisecondsOfYearWithCalendar() {
final long testResult = DateUtils.getFragmentInMilliseconds(aCalendar, Calendar.YEAR);
assertEquals(millis + (seconds * DateUtils.MILLIS_PER_SECOND) + (minutes * DateUtils.MILLIS_PER_MINUTE)
+ (hours * DateUtils.MILLIS_PER_HOUR) + ((aCalendar.get(Calendar.DAY_OF_YEAR) - 1) * DateUtils.MILLIS_PER_DAY),
assertEquals(millis + seconds * DateUtils.MILLIS_PER_SECOND + minutes * DateUtils.MILLIS_PER_MINUTE
+ hours * DateUtils.MILLIS_PER_HOUR + (aCalendar.get(Calendar.DAY_OF_YEAR) - 1) * DateUtils.MILLIS_PER_DAY,
testResult);
}
@ -287,8 +287,8 @@ testResult);
final long testResult = DateUtils.getFragmentInMilliseconds(aDate, Calendar.YEAR);
final Calendar cal = Calendar.getInstance();
cal.setTime(aDate);
assertEquals(millis + (seconds * DateUtils.MILLIS_PER_SECOND) + (minutes * DateUtils.MILLIS_PER_MINUTE)
+ (hours * DateUtils.MILLIS_PER_HOUR) + ((cal.get(Calendar.DAY_OF_YEAR) - 1)* DateUtils.MILLIS_PER_DAY),
assertEquals(millis + seconds * DateUtils.MILLIS_PER_SECOND + minutes * DateUtils.MILLIS_PER_MINUTE
+ hours * DateUtils.MILLIS_PER_HOUR + (cal.get(Calendar.DAY_OF_YEAR) - 1)* DateUtils.MILLIS_PER_DAY,
testResult);
}
@ -309,7 +309,7 @@ testResult);
@Test
public void testMinutesOfDayWithCalendar() {
long testResult = DateUtils.getFragmentInMinutes(aCalendar, Calendar.DATE);
final long expectedValue = minutes + ((hours * DateUtils.MILLIS_PER_HOUR))/ DateUtils.MILLIS_PER_MINUTE;
final long expectedValue = minutes + hours * DateUtils.MILLIS_PER_HOUR/ DateUtils.MILLIS_PER_MINUTE;
assertEquals(expectedValue, testResult);
testResult = DateUtils.getFragmentInMinutes(aCalendar, Calendar.DAY_OF_YEAR);
assertEquals(expectedValue, testResult);
@ -318,7 +318,7 @@ testResult);
@Test
public void testMinutesOfDayWithDate() {
long testResult = DateUtils.getFragmentInMinutes(aDate, Calendar.DATE);
final long expectedValue = minutes + ((hours * DateUtils.MILLIS_PER_HOUR))/ DateUtils.MILLIS_PER_MINUTE;
final long expectedValue = minutes + hours * DateUtils.MILLIS_PER_HOUR/ DateUtils.MILLIS_PER_MINUTE;
assertEquals(expectedValue, testResult);
testResult = DateUtils.getFragmentInMinutes(aDate, Calendar.DAY_OF_YEAR);
assertEquals(expectedValue, testResult);
@ -339,7 +339,7 @@ testResult);
@Test
public void testMinutesOfMonthWithCalendar() {
final long testResult = DateUtils.getFragmentInMinutes(aCalendar, Calendar.MONTH);
assertEquals( minutes +((hours * DateUtils.MILLIS_PER_HOUR) + ((days - 1) * DateUtils.MILLIS_PER_DAY))
assertEquals( minutes +(hours * DateUtils.MILLIS_PER_HOUR + (days - 1) * DateUtils.MILLIS_PER_DAY)
/ DateUtils.MILLIS_PER_MINUTE,
testResult);
}
@ -348,7 +348,7 @@ testResult);
public void testMinutesOfMonthWithDate() {
final long testResult = DateUtils.getFragmentInMinutes(aDate, Calendar.MONTH);
assertEquals(minutes
+ ((hours * DateUtils.MILLIS_PER_HOUR) + ((days - 1) * DateUtils.MILLIS_PER_DAY))
+ (hours * DateUtils.MILLIS_PER_HOUR + (days - 1) * DateUtils.MILLIS_PER_DAY)
/ DateUtils.MILLIS_PER_MINUTE,
testResult);
}
@ -356,7 +356,7 @@ testResult);
@Test
public void testMinutesOfYearWithCalendar() {
final long testResult = DateUtils.getFragmentInMinutes(aCalendar, Calendar.YEAR);
assertEquals( minutes +((hours * DateUtils.MILLIS_PER_HOUR) + ((aCalendar.get(Calendar.DAY_OF_YEAR) - 1) * DateUtils.MILLIS_PER_DAY))
assertEquals( minutes +(hours * DateUtils.MILLIS_PER_HOUR + (aCalendar.get(Calendar.DAY_OF_YEAR) - 1) * DateUtils.MILLIS_PER_DAY)
/ DateUtils.MILLIS_PER_MINUTE,
testResult);
}
@ -367,7 +367,7 @@ testResult);
final Calendar cal = Calendar.getInstance();
cal.setTime(aDate);
assertEquals(minutes
+ ((hours * DateUtils.MILLIS_PER_HOUR) + ((cal.get(Calendar.DAY_OF_YEAR) - 1) * DateUtils.MILLIS_PER_DAY))
+ (hours * DateUtils.MILLIS_PER_HOUR + (cal.get(Calendar.DAY_OF_YEAR) - 1) * DateUtils.MILLIS_PER_DAY)
/ DateUtils.MILLIS_PER_MINUTE,
testResult);
}
@ -422,7 +422,7 @@ testResult);
@Test
public void testSecondsOfDayWithCalendar() {
long testresult = DateUtils.getFragmentInSeconds(aCalendar, Calendar.DATE);
final long expectedValue = seconds + ((minutes * DateUtils.MILLIS_PER_MINUTE) + (hours * DateUtils.MILLIS_PER_HOUR))/ DateUtils.MILLIS_PER_SECOND;
final long expectedValue = seconds + (minutes * DateUtils.MILLIS_PER_MINUTE + hours * DateUtils.MILLIS_PER_HOUR)/ DateUtils.MILLIS_PER_SECOND;
assertEquals(expectedValue, testresult);
testresult = DateUtils.getFragmentInSeconds(aCalendar, Calendar.DAY_OF_YEAR);
assertEquals(expectedValue, testresult);
@ -431,7 +431,7 @@ testResult);
@Test
public void testSecondsOfDayWithDate() {
long testresult = DateUtils.getFragmentInSeconds(aDate, Calendar.DATE);
final long expectedValue = seconds + ((minutes * DateUtils.MILLIS_PER_MINUTE) + (hours * DateUtils.MILLIS_PER_HOUR))/ DateUtils.MILLIS_PER_SECOND;
final long expectedValue = seconds + (minutes * DateUtils.MILLIS_PER_MINUTE + hours * DateUtils.MILLIS_PER_HOUR)/ DateUtils.MILLIS_PER_SECOND;
assertEquals(expectedValue, testresult);
testresult = DateUtils.getFragmentInSeconds(aDate, Calendar.DAY_OF_YEAR);
assertEquals(expectedValue, testresult);
@ -442,8 +442,8 @@ testResult);
final long testResult = DateUtils.getFragmentInSeconds(aCalendar, Calendar.HOUR_OF_DAY);
assertEquals(
seconds
+ (minutes
* DateUtils.MILLIS_PER_MINUTE / DateUtils.MILLIS_PER_SECOND),
+ minutes
* DateUtils.MILLIS_PER_MINUTE / DateUtils.MILLIS_PER_SECOND,
testResult);
}
@ -452,8 +452,8 @@ testResult);
final long testResult = DateUtils.getFragmentInSeconds(aDate, Calendar.HOUR_OF_DAY);
assertEquals(
seconds
+ (minutes
* DateUtils.MILLIS_PER_MINUTE / DateUtils.MILLIS_PER_SECOND),
+ minutes
* DateUtils.MILLIS_PER_MINUTE / DateUtils.MILLIS_PER_SECOND,
testResult);
}
@ -475,8 +475,8 @@ testResult);
final long testResult = DateUtils.getFragmentInSeconds(aCalendar, Calendar.MONTH);
assertEquals(
seconds
+ ((minutes * DateUtils.MILLIS_PER_MINUTE)
+ (hours * DateUtils.MILLIS_PER_HOUR) + ((days - 1) * DateUtils.MILLIS_PER_DAY))
+ (minutes * DateUtils.MILLIS_PER_MINUTE
+ hours * DateUtils.MILLIS_PER_HOUR + (days - 1) * DateUtils.MILLIS_PER_DAY)
/ DateUtils.MILLIS_PER_SECOND,
testResult);
}
@ -486,8 +486,8 @@ testResult);
final long testResult = DateUtils.getFragmentInSeconds(aDate, Calendar.MONTH);
assertEquals(
seconds
+ ((minutes * DateUtils.MILLIS_PER_MINUTE)
+ (hours * DateUtils.MILLIS_PER_HOUR) + ((days - 1) * DateUtils.MILLIS_PER_DAY))
+ (minutes * DateUtils.MILLIS_PER_MINUTE
+ hours * DateUtils.MILLIS_PER_HOUR + (days - 1) * DateUtils.MILLIS_PER_DAY)
/ DateUtils.MILLIS_PER_SECOND,
testResult);
}
@ -497,8 +497,8 @@ testResult);
final long testResult = DateUtils.getFragmentInSeconds(aCalendar, Calendar.YEAR);
assertEquals(
seconds
+ ((minutes * DateUtils.MILLIS_PER_MINUTE)
+ (hours * DateUtils.MILLIS_PER_HOUR) + ((aCalendar.get(Calendar.DAY_OF_YEAR) - 1) * DateUtils.MILLIS_PER_DAY))
+ (minutes * DateUtils.MILLIS_PER_MINUTE
+ hours * DateUtils.MILLIS_PER_HOUR + (aCalendar.get(Calendar.DAY_OF_YEAR) - 1) * DateUtils.MILLIS_PER_DAY)
/ DateUtils.MILLIS_PER_SECOND,
testResult);
}
@ -510,8 +510,8 @@ testResult);
cal.setTime(aDate);
assertEquals(
seconds
+ ((minutes * DateUtils.MILLIS_PER_MINUTE)
+ (hours * DateUtils.MILLIS_PER_HOUR) + ((cal.get(Calendar.DAY_OF_YEAR) - 1) * DateUtils.MILLIS_PER_DAY))
+ (minutes * DateUtils.MILLIS_PER_MINUTE
+ hours * DateUtils.MILLIS_PER_HOUR + (cal.get(Calendar.DAY_OF_YEAR) - 1) * DateUtils.MILLIS_PER_DAY)
/ DateUtils.MILLIS_PER_SECOND,
testResult);
}

View File

@ -83,7 +83,7 @@ public class DurationFormatUtilsTest extends AbstractLangTest {
}
private DurationFormatUtils.Token createTokenWithCount(final Object value, final int count) {
DurationFormatUtils.Token token = new DurationFormatUtils.Token(value, false, -1);
final DurationFormatUtils.Token token = new DurationFormatUtils.Token(value, false, -1);
for (int i = 1; i < count; i++) {
token.increment();
}
@ -92,7 +92,7 @@ public class DurationFormatUtilsTest extends AbstractLangTest {
@Test
public void testAlternatingLiteralOptionals() {
String format = "['d'dH'h'][m'm']['s's]['ms'S]";
final String format = "['d'dH'h'][m'm']['s's]['ms'S]";
assertEquals("d1",
DurationFormatUtils.formatDuration(Duration.ofDays(1).toMillis(), format));

View File

@ -627,7 +627,7 @@ public class FastDateParserTest extends AbstractLangTest {
}
}
// SDF and FDF should produce equivalent results
assertEquals((f == null), (s == null), "Should both or neither throw Exceptions");
assertEquals(f == null, s == null, "Should both or neither throw Exceptions");
assertEquals(dsdf, dfdp, "Parsed dates should be equal");
}

View File

@ -116,7 +116,7 @@ public class FastDateParser_TimeZoneStrategyTest extends AbstractLangTest {
// An exception will be thrown and the test will fail if parsing isn't successful
try {
parser.parse(tzDisplay);
} catch (ParseException e) {
} catch (final ParseException e) {
// Hack Start
// See failures on GitHub Actions builds for Java 17.
final String localeStr = locale.toString();
@ -131,7 +131,8 @@ public class FastDateParser_TimeZoneStrategyTest extends AbstractLangTest {
localeStr, tzDisplay);
assumeTrue(false, localeStr);
continue;
} else if (SystemUtils.IS_JAVA_11
}
if (SystemUtils.IS_JAVA_11
&& (localeStr.contains("_") || "Coordinated Universal Time".equals(tzDisplay))) {
Java11Failures.add(locale);
// Mark as an assumption failure instead of a hard fail
@ -167,7 +168,7 @@ public class FastDateParser_TimeZoneStrategyTest extends AbstractLangTest {
final String displayName = timeZone.getDisplayName(locale);
try {
parser.parse(displayName);
} catch (ParseException e) {
} catch (final ParseException e) {
// Missing "Zulu" or something else in broken JDK's GH builds?
fail(String.format("%s: with locale = %s, id = '%s', timeZone = %s, displayName = '%s', parser = '%s'", e, locale, id, timeZone, displayName,
parser.toStringAll()), e);