This commit is contained in:
Jochen Wiedmann 2020-02-14 22:32:54 +01:00
commit ee87df8472
53 changed files with 326 additions and 305 deletions

View File

@ -1,5 +1,5 @@
Apache Commons Lang Apache Commons Lang
Copyright 2001-2019 The Apache Software Foundation Copyright 2001-2020 The Apache Software Foundation
This product includes software developed at This product includes software developed at
The Apache Software Foundation (http://www.apache.org/). The Apache Software Foundation (http://www.apache.org/).

View File

@ -516,13 +516,13 @@
<dependency> <dependency>
<groupId>org.junit.jupiter</groupId> <groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId> <artifactId>junit-jupiter</artifactId>
<version>5.5.2</version> <version>5.6.0</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.junit-pioneer</groupId> <groupId>org.junit-pioneer</groupId>
<artifactId>junit-pioneer</artifactId> <artifactId>junit-pioneer</artifactId>
<version>0.4.2</version> <version>0.5.3</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
@ -535,7 +535,7 @@
<dependency> <dependency>
<groupId>org.easymock</groupId> <groupId>org.easymock</groupId>
<artifactId>easymock</artifactId> <artifactId>easymock</artifactId>
<version>4.1</version> <version>4.2</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
@ -764,7 +764,7 @@
<dependency> <dependency>
<groupId>com.github.spotbugs</groupId> <groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs</artifactId> <artifactId>spotbugs</artifactId>
<version>4.0.0-beta4</version> <version>4.0.0-RC3</version>
</dependency> </dependency>
</dependencies> </dependencies>
<configuration> <configuration>

View File

@ -46,6 +46,7 @@ The <action> type attribute can be add,update,fix,remove.
<body> <body>
<release version="3.10" date="YYYY-MM-DD" description="New features and bug fixes. Requires Java 8, supports Java 9, 10, 11."> <release version="3.10" date="YYYY-MM-DD" description="New features and bug fixes. Requires Java 8, supports Java 9, 10, 11.">
<action issue="LANG-1514" type="fix" dev="kinow" due-to="contextshuffling">Make test more stable by wrapping assertions in hashset.</action>
<action issue="LANG-1450" type="fix" dev="chtompki">Generate Javadoc jar on build.</action> <action issue="LANG-1450" type="fix" dev="chtompki">Generate Javadoc jar on build.</action>
<action issue="LANG-1457" type="add" dev="ggregory">Add ExceptionUtils.throwableOfType(Throwable, Class) and friends.</action> <action issue="LANG-1457" type="add" dev="ggregory">Add ExceptionUtils.throwableOfType(Throwable, Class) and friends.</action>
<action issue="LANG-1458" type="add" dev="ggregory">Add EMPTY_ARRAY constants to classes in org.apache.commons.lang3.tuple.</action> <action issue="LANG-1458" type="add" dev="ggregory">Add EMPTY_ARRAY constants to classes in org.apache.commons.lang3.tuple.</action>
@ -96,6 +97,9 @@ The <action> type attribute can be add,update,fix,remove.
<action issue="LANG-1512" type="add" dev="ggregory" due-to="Gary Gregory">Add IS_JAVA_14 and IS_JAVA_15 to org.apache.commons.lang3.SystemUtils.</action> <action issue="LANG-1512" type="add" dev="ggregory" due-to="Gary Gregory">Add IS_JAVA_14 and IS_JAVA_15 to org.apache.commons.lang3.SystemUtils.</action>
<action issue="LANG-1513" type="add" dev="ggregory" due-to="Bernhard Bonigl, Gary Gregory">ObjectUtils: Get first non-null supplier value.</action> <action issue="LANG-1513" type="add" dev="ggregory" due-to="Bernhard Bonigl, Gary Gregory">ObjectUtils: Get first non-null supplier value.</action>
<action type="add" dev="jochen">Added the Streams class, and Functions.stream() as an accessor thereof.</action> <action type="add" dev="jochen">Added the Streams class, and Functions.stream() as an accessor thereof.</action>
<action type="update" dev="ggregory" due-to="Gary Gregory">org.easymock:easymock 4.1 -> 4.2.</action>
<action type="update" dev="ggregory" due-to="Gary Gregory">org.junit-pioneer:junit-pioneer 0.4.2 -> 0.5.3.</action>
<action type="update" dev="ggregory" due-to="Gary Gregory">org.junit.jupiter:junit-jupiter 5.5.2 -> 5.6.0.</action>
</release> </release>
<release version="3.9" date="2019-04-09" description="New features and bug fixes. Requires Java 8, supports Java 9, 10, 11."> <release version="3.9" date="2019-04-09" description="New features and bug fixes. Requires Java 8, supports Java 9, 10, 11.">

View File

@ -1727,7 +1727,7 @@ public static BitSet indexesOf(final boolean[] array, final boolean valueToFind)
* @since 3.10 * @since 3.10
*/ */
public static BitSet indexesOf(final boolean[] array, final boolean valueToFind, int startIndex) { public static BitSet indexesOf(final boolean[] array, final boolean valueToFind, int startIndex) {
BitSet bitSet = new BitSet(); final BitSet bitSet = new BitSet();
if (array == null) { if (array == null) {
return bitSet; return bitSet;
@ -1778,7 +1778,7 @@ public static BitSet indexesOf(final byte[] array, final byte valueToFind) {
* @since 3.10 * @since 3.10
*/ */
public static BitSet indexesOf(final byte[] array, final byte valueToFind, int startIndex) { public static BitSet indexesOf(final byte[] array, final byte valueToFind, int startIndex) {
BitSet bitSet = new BitSet(); final BitSet bitSet = new BitSet();
if (array == null) { if (array == null) {
return bitSet; return bitSet;
@ -1829,7 +1829,7 @@ public static BitSet indexesOf(final char[] array, final char valueToFind) {
* @since 3.10 * @since 3.10
*/ */
public static BitSet indexesOf(final char[] array, final char valueToFind, int startIndex) { public static BitSet indexesOf(final char[] array, final char valueToFind, int startIndex) {
BitSet bitSet = new BitSet(); final BitSet bitSet = new BitSet();
if (array == null) { if (array == null) {
return bitSet; return bitSet;
@ -1901,7 +1901,7 @@ public static BitSet indexesOf(final double[] array, final double valueToFind, f
* @since 3.10 * @since 3.10
*/ */
public static BitSet indexesOf(final double[] array, final double valueToFind, int startIndex) { public static BitSet indexesOf(final double[] array, final double valueToFind, int startIndex) {
BitSet bitSet = new BitSet(); final BitSet bitSet = new BitSet();
if (array == null) { if (array == null) {
return bitSet; return bitSet;
@ -1943,7 +1943,7 @@ public static BitSet indexesOf(final double[] array, final double valueToFind, i
* @since 3.10 * @since 3.10
*/ */
public static BitSet indexesOf(final double[] array, final double valueToFind, int startIndex, final double tolerance) { public static BitSet indexesOf(final double[] array, final double valueToFind, int startIndex, final double tolerance) {
BitSet bitSet = new BitSet(); final BitSet bitSet = new BitSet();
if (array == null) { if (array == null) {
return bitSet; return bitSet;
@ -1994,7 +1994,7 @@ public static BitSet indexesOf(final float[] array, final float valueToFind) {
* @since 3.10 * @since 3.10
*/ */
public static BitSet indexesOf(final float[] array, final float valueToFind, int startIndex) { public static BitSet indexesOf(final float[] array, final float valueToFind, int startIndex) {
BitSet bitSet = new BitSet(); final BitSet bitSet = new BitSet();
if (array == null) { if (array == null) {
return bitSet; return bitSet;
@ -2045,7 +2045,7 @@ public static BitSet indexesOf(final int[] array, final int valueToFind) {
* @since 3.10 * @since 3.10
*/ */
public static BitSet indexesOf(final int[] array, final int valueToFind, int startIndex) { public static BitSet indexesOf(final int[] array, final int valueToFind, int startIndex) {
BitSet bitSet = new BitSet(); final BitSet bitSet = new BitSet();
if (array == null) { if (array == null) {
return bitSet; return bitSet;
@ -2096,7 +2096,7 @@ public static BitSet indexesOf(final long[] array, final long valueToFind) {
* @since 3.10 * @since 3.10
*/ */
public static BitSet indexesOf(final long[] array, final long valueToFind, int startIndex) { public static BitSet indexesOf(final long[] array, final long valueToFind, int startIndex) {
BitSet bitSet = new BitSet(); final BitSet bitSet = new BitSet();
if (array == null) { if (array == null) {
return bitSet; return bitSet;
@ -2147,7 +2147,7 @@ public static BitSet indexesOf(final Object[] array, final Object objectToFind)
* @since 3.10 * @since 3.10
*/ */
public static BitSet indexesOf(final Object[] array, final Object objectToFind, int startIndex) { public static BitSet indexesOf(final Object[] array, final Object objectToFind, int startIndex) {
BitSet bitSet = new BitSet(); final BitSet bitSet = new BitSet();
if (array == null) { if (array == null) {
return bitSet; return bitSet;
@ -2198,7 +2198,7 @@ public static BitSet indexesOf(final short[] array, final short valueToFind) {
* @since 3.10 * @since 3.10
*/ */
public static BitSet indexesOf(final short[] array, final short valueToFind, int startIndex) { public static BitSet indexesOf(final short[] array, final short valueToFind, int startIndex) {
BitSet bitSet = new BitSet(); final BitSet bitSet = new BitSet();
if (array == null) { if (array == null) {
return bitSet; return bitSet;
@ -3084,7 +3084,7 @@ public static <T> T[] insert(final int index, final T[] array, final T... values
* @return Whether the given index is safely-accessible in the given array * @return Whether the given index is safely-accessible in the given array
* @since 3.8 * @since 3.8
*/ */
public static <T> boolean isArrayIndexValid(T[] array, int index) { public static <T> boolean isArrayIndexValid(final T[] array, final int index) {
if (getLength(array) == 0 || array.length <= index) { if (getLength(array) == 0 || array.length <= index) {
return false; return false;
} }

View File

@ -271,7 +271,7 @@ private static class CharacterIterator implements Iterator<Character> {
private boolean hasNext; private boolean hasNext;
/** /**
* Construct a new iterator for the character range. * Constructs a new iterator for the character range.
* *
* @param r The character range * @param r The character range
*/ */
@ -296,7 +296,7 @@ private CharacterIterator(final CharRange r) {
} }
/** /**
* Prepare the next character in the range. * Prepares the next character in the range.
*/ */
private void prepareNext() { private void prepareNext() {
if (range.negated) { if (range.negated) {
@ -329,7 +329,7 @@ public boolean hasNext() {
} }
/** /**
* Return the next character in the iteration * Returns the next character in the iteration
* *
* @return {@code Character} for the next character * @return {@code Character} for the next character
*/ */
@ -346,7 +346,7 @@ public Character next() {
/** /**
* Always throws UnsupportedOperationException. * Always throws UnsupportedOperationException.
* *
* @throws UnsupportedOperationException * @throws UnsupportedOperationException Always thrown.
* @see java.util.Iterator#remove() * @see java.util.Iterator#remove()
*/ */
@Override @Override

View File

@ -50,7 +50,12 @@ public class ClassUtils {
* @since 3.2 * @since 3.2
*/ */
public enum Interfaces { public enum Interfaces {
INCLUDE, EXCLUDE
/** Includes interfaces. */
INCLUDE,
/** Excludes interfaces. */
EXCLUDE
} }
/** /**
@ -277,7 +282,7 @@ public static String getSimpleName(final Class<?> cls) {
* @since 3.0 * @since 3.0
* @see Class#getSimpleName() * @see Class#getSimpleName()
*/ */
public static String getSimpleName(final Class<?> cls, String valueIfNull) { public static String getSimpleName(final Class<?> cls, final String valueIfNull) {
return cls == null ? valueIfNull : cls.getSimpleName(); return cls == null ? valueIfNull : cls.getSimpleName();
} }
@ -598,7 +603,7 @@ public static List<Class<?>> getAllInterfaces(final Class<?> cls) {
} }
/** /**
* Get the interfaces for the specified class. * Gets the interfaces for the specified class.
* *
* @param cls the class to look up, may be {@code null} * @param cls the class to look up, may be {@code null}
* @param interfacesFound the {@code Set} of interfaces for the class * @param interfacesFound the {@code Set} of interfaces for the class
@ -1468,7 +1473,7 @@ private static String getCanonicalName(String className) {
} }
/** /**
* Get an {@link Iterable} that can iterate over a class hierarchy in ascending (subclass to superclass) order, * Gets an {@link Iterable} that can iterate over a class hierarchy in ascending (subclass to superclass) order,
* excluding interfaces. * excluding interfaces.
* *
* @param type the type to get the class hierarchy from * @param type the type to get the class hierarchy from
@ -1480,7 +1485,7 @@ public static Iterable<Class<?>> hierarchy(final Class<?> type) {
} }
/** /**
* Get an {@link Iterable} that can iterate over a class hierarchy in ascending (subclass to superclass) order. * Gets an {@link Iterable} that can iterate over a class hierarchy in ascending (subclass to superclass) order.
* *
* @param type the type to get the class hierarchy from * @param type the type to get the class hierarchy from
* @param interfacesBehavior switch indicating whether to include or exclude interfaces * @param interfacesBehavior switch indicating whether to include or exclude interfaces

View File

@ -162,7 +162,7 @@ public interface FailableSupplier<O, T extends Throwable> {
* @param pRunnable a {@code FailableRunnable} * @param pRunnable a {@code FailableRunnable}
* @return a standard {@code Runnable} * @return a standard {@code Runnable}
*/ */
public static Runnable asRunnable(FailableRunnable<?> pRunnable) { public static Runnable asRunnable(final FailableRunnable<?> pRunnable) {
return () -> run(pRunnable); return () -> run(pRunnable);
} }
@ -173,7 +173,7 @@ public static Runnable asRunnable(FailableRunnable<?> pRunnable) {
* @param pConsumer a {@code FailableConsumer} * @param pConsumer a {@code FailableConsumer}
* @return a standard {@code Consumer} * @return a standard {@code Consumer}
*/ */
public static <I> Consumer<I> asConsumer(FailableConsumer<I, ?> pConsumer) { public static <I> Consumer<I> asConsumer(final FailableConsumer<I, ?> pConsumer) {
return (pInput) -> accept(pConsumer, pInput); return (pInput) -> accept(pConsumer, pInput);
} }
@ -184,7 +184,7 @@ public static <I> Consumer<I> asConsumer(FailableConsumer<I, ?> pConsumer) {
* @param pCallable a {@code FailableCallable} * @param pCallable a {@code FailableCallable}
* @return a standard {@code Callable} * @return a standard {@code Callable}
*/ */
public static <O> Callable<O> asCallable(FailableCallable<O, ?> pCallable) { public static <O> Callable<O> asCallable(final FailableCallable<O, ?> pCallable) {
return () -> call(pCallable); return () -> call(pCallable);
} }
@ -196,7 +196,7 @@ public static <O> Callable<O> asCallable(FailableCallable<O, ?> pCallable) {
* @param pConsumer a failable {@code BiConsumer} * @param pConsumer a failable {@code BiConsumer}
* @return a standard {@code BiConsumer} * @return a standard {@code BiConsumer}
*/ */
public static <I1, I2> BiConsumer<I1, I2> asBiConsumer(FailableBiConsumer<I1, I2, ?> pConsumer) { public static <I1, I2> BiConsumer<I1, I2> asBiConsumer(final FailableBiConsumer<I1, I2, ?> pConsumer) {
return (pInput1, pInput2) -> accept(pConsumer, pInput1, pInput2); return (pInput1, pInput2) -> accept(pConsumer, pInput1, pInput2);
} }
@ -208,7 +208,7 @@ public static <I1, I2> BiConsumer<I1, I2> asBiConsumer(FailableBiConsumer<I1, I2
* @param pFunction a {code FailableFunction} * @param pFunction a {code FailableFunction}
* @return a standard {@code Function} * @return a standard {@code Function}
*/ */
public static <I, O> Function<I, O> asFunction(FailableFunction<I, O, ?> pFunction) { public static <I, O> Function<I, O> asFunction(final FailableFunction<I, O, ?> pFunction) {
return (pInput) -> apply(pFunction, pInput); return (pInput) -> apply(pFunction, pInput);
} }
@ -221,7 +221,7 @@ public static <I, O> Function<I, O> asFunction(FailableFunction<I, O, ?> pFuncti
* @param pFunction a {@code FailableBiFunction} * @param pFunction a {@code FailableBiFunction}
* @return a standard {@code BiFunction} * @return a standard {@code BiFunction}
*/ */
public static <I1, I2, O> BiFunction<I1, I2, O> asBiFunction(FailableBiFunction<I1, I2, O, ?> pFunction) { public static <I1, I2, O> BiFunction<I1, I2, O> asBiFunction(final FailableBiFunction<I1, I2, O, ?> pFunction) {
return (pInput1, pInput2) -> apply(pFunction, pInput1, pInput2); return (pInput1, pInput2) -> apply(pFunction, pInput1, pInput2);
} }
@ -232,7 +232,7 @@ public static <I1, I2, O> BiFunction<I1, I2, O> asBiFunction(FailableBiFunction<
* @param pPredicate a {@code FailablePredicate} * @param pPredicate a {@code FailablePredicate}
* @return a standard {@code Predicate} * @return a standard {@code Predicate}
*/ */
public static <I> Predicate<I> asPredicate(FailablePredicate<I, ?> pPredicate) { public static <I> Predicate<I> asPredicate(final FailablePredicate<I, ?> pPredicate) {
return (pInput) -> test(pPredicate, pInput); return (pInput) -> test(pPredicate, pInput);
} }
@ -244,7 +244,7 @@ public static <I> Predicate<I> asPredicate(FailablePredicate<I, ?> pPredicate) {
* @param pPredicate a {@code FailableBiPredicate} * @param pPredicate a {@code FailableBiPredicate}
* @return a standard {@code BiPredicate} * @return a standard {@code BiPredicate}
*/ */
public static <I1, I2> BiPredicate<I1, I2> asBiPredicate(FailableBiPredicate<I1, I2, ?> pPredicate) { public static <I1, I2> BiPredicate<I1, I2> asBiPredicate(final FailableBiPredicate<I1, I2, ?> pPredicate) {
return (pInput1, pInput2) -> test(pPredicate, pInput1, pInput2); return (pInput1, pInput2) -> test(pPredicate, pInput1, pInput2);
} }
@ -255,7 +255,7 @@ public static <I1, I2> BiPredicate<I1, I2> asBiPredicate(FailableBiPredicate<I1,
* @param pSupplier a {@code FailableSupplier} * @param pSupplier a {@code FailableSupplier}
* @return a standard {@code Supplier} * @return a standard {@code Supplier}
*/ */
public static <O> Supplier<O> asSupplier(FailableSupplier<O, ?> pSupplier) { public static <O> Supplier<O> asSupplier(final FailableSupplier<O, ?> pSupplier) {
return () -> get(pSupplier); return () -> get(pSupplier);
} }
@ -264,10 +264,10 @@ public static <O> Supplier<O> asSupplier(FailableSupplier<O, ?> pSupplier) {
* @param pRunnable The runnable to run * @param pRunnable The runnable to run
* @param <T> the type of checked exception the runnable may throw * @param <T> the type of checked exception the runnable may throw
*/ */
public static <T extends Throwable> void run(FailableRunnable<T> pRunnable) { public static <T extends Throwable> void run(final FailableRunnable<T> pRunnable) {
try { try {
pRunnable.run(); pRunnable.run();
} catch (Throwable t) { } catch (final Throwable t) {
throw rethrow(t); throw rethrow(t);
} }
} }
@ -279,10 +279,10 @@ public static <T extends Throwable> void run(FailableRunnable<T> pRunnable) {
* @param <T> the type of checked exception the callable may throw * @param <T> the type of checked exception the callable may throw
* @return the value returned from the callable * @return the value returned from the callable
*/ */
public static <O, T extends Throwable> O call(FailableCallable<O, T> pCallable) { public static <O, T extends Throwable> O call(final FailableCallable<O, T> pCallable) {
try { try {
return pCallable.call(); return pCallable.call();
} catch (Throwable t) { } catch (final Throwable t) {
throw rethrow(t); throw rethrow(t);
} }
} }
@ -294,10 +294,10 @@ public static <O, T extends Throwable> O call(FailableCallable<O, T> pCallable)
* @param <O> the type the consumer accepts * @param <O> the type the consumer accepts
* @param <T> the type of checked exception the consumer may throw * @param <T> the type of checked exception the consumer may throw
*/ */
public static <O, T extends Throwable> void accept(FailableConsumer<O, T> pConsumer, O pObject) { public static <O, T extends Throwable> void accept(final FailableConsumer<O, T> pConsumer, final O pObject) {
try { try {
pConsumer.accept(pObject); pConsumer.accept(pObject);
} catch (Throwable t) { } catch (final Throwable t) {
throw rethrow(t); throw rethrow(t);
} }
} }
@ -311,10 +311,10 @@ public static <O, T extends Throwable> void accept(FailableConsumer<O, T> pConsu
* @param <O2> the type of the second argument the consumer accepts * @param <O2> the type of the second argument the consumer accepts
* @param <T> the type of checked exception the consumer may throw * @param <T> the type of checked exception the consumer may throw
*/ */
public static <O1, O2, T extends Throwable> void accept(FailableBiConsumer<O1, O2, T> pConsumer, O1 pObject1, O2 pObject2) { public static <O1, O2, T extends Throwable> void accept(final FailableBiConsumer<O1, O2, T> pConsumer, final O1 pObject1, final O2 pObject2) {
try { try {
pConsumer.accept(pObject1, pObject2); pConsumer.accept(pObject1, pObject2);
} catch (Throwable t) { } catch (final Throwable t) {
throw rethrow(t); throw rethrow(t);
} }
} }
@ -328,10 +328,10 @@ public static <O1, O2, T extends Throwable> void accept(FailableBiConsumer<O1, O
* @param <T> the type of checked exception the function may throw * @param <T> the type of checked exception the function may throw
* @return the value returned from the function * @return the value returned from the function
*/ */
public static <I, O, T extends Throwable> O apply(FailableFunction<I, O, T> pFunction, I pInput) { public static <I, O, T extends Throwable> O apply(final FailableFunction<I, O, T> pFunction, final I pInput) {
try { try {
return pFunction.apply(pInput); return pFunction.apply(pInput);
} catch (Throwable t) { } catch (final Throwable t) {
throw rethrow(t); throw rethrow(t);
} }
} }
@ -347,10 +347,10 @@ public static <I, O, T extends Throwable> O apply(FailableFunction<I, O, T> pFun
* @param <T> the type of checked exception the function may throw * @param <T> the type of checked exception the function may throw
* @return the value returned from the function * @return the value returned from the function
*/ */
public static <I1, I2, O, T extends Throwable> O apply(FailableBiFunction<I1, I2, O, T> pFunction, I1 pInput1, I2 pInput2) { public static <I1, I2, O, T extends Throwable> O apply(final FailableBiFunction<I1, I2, O, T> pFunction, final I1 pInput1, final I2 pInput2) {
try { try {
return pFunction.apply(pInput1, pInput2); return pFunction.apply(pInput1, pInput2);
} catch (Throwable t) { } catch (final Throwable t) {
throw rethrow(t); throw rethrow(t);
} }
} }
@ -363,10 +363,10 @@ public static <I1, I2, O, T extends Throwable> O apply(FailableBiFunction<I1, I2
* @param <T> the type of checked exception the predicate may throw * @param <T> the type of checked exception the predicate may throw
* @return the boolean value returned by the predicate * @return the boolean value returned by the predicate
*/ */
public static <O, T extends Throwable> boolean test(FailablePredicate<O, T> pPredicate, O pObject) { public static <O, T extends Throwable> boolean test(final FailablePredicate<O, T> pPredicate, final O pObject) {
try { try {
return pPredicate.test(pObject); return pPredicate.test(pObject);
} catch (Throwable t) { } catch (final Throwable t) {
throw rethrow(t); throw rethrow(t);
} }
} }
@ -381,10 +381,10 @@ public static <O, T extends Throwable> boolean test(FailablePredicate<O, T> pPre
* @param <T> the type of checked exception the predicate may throw * @param <T> the type of checked exception the predicate may throw
* @return the boolean value returned by the predicate * @return the boolean value returned by the predicate
*/ */
public static <O1, O2, T extends Throwable> boolean test(FailableBiPredicate<O1, O2, T> pPredicate, O1 pObject1, O2 pObject2) { public static <O1, O2, T extends Throwable> boolean test(final FailableBiPredicate<O1, O2, T> pPredicate, final O1 pObject1, final O2 pObject2) {
try { try {
return pPredicate.test(pObject1, pObject2); return pPredicate.test(pObject1, pObject2);
} catch (Throwable t) { } catch (final Throwable t) {
throw rethrow(t); throw rethrow(t);
} }
} }
@ -396,10 +396,10 @@ public static <O1, O2, T extends Throwable> boolean test(FailableBiPredicate<O1,
* @param <T> The type of checked exception, which the supplier can throw. * @param <T> The type of checked exception, which the supplier can throw.
* @return The object, which has been created by the supplier * @return The object, which has been created by the supplier
*/ */
public static <O, T extends Throwable> O get(FailableSupplier<O, T> pSupplier) { public static <O, T extends Throwable> O get(final FailableSupplier<O, T> pSupplier) {
try { try {
return pSupplier.get(); return pSupplier.get();
} catch (Throwable t) { } catch (final Throwable t) {
throw rethrow(t); throw rethrow(t);
} }
} }
@ -416,8 +416,8 @@ public static <O, T extends Throwable> O get(FailableSupplier<O, T> pSupplier) {
* @param <O> The streams element type. * @param <O> The streams element type.
* @return The created {@link FailableStream}. * @return The created {@link FailableStream}.
*/ */
public static <O> FailableStream<O> stream(Stream<O> pStream) { public static <O> FailableStream<O> stream(final Stream<O> pStream) {
return new FailableStream<O>(pStream); return new FailableStream<>(pStream);
} }
/** /**
@ -433,8 +433,8 @@ public static <O> FailableStream<O> stream(Stream<O> pStream) {
* streams element type.) * streams element type.)
* @return The created {@link FailableStream}. * @return The created {@link FailableStream}.
*/ */
public static <O> FailableStream<O> stream(Collection<O> pCollection) { public static <O> FailableStream<O> stream(final Collection<O> pCollection) {
return new FailableStream<O>(pCollection.stream()); return new FailableStream<>(pCollection.stream());
} }
@ -461,9 +461,9 @@ public static <O> FailableStream<O> stream(Collection<O> pCollection) {
* @see #tryWithResources(FailableRunnable, FailableRunnable...) * @see #tryWithResources(FailableRunnable, FailableRunnable...)
*/ */
@SafeVarargs @SafeVarargs
public static void tryWithResources(FailableRunnable<? extends Throwable> pAction, public static void tryWithResources(final FailableRunnable<? extends Throwable> pAction,
FailableConsumer<Throwable, ? extends Throwable> pErrorHandler, final FailableConsumer<Throwable, ? extends Throwable> pErrorHandler,
FailableRunnable<? extends Throwable>... pResources) { final FailableRunnable<? extends Throwable>... pResources) {
final FailableConsumer<Throwable, ? extends Throwable> errorHandler; final FailableConsumer<Throwable, ? extends Throwable> errorHandler;
if (pErrorHandler == null) { if (pErrorHandler == null) {
errorHandler = (t) -> rethrow(t); errorHandler = (t) -> rethrow(t);
@ -471,21 +471,21 @@ public static void tryWithResources(FailableRunnable<? extends Throwable> pActio
errorHandler = pErrorHandler; errorHandler = pErrorHandler;
} }
if (pResources != null) { if (pResources != null) {
for (FailableRunnable<? extends Throwable> failableRunnable : pResources) { for (final FailableRunnable<? extends Throwable> failableRunnable : pResources) {
Objects.requireNonNull(failableRunnable, "runnable"); Objects.requireNonNull(failableRunnable, "runnable");
} }
} }
Throwable th = null; Throwable th = null;
try { try {
pAction.run(); pAction.run();
} catch (Throwable t) { } catch (final Throwable t) {
th = t; th = t;
} }
if (pResources != null) { if (pResources != null) {
for (FailableRunnable<? extends Object> runnable : pResources) { for (final FailableRunnable<? extends Object> runnable : pResources) {
try { try {
runnable.run(); runnable.run();
} catch (Throwable t) { } catch (final Throwable t) {
if (th == null) { if (th == null) {
th = t; th = t;
} }
@ -495,7 +495,7 @@ public static void tryWithResources(FailableRunnable<? extends Throwable> pActio
if (th != null) { if (th != null) {
try { try {
errorHandler.accept(th); errorHandler.accept(th);
} catch (Throwable t) { } catch (final Throwable t) {
throw rethrow(t); throw rethrow(t);
} }
} }
@ -521,8 +521,8 @@ public static void tryWithResources(FailableRunnable<? extends Throwable> pActio
* @see #tryWithResources(FailableRunnable, FailableConsumer, FailableRunnable...) * @see #tryWithResources(FailableRunnable, FailableConsumer, FailableRunnable...)
*/ */
@SafeVarargs @SafeVarargs
public static void tryWithResources(FailableRunnable<? extends Throwable> pAction, public static void tryWithResources(final FailableRunnable<? extends Throwable> pAction,
FailableRunnable<? extends Throwable>... pResources) { final FailableRunnable<? extends Throwable>... pResources) {
tryWithResources(pAction, null, pResources); tryWithResources(pAction, null, pResources);
} }
@ -549,7 +549,7 @@ public static void tryWithResources(FailableRunnable<? extends Throwable> pActio
* @param pThrowable The throwable to rethrow possibly wrapped into an unchecked exception * @param pThrowable The throwable to rethrow possibly wrapped into an unchecked exception
* @return Never returns anything, this method never terminates normally. * @return Never returns anything, this method never terminates normally.
*/ */
public static RuntimeException rethrow(Throwable pThrowable) { public static RuntimeException rethrow(final Throwable pThrowable) {
Objects.requireNonNull(pThrowable, "pThrowable"); Objects.requireNonNull(pThrowable, "pThrowable");
if (pThrowable instanceof RuntimeException) { if (pThrowable instanceof RuntimeException) {
throw (RuntimeException) pThrowable; throw (RuntimeException) pThrowable;

View File

@ -238,7 +238,7 @@ public static <T> T getFirstNonNull(final Supplier<T>... suppliers) {
if (suppliers != null) { if (suppliers != null) {
for (final Supplier<T> supplier : suppliers) { for (final Supplier<T> supplier : suppliers) {
if (supplier != null) { if (supplier != null) {
T value = supplier.get(); final T value = supplier.get();
if (value != null) { if (value != null) {
return value; return value;
} }

View File

@ -37,10 +37,10 @@
import org.apache.commons.lang3.Functions.FailablePredicate; import org.apache.commons.lang3.Functions.FailablePredicate;
/** /**
* This class provides utility functions, and classes for working with the * Provides utility functions, and classes for working with the
* java.util.stream package, or more generally, with Java 8 lambdas. More * {@code java.util.stream} package, or more generally, with Java 8 lambdas. More
* specifically, it attempts to address the fact that lambdas are supposed * specifically, it attempts to address the fact that lambdas are supposed
* not to throw Exceptions, at least not checked Exceptions, aka instances * not to throw Exceptions, at least not checked Exceptions, AKA instances
* of {@link Exception}. This enforces the use of constructs like * of {@link Exception}. This enforces the use of constructs like
* <pre> * <pre>
* Consumer&lt;java.lang.reflect.Method&gt; consumer = (m) -&gt; { * Consumer&lt;java.lang.reflect.Method&gt; consumer = (m) -&gt; {
@ -58,20 +58,29 @@
* </pre> * </pre>
* Obviously, the second version is much more concise and the spirit of * Obviously, the second version is much more concise and the spirit of
* Lambda expressions is met better than in the first version. * Lambda expressions is met better than in the first version.
*
* @see Stream * @see Stream
* @see Functions * @see Functions
* @since 3.10
*/ */
public class Streams { public class Streams {
/** A reduced, and simplified version of a {@link Stream} with
* failable method signatures. /**
* @param <O> The streams element type. * A reduced, and simplified version of a {@link Stream} with
*/ * failable method signatures.
* @param <O> The streams element type.
*/
public static class FailableStream<O extends Object> { public static class FailableStream<O extends Object> {
private Stream<O> stream; private Stream<O> stream;
private boolean terminated; private boolean terminated;
public FailableStream(Stream<O> pStream) { /**
stream = pStream; * Constructs a new instance with the given {@code stream}.
* @param stream The stream.
*/
public FailableStream(final Stream<O> stream) {
this.stream = stream;
} }
protected void assertNotTerminated() { protected void assertNotTerminated() {
@ -91,13 +100,13 @@ protected void makeTerminated() {
* *
* <p>This is an intermediate operation. * <p>This is an intermediate operation.
* *
* @param pPredicate a non-interfering, stateless predicate to apply to each * @param predicate a non-interfering, stateless predicate to apply to each
* element to determine if it should be included. * element to determine if it should be included.
* @return the new stream * @return the new stream
*/ */
public FailableStream<O> filter(FailablePredicate<O, ?> pPredicate){ public FailableStream<O> filter(final FailablePredicate<O, ?> predicate){
assertNotTerminated(); assertNotTerminated();
stream = stream.filter(Functions.asPredicate(pPredicate)); stream = stream.filter(Functions.asPredicate(predicate));
return this; return this;
} }
@ -114,11 +123,11 @@ public FailableStream<O> filter(FailablePredicate<O, ?> pPredicate){
* library chooses. If the action accesses shared state, it is * library chooses. If the action accesses shared state, it is
* responsible for providing the required synchronization. * responsible for providing the required synchronization.
* *
* @param pAction a non-interfering action to perform on the elements * @param action a non-interfering action to perform on the elements
*/ */
public void forEach(FailableConsumer<O, ?> pAction) { public void forEach(final FailableConsumer<O, ?> action) {
makeTerminated(); makeTerminated();
stream().forEach(Functions.asConsumer(pAction)); stream().forEach(Functions.asConsumer(action));
} }
/** /**
@ -164,14 +173,14 @@ public void forEach(FailableConsumer<O, ?> pAction) {
* *
* @param <R> the type of the result * @param <R> the type of the result
* @param <A> the intermediate accumulation type of the {@code Collector} * @param <A> the intermediate accumulation type of the {@code Collector}
* @param pCollector the {@code Collector} describing the reduction * @param collector the {@code Collector} describing the reduction
* @return the result of the reduction * @return the result of the reduction
* @see #collect(Supplier, BiConsumer, BiConsumer) * @see #collect(Supplier, BiConsumer, BiConsumer)
* @see Collectors * @see Collectors
*/ */
public <A, R> R collect(Collector<? super O, A, R> pCollector) { public <A, R> R collect(final Collector<? super O, A, R> collector) {
makeTerminated(); makeTerminated();
return stream().collect(pCollector); return stream().collect(collector);
} }
/** /**
@ -209,19 +218,19 @@ public <A, R> R collect(Collector<? super O, A, R> pCollector) {
* *
* @param <R> type of the result * @param <R> type of the result
* @param <A> Type of the accumulator. * @param <A> Type of the accumulator.
* @param pSupplier a function that creates a new result container. For a * @param pupplier a function that creates a new result container. For a
* parallel execution, this function may be called * parallel execution, this function may be called
* multiple times and must return a fresh value each time. * multiple times and must return a fresh value each time.
* @param pAccumulator An associative, non-interfering, stateless function for * @param accumulator An associative, non-interfering, stateless function for
* incorporating an additional element into a result * incorporating an additional element into a result
* @param pCombiner An associative, non-interfering, stateless * @param combiner An associative, non-interfering, stateless
* function for combining two values, which must be compatible with the * function for combining two values, which must be compatible with the
* accumulator function * accumulator function
* @return The result of the reduction * @return The result of the reduction
*/ */
public <A, R> R collect(Supplier<R> pSupplier, BiConsumer<R, ? super O> pAccumulator, BiConsumer<R, R> pCombiner) { public <A, R> R collect(final Supplier<R> pupplier, final BiConsumer<R, ? super O> accumulator, final BiConsumer<R, R> combiner) {
makeTerminated(); makeTerminated();
return stream().collect(pSupplier, pAccumulator, pCombiner); return stream().collect(pupplier, accumulator, combiner);
} }
/** /**
@ -262,14 +271,14 @@ public <A, R> R collect(Supplier<R> pSupplier, BiConsumer<R, ? super O> pAccumul
* operations parallelize more gracefully, without needing additional * operations parallelize more gracefully, without needing additional
* synchronization and with greatly reduced risk of data races. * synchronization and with greatly reduced risk of data races.
* *
* @param pIdentity the identity value for the accumulating function * @param identity the identity value for the accumulating function
* @param pAccumulator an associative, non-interfering, stateless * @param accumulator an associative, non-interfering, stateless
* function for combining two values * function for combining two values
* @return the result of the reduction * @return the result of the reduction
*/ */
public O reduce(O pIdentity, BinaryOperator<O> pAccumulator) { public O reduce(final O identity, final BinaryOperator<O> accumulator) {
makeTerminated(); makeTerminated();
return stream().reduce(pIdentity, pAccumulator); return stream().reduce(identity, accumulator);
} }
/** /**
@ -279,12 +288,12 @@ public O reduce(O pIdentity, BinaryOperator<O> pAccumulator) {
* <p>This is an intermediate operation. * <p>This is an intermediate operation.
* *
* @param <R> The element type of the new stream * @param <R> The element type of the new stream
* @param pMapper A non-interfering, stateless function to apply to each element * @param mapper A non-interfering, stateless function to apply to each element
* @return the new stream * @return the new stream
*/ */
public <R> FailableStream<R> map(FailableFunction<O, R, ?> pMapper) { public <R> FailableStream<R> map(final FailableFunction<O, R, ?> mapper) {
assertNotTerminated(); assertNotTerminated();
return new FailableStream<R>(stream.map(Functions.asFunction(pMapper))); return new FailableStream<>(stream.map(Functions.asFunction(mapper)));
} }
/** /**
@ -309,14 +318,14 @@ public Stream<O> stream() {
* stream is empty, the quantification is said to be <em>vacuously * stream is empty, the quantification is said to be <em>vacuously
* satisfied</em> and is always {@code true} (regardless of P(x)). * satisfied</em> and is always {@code true} (regardless of P(x)).
* *
* @param pPredicate A non-interfering, stateless predicate to apply to * @param predicate A non-interfering, stateless predicate to apply to
* elements of this stream * elements of this stream
* @return {@code true} If either all elements of the stream match the * @return {@code true} If either all elements of the stream match the
* provided predicate or the stream is empty, otherwise {@code false}. * provided predicate or the stream is empty, otherwise {@code false}.
*/ */
public boolean allMatch(FailablePredicate<O, ?> pPredicate) { public boolean allMatch(final FailablePredicate<O, ?> predicate) {
assertNotTerminated(); assertNotTerminated();
return stream().allMatch(Functions.asPredicate(pPredicate)); return stream().allMatch(Functions.asPredicate(predicate));
} }
/** /**
@ -331,14 +340,14 @@ public boolean allMatch(FailablePredicate<O, ?> pPredicate) {
* This method evaluates the <em>existential quantification</em> of the * This method evaluates the <em>existential quantification</em> of the
* predicate over the elements of the stream (for some x P(x)). * predicate over the elements of the stream (for some x P(x)).
* *
* @param pPredicate A non-interfering, stateless predicate to apply to * @param predicate A non-interfering, stateless predicate to apply to
* elements of this stream * elements of this stream
* @return {@code true} if any elements of the stream match the provided * @return {@code true} if any elements of the stream match the provided
* predicate, otherwise {@code false} * predicate, otherwise {@code false}
*/ */
public boolean anyMatch(FailablePredicate<O, ?> pPredicate) { public boolean anyMatch(final FailablePredicate<O, ?> predicate) {
assertNotTerminated(); assertNotTerminated();
return stream().anyMatch(Functions.asPredicate(pPredicate)); return stream().anyMatch(Functions.asPredicate(predicate));
} }
} }
@ -376,12 +385,12 @@ public boolean anyMatch(FailablePredicate<O, ?> pPredicate) {
* concise, and readable, and meets the spirit of Lambdas better * concise, and readable, and meets the spirit of Lambdas better
* than the first version. * than the first version.
* @param <O> The streams element type. * @param <O> The streams element type.
* @param pStream The stream, which is being converted. * @param stream The stream, which is being converted.
* @return The {@link FailableStream}, which has been created by * @return The {@link FailableStream}, which has been created by
* converting the stream. * converting the stream.
*/ */
public static <O> FailableStream<O> stream(Stream<O> pStream) { public static <O> FailableStream<O> stream(final Stream<O> stream) {
return new FailableStream<O>(pStream); return new FailableStream<>(stream);
} }
/** /**
@ -418,12 +427,12 @@ public static <O> FailableStream<O> stream(Stream<O> pStream) {
* concise, and readable, and meets the spirit of Lambdas better * concise, and readable, and meets the spirit of Lambdas better
* than the first version. * than the first version.
* @param <O> The streams element type. * @param <O> The streams element type.
* @param pStream The stream, which is being converted. * @param stream The stream, which is being converted.
* @return The {@link FailableStream}, which has been created by * @return The {@link FailableStream}, which has been created by
* converting the stream. * converting the stream.
*/ */
public static <O> FailableStream<O> stream(Collection<O> pStream) { public static <O> FailableStream<O> stream(final Collection<O> stream) {
return stream(pStream.stream()); return stream(stream.stream());
} }
public static class ArrayCollector<O> implements Collector<O, List<O>, O[]> { public static class ArrayCollector<O> implements Collector<O, List<O>, O[]> {

View File

@ -535,7 +535,7 @@ public static String appendIfMissingIgnoreCase(final String str, final CharSeque
* @since 2.0 * @since 2.0
*/ */
public static String capitalize(final String str) { public static String capitalize(final String str) {
int strLen = length(str); final int strLen = length(str);
if (strLen == 0) { if (strLen == 0) {
return str; return str;
} }
@ -3546,7 +3546,7 @@ public static boolean isAsciiPrintable(final CharSequence cs) {
* @since 3.0 Changed signature from isBlank(String) to isBlank(CharSequence) * @since 3.0 Changed signature from isBlank(String) to isBlank(CharSequence)
*/ */
public static boolean isBlank(final CharSequence cs) { public static boolean isBlank(final CharSequence cs) {
int strLen = length(cs); final int strLen = length(cs);
if (strLen == 0) { if (strLen == 0) {
return true; return true;
} }
@ -8355,7 +8355,7 @@ public static String stripEnd(final String str, final String stripChars) {
* @return the stripped String, {@code null} if null String input * @return the stripped String, {@code null} if null String input
*/ */
public static String stripStart(final String str, final String stripChars) { public static String stripStart(final String str, final String stripChars) {
int strLen = length(str); final int strLen = length(str);
if (strLen == 0) { if (strLen == 0) {
return str; return str;
} }
@ -9203,7 +9203,7 @@ public static String truncate(final String str, final int offset, final int maxW
* @since 2.0 * @since 2.0
*/ */
public static String uncapitalize(final String str) { public static String uncapitalize(final String str) {
int strLen = length(str); final int strLen = length(str);
if (strLen == 0) { if (strLen == 0) {
return str; return str;
} }

View File

@ -36,7 +36,7 @@
public class ThreadUtils { public class ThreadUtils {
/** /**
* Return the active thread with the specified id if it belongs to the specified thread group. * Finds the active thread with the specified id if it belongs to the specified thread group.
* *
* @param threadId The thread id * @param threadId The thread id
* @param threadGroup The thread group * @param threadGroup The thread group
@ -59,7 +59,7 @@ public static Thread findThreadById(final long threadId, final ThreadGroup threa
} }
/** /**
* Return the active thread with the specified id if it belongs to a thread group with the specified group name. * Finds the active thread with the specified id if it belongs to a thread group with the specified group name.
* *
* @param threadId The thread id * @param threadId The thread id
* @param threadGroupName The thread group name * @param threadGroupName The thread group name
@ -82,7 +82,7 @@ public static Thread findThreadById(final long threadId, final String threadGrou
} }
/** /**
* Return active threads with the specified name if they belong to a specified thread group. * Finds active threads with the specified name if they belong to a specified thread group.
* *
* @param threadName The thread name * @param threadName The thread name
* @param threadGroup The thread group * @param threadGroup The thread group
@ -100,7 +100,7 @@ public static Collection<Thread> findThreadsByName(final String threadName, fina
} }
/** /**
* Return active threads with the specified name if they belong to a thread group with the specified group name. * Finds active threads with the specified name if they belong to a thread group with the specified group name.
* *
* @param threadName The thread name * @param threadName The thread name
* @param threadGroupName The thread group name * @param threadGroupName The thread group name
@ -132,7 +132,7 @@ public static Collection<Thread> findThreadsByName(final String threadName, fina
} }
/** /**
* Return active thread groups with the specified group name. * Finds active thread groups with the specified group name.
* *
* @param threadGroupName The thread group name * @param threadGroupName The thread group name
* @return the thread groups with the specified group name or an empty collection if no such thread group exists. The collection returned is always unmodifiable. * @return the thread groups with the specified group name or an empty collection if no such thread group exists. The collection returned is always unmodifiable.
@ -148,7 +148,7 @@ public static Collection<ThreadGroup> findThreadGroupsByName(final String thread
} }
/** /**
* Return all active thread groups excluding the system thread group (A thread group is active if it has been not destroyed). * Gets all active thread groups excluding the system thread group (A thread group is active if it has been not destroyed).
* *
* @return all thread groups excluding the system thread group. The collection returned is always unmodifiable. * @return all thread groups excluding the system thread group. The collection returned is always unmodifiable.
* @throws SecurityException * @throws SecurityException
@ -162,7 +162,7 @@ public static Collection<ThreadGroup> getAllThreadGroups() {
} }
/** /**
* Return the system thread group (sometimes also referred as "root thread group"). * Gets the system thread group (sometimes also referred as "root thread group").
* *
* @return the system thread group * @return the system thread group
* @throws SecurityException if the current thread cannot modify * @throws SecurityException if the current thread cannot modify
@ -177,7 +177,7 @@ public static ThreadGroup getSystemThreadGroup() {
} }
/** /**
* Return all active threads (A thread is active if it has been started and has not yet died). * Gets all active threads (A thread is active if it has been started and has not yet died).
* *
* @return all active threads. The collection returned is always unmodifiable. * @return all active threads. The collection returned is always unmodifiable.
* @throws SecurityException * @throws SecurityException
@ -191,7 +191,7 @@ public static Collection<Thread> getAllThreads() {
} }
/** /**
* Return active threads with the specified name. * Finds active threads with the specified name.
* *
* @param threadName The thread name * @param threadName The thread name
* @return The threads with the specified name or an empty collection if no such thread exists. The collection returned is always unmodifiable. * @return The threads with the specified name or an empty collection if no such thread exists. The collection returned is always unmodifiable.
@ -207,7 +207,7 @@ public static Collection<Thread> findThreadsByName(final String threadName) {
} }
/** /**
* Return the active thread with the specified id. * Finds the active thread with the specified id.
* *
* @param threadId The thread id * @param threadId The thread id
* @return The thread with the specified id or {@code null} if no such thread exists * @return The thread with the specified id or {@code null} if no such thread exists

View File

@ -267,7 +267,7 @@ public EqualsBuilder setTestRecursive(final boolean testRecursive) {
* @return EqualsBuilder - used to chain calls. * @return EqualsBuilder - used to chain calls.
* @since 3.8 * @since 3.8
*/ */
public EqualsBuilder setBypassReflectionClasses(List<Class<?>> bypassReflectionClasses) { public EqualsBuilder setBypassReflectionClasses(final List<Class<?>> bypassReflectionClasses) {
this.bypassReflectionClasses = bypassReflectionClasses; this.bypassReflectionClasses = bypassReflectionClasses;
return this; return this;
} }

View File

@ -959,7 +959,7 @@ public HashCodeBuilder appendSuper(final int superHashCode) {
/** /**
* <p> * <p>
* Return the computed {@code hashCode}. * Returns the computed {@code hashCode}.
* </p> * </p>
* *
* @return {@code hashCode} based on the fields appended * @return {@code hashCode} based on the fields appended

View File

@ -31,6 +31,8 @@ public class ComparableUtils {
/** /**
* Provides access to the available methods * Provides access to the available methods
*
* @param <A> the type of objects that this object may be compared against.
*/ */
public static class ComparableCheckBuilder<A extends Comparable<A>> { public static class ComparableCheckBuilder<A extends Comparable<A>> {

View File

@ -62,7 +62,7 @@ public abstract class AtomicSafeInitializer<T> implements
private final AtomicReference<T> reference = new AtomicReference<>(); private final AtomicReference<T> reference = new AtomicReference<>();
/** /**
* Get (and initialize, if not initialized yet) the required object * Gets (and initialize, if not initialized yet) the required object
* *
* @return lazily initialized object * @return lazily initialized object
* @throws ConcurrentException if the initialization of the object causes an * @throws ConcurrentException if the initialization of the object causes an

View File

@ -225,7 +225,7 @@ public void removeListener(final L listener) {
} }
/** /**
* Get an array containing the currently registered listeners. * Gets an array containing the currently registered listeners.
* Modification to this array's elements will have no effect on the * Modification to this array's elements will have no effect on the
* {@link EventListenerSupport} instance. * {@link EventListenerSupport} instance.
* @return L[] * @return L[]

View File

@ -785,7 +785,7 @@ private static int distance(final Class<?>[] classArray, final Class<?>[] toClas
} }
/** /**
* Get the hierarchy of overridden methods down to {@code result} respecting generics. * Gets the hierarchy of overridden methods down to {@code result} respecting generics.
* @param method lowest to consider * @param method lowest to consider
* @param interfacesBehavior whether to search interfaces, {@code null} {@code implies} false * @param interfacesBehavior whether to search interfaces, {@code null} {@code implies} false
* @return Set&lt;Method&gt; in ascending order from sub- to superclass * @return Set&lt;Method&gt; in ascending order from sub- to superclass

View File

@ -1338,7 +1338,7 @@ public static boolean isArrayType(final Type type) {
} }
/** /**
* Get the array component type of {@code type}. * Gets the array component type of {@code type}.
* @param type the type to be checked * @param type the type to be checked
* @return component type or null if type is not an array type * @return component type or null if type is not an array type
*/ */
@ -1354,7 +1354,7 @@ public static Type getArrayComponentType(final Type type) {
} }
/** /**
* Get a type representing {@code type} with variable assignments "unrolled." * Gets a type representing {@code type} with variable assignments "unrolled."
* *
* @param typeArguments as from {@link TypeUtils#getTypeArguments(Type, Class)} * @param typeArguments as from {@link TypeUtils#getTypeArguments(Type, Class)}
* @param type the type to unroll variable assignments for * @param type the type to unroll variable assignments for
@ -1540,7 +1540,7 @@ private static Type[] extractTypeArgumentsFrom(final Map<TypeVariable<?>, Type>
} }
/** /**
* Get a {@link WildcardTypeBuilder}. * Gets a {@link WildcardTypeBuilder}.
* @return {@link WildcardTypeBuilder} * @return {@link WildcardTypeBuilder}
* @since 3.2 * @since 3.2
*/ */

View File

@ -295,7 +295,7 @@ public int hashCode() {
} }
/** /**
* Get a custom format from a format description. * Gets a custom format from a format description.
* *
* @param desc String * @param desc String
* @return Format * @return Format

View File

@ -59,7 +59,7 @@ public FormattableUtils() {
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
/** /**
* Get the default formatted representation of the specified * Gets the default formatted representation of the specified
* {@code Formattable}. * {@code Formattable}.
* *
* @param formattable the instance to convert to a string, not null * @param formattable the instance to convert to a string, not null

View File

@ -1821,7 +1821,7 @@ public boolean hasNext() {
} }
/** /**
* Return the next calendar in the iteration * Returns the next calendar in the iteration
* *
* @return Object calendar for the next date * @return Object calendar for the next date
*/ */

View File

@ -451,7 +451,7 @@ private static StringBuilder simpleQuote(final StringBuilder sb, final String va
} }
/** /**
* Get the short and long values displayed for a field * Gets the short and long values displayed for a field
* @param cal The calendar to obtain the short and long values * @param cal The calendar to obtain the short and long values
* @param locale The locale of display names * @param locale The locale of display names
* @param field The field of interest * @param field The field of interest
@ -606,7 +606,7 @@ private Strategy getStrategy(final char f, final int width, final Calendar defin
private static final ConcurrentMap<Locale, Strategy>[] caches = new ConcurrentMap[Calendar.FIELD_COUNT]; private static final ConcurrentMap<Locale, Strategy>[] caches = new ConcurrentMap[Calendar.FIELD_COUNT];
/** /**
* Get a cache of Strategies for a particular field * Gets a cache of Strategies for a particular field
* @param field The Calendar field * @param field The Calendar field
* @return a cache of Locale to Strategy * @return a cache of Locale to Strategy
*/ */
@ -620,7 +620,7 @@ private static ConcurrentMap<Locale, Strategy> getCache(final int field) {
} }
/** /**
* Construct a Strategy that parses a Text field * Constructs a Strategy that parses a Text field
* @param field The Calendar field * @param field The Calendar field
* @param definingCalendar The calendar to obtain the short and long values * @param definingCalendar The calendar to obtain the short and long values
* @return a TextStrategy for the field and Locale * @return a TextStrategy for the field and Locale
@ -648,7 +648,7 @@ private static class CopyQuotedStrategy extends Strategy {
private final String formatField; private final String formatField;
/** /**
* Construct a Strategy that ensures the formatField has literal text * Constructs a Strategy that ensures the formatField has literal text
* @param formatField The literal text to match * @param formatField The literal text to match
*/ */
CopyQuotedStrategy(final String formatField) { CopyQuotedStrategy(final String formatField) {
@ -690,7 +690,7 @@ private static class CaseInsensitiveTextStrategy extends PatternStrategy {
private final Map<String, Integer> lKeyValues; private final Map<String, Integer> lKeyValues;
/** /**
* Construct a Strategy that parses a Text field * Constructs a Strategy that parses a Text field
* @param field The Calendar field * @param field The Calendar field
* @param definingCalendar The Calendar to use * @param definingCalendar The Calendar to use
* @param locale The Locale to use * @param locale The Locale to use
@ -730,7 +730,7 @@ private static class NumberStrategy extends Strategy {
private final int field; private final int field;
/** /**
* Construct a Strategy that parses a Number field * Constructs a Strategy that parses a Number field
* @param field The Calendar field * @param field The Calendar field
*/ */
NumberStrategy(final int field) { NumberStrategy(final int field) {
@ -833,7 +833,7 @@ private static class TzInfo {
private static final int ID = 0; private static final int ID = 0;
/** /**
* Construct a Strategy that parses a TimeZone * Constructs a Strategy that parses a TimeZone
* @param locale The Locale * @param locale The Locale
*/ */
TimeZoneStrategy(final Locale locale) { TimeZoneStrategy(final Locale locale) {
@ -912,7 +912,7 @@ private static class ISO8601TimeZoneStrategy extends PatternStrategy {
// Z, +hh, -hh, +hhmm, -hhmm, +hh:mm or -hh:mm // Z, +hh, -hh, +hhmm, -hhmm, +hh:mm or -hh:mm
/** /**
* Construct a Strategy that parses a TimeZone * Constructs a Strategy that parses a TimeZone
* @param pattern The Pattern * @param pattern The Pattern
*/ */
ISO8601TimeZoneStrategy(final String pattern) { ISO8601TimeZoneStrategy(final String pattern) {

View File

@ -55,7 +55,7 @@ public R getRight() {
} }
@Override @Override
public R setValue(R value) { public R setValue(final R value) {
return null; return null;
} }

View File

@ -98,7 +98,7 @@ public void testArch() {
@Test @Test
public void testArchLabels() { public void testArchLabels() {
for (Arch arch : Arch.values()) { for (final Arch arch : Arch.values()) {
// Only test label presence. // Only test label presence.
assertFalse(arch.getLabel().isEmpty()); assertFalse(arch.getLabel().isEmpty());
} }

View File

@ -3146,8 +3146,8 @@ public void testIndexOfWithStartIndex() {
@Test @Test
public void testIndexesOf() { public void testIndexesOf() {
final Object[] array = new Object[]{"0", "1", "2", "3", null, "0"}; final Object[] array = new Object[]{"0", "1", "2", "3", null, "0"};
BitSet emptySet = new BitSet(); final BitSet emptySet = new BitSet();
BitSet testSet = new BitSet(); final BitSet testSet = new BitSet();
assertEquals(emptySet, ArrayUtils.indexesOf((Object[]) null, null)); assertEquals(emptySet, ArrayUtils.indexesOf((Object[]) null, null));
assertEquals(emptySet, ArrayUtils.indexesOf(new Object[0], "0")); assertEquals(emptySet, ArrayUtils.indexesOf(new Object[0], "0"));
testSet.set(5); testSet.set(5);
@ -3168,8 +3168,8 @@ public void testIndexesOf() {
@Test @Test
public void testIndexesOfWithStartIndex() { public void testIndexesOfWithStartIndex() {
final Object[] array = new Object[]{"0", "1", "2", "3", "2", "3", "1", null, "0"}; final Object[] array = new Object[]{"0", "1", "2", "3", "2", "3", "1", null, "0"};
BitSet emptySet = new BitSet(); final BitSet emptySet = new BitSet();
BitSet testSet = new BitSet(); final BitSet testSet = new BitSet();
assertEquals(emptySet, ArrayUtils.indexesOf(null, null, 2)); assertEquals(emptySet, ArrayUtils.indexesOf(null, null, 2));
assertEquals(emptySet, ArrayUtils.indexesOf(new Object[0], "0", 0)); assertEquals(emptySet, ArrayUtils.indexesOf(new Object[0], "0", 0));
assertEquals(emptySet, ArrayUtils.indexesOf(null, "0", 2)); assertEquals(emptySet, ArrayUtils.indexesOf(null, "0", 2));
@ -3288,8 +3288,8 @@ public void testIndexOfLongWithStartIndex() {
@Test @Test
public void testIndexesOfLong() { public void testIndexesOfLong() {
final long[] array = new long[]{0, 1, 2, 3}; final long[] array = new long[]{0, 1, 2, 3};
BitSet emptySet = new BitSet(); final BitSet emptySet = new BitSet();
BitSet testSet = new BitSet(); final BitSet testSet = new BitSet();
assertEquals(emptySet, ArrayUtils.indexesOf((long[]) null, 0)); assertEquals(emptySet, ArrayUtils.indexesOf((long[]) null, 0));
assertEquals(emptySet, ArrayUtils.indexesOf(array, 4)); assertEquals(emptySet, ArrayUtils.indexesOf(array, 4));
testSet.set(0); testSet.set(0);
@ -3308,8 +3308,8 @@ public void testIndexesOfLong() {
@Test @Test
public void testIndexesOfLongWithStartIndex() { public void testIndexesOfLongWithStartIndex() {
final long[] array = new long[]{0, 1, 2, 3, 2, 1, 0, 1}; final long[] array = new long[]{0, 1, 2, 3, 2, 1, 0, 1};
BitSet emptySet = new BitSet(); final BitSet emptySet = new BitSet();
BitSet testSet = new BitSet(); final BitSet testSet = new BitSet();
assertEquals(emptySet, ArrayUtils.indexesOf((long[]) null, 0, 0)); assertEquals(emptySet, ArrayUtils.indexesOf((long[]) null, 0, 0));
assertEquals(emptySet, ArrayUtils.indexesOf(array, 4, 0)); assertEquals(emptySet, ArrayUtils.indexesOf(array, 4, 0));
testSet.set(6); testSet.set(6);
@ -3399,8 +3399,8 @@ public void testIndexOfIntWithStartIndex() {
@Test @Test
public void textIndexesOfInt() { public void textIndexesOfInt() {
int[] array = null; int[] array = null;
BitSet emptySet = new BitSet(); final BitSet emptySet = new BitSet();
BitSet testSet = new BitSet(); final BitSet testSet = new BitSet();
assertEquals(emptySet, ArrayUtils.indexesOf(array, 0)); assertEquals(emptySet, ArrayUtils.indexesOf(array, 0));
array = new int[]{0, 1, 2, 3, 0}; array = new int[]{0, 1, 2, 3, 0};
testSet.set(0); testSet.set(0);
@ -3421,8 +3421,8 @@ public void textIndexesOfInt() {
@Test @Test
public void testIndexesOfIntWithStartIndex() { public void testIndexesOfIntWithStartIndex() {
int[] array = null; int[] array = null;
BitSet emptySet = new BitSet(); final BitSet emptySet = new BitSet();
BitSet testSet = new BitSet(); final BitSet testSet = new BitSet();
assertEquals(emptySet, ArrayUtils.indexesOf(array, 0, 2)); assertEquals(emptySet, ArrayUtils.indexesOf(array, 0, 2));
array = new int[]{0, 1, 2, 3, 0}; array = new int[]{0, 1, 2, 3, 0};
testSet.set(4); testSet.set(4);
@ -3510,8 +3510,8 @@ public void testIndexOfShortWithStartIndex() {
@Test @Test
public void testIndexesOfShort() { public void testIndexesOfShort() {
short[] array = null; short[] array = null;
BitSet emptySet = new BitSet(); final BitSet emptySet = new BitSet();
BitSet testSet = new BitSet(); final BitSet testSet = new BitSet();
assertEquals(emptySet, ArrayUtils.indexesOf(array, (short) 0)); assertEquals(emptySet, ArrayUtils.indexesOf(array, (short) 0));
array = new short[]{0, 1, 2, 3, 0}; array = new short[]{0, 1, 2, 3, 0};
testSet.set(0); testSet.set(0);
@ -3532,8 +3532,8 @@ public void testIndexesOfShort() {
@Test @Test
public void testIndexesOfShortWithStartIndex() { public void testIndexesOfShortWithStartIndex() {
short[] array = null; short[] array = null;
BitSet emptySet = new BitSet(); final BitSet emptySet = new BitSet();
BitSet testSet = new BitSet(); final BitSet testSet = new BitSet();
assertEquals(emptySet, ArrayUtils.indexesOf(array, (short) 0, 2)); assertEquals(emptySet, ArrayUtils.indexesOf(array, (short) 0, 2));
array = new short[]{0, 1, 2, 3, 0}; array = new short[]{0, 1, 2, 3, 0};
testSet.set(4); testSet.set(4);
@ -3621,8 +3621,8 @@ public void testIndexOfCharWithStartIndex() {
@Test @Test
public void testIndexesOfChar() { public void testIndexesOfChar() {
char[] array = null; char[] array = null;
BitSet emptySet = new BitSet(); final BitSet emptySet = new BitSet();
BitSet testSet = new BitSet(); final BitSet testSet = new BitSet();
assertEquals(emptySet, ArrayUtils.indexesOf(array, 'a')); assertEquals(emptySet, ArrayUtils.indexesOf(array, 'a'));
array = new char[]{'a', 'b', 'c', 'd', 'a'}; array = new char[]{'a', 'b', 'c', 'd', 'a'};
testSet.set(0); testSet.set(0);
@ -3643,8 +3643,8 @@ public void testIndexesOfChar() {
@Test @Test
public void testIndexesOfCharWithStartIndex() { public void testIndexesOfCharWithStartIndex() {
char[] array = null; char[] array = null;
BitSet emptySet = new BitSet(); final BitSet emptySet = new BitSet();
BitSet testSet = new BitSet(); final BitSet testSet = new BitSet();
assertEquals(emptySet, ArrayUtils.indexesOf(array, 'a', 0)); assertEquals(emptySet, ArrayUtils.indexesOf(array, 'a', 0));
array = new char[]{'a', 'b', 'c', 'd', 'a'}; array = new char[]{'a', 'b', 'c', 'd', 'a'};
testSet.set(4); testSet.set(4);
@ -3733,8 +3733,8 @@ public void testIndexOfByteWithStartIndex() {
@Test @Test
public void testIndexesOfByte() { public void testIndexesOfByte() {
byte[] array = null; byte[] array = null;
BitSet emptySet = new BitSet(); final BitSet emptySet = new BitSet();
BitSet testSet = new BitSet(); final BitSet testSet = new BitSet();
assertEquals(emptySet, ArrayUtils.indexesOf(array, (byte) 0)); assertEquals(emptySet, ArrayUtils.indexesOf(array, (byte) 0));
array = new byte[]{0, 1, 2, 3, 0}; array = new byte[]{0, 1, 2, 3, 0};
testSet.set(0); testSet.set(0);
@ -3755,8 +3755,8 @@ public void testIndexesOfByte() {
@Test @Test
public void testIndexesOfByteWithStartIndex() { public void testIndexesOfByteWithStartIndex() {
byte[] array = null; byte[] array = null;
BitSet emptySet = new BitSet(); final BitSet emptySet = new BitSet();
BitSet testSet = new BitSet(); final BitSet testSet = new BitSet();
assertEquals(emptySet, ArrayUtils.indexesOf(array, (byte) 0, 2)); assertEquals(emptySet, ArrayUtils.indexesOf(array, (byte) 0, 2));
array = new byte[]{0, 1, 2, 3, 0}; array = new byte[]{0, 1, 2, 3, 0};
testSet.set(4); testSet.set(4);
@ -3883,8 +3883,8 @@ public void testIndexOfDoubleWithStartIndexTolerance() {
@Test @Test
public void testIndexesOfDouble() { public void testIndexesOfDouble() {
double[] array = null; double[] array = null;
BitSet emptySet = new BitSet(); final BitSet emptySet = new BitSet();
BitSet testSet = new BitSet(); final BitSet testSet = new BitSet();
assertEquals(emptySet, ArrayUtils.indexesOf(array, 0)); assertEquals(emptySet, ArrayUtils.indexesOf(array, 0));
array = new double[]{0, 1, 2, 3, 0}; array = new double[]{0, 1, 2, 3, 0};
testSet.set(0); testSet.set(0);
@ -3906,8 +3906,8 @@ public void testIndexesOfDouble() {
@Test @Test
public void testIndexesOfDoubleWithStartIndex() { public void testIndexesOfDoubleWithStartIndex() {
double[] array = null; double[] array = null;
BitSet emptySet = new BitSet(); final BitSet emptySet = new BitSet();
BitSet testSet = new BitSet(); final BitSet testSet = new BitSet();
assertEquals(emptySet, ArrayUtils.indexesOf(array, 0, 2)); assertEquals(emptySet, ArrayUtils.indexesOf(array, 0, 2));
array = new double[]{0, 1, 2, 3, 0}; array = new double[]{0, 1, 2, 3, 0};
testSet.set(4); testSet.set(4);
@ -3931,8 +3931,8 @@ public void testIndexesOfDoubleWithStartIndex() {
@Test @Test
public void testIndexesOfDoubleTolerance() { public void testIndexesOfDoubleTolerance() {
double[] array = null; double[] array = null;
BitSet emptySet = new BitSet(); final BitSet emptySet = new BitSet();
BitSet testSet = new BitSet(); final BitSet testSet = new BitSet();
assertEquals(emptySet, ArrayUtils.indexesOf(array, (double) 0, (double) 0)); assertEquals(emptySet, ArrayUtils.indexesOf(array, (double) 0, (double) 0));
array = new double[0]; array = new double[0];
assertEquals(emptySet, ArrayUtils.indexesOf(array, (double) 0, (double) 0)); assertEquals(emptySet, ArrayUtils.indexesOf(array, (double) 0, (double) 0));
@ -3952,8 +3952,8 @@ public void testIndexesOfDoubleTolerance() {
@Test @Test
public void testIndexesOfDoubleWithStartIndexTolerance() { public void testIndexesOfDoubleWithStartIndexTolerance() {
double[] array = null; double[] array = null;
BitSet emptySet = new BitSet(); final BitSet emptySet = new BitSet();
BitSet testSet = new BitSet(); final BitSet testSet = new BitSet();
assertEquals(emptySet, ArrayUtils.indexesOf(array, (double) 0, 0, (double) 0)); assertEquals(emptySet, ArrayUtils.indexesOf(array, (double) 0, 0, (double) 0));
array = new double[0]; array = new double[0];
assertEquals(emptySet, ArrayUtils.indexesOf(array, (double) 0, 0, (double) 0)); assertEquals(emptySet, ArrayUtils.indexesOf(array, (double) 0, 0, (double) 0));
@ -4102,8 +4102,8 @@ public void testIndexOfFloatWithStartIndex() {
@Test @Test
public void testIndexesOfFloat() { public void testIndexesOfFloat() {
float[] array = null; float[] array = null;
BitSet emptySet = new BitSet(); final BitSet emptySet = new BitSet();
BitSet testSet = new BitSet(); final BitSet testSet = new BitSet();
assertEquals(emptySet, ArrayUtils.indexesOf(array, 0)); assertEquals(emptySet, ArrayUtils.indexesOf(array, 0));
array = new float[]{0, 1, 2, 3, 0}; array = new float[]{0, 1, 2, 3, 0};
testSet.set(0); testSet.set(0);
@ -4125,8 +4125,8 @@ public void testIndexesOfFloat() {
@Test @Test
public void testIndexesOfFloatWithStartIndex() { public void testIndexesOfFloatWithStartIndex() {
float[] array = null; float[] array = null;
BitSet emptySet = new BitSet(); final BitSet emptySet = new BitSet();
BitSet testSet = new BitSet(); final BitSet testSet = new BitSet();
assertEquals(emptySet, ArrayUtils.indexesOf(array, 0, 2)); assertEquals(emptySet, ArrayUtils.indexesOf(array, 0, 2));
array = new float[]{0, 1, 2, 3, 0}; array = new float[]{0, 1, 2, 3, 0};
testSet.set(4); testSet.set(4);
@ -4224,8 +4224,8 @@ public void testIndexOfBooleanWithStartIndex() {
@Test @Test
public void testIndexesOfBoolean() { public void testIndexesOfBoolean() {
boolean[] array = null; boolean[] array = null;
BitSet emptySet = new BitSet(); final BitSet emptySet = new BitSet();
BitSet testSet = new BitSet(); final BitSet testSet = new BitSet();
assertEquals(emptySet, ArrayUtils.indexesOf(array, true)); assertEquals(emptySet, ArrayUtils.indexesOf(array, true));
array = new boolean[0]; array = new boolean[0];
assertEquals(emptySet, ArrayUtils.indexesOf(array, true)); assertEquals(emptySet, ArrayUtils.indexesOf(array, true));
@ -4243,8 +4243,8 @@ public void testIndexesOfBoolean() {
@Test @Test
public void testIndexesOfBooleanWithStartIndex() { public void testIndexesOfBooleanWithStartIndex() {
boolean[] array = null; boolean[] array = null;
BitSet emptySet = new BitSet(); final BitSet emptySet = new BitSet();
BitSet testSet = new BitSet(); final BitSet testSet = new BitSet();
assertEquals(emptySet, ArrayUtils.indexesOf(array, true, 0)); assertEquals(emptySet, ArrayUtils.indexesOf(array, true, 0));
array = new boolean[0]; array = new boolean[0];
assertEquals(emptySet, ArrayUtils.indexesOf(array, true, 0)); assertEquals(emptySet, ArrayUtils.indexesOf(array, true, 0));
@ -5160,7 +5160,7 @@ public void testShuffleDouble() {
@Test @Test
public void testIsArrayIndexValid() { public void testIsArrayIndexValid() {
assertFalse(ArrayUtils.isArrayIndexValid(null, 0)); assertFalse(ArrayUtils.isArrayIndexValid(null, 0));
String[] array = new String[1]; final String[] array = new String[1];
//too big //too big
assertFalse(ArrayUtils.isArrayIndexValid(array, 1)); assertFalse(ArrayUtils.isArrayIndexValid(array, 1));

View File

@ -311,7 +311,7 @@ public void testContains_Charrange() {
@Test @Test
public void testContainsNullArg() { public void testContainsNullArg() {
final CharRange range = CharRange.is('a'); final CharRange range = CharRange.is('a');
IllegalArgumentException e = assertThrows(IllegalArgumentException.class, () -> range.contains(null)); final IllegalArgumentException e = assertThrows(IllegalArgumentException.class, () -> range.contains(null));
assertEquals("The Range must not be null", e.getMessage()); assertEquals("The Range must not be null", e.getMessage());
} }

View File

@ -49,11 +49,11 @@ public static class SomeException extends Exception {
private Throwable t; private Throwable t;
SomeException(String pMsg) { SomeException(final String pMsg) {
super(pMsg); super(pMsg);
} }
public void setThrowable(Throwable pThrowable) { public void setThrowable(final Throwable pThrowable) {
t = pThrowable; t = pThrowable;
} }
@ -66,11 +66,11 @@ public void test() throws Throwable {
public static class Testable { public static class Testable {
private Throwable t; private Throwable t;
Testable(Throwable pTh) { Testable(final Throwable pTh) {
t = pTh; t = pTh;
} }
public void setThrowable(Throwable pThrowable) { public void setThrowable(final Throwable pThrowable) {
t = pThrowable; t = pThrowable;
} }
@ -78,7 +78,7 @@ public void test() throws Throwable {
test(t); test(t);
} }
public void test(Throwable pThrowable) throws Throwable { public void test(final Throwable pThrowable) throws Throwable {
if (pThrowable != null) { if (pThrowable != null) {
throw pThrowable; throw pThrowable;
} }
@ -88,7 +88,7 @@ public Integer testInt() throws Throwable {
return testInt(t); return testInt(t);
} }
public Integer testInt(Throwable pThrowable) throws Throwable { public Integer testInt(final Throwable pThrowable) throws Throwable {
if (pThrowable != null) { if (pThrowable != null) {
throw pThrowable; throw pThrowable;
} }
@ -117,7 +117,7 @@ static boolean failingBool() throws SomeException {
public static class CloseableObject { public static class CloseableObject {
private boolean closed; private boolean closed;
public void run(Throwable pTh) throws Throwable { public void run(final Throwable pTh) throws Throwable {
if (pTh != null) { if (pTh != null) {
throw pTh; throw pTh;
} }
@ -139,7 +139,7 @@ public boolean isClosed() {
@Test @Test
void testRunnable() { void testRunnable() {
FailureOnOddInvocations.invocation = 0; FailureOnOddInvocations.invocation = 0;
UndeclaredThrowableException e = assertThrows(UndeclaredThrowableException.class, () -> Functions.run(FailureOnOddInvocations::new)); final UndeclaredThrowableException e = assertThrows(UndeclaredThrowableException.class, () -> Functions.run(FailureOnOddInvocations::new));
final Throwable cause = e.getCause(); final Throwable cause = e.getCause();
assertNotNull(cause); assertNotNull(cause);
assertTrue(cause instanceof SomeException); assertTrue(cause instanceof SomeException);
@ -152,8 +152,8 @@ void testRunnable() {
@Test @Test
void testAsRunnable() { void testAsRunnable() {
FailureOnOddInvocations.invocation = 0; FailureOnOddInvocations.invocation = 0;
Runnable runnable = Functions.asRunnable(() -> new FailureOnOddInvocations()); final Runnable runnable = Functions.asRunnable(() -> new FailureOnOddInvocations());
UndeclaredThrowableException e = assertThrows(UndeclaredThrowableException.class, () -> runnable.run()); final UndeclaredThrowableException e = assertThrows(UndeclaredThrowableException.class, () -> runnable.run());
final Throwable cause = e.getCause(); final Throwable cause = e.getCause();
assertNotNull(cause); assertNotNull(cause);
assertTrue(cause instanceof SomeException); assertTrue(cause instanceof SomeException);
@ -166,7 +166,7 @@ void testAsRunnable() {
@Test @Test
void testCallable() { void testCallable() {
FailureOnOddInvocations.invocation = 0; FailureOnOddInvocations.invocation = 0;
UndeclaredThrowableException e = assertThrows(UndeclaredThrowableException.class, () -> Functions.run(FailureOnOddInvocations::new)); final UndeclaredThrowableException e = assertThrows(UndeclaredThrowableException.class, () -> Functions.run(FailureOnOddInvocations::new));
final Throwable cause = e.getCause(); final Throwable cause = e.getCause();
assertNotNull(cause); assertNotNull(cause);
assertTrue(cause instanceof SomeException); assertTrue(cause instanceof SomeException);
@ -182,7 +182,7 @@ void testAsCallable() {
return new FailureOnOddInvocations(); return new FailureOnOddInvocations();
}; };
final Callable<FailureOnOddInvocations> callable = Functions.asCallable(failableCallable); final Callable<FailureOnOddInvocations> callable = Functions.asCallable(failableCallable);
UndeclaredThrowableException e = assertThrows(UndeclaredThrowableException.class, () -> callable.call()); final UndeclaredThrowableException e = assertThrows(UndeclaredThrowableException.class, () -> callable.call());
final Throwable cause = e.getCause(); final Throwable cause = e.getCause();
assertNotNull(cause); assertNotNull(cause);
assertTrue(cause instanceof SomeException); assertTrue(cause instanceof SomeException);
@ -190,7 +190,7 @@ void testAsCallable() {
final FailureOnOddInvocations instance; final FailureOnOddInvocations instance;
try { try {
instance = callable.call(); instance = callable.call();
} catch (Exception ex) { } catch (final Exception ex) {
throw Functions.rethrow(ex); throw Functions.rethrow(ex);
} }
assertNotNull(instance); assertNotNull(instance);
@ -394,7 +394,7 @@ public void testAsBiFunction() {
@Test @Test
public void testGetFromSupplier() { public void testGetFromSupplier() {
FailureOnOddInvocations.invocation = 0; FailureOnOddInvocations.invocation = 0;
UndeclaredThrowableException e = assertThrows(UndeclaredThrowableException.class, () -> Functions.run(FailureOnOddInvocations::new)); final UndeclaredThrowableException e = assertThrows(UndeclaredThrowableException.class, () -> Functions.run(FailureOnOddInvocations::new));
final Throwable cause = e.getCause(); final Throwable cause = e.getCause();
assertNotNull(cause); assertNotNull(cause);
assertTrue(cause instanceof SomeException); assertTrue(cause instanceof SomeException);
@ -409,7 +409,7 @@ public void testAsPredicate() {
FailureOnOddInvocations.invocation = 0; FailureOnOddInvocations.invocation = 0;
final Functions.FailablePredicate<Object, Throwable> failablePredicate = (t) -> FailureOnOddInvocations.failingBool(); final Functions.FailablePredicate<Object, Throwable> failablePredicate = (t) -> FailureOnOddInvocations.failingBool();
final Predicate<?> predicate = Functions.asPredicate(failablePredicate); final Predicate<?> predicate = Functions.asPredicate(failablePredicate);
UndeclaredThrowableException e = assertThrows(UndeclaredThrowableException.class, () -> predicate.test(null)); final UndeclaredThrowableException e = assertThrows(UndeclaredThrowableException.class, () -> predicate.test(null));
final Throwable cause = e.getCause(); final Throwable cause = e.getCause();
assertNotNull(cause); assertNotNull(cause);
assertTrue(cause instanceof SomeException); assertTrue(cause instanceof SomeException);
@ -424,7 +424,7 @@ public void testAsBiPredicate() {
FailureOnOddInvocations.invocation = 0; FailureOnOddInvocations.invocation = 0;
final Functions.FailableBiPredicate<Object, Object, Throwable> failableBiPredicate = (t1, t2) -> FailureOnOddInvocations.failingBool(); final Functions.FailableBiPredicate<Object, Object, Throwable> failableBiPredicate = (t1, t2) -> FailureOnOddInvocations.failingBool();
final BiPredicate<?, ?> predicate = Functions.asBiPredicate(failableBiPredicate); final BiPredicate<?, ?> predicate = Functions.asBiPredicate(failableBiPredicate);
UndeclaredThrowableException e = assertThrows(UndeclaredThrowableException.class, () -> predicate.test(null, null)); final UndeclaredThrowableException e = assertThrows(UndeclaredThrowableException.class, () -> predicate.test(null, null));
final Throwable cause = e.getCause(); final Throwable cause = e.getCause();
assertNotNull(cause); assertNotNull(cause);
assertTrue(cause instanceof SomeException); assertTrue(cause instanceof SomeException);
@ -438,7 +438,7 @@ public void testAsSupplier() {
FailureOnOddInvocations.invocation = 0; FailureOnOddInvocations.invocation = 0;
final FailableSupplier<FailureOnOddInvocations, Throwable> failableSupplier = () -> new FailureOnOddInvocations(); final FailableSupplier<FailureOnOddInvocations, Throwable> failableSupplier = () -> new FailureOnOddInvocations();
final Supplier<FailureOnOddInvocations> supplier = Functions.asSupplier(failableSupplier); final Supplier<FailureOnOddInvocations> supplier = Functions.asSupplier(failableSupplier);
UndeclaredThrowableException e = assertThrows(UndeclaredThrowableException.class, () -> supplier.get()); final UndeclaredThrowableException e = assertThrows(UndeclaredThrowableException.class, () -> supplier.get());
final Throwable cause = e.getCause(); final Throwable cause = e.getCause();
assertNotNull(cause); assertNotNull(cause);
assertTrue(cause instanceof SomeException); assertTrue(cause instanceof SomeException);
@ -464,7 +464,7 @@ public void testTryWithResources() {
assertTrue(co.isClosed()); assertTrue(co.isClosed());
co.reset(); co.reset();
final IOException ioe = new IOException("Unknown I/O error"); final IOException ioe = new IOException("Unknown I/O error");
UncheckedIOException uioe = assertThrows(UncheckedIOException.class, () -> Functions.tryWithResources(() -> consumer.accept(ioe), co::close)); final UncheckedIOException uioe = assertThrows(UncheckedIOException.class, () -> Functions.tryWithResources(() -> consumer.accept(ioe), co::close));
final IOException cause = uioe.getCause(); final IOException cause = uioe.getCause();
assertSame(ioe, cause); assertSame(ioe, cause);

View File

@ -524,7 +524,7 @@ public void testLang865() {
@ParameterizedTest @ParameterizedTest
@MethodSource("java.util.Locale#getAvailableLocales") @MethodSource("java.util.Locale#getAvailableLocales")
public void testParseAllLocales(Locale l) { public void testParseAllLocales(final Locale l) {
// Check if it's possible to recreate the Locale using just the standard constructor // Check if it's possible to recreate the Locale using just the standard constructor
final Locale locale = new Locale(l.getLanguage(), l.getCountry(), l.getVariant()); final Locale locale = new Locale(l.getLanguage(), l.getCountry(), l.getVariant());
if (l.equals(locale)) { // it is possible for LocaleUtils.toLocale to handle these Locales if (l.equals(locale)) { // it is possible for LocaleUtils.toLocale to handle these Locales

View File

@ -121,8 +121,8 @@ public void testDefaultIfNull() {
assertSame(o, ObjectUtils.getIfNull(o, () -> dflt), "dflt was returned when o was not null"); assertSame(o, ObjectUtils.getIfNull(o, () -> dflt), "dflt was returned when o was not null");
assertSame(o, ObjectUtils.getIfNull(FOO, () -> dflt), "dflt was returned when o was not null"); assertSame(o, ObjectUtils.getIfNull(FOO, () -> dflt), "dflt was returned when o was not null");
assertSame(o, ObjectUtils.getIfNull("foo", () -> dflt), "dflt was returned when o was not null"); assertSame(o, ObjectUtils.getIfNull("foo", () -> dflt), "dflt was returned when o was not null");
MutableInt callsCounter = new MutableInt(0); final MutableInt callsCounter = new MutableInt(0);
Supplier<Object> countingDefaultSupplier = () -> { final Supplier<Object> countingDefaultSupplier = () -> {
callsCounter.increment(); callsCounter.increment();
return dflt; return dflt;
}; };
@ -539,7 +539,7 @@ public void testCloneOfNotCloneable() {
@Test @Test
public void testCloneOfUncloneable() { public void testCloneOfUncloneable() {
final UncloneableString string = new UncloneableString("apache"); final UncloneableString string = new UncloneableString("apache");
CloneFailedException e = assertThrows(CloneFailedException.class, () -> ObjectUtils.clone(string)); final CloneFailedException e = assertThrows(CloneFailedException.class, () -> ObjectUtils.clone(string));
assertEquals(NoSuchMethodException.class, e.getCause().getClass()); assertEquals(NoSuchMethodException.class, e.getCause().getClass());
} }
@ -585,7 +585,7 @@ public void testPossibleCloneOfNotCloneable() {
@Test @Test
public void testPossibleCloneOfUncloneable() { public void testPossibleCloneOfUncloneable() {
final UncloneableString string = new UncloneableString("apache"); final UncloneableString string = new UncloneableString("apache");
CloneFailedException e = assertThrows(CloneFailedException.class, () -> ObjectUtils.cloneIfPossible(string)); final CloneFailedException e = assertThrows(CloneFailedException.class, () -> ObjectUtils.cloneIfPossible(string));
assertEquals(NoSuchMethodException.class, e.getCause().getClass()); assertEquals(NoSuchMethodException.class, e.getCause().getClass());
} }

View File

@ -158,7 +158,7 @@ public void testLANG805() {
@Test @Test
public void testLANG807() { public void testLANG807() {
IllegalArgumentException ex = final IllegalArgumentException ex =
assertThrows(IllegalArgumentException.class, () -> RandomStringUtils.random(3, 5, 5, false, false)); assertThrows(IllegalArgumentException.class, () -> RandomStringUtils.random(3, 5, 5, false, false));
final String msg = ex.getMessage(); final String msg = ex.getMessage();
assertTrue(msg.contains("start"), "Message (" + msg + ") must contain 'start'"); assertTrue(msg.contains("start"), "Message (" + msg + ") must contain 'start'");

View File

@ -159,7 +159,7 @@ public void write(final int arg0) throws IOException {
throw new IOException(SERIALIZE_IO_EXCEPTION_MESSAGE); throw new IOException(SERIALIZE_IO_EXCEPTION_MESSAGE);
} }
}; };
SerializationException e = final SerializationException e =
assertThrows(SerializationException.class, () -> SerializationUtils.serialize(iMap, streamTest)); assertThrows(SerializationException.class, () -> SerializationUtils.serialize(iMap, streamTest));
assertEquals("java.io.IOException: " + SERIALIZE_IO_EXCEPTION_MESSAGE, e.getMessage()); assertEquals("java.io.IOException: " + SERIALIZE_IO_EXCEPTION_MESSAGE, e.getMessage());
} }
@ -232,7 +232,7 @@ public void testDeserializeStreamClassNotFound() throws Exception {
oos.close(); oos.close();
final ByteArrayInputStream inTest = new ByteArrayInputStream(streamReal.toByteArray()); final ByteArrayInputStream inTest = new ByteArrayInputStream(streamReal.toByteArray());
SerializationException se = final SerializationException se =
assertThrows(SerializationException.class, () -> SerializationUtils.deserialize(inTest)); assertThrows(SerializationException.class, () -> SerializationUtils.deserialize(inTest));
assertEquals("java.lang.ClassNotFoundException: " + CLASS_NOT_FOUND_MESSAGE, se.getMessage()); assertEquals("java.lang.ClassNotFoundException: " + CLASS_NOT_FOUND_MESSAGE, se.getMessage());
} }

View File

@ -49,7 +49,7 @@ void testSimpleStreamMapFailing() {
try { try {
Functions.stream(input).map((s) -> Integer.valueOf(s)).collect(Collectors.toList()); Functions.stream(input).map((s) -> Integer.valueOf(s)).collect(Collectors.toList());
fail("Expected Exception"); fail("Expected Exception");
} catch (NumberFormatException nfe) { } catch (final NumberFormatException nfe) {
assertEquals("For input string: \"4 \"", nfe.getMessage()); assertEquals("For input string: \"4 \"", nfe.getMessage());
} }
} }
@ -75,7 +75,7 @@ void testToArray() {
assertEquals("1", array[2]); assertEquals("1", array[2]);
} }
protected <T extends Throwable> FailableConsumer<String, T> asIntConsumer(T pThrowable) { protected <T extends Throwable> FailableConsumer<String, T> asIntConsumer(final T pThrowable) {
return (s) -> { return (s) -> {
final Integer i = Integer.valueOf(s); final Integer i = Integer.valueOf(s);
if (i.intValue() == 4) { if (i.intValue() == 4) {
@ -92,7 +92,7 @@ void testSimpleStreamForEachFailing() {
try { try {
Functions.stream(input).forEach(asIntConsumer(ise)); Functions.stream(input).forEach(asIntConsumer(ise));
fail("Expected Exception"); fail("Expected Exception");
} catch (IllegalArgumentException e) { } catch (final IllegalArgumentException e) {
assertSame(ise, e); assertSame(ise, e);
} }
output.clear(); output.clear();
@ -100,7 +100,7 @@ void testSimpleStreamForEachFailing() {
try { try {
Functions.stream(input).forEach(asIntConsumer(oome)); Functions.stream(input).forEach(asIntConsumer(oome));
fail("Expected Exception"); fail("Expected Exception");
} catch (Throwable t) { } catch (final Throwable t) {
assertSame(oome, t); assertSame(oome, t);
} }
output.clear(); output.clear();
@ -108,7 +108,7 @@ void testSimpleStreamForEachFailing() {
try { try {
Functions.stream(input).forEach(asIntConsumer(se)); Functions.stream(input).forEach(asIntConsumer(se));
fail("Expected Exception"); fail("Expected Exception");
} catch (UndeclaredThrowableException ute) { } catch (final UndeclaredThrowableException ute) {
assertSame(se, ute.getCause()); assertSame(se, ute.getCause());
} }
} }
@ -132,7 +132,7 @@ private void assertEvenNumbers(final List<Integer> output) {
} }
} }
protected <T extends Throwable> FailablePredicate<Integer, T> asIntPredicate(T pThrowable) { protected <T extends Throwable> FailablePredicate<Integer, T> asIntPredicate(final T pThrowable) {
return (i) -> { return (i) -> {
if (i.intValue() == 5) { if (i.intValue() == 5) {
if (pThrowable != null) { if (pThrowable != null) {
@ -160,7 +160,7 @@ void testSimpleStreamFilterFailing() {
.filter(asIntPredicate(iae)) .filter(asIntPredicate(iae))
.collect(Collectors.toList()); .collect(Collectors.toList());
fail("Expected Exception"); fail("Expected Exception");
} catch (IllegalArgumentException e) { } catch (final IllegalArgumentException e) {
assertSame(iae, e); assertSame(iae, e);
} }
@ -172,7 +172,7 @@ void testSimpleStreamFilterFailing() {
.filter(asIntPredicate(oome)) .filter(asIntPredicate(oome))
.collect(Collectors.toList()); .collect(Collectors.toList());
fail("Expected Exception"); fail("Expected Exception");
} catch (Throwable t) { } catch (final Throwable t) {
assertSame(oome, t); assertSame(oome, t);
} }
@ -184,7 +184,7 @@ void testSimpleStreamFilterFailing() {
.filter(asIntPredicate(se)) .filter(asIntPredicate(se))
.collect(Collectors.toList()); .collect(Collectors.toList());
fail("Expected Exception"); fail("Expected Exception");
} catch (UndeclaredThrowableException t) { } catch (final UndeclaredThrowableException t) {
assertSame(se, t.getCause()); assertSame(se, t.getCause());
} }
} }

View File

@ -239,7 +239,7 @@ private void innerTestSplitPreserveAllTokens(final char separator, final String
//Fixed LANG-1463 //Fixed LANG-1463
@Test @Test
public void testAbbreviateMarkerWithEmptyString() { public void testAbbreviateMarkerWithEmptyString() {
String greaterThanMaxTest = "much too long text"; final String greaterThanMaxTest = "much too long text";
assertEquals("much too long", StringUtils.abbreviate(greaterThanMaxTest, "", 13)); assertEquals("much too long", StringUtils.abbreviate(greaterThanMaxTest, "", 13));
} }
@ -684,8 +684,8 @@ public void testGetIfBlank_StringStringSupplier() {
final String s = StringUtils.getIfBlank("abc", () -> "NULL"); final String s = StringUtils.getIfBlank("abc", () -> "NULL");
assertEquals("abc", s); assertEquals("abc", s);
//Checking that default value supplied only on demand //Checking that default value supplied only on demand
MutableInt numberOfCalls = new MutableInt(0); final MutableInt numberOfCalls = new MutableInt(0);
Supplier<String> countingDefaultSupplier = () -> { final Supplier<String> countingDefaultSupplier = () -> {
numberOfCalls.increment(); numberOfCalls.increment();
return "NULL"; return "NULL";
}; };
@ -752,8 +752,8 @@ public void testGetIfEmpty_StringStringSupplier() {
final String s = StringUtils.getIfEmpty("abc", () -> "NULL"); final String s = StringUtils.getIfEmpty("abc", () -> "NULL");
assertEquals("abc", s); assertEquals("abc", s);
//Checking that default value supplied only on demand //Checking that default value supplied only on demand
MutableInt numberOfCalls = new MutableInt(0); final MutableInt numberOfCalls = new MutableInt(0);
Supplier<String> countingDefaultSupplier = () -> { final Supplier<String> countingDefaultSupplier = () -> {
numberOfCalls.increment(); numberOfCalls.increment();
return "NULL"; return "NULL";
}; };
@ -3273,7 +3273,7 @@ public void testToRootLowerCase() {
assertEquals("title", "TITLE".toLowerCase(Locale.ROOT)); assertEquals("title", "TITLE".toLowerCase(Locale.ROOT));
assertEquals("title", StringUtils.toRootLowerCase("TITLE")); assertEquals("title", StringUtils.toRootLowerCase("TITLE"));
// Make sure we are not using the default Locale: // Make sure we are not using the default Locale:
Locale defaultLocales = Locale.getDefault(); final Locale defaultLocales = Locale.getDefault();
try { try {
Locale.setDefault(TURKISH); Locale.setDefault(TURKISH);
assertEquals("title", StringUtils.toRootLowerCase("TITLE")); assertEquals("title", StringUtils.toRootLowerCase("TITLE"));
@ -3293,7 +3293,7 @@ public void testToRootUpperCase() {
assertEquals("TITLE", "title".toUpperCase(Locale.ROOT)); assertEquals("TITLE", "title".toUpperCase(Locale.ROOT));
assertEquals("TITLE", StringUtils.toRootUpperCase("title")); assertEquals("TITLE", StringUtils.toRootUpperCase("title"));
// Make sure we are not using the default Locale: // Make sure we are not using the default Locale:
Locale defaultLocales = Locale.getDefault(); final Locale defaultLocales = Locale.getDefault();
try { try {
Locale.setDefault(TURKISH); Locale.setDefault(TURKISH);
assertEquals("TITLE", StringUtils.toRootUpperCase("title")); assertEquals("TITLE", StringUtils.toRootUpperCase("title"));

View File

@ -712,7 +712,7 @@ void shouldNotThrowExceptionForNonEmptyCollection() {
@Test @Test
void shouldReturnSameInstance() { void shouldReturnSameInstance() {
Set<String> col = Collections.singleton("a"); final Set<String> col = Collections.singleton("a");
final Set<String> result = Validate.noNullElements(col); final Set<String> result = Validate.noNullElements(col);
assertSame(col, result); assertSame(col, result);
@ -747,7 +747,7 @@ void shouldNotThrowExceptionForNonEmptyCollection() {
@Test @Test
void shouldReturnSameInstance() { void shouldReturnSameInstance() {
Set<String> col = Collections.singleton("a"); final Set<String> col = Collections.singleton("a");
final Set<String> result = Validate.noNullElements(col, "MSG"); final Set<String> result = Validate.noNullElements(col, "MSG");
assertSame(col, result); assertSame(col, result);

View File

@ -447,7 +447,7 @@ public void testObjectRecursiveGenericInteger() {
@Test @Test
public void testObjectRecursiveGenericString() { public void testObjectRecursiveGenericString() {
// Note: Do not use literals, because string literals are always mapped by same object (internal() of String))! // Note: Do not use literals, because string literals are always mapped by same object (internal() of String))!
String s1_a = String.valueOf(1); final String s1_a = String.valueOf(1);
final TestRecursiveGenericObject<String> o1_a = new TestRecursiveGenericObject<>(s1_a); final TestRecursiveGenericObject<String> o1_a = new TestRecursiveGenericObject<>(s1_a);
final TestRecursiveGenericObject<String> o1_b = new TestRecursiveGenericObject<>(String.valueOf(1)); final TestRecursiveGenericObject<String> o1_b = new TestRecursiveGenericObject<>(String.valueOf(1));
final TestRecursiveGenericObject<String> o2 = new TestRecursiveGenericObject<>(String.valueOf(2)); final TestRecursiveGenericObject<String> o2 = new TestRecursiveGenericObject<>(String.valueOf(2));

View File

@ -23,10 +23,10 @@
public class ReflectionToStringBuilderSummaryTest { public class ReflectionToStringBuilderSummaryTest {
@SuppressWarnings("unused") @SuppressWarnings("unused")
private String stringField = "string"; private final String stringField = "string";
@ToStringSummary @ToStringSummary
private String summaryString = "summary"; private final String summaryString = "summary";
@Test @Test
public void testSummary() { public void testSummary() {

View File

@ -179,7 +179,7 @@ public void testGetRuntimeException() {
final RuntimeException rex = new RuntimeException(); final RuntimeException rex = new RuntimeException();
init.ex = rex; init.ex = rex;
init.start(); init.start();
Exception ex = assertThrows(Exception.class, init::get); final Exception ex = assertThrows(Exception.class, init::get);
assertEquals(rex, ex, "Runtime exception not thrown"); assertEquals(rex, ex, "Runtime exception not thrown");
} }
@ -193,7 +193,7 @@ public void testGetCheckedException() {
final Exception ex = new Exception(); final Exception ex = new Exception();
init.ex = ex; init.ex = ex;
init.start(); init.start();
ConcurrentException cex = assertThrows(ConcurrentException.class, init::get); final ConcurrentException cex = assertThrows(ConcurrentException.class, init::get);
assertEquals(ex, cex.getCause(), "Exception not thrown"); assertEquals(ex, cex.getCause(), "Exception not thrown");
} }

View File

@ -107,7 +107,7 @@ public void testExtractCauseNullCause() {
@Test @Test
public void testExtractCauseError() { public void testExtractCauseError() {
final Error err = new AssertionError("Test"); final Error err = new AssertionError("Test");
AssertionError e = final AssertionError e =
assertThrows(AssertionError.class, () -> ConcurrentUtils.extractCause(new ExecutionException(err))); assertThrows(AssertionError.class, () -> ConcurrentUtils.extractCause(new ExecutionException(err)));
assertEquals(err, e, "Wrong error"); assertEquals(err, e, "Wrong error");
} }
@ -154,7 +154,7 @@ public void testExtractCauseUncheckedNullCause() {
@Test @Test
public void testExtractCauseUncheckedError() { public void testExtractCauseUncheckedError() {
final Error err = new AssertionError("Test"); final Error err = new AssertionError("Test");
Error e = assertThrows(Error.class, () -> ConcurrentUtils.extractCauseUnchecked(new ExecutionException(err))); final Error e = assertThrows(Error.class, () -> ConcurrentUtils.extractCauseUnchecked(new ExecutionException(err)));
assertEquals(err, e, "Wrong error"); assertEquals(err, e, "Wrong error");
} }
@ -164,7 +164,7 @@ public void testExtractCauseUncheckedError() {
@Test @Test
public void testExtractCauseUncheckedUncheckedException() { public void testExtractCauseUncheckedUncheckedException() {
final RuntimeException rex = new RuntimeException("Test"); final RuntimeException rex = new RuntimeException("Test");
RuntimeException r = final RuntimeException r =
assertThrows(RuntimeException.class, () -> ConcurrentUtils.extractCauseUnchecked(new ExecutionException(rex))); assertThrows(RuntimeException.class, () -> ConcurrentUtils.extractCauseUnchecked(new ExecutionException(rex)));
assertEquals(rex, r, "Wrong exception"); assertEquals(rex, r, "Wrong exception");
} }
@ -186,7 +186,7 @@ public void testExtractCauseUncheckedChecked() {
@Test @Test
public void testHandleCauseError() { public void testHandleCauseError() {
final Error err = new AssertionError("Test"); final Error err = new AssertionError("Test");
Error e = assertThrows(Error.class, () -> ConcurrentUtils.handleCause(new ExecutionException(err))); final Error e = assertThrows(Error.class, () -> ConcurrentUtils.handleCause(new ExecutionException(err)));
assertEquals(err, e, "Wrong error"); assertEquals(err, e, "Wrong error");
} }
@ -196,7 +196,7 @@ public void testHandleCauseError() {
@Test @Test
public void testHandleCauseUncheckedException() { public void testHandleCauseUncheckedException() {
final RuntimeException rex = new RuntimeException("Test"); final RuntimeException rex = new RuntimeException("Test");
RuntimeException r = final RuntimeException r =
assertThrows(RuntimeException.class, () -> ConcurrentUtils.handleCause(new ExecutionException(rex))); assertThrows(RuntimeException.class, () -> ConcurrentUtils.handleCause(new ExecutionException(rex)));
assertEquals(rex, r, "Wrong exception"); assertEquals(rex, r, "Wrong exception");
} }
@ -207,7 +207,7 @@ public void testHandleCauseUncheckedException() {
@Test @Test
public void testHandleCauseChecked() { public void testHandleCauseChecked() {
final Exception ex = new Exception("Test"); final Exception ex = new Exception("Test");
ConcurrentException cex = final ConcurrentException cex =
assertThrows(ConcurrentException.class, () -> ConcurrentUtils.handleCause(new ExecutionException(ex))); assertThrows(ConcurrentException.class, () -> ConcurrentUtils.handleCause(new ExecutionException(ex)));
assertEquals(ex, cex.getCause(), "Wrong cause"); assertEquals(ex, cex.getCause(), "Wrong cause");
} }
@ -231,7 +231,7 @@ public void testHandleCauseNull() throws ConcurrentException {
@Test @Test
public void testHandleCauseUncheckedError() { public void testHandleCauseUncheckedError() {
final Error err = new AssertionError("Test"); final Error err = new AssertionError("Test");
Error e = assertThrows(Error.class, () -> ConcurrentUtils.handleCauseUnchecked(new ExecutionException(err))); final Error e = assertThrows(Error.class, () -> ConcurrentUtils.handleCauseUnchecked(new ExecutionException(err)));
assertEquals(err, e, "Wrong error"); assertEquals(err, e, "Wrong error");
} }
@ -241,7 +241,7 @@ public void testHandleCauseUncheckedError() {
@Test @Test
public void testHandleCauseUncheckedUncheckedException() { public void testHandleCauseUncheckedUncheckedException() {
final RuntimeException rex = new RuntimeException("Test"); final RuntimeException rex = new RuntimeException("Test");
RuntimeException r = final RuntimeException r =
assertThrows(RuntimeException.class, () -> ConcurrentUtils.handleCauseUnchecked(new ExecutionException(rex))); assertThrows(RuntimeException.class, () -> ConcurrentUtils.handleCauseUnchecked(new ExecutionException(rex)));
assertEquals(rex, r, "Wrong exception"); assertEquals(rex, r, "Wrong exception");
} }
@ -252,7 +252,7 @@ public void testHandleCauseUncheckedUncheckedException() {
@Test @Test
public void testHandleCauseUncheckedChecked() { public void testHandleCauseUncheckedChecked() {
final Exception ex = new Exception("Test"); final Exception ex = new Exception("Test");
ConcurrentRuntimeException crex = final ConcurrentRuntimeException crex =
assertThrows(ConcurrentRuntimeException.class, () -> ConcurrentUtils.handleCauseUnchecked(new ExecutionException(ex))); assertThrows(ConcurrentRuntimeException.class, () -> ConcurrentUtils.handleCauseUnchecked(new ExecutionException(ex)));
assertEquals(ex, crex.getCause(), "Wrong cause"); assertEquals(ex, crex.getCause(), "Wrong cause");
} }
@ -346,7 +346,7 @@ public void testInitializeUncheckedEx() throws ConcurrentException {
final Exception cause = new Exception(); final Exception cause = new Exception();
EasyMock.expect(init.get()).andThrow(new ConcurrentException(cause)); EasyMock.expect(init.get()).andThrow(new ConcurrentException(cause));
EasyMock.replay(init); EasyMock.replay(init);
ConcurrentRuntimeException crex = final ConcurrentRuntimeException crex =
assertThrows(ConcurrentRuntimeException.class, () -> ConcurrentUtils.initializeUnchecked(init)); assertThrows(ConcurrentRuntimeException.class, () -> ConcurrentUtils.initializeUnchecked(init));
assertSame(cause, crex.getCause(), "Wrong cause"); assertSame(cause, crex.getCause(), "Wrong cause");
EasyMock.verify(init); EasyMock.verify(init);
@ -524,7 +524,7 @@ public void testCreateIfAbsentUncheckedException()
final Exception ex = new Exception(); final Exception ex = new Exception();
EasyMock.expect(init.get()).andThrow(new ConcurrentException(ex)); EasyMock.expect(init.get()).andThrow(new ConcurrentException(ex));
EasyMock.replay(init); EasyMock.replay(init);
ConcurrentRuntimeException crex = final ConcurrentRuntimeException crex =
assertThrows( assertThrows(
ConcurrentRuntimeException.class, ConcurrentRuntimeException.class,
() -> ConcurrentUtils.createIfAbsentUnchecked(new ConcurrentHashMap<>(), "test", init)); () -> ConcurrentUtils.createIfAbsentUnchecked(new ConcurrentHashMap<>(), "test", init));

View File

@ -161,8 +161,8 @@ public void testOpeningWhenThresholdReachedThroughBatch() {
final long timeIncrement = NANO_FACTOR / OPENING_THRESHOLD - 1; final long timeIncrement = NANO_FACTOR / OPENING_THRESHOLD - 1;
final EventCountCircuitBreakerTestImpl breaker = new EventCountCircuitBreakerTestImpl(OPENING_THRESHOLD, 1, final EventCountCircuitBreakerTestImpl breaker = new EventCountCircuitBreakerTestImpl(OPENING_THRESHOLD, 1,
TimeUnit.SECONDS, CLOSING_THRESHOLD, 1, TimeUnit.SECONDS); TimeUnit.SECONDS, CLOSING_THRESHOLD, 1, TimeUnit.SECONDS);
long startTime = timeIncrement * (OPENING_THRESHOLD + 1); final long startTime = timeIncrement * (OPENING_THRESHOLD + 1);
boolean open = !breaker.at(startTime).incrementAndCheckState(OPENING_THRESHOLD + 1); final boolean open = !breaker.at(startTime).incrementAndCheckState(OPENING_THRESHOLD + 1);
assertTrue(open, "Not open"); assertTrue(open, "Not open");
assertFalse(breaker.isClosed(), "Closed"); assertFalse(breaker.isClosed(), "Closed");
} }

View File

@ -273,7 +273,7 @@ public void testInitializeRuntimeEx() {
child.ex = new RuntimeException(); child.ex = new RuntimeException();
initializer.addInitializer(CHILD_INIT, child); initializer.addInitializer(CHILD_INIT, child);
initializer.start(); initializer.start();
Exception ex = assertThrows(Exception.class, initializer::get); final Exception ex = assertThrows(Exception.class, initializer::get);
assertEquals(child.ex, ex, "Wrong exception"); assertEquals(child.ex, ex, "Wrong exception");
} }

View File

@ -69,7 +69,7 @@ public void testAddEventListenerWithNoAddMethod() {
final PropertyChangeSource src = new PropertyChangeSource(); final PropertyChangeSource src = new PropertyChangeSource();
final EventCountingInvociationHandler handler = new EventCountingInvociationHandler(); final EventCountingInvociationHandler handler = new EventCountingInvociationHandler();
final ObjectChangeListener listener = handler.createListener(ObjectChangeListener.class); final ObjectChangeListener listener = handler.createListener(ObjectChangeListener.class);
IllegalArgumentException e = final IllegalArgumentException e =
assertThrows(IllegalArgumentException.class, () -> EventUtils.addEventListener(src, ObjectChangeListener.class, listener)); assertThrows(IllegalArgumentException.class, () -> EventUtils.addEventListener(src, ObjectChangeListener.class, listener));
assertEquals("Class " + src.getClass().getName() + " does not have a public add" + ObjectChangeListener.class.getSimpleName() + " method which takes a parameter of type " + ObjectChangeListener.class.getName() + ".", assertEquals("Class " + src.getClass().getName() + " does not have a public add" + ObjectChangeListener.class.getSimpleName() + " method which takes a parameter of type " + ObjectChangeListener.class.getName() + ".",
e.getMessage()); e.getMessage());
@ -90,7 +90,7 @@ public void testAddEventListenerWithPrivateAddMethod() {
final PropertyChangeSource src = new PropertyChangeSource(); final PropertyChangeSource src = new PropertyChangeSource();
final EventCountingInvociationHandler handler = new EventCountingInvociationHandler(); final EventCountingInvociationHandler handler = new EventCountingInvociationHandler();
final VetoableChangeListener listener = handler.createListener(VetoableChangeListener.class); final VetoableChangeListener listener = handler.createListener(VetoableChangeListener.class);
IllegalArgumentException e = final IllegalArgumentException e =
assertThrows(IllegalArgumentException.class, () -> EventUtils.addEventListener(src, VetoableChangeListener.class, listener)); assertThrows(IllegalArgumentException.class, () -> EventUtils.addEventListener(src, VetoableChangeListener.class, listener));
assertEquals("Class " + src.getClass().getName() + " does not have a public add" + VetoableChangeListener.class.getSimpleName() + " method which takes a parameter of type " + VetoableChangeListener.class.getName() + ".", assertEquals("Class " + src.getClass().getName() + " does not have a public add" + VetoableChangeListener.class.getSimpleName() + " method which takes a parameter of type " + VetoableChangeListener.class.getName() + ".",
e.getMessage()); e.getMessage());

View File

@ -566,7 +566,7 @@ public void testRemoveCommonFrames_ListList() {
@Test @Test
public void testThrow() { public void testThrow() {
final Exception expected = new InterruptedException(); final Exception expected = new InterruptedException();
Exception actual = assertThrows(Exception.class, () -> ExceptionUtils.rethrow(expected)); final Exception actual = assertThrows(Exception.class, () -> ExceptionUtils.rethrow(expected));
assertSame(expected, actual); assertSame(expected, actual);
} }
@ -678,25 +678,25 @@ public void testThrowableOfType_ThrowableClassInt() {
@Test @Test
public void testWrapAndUnwrapCheckedException() { public void testWrapAndUnwrapCheckedException() {
Throwable t = assertThrows(Throwable.class, () -> ExceptionUtils.wrapAndThrow(new IOException())); final Throwable t = assertThrows(Throwable.class, () -> ExceptionUtils.wrapAndThrow(new IOException()));
assertTrue(ExceptionUtils.hasCause(t, IOException.class)); assertTrue(ExceptionUtils.hasCause(t, IOException.class));
} }
@Test @Test
public void testWrapAndUnwrapError() { public void testWrapAndUnwrapError() {
Throwable t = assertThrows(Throwable.class, () -> ExceptionUtils.wrapAndThrow(new OutOfMemoryError())); final Throwable t = assertThrows(Throwable.class, () -> ExceptionUtils.wrapAndThrow(new OutOfMemoryError()));
assertTrue(ExceptionUtils.hasCause(t, Error.class)); assertTrue(ExceptionUtils.hasCause(t, Error.class));
} }
@Test @Test
public void testWrapAndUnwrapRuntimeException() { public void testWrapAndUnwrapRuntimeException() {
Throwable t = assertThrows(Throwable.class, () -> ExceptionUtils.wrapAndThrow(new IllegalArgumentException())); final Throwable t = assertThrows(Throwable.class, () -> ExceptionUtils.wrapAndThrow(new IllegalArgumentException()));
assertTrue(ExceptionUtils.hasCause(t, RuntimeException.class)); assertTrue(ExceptionUtils.hasCause(t, RuntimeException.class));
} }
@Test @Test
public void testWrapAndUnwrapThrowable() { public void testWrapAndUnwrapThrowable() {
Throwable t = assertThrows(Throwable.class, () -> ExceptionUtils.wrapAndThrow(new TestThrowable())); final Throwable t = assertThrows(Throwable.class, () -> ExceptionUtils.wrapAndThrow(new TestThrowable()));
assertTrue(ExceptionUtils.hasCause(t, TestThrowable.class)); assertTrue(ExceptionUtils.hasCause(t, TestThrowable.class));
} }
} }

View File

@ -36,6 +36,7 @@
import java.lang.reflect.Modifier; import java.lang.reflect.Modifier;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashSet;
import java.util.List; import java.util.List;
import static org.junit.jupiter.api.Assertions.assertArrayEquals; import static org.junit.jupiter.api.Assertions.assertArrayEquals;
@ -172,7 +173,7 @@ public void testGetAllFields() {
final Field[] allFields = FieldUtils.getAllFields(PublicChild.class); final Field[] allFields = FieldUtils.getAllFields(PublicChild.class);
// Under Jacoco,0.8.1 and Java 10, the field count is 7. // Under Jacoco,0.8.1 and Java 10, the field count is 7.
int expected = 5; int expected = 5;
for (Field field : allFields) { for (final Field field : allFields) {
if (field.getName().equals(JACOCO_DATA_FIELD_NAME)) { if (field.getName().equals(JACOCO_DATA_FIELD_NAME)) {
expected++; expected++;
} }
@ -188,11 +189,11 @@ public void testGetAllFieldsList() {
final List<Field> fieldsInteger = Arrays.asList(Integer.class.getDeclaredFields()); final List<Field> fieldsInteger = Arrays.asList(Integer.class.getDeclaredFields());
final List<Field> allFieldsInteger = new ArrayList<>(fieldsInteger); final List<Field> allFieldsInteger = new ArrayList<>(fieldsInteger);
allFieldsInteger.addAll(fieldsNumber); allFieldsInteger.addAll(fieldsNumber);
assertEquals(allFieldsInteger, FieldUtils.getAllFieldsList(Integer.class)); assertEquals(new HashSet(allFieldsInteger), new HashSet(FieldUtils.getAllFieldsList(Integer.class)));
final List<Field> allFields = FieldUtils.getAllFieldsList(PublicChild.class); final List<Field> allFields = FieldUtils.getAllFieldsList(PublicChild.class);
// Under Jacoco,0.8.1 and Java 10, the field count is 7. // Under Jacoco,0.8.1 and Java 10, the field count is 7.
int expected = 5; int expected = 5;
for (Field field : allFields) { for (final Field field : allFields) {
if (field.getName().equals(JACOCO_DATA_FIELD_NAME)) { if (field.getName().equals(JACOCO_DATA_FIELD_NAME)) {
expected++; expected++;
} }
@ -671,7 +672,7 @@ public void testReadDeclaredNamedFieldForceAccess() throws Exception {
@Test @Test
public void testWriteStaticField() throws Exception { public void testWriteStaticField() throws Exception {
Field field = StaticContainer.class.getDeclaredField("mutablePublic"); final Field field = StaticContainer.class.getDeclaredField("mutablePublic");
FieldUtils.writeStaticField(field, "new"); FieldUtils.writeStaticField(field, "new");
assertEquals("new", StaticContainer.mutablePublic); assertEquals("new", StaticContainer.mutablePublic);
assertThrows( assertThrows(
@ -829,7 +830,7 @@ public void testWriteDeclaredNamedStaticFieldForceAccess() throws Exception {
@Test @Test
public void testWriteField() throws Exception { public void testWriteField() throws Exception {
Field field = parentClass.getDeclaredField("s"); final Field field = parentClass.getDeclaredField("s");
FieldUtils.writeField(field, publicChild, "S"); FieldUtils.writeField(field, publicChild, "S");
assertEquals("S", field.get(publicChild)); assertEquals("S", field.get(publicChild));
assertThrows( assertThrows(
@ -1048,10 +1049,10 @@ public void testRemoveFinalModifierAccessNotNeeded() throws Exception {
* @param forceAccess {@link Boolean} to be curried into * @param forceAccess {@link Boolean} to be curried into
* {@link FieldUtils#removeFinalModifier(Field, boolean)}. * {@link FieldUtils#removeFinalModifier(Field, boolean)}.
*/ */
private void callRemoveFinalModifierCheckForException(Field field, Boolean forceAccess) { private void callRemoveFinalModifierCheckForException(final Field field, final Boolean forceAccess) {
try { try {
FieldUtils.removeFinalModifier(field, forceAccess); FieldUtils.removeFinalModifier(field, forceAccess);
} catch (UnsupportedOperationException exception) { } catch (final UnsupportedOperationException exception) {
if (SystemUtils.isJavaVersionAtLeast(JavaVersion.JAVA_12)) { if (SystemUtils.isJavaVersionAtLeast(JavaVersion.JAVA_12)) {
assertTrue(exception.getCause() instanceof NoSuchFieldException); assertTrue(exception.getCause() instanceof NoSuchFieldException);
} else { } else {

View File

@ -521,7 +521,7 @@ public void testGetCharsIntIntCharArrayInt( ) {
final StrBuilder sb = new StrBuilder(); final StrBuilder sb = new StrBuilder();
sb.append("junit"); sb.append("junit");
char[] a = new char[5]; final char[] a = new char[5];
sb.getChars(0, 5, a, 0); sb.getChars(0, 5, a, 0);
assertArrayEquals(new char[]{'j', 'u', 'n', 'i', 't'}, a); assertArrayEquals(new char[]{'j', 'u', 'n', 'i', 't'}, a);
@ -538,7 +538,7 @@ public void testGetCharsIntIntCharArrayInt( ) {
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
@Test @Test
public void testDeleteIntInt() { public void testDeleteIntInt() {
StrBuilder sb = new StrBuilder("abc"); final StrBuilder sb = new StrBuilder("abc");
sb.delete(0, 1); sb.delete(0, 1);
assertEquals("bc", sb.toString()); assertEquals("bc", sb.toString());
sb.delete(1, 2); sb.delete(1, 2);
@ -679,7 +679,7 @@ public void testDeleteFirst_StrMatcher() {
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
@Test @Test
public void testReplace_int_int_String() { public void testReplace_int_int_String() {
StrBuilder sb = new StrBuilder("abc"); final StrBuilder sb = new StrBuilder("abc");
sb.replace(0, 1, "d"); sb.replace(0, 1, "d");
assertEquals("dbc", sb.toString()); assertEquals("dbc", sb.toString());
sb.replace(0, 1, "aaa"); sb.replace(0, 1, "aaa");
@ -693,12 +693,12 @@ public void testReplace_int_int_String() {
sb.replace(0, 1000, "text"); sb.replace(0, 1000, "text");
assertEquals("text", sb.toString()); assertEquals("text", sb.toString());
StrBuilder sb1 = new StrBuilder("atext"); final StrBuilder sb1 = new StrBuilder("atext");
sb1.replace(1, 1, "ny"); sb1.replace(1, 1, "ny");
assertEquals("anytext", sb1.toString()); assertEquals("anytext", sb1.toString());
assertThrows(IndexOutOfBoundsException.class, () -> sb1.replace(2, 1, "anything")); assertThrows(IndexOutOfBoundsException.class, () -> sb1.replace(2, 1, "anything"));
StrBuilder sb2 = new StrBuilder(); final StrBuilder sb2 = new StrBuilder();
assertThrows(IndexOutOfBoundsException.class, () -> sb2.replace(1, 2, "anything")); assertThrows(IndexOutOfBoundsException.class, () -> sb2.replace(1, 2, "anything"));
assertThrows(IndexOutOfBoundsException.class, () -> sb2.replace(-1, 1, "anything")); assertThrows(IndexOutOfBoundsException.class, () -> sb2.replace(-1, 1, "anything"));
} }
@ -960,13 +960,13 @@ public void testReplace_StrMatcher_String_int_int_int_VaryStartIndex() {
sb.replace(StrMatcher.stringMatcher("aa"), "-", 10, sb.length(), -1); sb.replace(StrMatcher.stringMatcher("aa"), "-", 10, sb.length(), -1);
assertEquals("aaxaaaayaa", sb.toString()); assertEquals("aaxaaaayaa", sb.toString());
StrBuilder sb1 = new StrBuilder("aaxaaaayaa"); final StrBuilder sb1 = new StrBuilder("aaxaaaayaa");
assertThrows( assertThrows(
IndexOutOfBoundsException.class, IndexOutOfBoundsException.class,
() -> sb1.replace(StrMatcher.stringMatcher("aa"), "-", 11, sb1.length(), -1)); () -> sb1.replace(StrMatcher.stringMatcher("aa"), "-", 11, sb1.length(), -1));
assertEquals("aaxaaaayaa", sb1.toString()); assertEquals("aaxaaaayaa", sb1.toString());
StrBuilder sb2 = new StrBuilder("aaxaaaayaa"); final StrBuilder sb2 = new StrBuilder("aaxaaaayaa");
assertThrows( assertThrows(
IndexOutOfBoundsException.class, IndexOutOfBoundsException.class,
() -> sb2.replace(StrMatcher.stringMatcher("aa"), "-", -1, sb2.length(), -1)); () -> sb2.replace(StrMatcher.stringMatcher("aa"), "-", -1, sb2.length(), -1));
@ -1019,7 +1019,7 @@ public void testReplace_StrMatcher_String_int_int_int_VaryEndIndex() {
sb.replace(StrMatcher.stringMatcher("aa"), "-", 0, 1000, -1); sb.replace(StrMatcher.stringMatcher("aa"), "-", 0, 1000, -1);
assertEquals("-x--y-", sb.toString()); assertEquals("-x--y-", sb.toString());
StrBuilder sb1 = new StrBuilder("aaxaaaayaa"); final StrBuilder sb1 = new StrBuilder("aaxaaaayaa");
assertThrows( assertThrows(
IndexOutOfBoundsException.class, IndexOutOfBoundsException.class,
() -> sb1.replace(StrMatcher.stringMatcher("aa"), "-", 2, 1, -1)); () -> sb1.replace(StrMatcher.stringMatcher("aa"), "-", 2, 1, -1));

View File

@ -245,7 +245,7 @@ public void testCyclicReplacement() {
map.put("critterSpeed", "quick"); map.put("critterSpeed", "quick");
map.put("critterColor", "brown"); map.put("critterColor", "brown");
map.put("critterType", "${animal}"); map.put("critterType", "${animal}");
StrSubstitutor sub = new StrSubstitutor(map); final StrSubstitutor sub = new StrSubstitutor(map);
assertThrows( assertThrows(
IllegalStateException.class, IllegalStateException.class,
() -> sub.replace("The ${animal} jumps over the ${target}."), () -> sub.replace("The ${animal} jumps over the ${target}."),
@ -253,7 +253,7 @@ public void testCyclicReplacement() {
// also check even when default value is set. // also check even when default value is set.
map.put("critterType", "${animal:-fox}"); map.put("critterType", "${animal:-fox}");
StrSubstitutor sub2 = new StrSubstitutor(map); final StrSubstitutor sub2 = new StrSubstitutor(map);
assertThrows( assertThrows(
IllegalStateException.class, IllegalStateException.class,
() -> sub2.replace("The ${animal} jumps over the ${target}."), () -> sub2.replace("The ${animal} jumps over the ${target}."),

View File

@ -1514,10 +1514,10 @@ public void testWeekIterator() {
it = DateUtils.iterator((Object) now, DateUtils.RANGE_WEEK_CENTER); it = DateUtils.iterator((Object) now, DateUtils.RANGE_WEEK_CENTER);
assertWeekIterator(it, centered); assertWeekIterator(it, centered);
Iterator<?> it2 = DateUtils.iterator((Object) now.getTime(), DateUtils.RANGE_WEEK_CENTER); final Iterator<?> it2 = DateUtils.iterator((Object) now.getTime(), DateUtils.RANGE_WEEK_CENTER);
assertWeekIterator(it2, centered); assertWeekIterator(it2, centered);
assertThrows(NoSuchElementException.class, it2::next); assertThrows(NoSuchElementException.class, it2::next);
Iterator<?> it3 = DateUtils.iterator(now, DateUtils.RANGE_WEEK_CENTER); final Iterator<?> it3 = DateUtils.iterator(now, DateUtils.RANGE_WEEK_CENTER);
it3.next(); it3.next();
assertThrows(UnsupportedOperationException.class, it3::remove); assertThrows(UnsupportedOperationException.class, it3::remove);

View File

@ -140,7 +140,7 @@ public void testLowerCasePP(final String format, final String input, final Local
checkParsePosition(input.toLowerCase(locale), format, locale, valid); checkParsePosition(input.toLowerCase(locale), format, locale, valid);
} }
private void checkParse(final String formattedDate, String format, Locale locale, boolean valid) { private void checkParse(final String formattedDate, final String format, final Locale locale, final boolean valid) {
final SimpleDateFormat sdf = new SimpleDateFormat(format, locale); final SimpleDateFormat sdf = new SimpleDateFormat(format, locale);
sdf.setTimeZone(timeZone); sdf.setTimeZone(timeZone);
final DateParser fdf = new FastDateParser(format, timeZone, locale); final DateParser fdf = new FastDateParser(format, timeZone, locale);
@ -176,7 +176,7 @@ private void checkParse(final String formattedDate, String format, Locale locale
assertEquals(sdfE, fdfE, locale.toString()+" "+formattedDate + " expected same Exception "); assertEquals(sdfE, fdfE, locale.toString()+" "+formattedDate + " expected same Exception ");
} }
} }
private void checkParsePosition(final String formattedDate, String format, Locale locale, boolean valid) { private void checkParsePosition(final String formattedDate, final String format, final Locale locale, final boolean valid) {
final SimpleDateFormat sdf = new SimpleDateFormat(format, locale); final SimpleDateFormat sdf = new SimpleDateFormat(format, locale);
sdf.setTimeZone(timeZone); sdf.setTimeZone(timeZone);
final DateParser fdf = new FastDateParser(format, timeZone, locale); final DateParser fdf = new FastDateParser(format, timeZone, locale);

View File

@ -37,7 +37,7 @@ public static Stream<TimeZone> data() {
@ParameterizedTest @ParameterizedTest
@MethodSource("data") @MethodSource("data")
public void testCalendarTimezoneRespected(TimeZone timeZone) { public void testCalendarTimezoneRespected(final TimeZone timeZone) {
final Calendar cal = Calendar.getInstance(timeZone); final Calendar cal = Calendar.getInstance(timeZone);
final SimpleDateFormat sdf = new SimpleDateFormat(PATTERN); final SimpleDateFormat sdf = new SimpleDateFormat(PATTERN);

View File

@ -54,7 +54,7 @@ public static Stream<Arguments> data() {
@ParameterizedTest @ParameterizedTest
@MethodSource("data") @MethodSource("data")
public void testParser(Calendar vulgar, String isoForm) { public void testParser(final Calendar vulgar, final String isoForm) {
final DateParser parser = new FastDateParser("YYYY-'W'ww-u", TimeZone.getDefault(), Locale.getDefault()); final DateParser parser = new FastDateParser("YYYY-'W'ww-u", TimeZone.getDefault(), Locale.getDefault());
final Calendar cal = Calendar.getInstance(); final Calendar cal = Calendar.getInstance();
@ -68,7 +68,7 @@ public void testParser(Calendar vulgar, String isoForm) {
@ParameterizedTest @ParameterizedTest
@MethodSource("data") @MethodSource("data")
public void testPrinter(Calendar vulgar, String isoForm) { public void testPrinter(final Calendar vulgar, final String isoForm) {
final FastDatePrinter printer = new FastDatePrinter("YYYY-'W'ww-u", TimeZone.getDefault(), Locale.getDefault()); final FastDatePrinter printer = new FastDatePrinter("YYYY-'W'ww-u", TimeZone.getDefault(), Locale.getDefault());
vulgar.setMinimalDaysInFirstWeek(4); vulgar.setMinimalDaysInFirstWeek(4);

View File

@ -154,7 +154,7 @@ public void testPairOfObjects() {
assertNull(pair2.getLeft()); assertNull(pair2.getLeft());
assertEquals("bar", pair2.right); assertEquals("bar", pair2.right);
assertEquals("bar", pair2.getRight()); assertEquals("bar", pair2.getRight());
ImmutablePair pair3 = ImmutablePair.of(null, null); final ImmutablePair pair3 = ImmutablePair.of(null, null);
assertNull(pair3.left); assertNull(pair3.left);
assertNull(pair3.right); assertNull(pair3.right);
} }
@ -182,11 +182,11 @@ public void testToString() {
@Test @Test
public void testUseAsKeyOfHashMap() { public void testUseAsKeyOfHashMap() {
HashMap<ImmutablePair<Object, Object>, String> map = new HashMap<>(); final HashMap<ImmutablePair<Object, Object>, String> map = new HashMap<>();
Object o1 = new Object(); final Object o1 = new Object();
Object o2 = new Object(); final Object o2 = new Object();
ImmutablePair<Object, Object> key1 = ImmutablePair.of(o1, o2); final ImmutablePair<Object, Object> key1 = ImmutablePair.of(o1, o2);
String value1 = "a1"; final String value1 = "a1";
map.put(key1, value1); map.put(key1, value1);
assertEquals(value1, map.get(key1)); assertEquals(value1, map.get(key1));
assertEquals(value1, map.get(ImmutablePair.of(o1, o2))); assertEquals(value1, map.get(ImmutablePair.of(o1, o2)));
@ -194,17 +194,17 @@ public void testUseAsKeyOfHashMap() {
@Test @Test
public void testUseAsKeyOfTreeMap() { public void testUseAsKeyOfTreeMap() {
TreeMap<ImmutablePair<Integer, Integer>, String> map = new TreeMap<>(); final TreeMap<ImmutablePair<Integer, Integer>, String> map = new TreeMap<>();
map.put(ImmutablePair.of(1, 2), "12"); map.put(ImmutablePair.of(1, 2), "12");
map.put(ImmutablePair.of(1, 1), "11"); map.put(ImmutablePair.of(1, 1), "11");
map.put(ImmutablePair.of(0, 1), "01"); map.put(ImmutablePair.of(0, 1), "01");
ArrayList<ImmutablePair<Integer, Integer>> expected = new ArrayList<>(); final ArrayList<ImmutablePair<Integer, Integer>> expected = new ArrayList<>();
expected.add(ImmutablePair.of(0, 1)); expected.add(ImmutablePair.of(0, 1));
expected.add(ImmutablePair.of(1, 1)); expected.add(ImmutablePair.of(1, 1));
expected.add(ImmutablePair.of(1, 2)); expected.add(ImmutablePair.of(1, 2));
Iterator<Entry<ImmutablePair<Integer, Integer>, String>> it = map.entrySet().iterator(); final Iterator<Entry<ImmutablePair<Integer, Integer>, String>> it = map.entrySet().iterator();
for (ImmutablePair<Integer, Integer> item : expected) { for (final ImmutablePair<Integer, Integer> item : expected) {
Entry<ImmutablePair<Integer, Integer>, String> entry = it.next(); final Entry<ImmutablePair<Integer, Integer>, String> entry = it.next();
assertEquals(item, entry.getKey()); assertEquals(item, entry.getKey());
assertEquals(item.getLeft() + "" + item.getRight(), entry.getValue()); assertEquals(item.getLeft() + "" + item.getRight(), entry.getValue());
} }

View File

@ -163,12 +163,12 @@ public void testTripleOf() {
@Test @Test
public void testUseAsKeyOfHashMap() { public void testUseAsKeyOfHashMap() {
HashMap<ImmutableTriple<Object, Object, Object>, String> map = new HashMap<>(); final HashMap<ImmutableTriple<Object, Object, Object>, String> map = new HashMap<>();
Object o1 = new Object(); final Object o1 = new Object();
Object o2 = new Object(); final Object o2 = new Object();
Object o3 = new Object(); final Object o3 = new Object();
ImmutableTriple<Object, Object, Object> key1 = ImmutableTriple.of(o1, o2, o3); final ImmutableTriple<Object, Object, Object> key1 = ImmutableTriple.of(o1, o2, o3);
String value1 = "a1"; final String value1 = "a1";
map.put(key1, value1); map.put(key1, value1);
assertEquals(value1, map.get(key1)); assertEquals(value1, map.get(key1));
assertEquals(value1, map.get(ImmutableTriple.of(o1, o2, o3))); assertEquals(value1, map.get(ImmutableTriple.of(o1, o2, o3)));
@ -176,17 +176,17 @@ public void testUseAsKeyOfHashMap() {
@Test @Test
public void testUseAsKeyOfTreeMap() { public void testUseAsKeyOfTreeMap() {
TreeMap<ImmutableTriple<Integer, Integer, Integer>, String> map = new TreeMap<>(); final TreeMap<ImmutableTriple<Integer, Integer, Integer>, String> map = new TreeMap<>();
map.put(ImmutableTriple.of(0, 1, 2), "012"); map.put(ImmutableTriple.of(0, 1, 2), "012");
map.put(ImmutableTriple.of(0, 1, 1), "011"); map.put(ImmutableTriple.of(0, 1, 1), "011");
map.put(ImmutableTriple.of(0, 0, 1), "001"); map.put(ImmutableTriple.of(0, 0, 1), "001");
ArrayList<ImmutableTriple<Integer, Integer, Integer>> expected = new ArrayList<>(); final ArrayList<ImmutableTriple<Integer, Integer, Integer>> expected = new ArrayList<>();
expected.add(ImmutableTriple.of(0, 0, 1)); expected.add(ImmutableTriple.of(0, 0, 1));
expected.add(ImmutableTriple.of(0, 1, 1)); expected.add(ImmutableTriple.of(0, 1, 1));
expected.add(ImmutableTriple.of(0, 1, 2)); expected.add(ImmutableTriple.of(0, 1, 2));
Iterator<Entry<ImmutableTriple<Integer, Integer, Integer>, String>> it = map.entrySet().iterator(); final Iterator<Entry<ImmutableTriple<Integer, Integer, Integer>, String>> it = map.entrySet().iterator();
for (ImmutableTriple<Integer, Integer, Integer> item : expected) { for (final ImmutableTriple<Integer, Integer, Integer> item : expected) {
Entry<ImmutableTriple<Integer, Integer, Integer>, String> entry = it.next(); final Entry<ImmutableTriple<Integer, Integer, Integer>, String> entry = it.next();
assertEquals(item, entry.getKey()); assertEquals(item, entry.getKey());
assertEquals(item.getLeft() + "" + item.getMiddle() + "" + item.getRight(), entry.getValue()); assertEquals(item.getLeft() + "" + item.getMiddle() + "" + item.getRight(), entry.getValue());
} }

View File

@ -123,7 +123,7 @@ public void testPairOfObjects() {
final MutablePair<Object, String> pair2 = MutablePair.of(null, "bar"); final MutablePair<Object, String> pair2 = MutablePair.of(null, "bar");
assertNull(pair2.getLeft()); assertNull(pair2.getLeft());
assertEquals("bar", pair2.getRight()); assertEquals("bar", pair2.getRight());
MutablePair pair3 = MutablePair.of(null, null); final MutablePair pair3 = MutablePair.of(null, null);
assertNull(pair3.left); assertNull(pair3.left);
assertNull(pair3.right); assertNull(pair3.right);
} }

View File

@ -123,7 +123,7 @@ public void testPairOfObjects() {
assertTrue(pair2 instanceof ImmutablePair<?, ?>); assertTrue(pair2 instanceof ImmutablePair<?, ?>);
assertNull(((ImmutablePair<Object, String>) pair2).left); assertNull(((ImmutablePair<Object, String>) pair2).left);
assertEquals("bar", ((ImmutablePair<Object, String>) pair2).right); assertEquals("bar", ((ImmutablePair<Object, String>) pair2).right);
Pair pair3 = Pair.of(null, null); final Pair pair3 = Pair.of(null, null);
assertNull(pair3.getLeft()); assertNull(pair3.getLeft());
assertNull(pair3.getRight()); assertNull(pair3.getRight());
} }