[LANG-1525] Internally use Validate.notNull(foo, ...) instead of

Validate.isTrue(foo != null, ...).
This commit is contained in:
Gary Gregory 2020-03-06 11:08:22 -05:00
parent 200d8e9745
commit ba607f525b
40 changed files with 176 additions and 177 deletions

View File

@ -106,6 +106,7 @@ The <action> type attribute can be add,update,fix,remove.
<action type="update" dev="ggregory" due-to="Peter Verhas">Reuse own code in Functions.java #493.</action> <action type="update" dev="ggregory" due-to="Peter Verhas">Reuse own code in Functions.java #493.</action>
<action issue="LANG-1518" type="fix" dev="ggregory" due-to="Michele Preti, Bruno P. Kinoshita, Gary Gregory">MethodUtils.getAnnotation() with searchSupers = true does not work if super is generic #494.</action> <action issue="LANG-1518" type="fix" dev="ggregory" due-to="Michele Preti, Bruno P. Kinoshita, Gary Gregory">MethodUtils.getAnnotation() with searchSupers = true does not work if super is generic #494.</action>
<action issue="LANG-1523" type="update" dev="ggregory" due-to="Edgar Asatryan, Bruno P. Kinoshita, Gary Gregory">Avoid unnecessary allocation in StringUtils.wrapIfMissing. #496.</action> <action issue="LANG-1523" type="update" dev="ggregory" due-to="Edgar Asatryan, Bruno P. Kinoshita, Gary Gregory">Avoid unnecessary allocation in StringUtils.wrapIfMissing. #496.</action>
<action issue="LANG-1525" type="update" dev="ggregory" due-to="Edgar Asatryan, Bruno P. Kinoshita, Gary Gregory">Internally use Validate.notNull(foo, ...) instead of Validate.isTrue(foo != null, ...).</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

@ -179,7 +179,7 @@ final class CharRange implements Iterable<Character>, Serializable {
* @throws IllegalArgumentException if {@code null} input * @throws IllegalArgumentException if {@code null} input
*/ */
public boolean contains(final CharRange range) { public boolean contains(final CharRange range) {
Validate.isTrue(range != null, "The Range must not be null"); Validate.notNull(range, "The Range must not be null");
if (negated) { if (negated) {
if (range.negated) { if (range.negated) {
return start >= range.start && end <= range.end; return start >= range.start && end <= range.end;

View File

@ -134,7 +134,7 @@ public class CharUtils {
* @throws IllegalArgumentException if the Character is null * @throws IllegalArgumentException if the Character is null
*/ */
public static char toChar(final Character ch) { public static char toChar(final Character ch) {
Validate.isTrue(ch != null, "The Character must not be null"); Validate.notNull(ch, "The Character must not be null");
return ch.charValue(); return ch.charValue();
} }
@ -175,7 +175,7 @@ public class CharUtils {
* @throws IllegalArgumentException if the String is empty * @throws IllegalArgumentException if the String is empty
*/ */
public static char toChar(final String str) { public static char toChar(final String str) {
Validate.isTrue(StringUtils.isNotEmpty(str), "The String must not be empty"); Validate.notEmpty(str, "The String must not be empty");
return str.charAt(0); return str.charAt(0);
} }
@ -263,7 +263,7 @@ public class CharUtils {
* @throws IllegalArgumentException if the Character is not ASCII numeric or is null * @throws IllegalArgumentException if the Character is not ASCII numeric or is null
*/ */
public static int toIntValue(final Character ch) { public static int toIntValue(final Character ch) {
Validate.isTrue(ch != null, "The character must not be null"); Validate.notNull(ch, "The character must not be null");
return toIntValue(ch.charValue()); return toIntValue(ch.charValue());
} }

View File

@ -116,7 +116,7 @@ public class EnumUtils {
Validate.notNull(values); Validate.notNull(values);
long total = 0; long total = 0;
for (final E constant : values) { for (final E constant : values) {
Validate.isTrue(constant != null, NULL_ELEMENTS_NOT_PERMITTED); Validate.notNull(constant, NULL_ELEMENTS_NOT_PERMITTED);
total |= 1L << constant.ordinal(); total |= 1L << constant.ordinal();
} }
return total; return total;
@ -173,7 +173,7 @@ public class EnumUtils {
Validate.notNull(values); Validate.notNull(values);
final EnumSet<E> condensed = EnumSet.noneOf(enumClass); final EnumSet<E> condensed = EnumSet.noneOf(enumClass);
for (final E constant : values) { for (final E constant : values) {
Validate.isTrue(constant != null, NULL_ELEMENTS_NOT_PERMITTED); Validate.notNull(constant, NULL_ELEMENTS_NOT_PERMITTED);
condensed.add(constant); condensed.add(constant);
} }
final long[] result = new long[(enumClass.getEnumConstants().length - 1) / Long.SIZE + 1]; final long[] result = new long[(enumClass.getEnumConstants().length - 1) / Long.SIZE + 1];

View File

@ -133,7 +133,7 @@ public class SerializationUtils {
* @throws SerializationException (runtime) if the serialization fails * @throws SerializationException (runtime) if the serialization fails
*/ */
public static void serialize(final Serializable obj, final OutputStream outputStream) { public static void serialize(final Serializable obj, final OutputStream outputStream) {
Validate.isTrue(outputStream != null, "The OutputStream must not be null"); Validate.notNull(outputStream, "The OutputStream must not be null");
try (ObjectOutputStream out = new ObjectOutputStream(outputStream)) { try (ObjectOutputStream out = new ObjectOutputStream(outputStream)) {
out.writeObject(obj); out.writeObject(obj);
} catch (final IOException ex) { } catch (final IOException ex) {
@ -188,7 +188,7 @@ public class SerializationUtils {
* (runtime) if the serialization fails * (runtime) if the serialization fails
*/ */
public static <T> T deserialize(final InputStream inputStream) { public static <T> T deserialize(final InputStream inputStream) {
Validate.isTrue(inputStream != null, "The InputStream must not be null"); Validate.notNull(inputStream, "The InputStream must not be null");
try (ObjectInputStream in = new ObjectInputStream(inputStream)) { try (ObjectInputStream in = new ObjectInputStream(inputStream)) {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
final T obj = (T) in.readObject(); final T obj = (T) in.readObject();
@ -219,7 +219,7 @@ public class SerializationUtils {
* (runtime) if the serialization fails * (runtime) if the serialization fails
*/ */
public static <T> T deserialize(final byte[] objectData) { public static <T> T deserialize(final byte[] objectData) {
Validate.isTrue(objectData != null, "The byte[] must not be null"); Validate.notNull(objectData, "The byte[] must not be null");
return deserialize(new ByteArrayInputStream(objectData)); return deserialize(new ByteArrayInputStream(objectData));
} }

View File

@ -50,7 +50,7 @@ public class ThreadUtils {
* thread groups from this thread's thread group up to the system thread group * thread groups from this thread's thread group up to the system thread group
*/ */
public static Thread findThreadById(final long threadId, final ThreadGroup threadGroup) { public static Thread findThreadById(final long threadId, final ThreadGroup threadGroup) {
Validate.isTrue(threadGroup != null, "The thread group must not be null"); Validate.notNull(threadGroup, "The thread group must not be null");
final Thread thread = findThreadById(threadId); final Thread thread = findThreadById(threadId);
if (thread != null && threadGroup.equals(thread.getThreadGroup())) { if (thread != null && threadGroup.equals(thread.getThreadGroup())) {
return thread; return thread;
@ -73,7 +73,7 @@ public class ThreadUtils {
* thread groups from this thread's thread group up to the system thread group * thread groups from this thread's thread group up to the system thread group
*/ */
public static Thread findThreadById(final long threadId, final String threadGroupName) { public static Thread findThreadById(final long threadId, final String threadGroupName) {
Validate.isTrue(threadGroupName != null, "The thread group name must not be null"); Validate.notNull(threadGroupName, "The thread group name must not be null");
final Thread thread = findThreadById(threadId); final Thread thread = findThreadById(threadId);
if (thread != null && thread.getThreadGroup() != null && thread.getThreadGroup().getName().equals(threadGroupName)) { if (thread != null && thread.getThreadGroup() != null && thread.getThreadGroup().getName().equals(threadGroupName)) {
return thread; return thread;
@ -114,8 +114,8 @@ public class ThreadUtils {
* thread groups from this thread's thread group up to the system thread group * thread groups from this thread's thread group up to the system thread group
*/ */
public static Collection<Thread> findThreadsByName(final String threadName, final String threadGroupName) { public static Collection<Thread> findThreadsByName(final String threadName, final String threadGroupName) {
Validate.isTrue(threadName != null, "The thread name must not be null"); Validate.notNull(threadName, "The thread name must not be null");
Validate.isTrue(threadGroupName != null, "The thread group name must not be null"); Validate.notNull(threadGroupName, "The thread group name must not be null");
final Collection<ThreadGroup> threadGroups = findThreadGroups(new NamePredicate(threadGroupName)); final Collection<ThreadGroup> threadGroups = findThreadGroups(new NamePredicate(threadGroupName));
@ -305,7 +305,7 @@ public class ThreadUtils {
*/ */
public NamePredicate(final String name) { public NamePredicate(final String name) {
super(); super();
Validate.isTrue(name != null, "The name must not be null"); Validate.notNull(name, "The name must not be null");
this.name = name; this.name = name;
} }
@ -390,8 +390,8 @@ public class ThreadUtils {
* thread groups from this thread's thread group up to the system thread group * thread groups from this thread's thread group up to the system thread group
*/ */
public static Collection<Thread> findThreads(final ThreadGroup group, final boolean recurse, final ThreadPredicate predicate) { public static Collection<Thread> findThreads(final ThreadGroup group, final boolean recurse, final ThreadPredicate predicate) {
Validate.isTrue(group != null, "The group must not be null"); Validate.notNull(group, "The group must not be null");
Validate.isTrue(predicate != null, "The predicate must not be null"); Validate.notNull(predicate, "The predicate must not be null");
int count = group.activeCount(); int count = group.activeCount();
Thread[] threads; Thread[] threads;
@ -422,8 +422,8 @@ public class ThreadUtils {
* thread groups from this thread's thread group up to the system thread group * thread groups from this thread's thread group up to the system thread group
*/ */
public static Collection<ThreadGroup> findThreadGroups(final ThreadGroup group, final boolean recurse, final ThreadGroupPredicate predicate) { public static Collection<ThreadGroup> findThreadGroups(final ThreadGroup group, final boolean recurse, final ThreadGroupPredicate predicate) {
Validate.isTrue(group != null, "The group must not be null"); Validate.notNull(group, "The group must not be null");
Validate.isTrue(predicate != null, "The predicate must not be null"); Validate.notNull(predicate, "The predicate must not be null");
int count = group.activeGroupCount(); int count = group.activeGroupCount();
ThreadGroup[] threadGroups; ThreadGroup[] threadGroups;

View File

@ -104,8 +104,8 @@ public class DiffBuilder<T> implements Builder<DiffResult<T>> {
public DiffBuilder(final T lhs, final T rhs, public DiffBuilder(final T lhs, final T rhs,
final ToStringStyle style, final boolean testTriviallyEqual) { final ToStringStyle style, final boolean testTriviallyEqual) {
Validate.isTrue(lhs != null, "lhs cannot be null"); Validate.notNull(lhs, "lhs cannot be null");
Validate.isTrue(rhs != null, "rhs cannot be null"); Validate.notNull(rhs, "rhs cannot be null");
this.diffs = new ArrayList<>(); this.diffs = new ArrayList<>();
this.left = lhs; this.left = lhs;
@ -950,7 +950,7 @@ public class DiffBuilder<T> implements Builder<DiffResult<T>> {
public DiffBuilder<T> append(final String fieldName, public DiffBuilder<T> append(final String fieldName,
final DiffResult<T> diffResult) { final DiffResult<T> diffResult) {
validateFieldNameNotNull(fieldName); validateFieldNameNotNull(fieldName);
Validate.isTrue(diffResult != null, "Diff result cannot be null"); Validate.notNull(diffResult, "Diff result cannot be null");
if (objectsTriviallyEqual) { if (objectsTriviallyEqual) {
return this; return this;
} }
@ -978,7 +978,7 @@ public class DiffBuilder<T> implements Builder<DiffResult<T>> {
} }
private void validateFieldNameNotNull(final String fieldName) { private void validateFieldNameNotNull(final String fieldName) {
Validate.isTrue(fieldName != null, "Field name cannot be null"); Validate.notNull(fieldName, "Field name cannot be null");
} }
} }

View File

@ -74,9 +74,9 @@ public class DiffResult<T> implements Iterable<Diff<?>> {
*/ */
DiffResult(final T lhs, final T rhs, final List<Diff<?>> diffs, DiffResult(final T lhs, final T rhs, final List<Diff<?>> diffs,
final ToStringStyle style) { final ToStringStyle style) {
Validate.isTrue(lhs != null, "Left hand object cannot be null"); Validate.notNull(lhs, "Left hand object cannot be null");
Validate.isTrue(rhs != null, "Right hand object cannot be null"); Validate.notNull(rhs, "Right hand object cannot be null");
Validate.isTrue(diffs != null, "List of differences cannot be null"); Validate.notNull(diffs, "List of differences cannot be null");
this.diffs = diffs; this.diffs = diffs;
this.lhs = lhs; this.lhs = lhs;

View File

@ -358,7 +358,7 @@ public class HashCodeBuilder implements Builder<Integer> {
*/ */
public static <T> int reflectionHashCode(final int initialNonZeroOddNumber, final int multiplierNonZeroOddNumber, final T object, public static <T> int reflectionHashCode(final int initialNonZeroOddNumber, final int multiplierNonZeroOddNumber, final T object,
final boolean testTransients, final Class<? super T> reflectUpToClass, final String... excludeFields) { final boolean testTransients, final Class<? super T> reflectUpToClass, final String... excludeFields) {
Validate.isTrue(object != null, "The object to build a hash code for must not be null"); Validate.notNull(object, "The object to build a hash code for must not be null");
final HashCodeBuilder builder = new HashCodeBuilder(initialNonZeroOddNumber, multiplierNonZeroOddNumber); final HashCodeBuilder builder = new HashCodeBuilder(initialNonZeroOddNumber, multiplierNonZeroOddNumber);
Class<?> clazz = object.getClass(); Class<?> clazz = object.getClass();
reflectionAppend(object, clazz, builder, testTransients, excludeFields); reflectionAppend(object, clazz, builder, testTransients, excludeFields);

View File

@ -434,8 +434,7 @@ public class ReflectionToStringBuilder extends ToStringBuilder {
} }
private static Object checkNotNull(final Object obj) { private static Object checkNotNull(final Object obj) {
Validate.isTrue(obj != null, "The Object passed in should not be null."); return Validate.notNull(obj, "The Object passed in should not be null.");
return obj;
} }
/** /**

View File

@ -133,8 +133,7 @@ public class ToStringBuilder implements Builder<String> {
* @throws IllegalArgumentException if the style is {@code null} * @throws IllegalArgumentException if the style is {@code null}
*/ */
public static void setDefaultStyle(final ToStringStyle style) { public static void setDefaultStyle(final ToStringStyle style) {
Validate.isTrue(style != null, "The style must not be null"); defaultStyle = Validate.notNull(style, "The style must not be null");
defaultStyle = style;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------

View File

@ -120,6 +120,6 @@ public class CallableBackgroundInitializer<T> extends BackgroundInitializer<T> {
* @throws IllegalArgumentException if the {@code Callable} is <b>null</b> * @throws IllegalArgumentException if the {@code Callable} is <b>null</b>
*/ */
private void checkCallable(final Callable<T> call) { private void checkCallable(final Callable<T> call) {
Validate.isTrue(call != null, "Callable must not be null!"); Validate.notNull(call, "Callable must not be null!");
} }
} }

View File

@ -133,8 +133,8 @@ public class MultiBackgroundInitializer
* @throws IllegalStateException if {@code start()} has already been called * @throws IllegalStateException if {@code start()} has already been called
*/ */
public void addInitializer(final String name, final BackgroundInitializer<?> init) { public void addInitializer(final String name, final BackgroundInitializer<?> init) {
Validate.isTrue(name != null, "Name of child initializer must not be null!"); Validate.notNull(name, "Name of child initializer must not be null!");
Validate.isTrue(init != null, "Child initializer must not be null!"); Validate.notNull(init, "Child initializer must not be null!");
synchronized (this) { synchronized (this) {
if (isStarted()) { if (isStarted()) {

View File

@ -632,7 +632,7 @@ public class ExceptionUtils {
if (throwable == null) { if (throwable == null) {
return; return;
} }
Validate.isTrue(stream != null, "The PrintStream must not be null"); Validate.notNull(stream, "The PrintStream must not be null");
final String trace[] = getRootCauseStackTrace(throwable); final String trace[] = getRootCauseStackTrace(throwable);
for (final String element : trace) { for (final String element : trace) {
stream.println(element); stream.println(element);
@ -663,7 +663,7 @@ public class ExceptionUtils {
if (throwable == null) { if (throwable == null) {
return; return;
} }
Validate.isTrue(writer != null, "The PrintWriter must not be null"); Validate.notNull(writer, "The PrintWriter must not be null");
final String trace[] = getRootCauseStackTrace(throwable); final String trace[] = getRootCauseStackTrace(throwable);
for (final String element : trace) { for (final String element : trace) {
writer.println(element); writer.println(element);

View File

@ -312,7 +312,7 @@ public final class Fraction extends Number implements Comparable<Fraction> {
* @throws NumberFormatException if the number format is invalid * @throws NumberFormatException if the number format is invalid
*/ */
public static Fraction getFraction(String str) { public static Fraction getFraction(String str) {
Validate.isTrue(str != null, "The string must not be null"); Validate.notNull(str, "The string must not be null");
// parse double format // parse double format
int pos = str.indexOf('.'); int pos = str.indexOf('.');
if (pos >= 0) { if (pos >= 0) {
@ -730,7 +730,7 @@ public final class Fraction extends Number implements Comparable<Fraction> {
* cannot be represented in an {@code int}. * cannot be represented in an {@code int}.
*/ */
private Fraction addSub(final Fraction fraction, final boolean isAdd) { private Fraction addSub(final Fraction fraction, final boolean isAdd) {
Validate.isTrue(fraction != null, "The fraction must not be null"); Validate.notNull(fraction, "The fraction must not be null");
// zero is identity for addition. // zero is identity for addition.
if (numerator == 0) { if (numerator == 0) {
return isAdd ? fraction : fraction.negate(); return isAdd ? fraction : fraction.negate();
@ -778,7 +778,7 @@ public final class Fraction extends Number implements Comparable<Fraction> {
* {@code Integer.MAX_VALUE} * {@code Integer.MAX_VALUE}
*/ */
public Fraction multiplyBy(final Fraction fraction) { public Fraction multiplyBy(final Fraction fraction) {
Validate.isTrue(fraction != null, "The fraction must not be null"); Validate.notNull(fraction, "The fraction must not be null");
if (numerator == 0 || fraction.numerator == 0) { if (numerator == 0 || fraction.numerator == 0) {
return ZERO; return ZERO;
} }
@ -801,7 +801,7 @@ public final class Fraction extends Number implements Comparable<Fraction> {
* {@code Integer.MAX_VALUE} * {@code Integer.MAX_VALUE}
*/ */
public Fraction divideBy(final Fraction fraction) { public Fraction divideBy(final Fraction fraction) {
Validate.isTrue(fraction != null, "The fraction must not be null"); Validate.notNull(fraction, "The fraction must not be null");
if (fraction.numerator == 0) { if (fraction.numerator == 0) {
throw new ArithmeticException("The fraction to divide by must not be zero"); throw new ArithmeticException("The fraction to divide by must not be zero");
} }

View File

@ -37,7 +37,7 @@ public class IEEE754rUtils {
* @since 3.4 Changed signature from min(double[]) to min(double...) * @since 3.4 Changed signature from min(double[]) to min(double...)
*/ */
public static double min(final double... array) { public static double min(final double... array) {
Validate.isTrue(array != null, "The Array must not be null"); Validate.notNull(array, "The Array must not be null");
Validate.isTrue(array.length != 0, "Array cannot be empty."); Validate.isTrue(array.length != 0, "Array cannot be empty.");
// Finds and returns min // Finds and returns min
@ -59,7 +59,7 @@ public class IEEE754rUtils {
* @since 3.4 Changed signature from min(float[]) to min(float...) * @since 3.4 Changed signature from min(float[]) to min(float...)
*/ */
public static float min(final float... array) { public static float min(final float... array) {
Validate.isTrue(array != null, "The Array must not be null"); Validate.notNull(array, "The Array must not be null");
Validate.isTrue(array.length != 0, "Array cannot be empty."); Validate.isTrue(array.length != 0, "Array cannot be empty.");
// Finds and returns min // Finds and returns min
@ -149,7 +149,7 @@ public class IEEE754rUtils {
* @since 3.4 Changed signature from max(double[]) to max(double...) * @since 3.4 Changed signature from max(double[]) to max(double...)
*/ */
public static double max(final double... array) { public static double max(final double... array) {
Validate.isTrue(array != null, "The Array must not be null"); Validate.notNull(array, "The Array must not be null");
Validate.isTrue(array.length != 0, "Array cannot be empty."); Validate.isTrue(array.length != 0, "Array cannot be empty.");
// Finds and returns max // Finds and returns max
@ -171,7 +171,7 @@ public class IEEE754rUtils {
* @since 3.4 Changed signature from max(float[]) to max(float...) * @since 3.4 Changed signature from max(float[]) to max(float...)
*/ */
public static float max(final float... array) { public static float max(final float... array) {
Validate.isTrue(array != null, "The Array must not be null"); Validate.notNull(array, "The Array must not be null");
Validate.isTrue(array.length != 0, "Array cannot be empty."); Validate.isTrue(array.length != 0, "Array cannot be empty.");
// Finds and returns max // Finds and returns max

View File

@ -1312,7 +1312,7 @@ public class NumberUtils {
* @throws IllegalArgumentException if {@code array} is either {@code null} or empty * @throws IllegalArgumentException if {@code array} is either {@code null} or empty
*/ */
private static void validateArray(final Object array) { private static void validateArray(final Object array) {
Validate.isTrue(array != null, "The Array must not be null"); Validate.notNull(array, "The Array must not be null");
Validate.isTrue(Array.getLength(array) != 0, "Array cannot be empty."); Validate.isTrue(Array.getLength(array) != 0, "Array cannot be empty.");
} }

View File

@ -86,7 +86,7 @@ public class FieldUtils {
* in the inheritance hierarchy * in the inheritance hierarchy
*/ */
public static Field getField(final Class<?> cls, final String fieldName, final boolean forceAccess) { public static Field getField(final Class<?> cls, final String fieldName, final boolean forceAccess) {
Validate.isTrue(cls != null, "The class must not be null"); Validate.notNull(cls, "The class must not be null");
Validate.isTrue(StringUtils.isNotBlank(fieldName), "The field name must not be blank/empty"); Validate.isTrue(StringUtils.isNotBlank(fieldName), "The field name must not be blank/empty");
// FIXME is this workaround still needed? lang requires Java 6 // FIXME is this workaround still needed? lang requires Java 6
// Sun Java 1.3 has a bugged implementation of getField hence we write the // Sun Java 1.3 has a bugged implementation of getField hence we write the
@ -169,7 +169,7 @@ public class FieldUtils {
* if the class is {@code null}, or the field name is blank or empty * if the class is {@code null}, or the field name is blank or empty
*/ */
public static Field getDeclaredField(final Class<?> cls, final String fieldName, final boolean forceAccess) { public static Field getDeclaredField(final Class<?> cls, final String fieldName, final boolean forceAccess) {
Validate.isTrue(cls != null, "The class must not be null"); Validate.notNull(cls, "The class must not be null");
Validate.isTrue(StringUtils.isNotBlank(fieldName), "The field name must not be blank/empty"); Validate.isTrue(StringUtils.isNotBlank(fieldName), "The field name must not be blank/empty");
try { try {
// only consider the specified class by using getDeclaredField() // only consider the specified class by using getDeclaredField()
@ -214,7 +214,7 @@ public class FieldUtils {
* @since 3.2 * @since 3.2
*/ */
public static List<Field> getAllFieldsList(final Class<?> cls) { public static List<Field> getAllFieldsList(final Class<?> cls) {
Validate.isTrue(cls != null, "The class must not be null"); Validate.notNull(cls, "The class must not be null");
final List<Field> allFields = new ArrayList<>(); final List<Field> allFields = new ArrayList<>();
Class<?> currentClass = cls; Class<?> currentClass = cls;
while (currentClass != null) { while (currentClass != null) {
@ -253,7 +253,7 @@ public class FieldUtils {
* @since 3.4 * @since 3.4
*/ */
public static List<Field> getFieldsListWithAnnotation(final Class<?> cls, final Class<? extends Annotation> annotationCls) { public static List<Field> getFieldsListWithAnnotation(final Class<?> cls, final Class<? extends Annotation> annotationCls) {
Validate.isTrue(annotationCls != null, "The annotation class must not be null"); Validate.notNull(annotationCls, "The annotation class must not be null");
final List<Field> allFields = getAllFieldsList(cls); final List<Field> allFields = getAllFieldsList(cls);
final List<Field> annotatedFields = new ArrayList<>(); final List<Field> annotatedFields = new ArrayList<>();
for (final Field field : allFields) { for (final Field field : allFields) {
@ -294,7 +294,7 @@ public class FieldUtils {
* if the field is not made accessible * if the field is not made accessible
*/ */
public static Object readStaticField(final Field field, final boolean forceAccess) throws IllegalAccessException { public static Object readStaticField(final Field field, final boolean forceAccess) throws IllegalAccessException {
Validate.isTrue(field != null, "The field must not be null"); Validate.notNull(field, "The field must not be null");
Validate.isTrue(Modifier.isStatic(field.getModifiers()), "The field '%s' is not static", field.getName()); Validate.isTrue(Modifier.isStatic(field.getModifiers()), "The field '%s' is not static", field.getName());
return readField(field, (Object) null, forceAccess); return readField(field, (Object) null, forceAccess);
} }
@ -337,7 +337,7 @@ public class FieldUtils {
*/ */
public static Object readStaticField(final Class<?> cls, final String fieldName, final boolean forceAccess) throws IllegalAccessException { public static Object readStaticField(final Class<?> cls, final String fieldName, final boolean forceAccess) throws IllegalAccessException {
final Field field = getField(cls, fieldName, forceAccess); final Field field = getField(cls, fieldName, forceAccess);
Validate.isTrue(field != null, "Cannot locate field '%s' on %s", fieldName, cls); Validate.notNull(field, "Cannot locate field '%s' on %s", fieldName, cls);
// already forced access above, don't repeat it here: // already forced access above, don't repeat it here:
return readStaticField(field, false); return readStaticField(field, false);
} }
@ -381,7 +381,7 @@ public class FieldUtils {
*/ */
public static Object readDeclaredStaticField(final Class<?> cls, final String fieldName, final boolean forceAccess) throws IllegalAccessException { public static Object readDeclaredStaticField(final Class<?> cls, final String fieldName, final boolean forceAccess) throws IllegalAccessException {
final Field field = getDeclaredField(cls, fieldName, forceAccess); final Field field = getDeclaredField(cls, fieldName, forceAccess);
Validate.isTrue(field != null, "Cannot locate declared field %s.%s", cls.getName(), fieldName); Validate.notNull(field, "Cannot locate declared field %s.%s", cls.getName(), fieldName);
// already forced access above, don't repeat it here: // already forced access above, don't repeat it here:
return readStaticField(field, false); return readStaticField(field, false);
} }
@ -420,7 +420,7 @@ public class FieldUtils {
* if the field is not made accessible * if the field is not made accessible
*/ */
public static Object readField(final Field field, final Object target, final boolean forceAccess) throws IllegalAccessException { public static Object readField(final Field field, final Object target, final boolean forceAccess) throws IllegalAccessException {
Validate.isTrue(field != null, "The field must not be null"); Validate.notNull(field, "The field must not be null");
if (forceAccess && !field.isAccessible()) { if (forceAccess && !field.isAccessible()) {
field.setAccessible(true); field.setAccessible(true);
} else { } else {
@ -464,7 +464,7 @@ public class FieldUtils {
* if the named field is not made accessible * if the named field is not made accessible
*/ */
public static Object readField(final Object target, final String fieldName, final boolean forceAccess) throws IllegalAccessException { public static Object readField(final Object target, final String fieldName, final boolean forceAccess) throws IllegalAccessException {
Validate.isTrue(target != null, "target object must not be null"); Validate.notNull(target, "target object must not be null");
final Class<?> cls = target.getClass(); final Class<?> cls = target.getClass();
final Field field = getField(cls, fieldName, forceAccess); final Field field = getField(cls, fieldName, forceAccess);
Validate.isTrue(field != null, "Cannot locate field %s on %s", fieldName, cls); Validate.isTrue(field != null, "Cannot locate field %s on %s", fieldName, cls);
@ -507,7 +507,7 @@ public class FieldUtils {
* if the field is not made accessible * if the field is not made accessible
*/ */
public static Object readDeclaredField(final Object target, final String fieldName, final boolean forceAccess) throws IllegalAccessException { public static Object readDeclaredField(final Object target, final String fieldName, final boolean forceAccess) throws IllegalAccessException {
Validate.isTrue(target != null, "target object must not be null"); Validate.notNull(target, "target object must not be null");
final Class<?> cls = target.getClass(); final Class<?> cls = target.getClass();
final Field field = getDeclaredField(cls, fieldName, forceAccess); final Field field = getDeclaredField(cls, fieldName, forceAccess);
Validate.isTrue(field != null, "Cannot locate declared field %s.%s", cls, fieldName); Validate.isTrue(field != null, "Cannot locate declared field %s.%s", cls, fieldName);
@ -548,7 +548,7 @@ public class FieldUtils {
* if the field is not made accessible or is {@code final} * if the field is not made accessible or is {@code final}
*/ */
public static void writeStaticField(final Field field, final Object value, final boolean forceAccess) throws IllegalAccessException { public static void writeStaticField(final Field field, final Object value, final boolean forceAccess) throws IllegalAccessException {
Validate.isTrue(field != null, "The field must not be null"); Validate.notNull(field, "The field must not be null");
Validate.isTrue(Modifier.isStatic(field.getModifiers()), "The field %s.%s is not static", field.getDeclaringClass().getName(), Validate.isTrue(Modifier.isStatic(field.getModifiers()), "The field %s.%s is not static", field.getDeclaringClass().getName(),
field.getName()); field.getName());
writeField(field, (Object) null, value, forceAccess); writeField(field, (Object) null, value, forceAccess);
@ -595,7 +595,7 @@ public class FieldUtils {
public static void writeStaticField(final Class<?> cls, final String fieldName, final Object value, final boolean forceAccess) public static void writeStaticField(final Class<?> cls, final String fieldName, final Object value, final boolean forceAccess)
throws IllegalAccessException { throws IllegalAccessException {
final Field field = getField(cls, fieldName, forceAccess); final Field field = getField(cls, fieldName, forceAccess);
Validate.isTrue(field != null, "Cannot locate field %s on %s", fieldName, cls); Validate.notNull(field, "Cannot locate field %s on %s", fieldName, cls);
// already forced access above, don't repeat it here: // already forced access above, don't repeat it here:
writeStaticField(field, value, false); writeStaticField(field, value, false);
} }
@ -640,7 +640,7 @@ public class FieldUtils {
public static void writeDeclaredStaticField(final Class<?> cls, final String fieldName, final Object value, final boolean forceAccess) public static void writeDeclaredStaticField(final Class<?> cls, final String fieldName, final Object value, final boolean forceAccess)
throws IllegalAccessException { throws IllegalAccessException {
final Field field = getDeclaredField(cls, fieldName, forceAccess); final Field field = getDeclaredField(cls, fieldName, forceAccess);
Validate.isTrue(field != null, "Cannot locate declared field %s.%s", cls.getName(), fieldName); Validate.notNull(field, "Cannot locate declared field %s.%s", cls.getName(), fieldName);
// already forced access above, don't repeat it here: // already forced access above, don't repeat it here:
writeField(field, (Object) null, value, false); writeField(field, (Object) null, value, false);
} }
@ -682,7 +682,7 @@ public class FieldUtils {
*/ */
public static void writeField(final Field field, final Object target, final Object value, final boolean forceAccess) public static void writeField(final Field field, final Object target, final Object value, final boolean forceAccess)
throws IllegalAccessException { throws IllegalAccessException {
Validate.isTrue(field != null, "The field must not be null"); Validate.notNull(field, "The field must not be null");
if (forceAccess && !field.isAccessible()) { if (forceAccess && !field.isAccessible()) {
field.setAccessible(true); field.setAccessible(true);
} else { } else {
@ -722,7 +722,7 @@ public class FieldUtils {
*/ */
@Deprecated @Deprecated
public static void removeFinalModifier(final Field field, final boolean forceAccess) { public static void removeFinalModifier(final Field field, final boolean forceAccess) {
Validate.isTrue(field != null, "The field must not be null"); Validate.notNull(field, "The field must not be null");
try { try {
if (Modifier.isFinal(field.getModifiers())) { if (Modifier.isFinal(field.getModifiers())) {
@ -791,7 +791,7 @@ public class FieldUtils {
*/ */
public static void writeField(final Object target, final String fieldName, final Object value, final boolean forceAccess) public static void writeField(final Object target, final String fieldName, final Object value, final boolean forceAccess)
throws IllegalAccessException { throws IllegalAccessException {
Validate.isTrue(target != null, "target object must not be null"); Validate.notNull(target, "target object must not be null");
final Class<?> cls = target.getClass(); final Class<?> cls = target.getClass();
final Field field = getField(cls, fieldName, forceAccess); final Field field = getField(cls, fieldName, forceAccess);
Validate.isTrue(field != null, "Cannot locate declared field %s.%s", cls.getName(), fieldName); Validate.isTrue(field != null, "Cannot locate declared field %s.%s", cls.getName(), fieldName);
@ -839,7 +839,7 @@ public class FieldUtils {
*/ */
public static void writeDeclaredField(final Object target, final String fieldName, final Object value, final boolean forceAccess) public static void writeDeclaredField(final Object target, final String fieldName, final Object value, final boolean forceAccess)
throws IllegalAccessException { throws IllegalAccessException {
Validate.isTrue(target != null, "target object must not be null"); Validate.notNull(target, "target object must not be null");
final Class<?> cls = target.getClass(); final Class<?> cls = target.getClass();
final Field field = getDeclaredField(cls, fieldName, forceAccess); final Field field = getDeclaredField(cls, fieldName, forceAccess);
Validate.isTrue(field != null, "Cannot locate declared field %s.%s", cls.getName(), fieldName); Validate.isTrue(field != null, "Cannot locate declared field %s.%s", cls.getName(), fieldName);

View File

@ -914,7 +914,7 @@ public class MethodUtils {
final Class<? extends Annotation> annotationCls, final Class<? extends Annotation> annotationCls,
final boolean searchSupers, final boolean ignoreAccess) { final boolean searchSupers, final boolean ignoreAccess) {
Validate.isTrue(cls != null, "The class must not be null"); Validate.notNull(cls, "The class must not be null");
Validate.isTrue(annotationCls != null, "The annotation class must not be null"); Validate.isTrue(annotationCls != null, "The annotation class must not be null");
final List<Class<?>> classes = (searchSupers ? getAllSuperclassesAndInterfaces(cls) final List<Class<?>> classes = (searchSupers ? getAllSuperclassesAndInterfaces(cls)
: new ArrayList<>()); : new ArrayList<>());
@ -957,7 +957,7 @@ public class MethodUtils {
public static <A extends Annotation> A getAnnotation(final Method method, final Class<A> annotationCls, public static <A extends Annotation> A getAnnotation(final Method method, final Class<A> annotationCls,
final boolean searchSupers, final boolean ignoreAccess) { final boolean searchSupers, final boolean ignoreAccess) {
Validate.isTrue(method != null, "The method must not be null"); Validate.notNull(method, "The method must not be null");
Validate.isTrue(annotationCls != null, "The annotation class must not be null"); Validate.isTrue(annotationCls != null, "The annotation class must not be null");
if (!ignoreAccess && !MemberUtils.isAccessible(method)) { if (!ignoreAccess && !MemberUtils.isAccessible(method)) {
return null; return null;

View File

@ -1786,7 +1786,7 @@ public class DateUtils {
} }
private static void validateDateNotNull(final Date date) { private static void validateDateNotNull(final Date date) {
Validate.isTrue(date != null, "The date must not be null"); Validate.notNull(date, "The date must not be null");
} }
//----------------------------------------------------------------------- //-----------------------------------------------------------------------

View File

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

View File

@ -200,7 +200,7 @@ public class CharUtilsTest {
public void testToChar_Character() { public void testToChar_Character() {
assertEquals('A', CharUtils.toChar(CHARACTER_A)); assertEquals('A', CharUtils.toChar(CHARACTER_A));
assertEquals('B', CharUtils.toChar(CHARACTER_B)); assertEquals('B', CharUtils.toChar(CHARACTER_B));
assertThrows(IllegalArgumentException.class, () -> CharUtils.toChar((Character) null)); assertThrows(NullPointerException.class, () -> CharUtils.toChar((Character) null));
} }
@Test @Test
@ -214,7 +214,7 @@ public class CharUtilsTest {
public void testToChar_String() { public void testToChar_String() {
assertEquals('A', CharUtils.toChar("A")); assertEquals('A', CharUtils.toChar("A"));
assertEquals('B', CharUtils.toChar("BA")); assertEquals('B', CharUtils.toChar("BA"));
assertThrows(IllegalArgumentException.class, () -> CharUtils.toChar((String) null)); assertThrows(NullPointerException.class, () -> CharUtils.toChar((String) null));
assertThrows(IllegalArgumentException.class, () -> CharUtils.toChar("")); assertThrows(IllegalArgumentException.class, () -> CharUtils.toChar(""));
} }
@ -284,7 +284,7 @@ public class CharUtilsTest {
public void testToIntValue_Character() { public void testToIntValue_Character() {
assertEquals(0, CharUtils.toIntValue(Character.valueOf('0'))); assertEquals(0, CharUtils.toIntValue(Character.valueOf('0')));
assertEquals(3, CharUtils.toIntValue(Character.valueOf('3'))); assertEquals(3, CharUtils.toIntValue(Character.valueOf('3')));
assertThrows(IllegalArgumentException.class, () -> CharUtils.toIntValue(null)); assertThrows(NullPointerException.class, () -> CharUtils.toIntValue(null));
assertThrows(IllegalArgumentException.class, () -> CharUtils.toIntValue(CHARACTER_A)); assertThrows(IllegalArgumentException.class, () -> CharUtils.toIntValue(CHARACTER_A));
} }

View File

@ -186,13 +186,13 @@ public class EnumUtilsTest {
@Test @Test
public void test_generateBitVector_nullElement() { public void test_generateBitVector_nullElement() {
assertThrows(IllegalArgumentException.class, assertThrows(NullPointerException.class,
() -> EnumUtils.generateBitVector(Traffic.class, Arrays.asList(Traffic.RED, null))); () -> EnumUtils.generateBitVector(Traffic.class, Arrays.asList(Traffic.RED, null)));
} }
@Test @Test
public void test_generateBitVectors_nullElement() { public void test_generateBitVectors_nullElement() {
assertThrows(IllegalArgumentException.class, assertThrows(NullPointerException.class,
() -> EnumUtils.generateBitVectors(Traffic.class, Arrays.asList(Traffic.RED, null))); () -> EnumUtils.generateBitVectors(Traffic.class, Arrays.asList(Traffic.RED, null)));
} }

View File

@ -141,12 +141,12 @@ public class SerializationUtilsTest {
@Test @Test
public void testSerializeStreamObjNull() { public void testSerializeStreamObjNull() {
assertThrows(IllegalArgumentException.class, () -> SerializationUtils.serialize(iMap, null)); assertThrows(NullPointerException.class, () -> SerializationUtils.serialize(iMap, null));
} }
@Test @Test
public void testSerializeStreamNullNull() { public void testSerializeStreamNullNull() {
assertThrows(IllegalArgumentException.class, () -> SerializationUtils.serialize(null, null)); assertThrows(NullPointerException.class, () -> SerializationUtils.serialize(null, null));
} }
@Test @Test
@ -214,7 +214,7 @@ public class SerializationUtilsTest {
@Test @Test
public void testDeserializeStreamNull() { public void testDeserializeStreamNull() {
assertThrows(IllegalArgumentException.class, () -> SerializationUtils.deserialize((InputStream) null)); assertThrows(NullPointerException.class, () -> SerializationUtils.deserialize((InputStream) null));
} }
@Test @Test
@ -317,7 +317,7 @@ public class SerializationUtilsTest {
@Test @Test
public void testDeserializeBytesNull() { public void testDeserializeBytesNull() {
assertThrows(IllegalArgumentException.class, () -> SerializationUtils.deserialize((byte[]) null)); assertThrows(NullPointerException.class, () -> SerializationUtils.deserialize((byte[]) null));
} }
@Test @Test

View File

@ -42,42 +42,42 @@ public class ThreadUtilsTest {
@Test @Test
public void testNullThreadName() { public void testNullThreadName() {
assertThrows(IllegalArgumentException.class, () -> ThreadUtils.findThreadsByName(null)); assertThrows(NullPointerException.class, () -> ThreadUtils.findThreadsByName(null));
} }
@Test @Test
public void testNullThreadGroupName() { public void testNullThreadGroupName() {
assertThrows(IllegalArgumentException.class, () -> ThreadUtils.findThreadGroupsByName(null)); assertThrows(NullPointerException.class, () -> ThreadUtils.findThreadGroupsByName(null));
} }
@Test @Test
public void testNullThreadThreadGroupName1() { public void testNullThreadThreadGroupName1() {
assertThrows(IllegalArgumentException.class, () -> ThreadUtils.findThreadsByName(null, "tgname")); assertThrows(NullPointerException.class, () -> ThreadUtils.findThreadsByName(null, "tgname"));
} }
@Test @Test
public void testNullThreadThreadGroupName2() { public void testNullThreadThreadGroupName2() {
assertThrows(IllegalArgumentException.class, () -> ThreadUtils.findThreadsByName("tname", (String) null)); assertThrows(NullPointerException.class, () -> ThreadUtils.findThreadsByName("tname", (String) null));
} }
@Test @Test
public void testNullThreadThreadGroupName3() { public void testNullThreadThreadGroupName3() {
assertThrows(IllegalArgumentException.class, () -> ThreadUtils.findThreadsByName(null, (String) null)); assertThrows(NullPointerException.class, () -> ThreadUtils.findThreadsByName(null, (String) null));
} }
@Test @Test
public void testNullThreadThreadGroup1() { public void testNullThreadThreadGroup1() {
assertThrows(IllegalArgumentException.class, () -> ThreadUtils.findThreadsByName("tname", (ThreadGroup) null)); assertThrows(NullPointerException.class, () -> ThreadUtils.findThreadsByName("tname", (ThreadGroup) null));
} }
@Test @Test
public void testNullThreadThreadGroup2() { public void testNullThreadThreadGroup2() {
assertThrows(IllegalArgumentException.class, () -> ThreadUtils.findThreadById(1L, (ThreadGroup) null)); assertThrows(NullPointerException.class, () -> ThreadUtils.findThreadById(1L, (ThreadGroup) null));
} }
@Test @Test
public void testNullThreadThreadGroup3() { public void testNullThreadThreadGroup3() {
assertThrows(IllegalArgumentException.class, () -> ThreadUtils.findThreadsByName(null, (ThreadGroup) null)); assertThrows(NullPointerException.class, () -> ThreadUtils.findThreadsByName(null, (ThreadGroup) null));
} }
@Test @Test
@ -87,24 +87,24 @@ public class ThreadUtilsTest {
@Test @Test
public void testThreadGroupsByIdFail() { public void testThreadGroupsByIdFail() {
assertThrows(IllegalArgumentException.class, assertThrows(NullPointerException.class,
() -> ThreadUtils.findThreadById(Thread.currentThread().getId(), (String) null)); () -> ThreadUtils.findThreadById(Thread.currentThread().getId(), (String) null));
} }
@Test @Test
public void testThreadgroupsNullParent() { public void testThreadgroupsNullParent() {
assertThrows(IllegalArgumentException.class, assertThrows(NullPointerException.class,
() -> ThreadUtils.findThreadGroups(null, true, ThreadUtils.ALWAYS_TRUE_PREDICATE)); () -> ThreadUtils.findThreadGroups(null, true, ThreadUtils.ALWAYS_TRUE_PREDICATE));
} }
@Test @Test
public void testThreadgroupsNullPredicate() { public void testThreadgroupsNullPredicate() {
assertThrows(IllegalArgumentException.class, () -> ThreadUtils.findThreadGroups(null)); assertThrows(NullPointerException.class, () -> ThreadUtils.findThreadGroups(null));
} }
@Test @Test
public void testThreadsNullPredicate() { public void testThreadsNullPredicate() {
assertThrows(IllegalArgumentException.class, () -> ThreadUtils.findThreads(null)); assertThrows(NullPointerException.class, () -> ThreadUtils.findThreads(null));
} }
@Test @Test

View File

@ -308,12 +308,12 @@ public class DiffBuilderTest {
@Test @Test
public void testNullLhs() { public void testNullLhs() {
assertThrows(IllegalArgumentException.class, () -> new DiffBuilder<>(null, this, ToStringStyle.DEFAULT_STYLE)); assertThrows(NullPointerException.class, () -> new DiffBuilder<>(null, this, ToStringStyle.DEFAULT_STYLE));
} }
@Test @Test
public void testNullRhs() { public void testNullRhs() {
assertThrows(IllegalArgumentException.class, () -> new DiffBuilder<>(this, null, ToStringStyle.DEFAULT_STYLE)); assertThrows(NullPointerException.class, () -> new DiffBuilder<>(this, null, ToStringStyle.DEFAULT_STYLE));
} }
@Test @Test

View File

@ -117,19 +117,19 @@ public class DiffResultTest {
@Test @Test
public void testNullLhs() { public void testNullLhs() {
assertThrows(IllegalArgumentException.class, assertThrows(NullPointerException.class,
() -> new DiffResult(null, SIMPLE_FALSE, SIMPLE_TRUE.diff(SIMPLE_FALSE).getDiffs(), SHORT_STYLE)); () -> new DiffResult(null, SIMPLE_FALSE, SIMPLE_TRUE.diff(SIMPLE_FALSE).getDiffs(), SHORT_STYLE));
} }
@Test @Test
public void testNullRhs() { public void testNullRhs() {
assertThrows(IllegalArgumentException.class, assertThrows(NullPointerException.class,
() -> new DiffResult(SIMPLE_TRUE, null, SIMPLE_TRUE.diff(SIMPLE_FALSE).getDiffs(), SHORT_STYLE)); () -> new DiffResult(SIMPLE_TRUE, null, SIMPLE_TRUE.diff(SIMPLE_FALSE).getDiffs(), SHORT_STYLE));
} }
@Test @Test
public void testNullList() { public void testNullList() {
assertThrows(IllegalArgumentException.class, assertThrows(NullPointerException.class,
() -> new DiffResult(SIMPLE_TRUE, SIMPLE_FALSE, null, SHORT_STYLE)); () -> new DiffResult(SIMPLE_TRUE, SIMPLE_FALSE, null, SHORT_STYLE));
} }

View File

@ -180,7 +180,7 @@ public class HashCodeBuilderTest {
@Test @Test
public void testReflectionHashCodeEx3() { public void testReflectionHashCodeEx3() {
assertThrows(IllegalArgumentException.class, () -> HashCodeBuilder.reflectionHashCode(13, 19, null, true)); assertThrows(NullPointerException.class, () -> HashCodeBuilder.reflectionHashCode(13, 19, null, true));
} }
@Test @Test

View File

@ -24,7 +24,7 @@ public class ReflectionToStringBuilderTest {
@Test @Test
public void testConstructorWithNullObject() { public void testConstructorWithNullObject() {
assertThrows(IllegalArgumentException.class, assertThrows(NullPointerException.class,
() -> new ReflectionToStringBuilder(null, ToStringStyle.DEFAULT_STYLE, new StringBuffer())); () -> new ReflectionToStringBuilder(null, ToStringStyle.DEFAULT_STYLE, new StringBuffer()));
} }

View File

@ -81,7 +81,7 @@ public class ToStringBuilderTest {
@Test @Test
public void testSetDefaultEx() { public void testSetDefaultEx() {
assertThrows(IllegalArgumentException.class, () -> ToStringBuilder.setDefaultStyle(null)); assertThrows(NullPointerException.class, () -> ToStringBuilder.setDefaultStyle(null));
} }
@Test @Test
@ -1278,7 +1278,7 @@ public class ToStringBuilderTest {
@Test @Test
public void testReflectionNull() { public void testReflectionNull() {
assertThrows(IllegalArgumentException.class, () -> ReflectionToStringBuilder.toString(null)); assertThrows(NullPointerException.class, () -> ReflectionToStringBuilder.toString(null));
} }
/** /**

View File

@ -39,7 +39,7 @@ public class CallableBackgroundInitializerTest {
*/ */
@Test() @Test()
public void testInitNullCallable() { public void testInitNullCallable() {
assertThrows(IllegalArgumentException.class, () -> new CallableBackgroundInitializer<>(null)); assertThrows(NullPointerException.class, () -> new CallableBackgroundInitializer<>(null));
} }
/** /**
@ -64,7 +64,7 @@ public class CallableBackgroundInitializerTest {
public void testInitExecutorNullCallable() throws InterruptedException { public void testInitExecutorNullCallable() throws InterruptedException {
final ExecutorService exec = Executors.newSingleThreadExecutor(); final ExecutorService exec = Executors.newSingleThreadExecutor();
try { try {
assertThrows(IllegalArgumentException.class, () -> new CallableBackgroundInitializer<Integer>(null, exec)); assertThrows(NullPointerException.class, () -> new CallableBackgroundInitializer<Integer>(null, exec));
} finally { } finally {
exec.shutdown(); exec.shutdown();
exec.awaitTermination(1, TimeUnit.SECONDS); exec.awaitTermination(1, TimeUnit.SECONDS);

View File

@ -72,7 +72,7 @@ public class MultiBackgroundInitializerTest {
*/ */
@Test @Test
public void testAddInitializerNullName() { public void testAddInitializerNullName() {
assertThrows(IllegalArgumentException.class, () -> initializer.addInitializer(null, new ChildBackgroundInitializer())); assertThrows(NullPointerException.class, () -> initializer.addInitializer(null, new ChildBackgroundInitializer()));
} }
/** /**
@ -81,7 +81,7 @@ public class MultiBackgroundInitializerTest {
*/ */
@Test @Test
public void testAddInitializerNullInit() { public void testAddInitializerNullInit() {
assertThrows(IllegalArgumentException.class, () -> initializer.addInitializer(CHILD_INIT, null)); assertThrows(NullPointerException.class, () -> initializer.addInitializer(CHILD_INIT, null));
} }
/** /**

View File

@ -521,7 +521,7 @@ public class ExceptionUtilsTest {
out = new ByteArrayOutputStream(1024); out = new ByteArrayOutputStream(1024);
assertThrows( assertThrows(
IllegalArgumentException.class, NullPointerException.class,
() -> ExceptionUtils.printRootCauseStackTrace(withCause, (PrintStream) null)); () -> ExceptionUtils.printRootCauseStackTrace(withCause, (PrintStream) null));
out = new ByteArrayOutputStream(1024); out = new ByteArrayOutputStream(1024);
@ -545,7 +545,7 @@ public class ExceptionUtilsTest {
writer = new StringWriter(1024); writer = new StringWriter(1024);
assertThrows( assertThrows(
IllegalArgumentException.class, NullPointerException.class,
() -> ExceptionUtils.printRootCauseStackTrace(withCause, (PrintWriter) null)); () -> ExceptionUtils.printRootCauseStackTrace(withCause, (PrintWriter) null));
writer = new StringWriter(1024); writer = new StringWriter(1024);

View File

@ -324,7 +324,7 @@ public class FractionTest {
@Test @Test
public void testFactory_String() { public void testFactory_String() {
assertThrows(IllegalArgumentException.class, () -> Fraction.getFraction(null)); assertThrows(NullPointerException.class, () -> Fraction.getFraction(null));
} }
@ -741,7 +741,7 @@ public class FractionTest {
assertEquals(13*13*17*2*2, fr.getDenominator()); assertEquals(13*13*17*2*2, fr.getDenominator());
assertEquals(-17 - 2*13*2, fr.getNumerator()); assertEquals(-17 - 2*13*2, fr.getNumerator());
assertThrows(IllegalArgumentException.class, () -> fr.add(null)); assertThrows(NullPointerException.class, () -> fr.add(null));
// if this fraction is added naively, it will overflow. // if this fraction is added naively, it will overflow.
// check that it doesn't. // check that it doesn't.
@ -836,7 +836,7 @@ public class FractionTest {
assertSame(f2, f); assertSame(f2, f);
final Fraction fr = f; final Fraction fr = f;
assertThrows(IllegalArgumentException.class, () -> fr.subtract(null)); assertThrows(NullPointerException.class, () -> fr.subtract(null));
// if this fraction is subtracted naively, it will overflow. // if this fraction is subtracted naively, it will overflow.
// check that it doesn't. // check that it doesn't.
@ -934,7 +934,7 @@ public class FractionTest {
assertEquals(1, f.getDenominator()); assertEquals(1, f.getDenominator());
final Fraction fr = f; final Fraction fr = f;
assertThrows(IllegalArgumentException.class, () -> fr.multiplyBy(null)); assertThrows(NullPointerException.class, () -> fr.multiplyBy(null));
final Fraction fr1 = Fraction.getFraction(1, Integer.MAX_VALUE); final Fraction fr1 = Fraction.getFraction(1, Integer.MAX_VALUE);
assertThrows(ArithmeticException.class, () -> fr1.multiplyBy(fr1)); assertThrows(ArithmeticException.class, () -> fr1.multiplyBy(fr1));
@ -979,7 +979,7 @@ public class FractionTest {
assertEquals(Integer.MIN_VALUE, fr.getNumerator()); assertEquals(Integer.MIN_VALUE, fr.getNumerator());
assertEquals(1, fr.getDenominator()); assertEquals(1, fr.getDenominator());
assertThrows(IllegalArgumentException.class, () -> fr.divideBy(null)); assertThrows(NullPointerException.class, () -> fr.divideBy(null));
final Fraction smallest = Fraction.getFraction(1, Integer.MAX_VALUE); final Fraction smallest = Fraction.getFraction(1, Integer.MAX_VALUE);
assertThrows(ArithmeticException.class, () -> smallest.divideBy(smallest.invert())); // Should overflow assertThrows(ArithmeticException.class, () -> smallest.divideBy(smallest.invert())); // Should overflow

View File

@ -56,7 +56,7 @@ public class IEEE754rUtilsTest {
@Test @Test
public void testEnforceExceptions() { public void testEnforceExceptions() {
assertThrows( assertThrows(
IllegalArgumentException.class, NullPointerException.class,
() -> IEEE754rUtils.min( (float[]) null), () -> IEEE754rUtils.min( (float[]) null),
"IllegalArgumentException expected for null input"); "IllegalArgumentException expected for null input");
@ -66,7 +66,7 @@ public class IEEE754rUtilsTest {
"IllegalArgumentException expected for empty input"); "IllegalArgumentException expected for empty input");
assertThrows( assertThrows(
IllegalArgumentException.class, NullPointerException.class,
() -> IEEE754rUtils.max( (float[]) null), () -> IEEE754rUtils.max( (float[]) null),
"IllegalArgumentException expected for null input"); "IllegalArgumentException expected for null input");
@ -76,7 +76,7 @@ public class IEEE754rUtilsTest {
"IllegalArgumentException expected for empty input"); "IllegalArgumentException expected for empty input");
assertThrows( assertThrows(
IllegalArgumentException.class, NullPointerException.class,
() -> IEEE754rUtils.min( (double[]) null), () -> IEEE754rUtils.min( (double[]) null),
"IllegalArgumentException expected for null input"); "IllegalArgumentException expected for null input");
@ -86,7 +86,7 @@ public class IEEE754rUtilsTest {
"IllegalArgumentException expected for empty input"); "IllegalArgumentException expected for empty input");
assertThrows( assertThrows(
IllegalArgumentException.class, NullPointerException.class,
() -> IEEE754rUtils.max( (double[]) null), () -> IEEE754rUtils.max( (double[]) null),
"IllegalArgumentException expected for null input"); "IllegalArgumentException expected for null input");

View File

@ -686,7 +686,7 @@ public class NumberUtilsTest {
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
@Test @Test
public void testMinLong_nullArray() { public void testMinLong_nullArray() {
assertThrows(IllegalArgumentException.class, () -> NumberUtils.min((long[]) null)); assertThrows(NullPointerException.class, () -> NumberUtils.min((long[]) null));
} }
@Test @Test
@ -705,7 +705,7 @@ public class NumberUtilsTest {
@Test @Test
public void testMinInt_nullArray() { public void testMinInt_nullArray() {
assertThrows(IllegalArgumentException.class, () -> NumberUtils.min((int[]) null)); assertThrows(NullPointerException.class, () -> NumberUtils.min((int[]) null));
} }
@Test @Test
@ -724,7 +724,7 @@ public class NumberUtilsTest {
@Test @Test
public void testMinShort_nullArray() { public void testMinShort_nullArray() {
assertThrows(IllegalArgumentException.class, () -> NumberUtils.min((short[]) null)); assertThrows(NullPointerException.class, () -> NumberUtils.min((short[]) null));
} }
@Test @Test
@ -743,7 +743,7 @@ public class NumberUtilsTest {
@Test @Test
public void testMinByte_nullArray() { public void testMinByte_nullArray() {
assertThrows(IllegalArgumentException.class, () -> NumberUtils.min((byte[]) null)); assertThrows(NullPointerException.class, () -> NumberUtils.min((byte[]) null));
} }
@Test @Test
@ -762,7 +762,7 @@ public class NumberUtilsTest {
@Test @Test
public void testMinDouble_nullArray() { public void testMinDouble_nullArray() {
assertThrows(IllegalArgumentException.class, () -> NumberUtils.min((double[]) null)); assertThrows(NullPointerException.class, () -> NumberUtils.min((double[]) null));
} }
@Test @Test
@ -781,7 +781,7 @@ public class NumberUtilsTest {
@Test @Test
public void testMinFloat_nullArray() { public void testMinFloat_nullArray() {
assertThrows(IllegalArgumentException.class, () -> NumberUtils.min((float[]) null)); assertThrows(NullPointerException.class, () -> NumberUtils.min((float[]) null));
} }
@Test @Test
@ -800,7 +800,7 @@ public class NumberUtilsTest {
@Test @Test
public void testMaxLong_nullArray() { public void testMaxLong_nullArray() {
assertThrows(IllegalArgumentException.class, () -> NumberUtils.max((long[]) null)); assertThrows(NullPointerException.class, () -> NumberUtils.max((long[]) null));
} }
@Test @Test
@ -819,7 +819,7 @@ public class NumberUtilsTest {
@Test @Test
public void testMaxInt_nullArray() { public void testMaxInt_nullArray() {
assertThrows(IllegalArgumentException.class, () -> NumberUtils.max((int[]) null)); assertThrows(NullPointerException.class, () -> NumberUtils.max((int[]) null));
} }
@Test @Test
@ -838,7 +838,7 @@ public class NumberUtilsTest {
@Test @Test
public void testMaxShort_nullArray() { public void testMaxShort_nullArray() {
assertThrows(IllegalArgumentException.class, () -> NumberUtils.max((short[]) null)); assertThrows(NullPointerException.class, () -> NumberUtils.max((short[]) null));
} }
@Test @Test
@ -857,7 +857,7 @@ public class NumberUtilsTest {
@Test @Test
public void testMaxByte_nullArray() { public void testMaxByte_nullArray() {
assertThrows(IllegalArgumentException.class, () -> NumberUtils.max((byte[]) null)); assertThrows(NullPointerException.class, () -> NumberUtils.max((byte[]) null));
} }
@Test @Test
@ -876,7 +876,7 @@ public class NumberUtilsTest {
@Test @Test
public void testMaxDouble_nullArray() { public void testMaxDouble_nullArray() {
assertThrows(IllegalArgumentException.class, () -> NumberUtils.max((double[]) null)); assertThrows(NullPointerException.class, () -> NumberUtils.max((double[]) null));
} }
@Test @Test
@ -888,7 +888,7 @@ public class NumberUtilsTest {
public void testMaxDouble() { public void testMaxDouble() {
final double[] d = null; final double[] d = null;
assertThrows( assertThrows(
IllegalArgumentException.class, () -> NumberUtils.max(d), "No exception was thrown for null input."); NullPointerException.class, () -> NumberUtils.max(d), "No exception was thrown for null input.");
assertThrows( assertThrows(
IllegalArgumentException.class, IllegalArgumentException.class,
@ -904,7 +904,7 @@ public class NumberUtilsTest {
@Test @Test
public void testMaxFloat_nullArray() { public void testMaxFloat_nullArray() {
assertThrows(IllegalArgumentException.class, () -> NumberUtils.max((float[]) null)); assertThrows(NullPointerException.class, () -> NumberUtils.max((float[]) null));
} }
@Test @Test

View File

@ -106,7 +106,7 @@ public class FieldUtilsTest {
@Test @Test
public void testGetFieldIllegalArgumentException1() { public void testGetFieldIllegalArgumentException1() {
assertThrows(IllegalArgumentException.class, () -> FieldUtils.getField(null, "none")); assertThrows(NullPointerException.class, () -> FieldUtils.getField(null, "none"));
} }
@Test @Test
@ -145,7 +145,7 @@ public class FieldUtilsTest {
@Test @Test
public void testGetFieldForceAccessIllegalArgumentException1() { public void testGetFieldForceAccessIllegalArgumentException1() {
assertThrows(IllegalArgumentException.class, () -> FieldUtils.getField(null, "none", true)); assertThrows(NullPointerException.class, () -> FieldUtils.getField(null, "none", true));
} }
@Test @Test
@ -214,17 +214,17 @@ public class FieldUtilsTest {
@Test @Test
public void testGetFieldsWithAnnotationIllegalArgumentException1() { public void testGetFieldsWithAnnotationIllegalArgumentException1() {
assertThrows(IllegalArgumentException.class, () -> FieldUtils.getFieldsWithAnnotation(FieldUtilsTest.class, null)); assertThrows(NullPointerException.class, () -> FieldUtils.getFieldsWithAnnotation(FieldUtilsTest.class, null));
} }
@Test @Test
public void testGetFieldsWithAnnotationIllegalArgumentException2() { public void testGetFieldsWithAnnotationIllegalArgumentException2() {
assertThrows(IllegalArgumentException.class, () -> FieldUtils.getFieldsWithAnnotation(null, Annotated.class)); assertThrows(NullPointerException.class, () -> FieldUtils.getFieldsWithAnnotation(null, Annotated.class));
} }
@Test @Test
public void testGetFieldsWithAnnotationIllegalArgumentException3() { public void testGetFieldsWithAnnotationIllegalArgumentException3() {
assertThrows(IllegalArgumentException.class, () -> FieldUtils.getFieldsWithAnnotation(null, null)); assertThrows(NullPointerException.class, () -> FieldUtils.getFieldsWithAnnotation(null, null));
} }
@Test @Test
@ -242,17 +242,17 @@ public class FieldUtilsTest {
@Test @Test
public void testGetFieldsListWithAnnotationIllegalArgumentException1() { public void testGetFieldsListWithAnnotationIllegalArgumentException1() {
assertThrows(IllegalArgumentException.class, () -> FieldUtils.getFieldsListWithAnnotation(FieldUtilsTest.class, null)); assertThrows(NullPointerException.class, () -> FieldUtils.getFieldsListWithAnnotation(FieldUtilsTest.class, null));
} }
@Test @Test
public void testGetFieldsListWithAnnotationIllegalArgumentException2() { public void testGetFieldsListWithAnnotationIllegalArgumentException2() {
assertThrows(IllegalArgumentException.class, () -> FieldUtils.getFieldsListWithAnnotation(null, Annotated.class)); assertThrows(NullPointerException.class, () -> FieldUtils.getFieldsListWithAnnotation(null, Annotated.class));
} }
@Test @Test
public void testGetFieldsListWithAnnotationIllegalArgumentException3() { public void testGetFieldsListWithAnnotationIllegalArgumentException3() {
assertThrows(IllegalArgumentException.class, () -> FieldUtils.getFieldsListWithAnnotation(null, null)); assertThrows(NullPointerException.class, () -> FieldUtils.getFieldsListWithAnnotation(null, null));
} }
@Test @Test
@ -276,7 +276,7 @@ public class FieldUtilsTest {
@Test @Test
public void testGetDeclaredFieldAccessIllegalArgumentException1() { public void testGetDeclaredFieldAccessIllegalArgumentException1() {
assertThrows(IllegalArgumentException.class, () -> FieldUtils.getDeclaredField(null, "none")); assertThrows(NullPointerException.class, () -> FieldUtils.getDeclaredField(null, "none"));
} }
@Test @Test
@ -315,7 +315,7 @@ public class FieldUtilsTest {
@Test @Test
public void testGetDeclaredFieldForceAccessIllegalArgumentException1() { public void testGetDeclaredFieldForceAccessIllegalArgumentException1() {
assertThrows(IllegalArgumentException.class, () -> FieldUtils.getDeclaredField(null, "none", true)); assertThrows(NullPointerException.class, () -> FieldUtils.getDeclaredField(null, "none", true));
} }
@Test @Test
@ -340,7 +340,7 @@ public class FieldUtilsTest {
@Test @Test
public void testReadStaticFieldIllegalArgumentException1() { public void testReadStaticFieldIllegalArgumentException1() {
assertThrows(IllegalArgumentException.class, () -> FieldUtils.readStaticField(null)); assertThrows(NullPointerException.class, () -> FieldUtils.readStaticField(null));
} }
@Test @Test
@ -359,7 +359,7 @@ public class FieldUtilsTest {
@Test @Test
public void testReadStaticFieldForceAccessIllegalArgumentException1() { public void testReadStaticFieldForceAccessIllegalArgumentException1() {
assertThrows(IllegalArgumentException.class, () -> FieldUtils.readStaticField(null, true)); assertThrows(NullPointerException.class, () -> FieldUtils.readStaticField(null, true));
} }
@Test @Test
@ -377,7 +377,7 @@ public class FieldUtilsTest {
assertEquals(Foo.VALUE, FieldUtils.readStaticField(PublicChild.class, "VALUE")); assertEquals(Foo.VALUE, FieldUtils.readStaticField(PublicChild.class, "VALUE"));
assertThrows( assertThrows(
IllegalArgumentException.class, NullPointerException.class,
() -> FieldUtils.readStaticField(null, "none"), () -> FieldUtils.readStaticField(null, "none"),
"null class should cause an IllegalArgumentException"); "null class should cause an IllegalArgumentException");
@ -397,7 +397,7 @@ public class FieldUtilsTest {
"blank field name should cause an IllegalArgumentException"); "blank field name should cause an IllegalArgumentException");
assertThrows( assertThrows(
IllegalArgumentException.class, NullPointerException.class,
() -> FieldUtils.readStaticField(Foo.class, "does_not_exist"), () -> FieldUtils.readStaticField(Foo.class, "does_not_exist"),
"a field that doesn't exist should cause an IllegalArgumentException"); "a field that doesn't exist should cause an IllegalArgumentException");
@ -415,7 +415,7 @@ public class FieldUtilsTest {
assertEquals("child", FieldUtils.readStaticField(PublicChild.class, "VALUE", true)); assertEquals("child", FieldUtils.readStaticField(PublicChild.class, "VALUE", true));
assertThrows( assertThrows(
IllegalArgumentException.class, NullPointerException.class,
() -> FieldUtils.readStaticField(null, "none", true), () -> FieldUtils.readStaticField(null, "none", true),
"null class should cause an IllegalArgumentException"); "null class should cause an IllegalArgumentException");
@ -435,7 +435,7 @@ public class FieldUtilsTest {
"blank field name should cause an IllegalArgumentException"); "blank field name should cause an IllegalArgumentException");
assertThrows( assertThrows(
IllegalArgumentException.class, NullPointerException.class,
() -> FieldUtils.readStaticField(Foo.class, "does_not_exist", true), () -> FieldUtils.readStaticField(Foo.class, "does_not_exist", true),
"a field that doesn't exist should cause an IllegalArgumentException"); "a field that doesn't exist should cause an IllegalArgumentException");
@ -449,12 +449,12 @@ public class FieldUtilsTest {
public void testReadDeclaredNamedStaticField() throws Exception { public void testReadDeclaredNamedStaticField() throws Exception {
assertEquals(Foo.VALUE, FieldUtils.readDeclaredStaticField(Foo.class, "VALUE")); assertEquals(Foo.VALUE, FieldUtils.readDeclaredStaticField(Foo.class, "VALUE"));
assertThrows( assertThrows(
IllegalArgumentException.class, () -> FieldUtils.readDeclaredStaticField(PublicChild.class, "VALUE")); NullPointerException.class, () -> FieldUtils.readDeclaredStaticField(PublicChild.class, "VALUE"));
assertThrows( assertThrows(
IllegalArgumentException.class, NullPointerException.class,
() -> FieldUtils.readDeclaredStaticField(PubliclyShadowedChild.class, "VALUE")); () -> FieldUtils.readDeclaredStaticField(PubliclyShadowedChild.class, "VALUE"));
assertThrows( assertThrows(
IllegalArgumentException.class, NullPointerException.class,
() -> FieldUtils.readDeclaredStaticField(PrivatelyShadowedChild.class, "VALUE")); () -> FieldUtils.readDeclaredStaticField(PrivatelyShadowedChild.class, "VALUE"));
} }
@ -463,10 +463,10 @@ public class FieldUtilsTest {
assertEquals(Foo.VALUE, FieldUtils.readDeclaredStaticField(Foo.class, "VALUE", true)); assertEquals(Foo.VALUE, FieldUtils.readDeclaredStaticField(Foo.class, "VALUE", true));
assertEquals("child", FieldUtils.readDeclaredStaticField(PublicChild.class, "VALUE", true)); assertEquals("child", FieldUtils.readDeclaredStaticField(PublicChild.class, "VALUE", true));
assertThrows( assertThrows(
IllegalArgumentException.class, NullPointerException.class,
() -> FieldUtils.readDeclaredStaticField(PubliclyShadowedChild.class, "VALUE", true)); () -> FieldUtils.readDeclaredStaticField(PubliclyShadowedChild.class, "VALUE", true));
assertThrows( assertThrows(
IllegalArgumentException.class, NullPointerException.class,
() -> FieldUtils.readDeclaredStaticField(PrivatelyShadowedChild.class, "VALUE", true)); () -> FieldUtils.readDeclaredStaticField(PrivatelyShadowedChild.class, "VALUE", true));
} }
@ -490,7 +490,7 @@ public class FieldUtilsTest {
assertEquals(D0, FieldUtils.readField(parentD, privatelyShadowedChild)); assertEquals(D0, FieldUtils.readField(parentD, privatelyShadowedChild));
assertThrows( assertThrows(
IllegalArgumentException.class, NullPointerException.class,
() -> FieldUtils.readField(null, publicChild), () -> FieldUtils.readField(null, publicChild),
"a null field should cause an IllegalArgumentException"); "a null field should cause an IllegalArgumentException");
} }
@ -519,7 +519,7 @@ public class FieldUtilsTest {
assertEquals(D0, FieldUtils.readField(parentD, privatelyShadowedChild, true)); assertEquals(D0, FieldUtils.readField(parentD, privatelyShadowedChild, true));
assertThrows( assertThrows(
IllegalArgumentException.class, NullPointerException.class,
() -> FieldUtils.readField(null, publicChild, true), () -> FieldUtils.readField(null, publicChild, true),
"a null field should cause an IllegalArgumentException"); "a null field should cause an IllegalArgumentException");
} }
@ -546,7 +546,7 @@ public class FieldUtilsTest {
"a blank field name should cause an IllegalArgumentException"); "a blank field name should cause an IllegalArgumentException");
assertThrows( assertThrows(
IllegalArgumentException.class, NullPointerException.class,
() -> FieldUtils.readField((Object) null, "none"), () -> FieldUtils.readField((Object) null, "none"),
"a null target should cause an IllegalArgumentException"); "a null target should cause an IllegalArgumentException");
@ -593,7 +593,7 @@ public class FieldUtilsTest {
"a blank field name should cause an IllegalArgumentException"); "a blank field name should cause an IllegalArgumentException");
assertThrows( assertThrows(
IllegalArgumentException.class, NullPointerException.class,
() -> FieldUtils.readField((Object) null, "none", true), () -> FieldUtils.readField((Object) null, "none", true),
"a null target should cause an IllegalArgumentException"); "a null target should cause an IllegalArgumentException");
} }
@ -616,7 +616,7 @@ public class FieldUtilsTest {
"a blank field name should cause an IllegalArgumentException"); "a blank field name should cause an IllegalArgumentException");
assertThrows( assertThrows(
IllegalArgumentException.class, NullPointerException.class,
() -> FieldUtils.readDeclaredField(null, "none"), () -> FieldUtils.readDeclaredField(null, "none"),
"a null target should cause an IllegalArgumentException"); "a null target should cause an IllegalArgumentException");
@ -652,7 +652,7 @@ public class FieldUtilsTest {
"a blank field name should cause an IllegalArgumentException"); "a blank field name should cause an IllegalArgumentException");
assertThrows( assertThrows(
IllegalArgumentException.class, NullPointerException.class,
() -> FieldUtils.readDeclaredField(null, "none", true), () -> FieldUtils.readDeclaredField(null, "none", true),
"a null target should cause an IllegalArgumentException"); "a null target should cause an IllegalArgumentException");
@ -731,25 +731,25 @@ public class FieldUtilsTest {
FieldUtils.writeStaticField(StaticContainerChild.class, "mutablePublic", "new"); FieldUtils.writeStaticField(StaticContainerChild.class, "mutablePublic", "new");
assertEquals("new", StaticContainer.mutablePublic); assertEquals("new", StaticContainer.mutablePublic);
assertThrows( assertThrows(
IllegalArgumentException.class, NullPointerException.class,
() -> FieldUtils.writeStaticField(StaticContainerChild.class, "mutableProtected", "new")); () -> FieldUtils.writeStaticField(StaticContainerChild.class, "mutableProtected", "new"));
assertThrows( assertThrows(
IllegalArgumentException.class, NullPointerException.class,
() -> FieldUtils.writeStaticField(StaticContainerChild.class, "mutablePackage", "new")); () -> FieldUtils.writeStaticField(StaticContainerChild.class, "mutablePackage", "new"));
assertThrows( assertThrows(
IllegalArgumentException.class, NullPointerException.class,
() -> FieldUtils.writeStaticField(StaticContainerChild.class, "mutablePrivate", "new")); () -> FieldUtils.writeStaticField(StaticContainerChild.class, "mutablePrivate", "new"));
assertThrows( assertThrows(
IllegalAccessException.class, IllegalAccessException.class,
() -> FieldUtils.writeStaticField(StaticContainerChild.class, "IMMUTABLE_PUBLIC", "new")); () -> FieldUtils.writeStaticField(StaticContainerChild.class, "IMMUTABLE_PUBLIC", "new"));
assertThrows( assertThrows(
IllegalArgumentException.class, NullPointerException.class,
() -> FieldUtils.writeStaticField(StaticContainerChild.class, "IMMUTABLE_PROTECTED", "new")); () -> FieldUtils.writeStaticField(StaticContainerChild.class, "IMMUTABLE_PROTECTED", "new"));
assertThrows( assertThrows(
IllegalArgumentException.class, NullPointerException.class,
() -> FieldUtils.writeStaticField(StaticContainerChild.class, "IMMUTABLE_PACKAGE", "new")); () -> FieldUtils.writeStaticField(StaticContainerChild.class, "IMMUTABLE_PACKAGE", "new"));
assertThrows( assertThrows(
IllegalArgumentException.class, NullPointerException.class,
() -> FieldUtils.writeStaticField(StaticContainerChild.class, "IMMUTABLE_PRIVATE", "new")); () -> FieldUtils.writeStaticField(StaticContainerChild.class, "IMMUTABLE_PRIVATE", "new"));
} }
@ -782,25 +782,25 @@ public class FieldUtilsTest {
FieldUtils.writeStaticField(StaticContainer.class, "mutablePublic", "new"); FieldUtils.writeStaticField(StaticContainer.class, "mutablePublic", "new");
assertEquals("new", StaticContainer.mutablePublic); assertEquals("new", StaticContainer.mutablePublic);
assertThrows( assertThrows(
IllegalArgumentException.class, NullPointerException.class,
() -> FieldUtils.writeDeclaredStaticField(StaticContainer.class, "mutableProtected", "new")); () -> FieldUtils.writeDeclaredStaticField(StaticContainer.class, "mutableProtected", "new"));
assertThrows( assertThrows(
IllegalArgumentException.class, NullPointerException.class,
() -> FieldUtils.writeDeclaredStaticField(StaticContainer.class, "mutablePackage", "new")); () -> FieldUtils.writeDeclaredStaticField(StaticContainer.class, "mutablePackage", "new"));
assertThrows( assertThrows(
IllegalArgumentException.class, NullPointerException.class,
() -> FieldUtils.writeDeclaredStaticField(StaticContainer.class, "mutablePrivate", "new")); () -> FieldUtils.writeDeclaredStaticField(StaticContainer.class, "mutablePrivate", "new"));
assertThrows( assertThrows(
IllegalAccessException.class, IllegalAccessException.class,
() -> FieldUtils.writeDeclaredStaticField(StaticContainer.class, "IMMUTABLE_PUBLIC", "new")); () -> FieldUtils.writeDeclaredStaticField(StaticContainer.class, "IMMUTABLE_PUBLIC", "new"));
assertThrows( assertThrows(
IllegalArgumentException.class, NullPointerException.class,
() -> FieldUtils.writeDeclaredStaticField(StaticContainer.class, "IMMUTABLE_PROTECTED", "new")); () -> FieldUtils.writeDeclaredStaticField(StaticContainer.class, "IMMUTABLE_PROTECTED", "new"));
assertThrows( assertThrows(
IllegalArgumentException.class, NullPointerException.class,
() -> FieldUtils.writeDeclaredStaticField(StaticContainer.class, "IMMUTABLE_PACKAGE", "new")); () -> FieldUtils.writeDeclaredStaticField(StaticContainer.class, "IMMUTABLE_PACKAGE", "new"));
assertThrows( assertThrows(
IllegalArgumentException.class, NullPointerException.class,
() -> FieldUtils.writeDeclaredStaticField(StaticContainer.class, "IMMUTABLE_PRIVATE", "new")); () -> FieldUtils.writeDeclaredStaticField(StaticContainer.class, "IMMUTABLE_PRIVATE", "new"));
} }

View File

@ -868,12 +868,12 @@ public class MethodUtilsTest {
@Test @Test
public void testGetMethodsWithAnnotationIllegalArgumentException2() { public void testGetMethodsWithAnnotationIllegalArgumentException2() {
assertThrows(IllegalArgumentException.class, () -> MethodUtils.getMethodsWithAnnotation(null, Annotated.class)); assertThrows(NullPointerException.class, () -> MethodUtils.getMethodsWithAnnotation(null, Annotated.class));
} }
@Test @Test
public void testGetMethodsWithAnnotationIllegalArgumentException3() { public void testGetMethodsWithAnnotationIllegalArgumentException3() {
assertThrows(IllegalArgumentException.class, () -> MethodUtils.getMethodsWithAnnotation(null, null)); assertThrows(NullPointerException.class, () -> MethodUtils.getMethodsWithAnnotation(null, null));
} }
@Test @Test
@ -896,12 +896,12 @@ public class MethodUtilsTest {
@Test @Test
public void testGetMethodsListWithAnnotationIllegalArgumentException2() { public void testGetMethodsListWithAnnotationIllegalArgumentException2() {
assertThrows(IllegalArgumentException.class, () -> MethodUtils.getMethodsListWithAnnotation(null, Annotated.class)); assertThrows(NullPointerException.class, () -> MethodUtils.getMethodsListWithAnnotation(null, Annotated.class));
} }
@Test @Test
public void testGetMethodsListWithAnnotationIllegalArgumentException3() { public void testGetMethodsListWithAnnotationIllegalArgumentException3() {
assertThrows(IllegalArgumentException.class, () -> MethodUtils.getMethodsListWithAnnotation(null, null)); assertThrows(NullPointerException.class, () -> MethodUtils.getMethodsListWithAnnotation(null, null));
} }
@Test @Test
@ -912,12 +912,12 @@ public class MethodUtilsTest {
@Test @Test
public void testGetAnnotationIllegalArgumentException2() { public void testGetAnnotationIllegalArgumentException2() {
assertThrows(IllegalArgumentException.class, () -> MethodUtils.getAnnotation(null, Annotated.class, true, true)); assertThrows(NullPointerException.class, () -> MethodUtils.getAnnotation(null, Annotated.class, true, true));
} }
@Test @Test
public void testGetAnnotationIllegalArgumentException3() { public void testGetAnnotationIllegalArgumentException3() {
assertThrows(IllegalArgumentException.class, () -> MethodUtils.getAnnotation(null, null, true, true)); assertThrows(NullPointerException.class, () -> MethodUtils.getAnnotation(null, null, true, true));
} }
private void expectMatchingAccessibleMethodParameterTypes(final Class<?> cls, private void expectMatchingAccessibleMethodParameterTypes(final Class<?> cls,

View File

@ -49,23 +49,23 @@ public class DateUtilsFragmentTest {
@Test @Test
public void testNullDate() { public void testNullDate() {
assertThrows( assertThrows(
IllegalArgumentException.class, NullPointerException.class,
() -> DateUtils.getFragmentInMilliseconds((Date) null, Calendar.MILLISECOND)); () -> DateUtils.getFragmentInMilliseconds((Date) null, Calendar.MILLISECOND));
assertThrows( assertThrows(
IllegalArgumentException.class, NullPointerException.class,
() -> DateUtils.getFragmentInSeconds((Date) null, Calendar.MILLISECOND)); () -> DateUtils.getFragmentInSeconds((Date) null, Calendar.MILLISECOND));
assertThrows( assertThrows(
IllegalArgumentException.class, NullPointerException.class,
() -> DateUtils.getFragmentInMinutes((Date) null, Calendar.MILLISECOND)); () -> DateUtils.getFragmentInMinutes((Date) null, Calendar.MILLISECOND));
assertThrows( assertThrows(
IllegalArgumentException.class, NullPointerException.class,
() -> DateUtils.getFragmentInHours((Date) null, Calendar.MILLISECOND)); () -> DateUtils.getFragmentInHours((Date) null, Calendar.MILLISECOND));
assertThrows( assertThrows(
IllegalArgumentException.class, NullPointerException.class,
() -> DateUtils.getFragmentInDays((Date) null, Calendar.MILLISECOND)); () -> DateUtils.getFragmentInDays((Date) null, Calendar.MILLISECOND));
} }

View File

@ -830,7 +830,7 @@ public class DateUtilsTest {
DateUtils.round((Object) dateAmPm4, Calendar.AM_PM), DateUtils.round((Object) dateAmPm4, Calendar.AM_PM),
"round ampm-4 failed"); "round ampm-4 failed");
assertThrows(IllegalArgumentException.class, () -> DateUtils.round((Date) null, Calendar.SECOND)); assertThrows(NullPointerException.class, () -> DateUtils.round((Date) null, Calendar.SECOND));
assertThrows(IllegalArgumentException.class, () -> DateUtils.round((Calendar) null, Calendar.SECOND)); assertThrows(IllegalArgumentException.class, () -> DateUtils.round((Calendar) null, Calendar.SECOND));
assertThrows(IllegalArgumentException.class, () -> DateUtils.round((Object) null, Calendar.SECOND)); assertThrows(IllegalArgumentException.class, () -> DateUtils.round((Object) null, Calendar.SECOND));
assertThrows(ClassCastException.class, () -> DateUtils.round("", Calendar.SECOND)); assertThrows(ClassCastException.class, () -> DateUtils.round("", Calendar.SECOND));
@ -1111,7 +1111,7 @@ public class DateUtilsTest {
DateUtils.truncate((Object) calAmPm4, Calendar.AM_PM), DateUtils.truncate((Object) calAmPm4, Calendar.AM_PM),
"truncate ampm-4 failed"); "truncate ampm-4 failed");
assertThrows(IllegalArgumentException.class, () -> DateUtils.truncate((Date) null, Calendar.SECOND)); assertThrows(NullPointerException.class, () -> DateUtils.truncate((Date) null, Calendar.SECOND));
assertThrows(IllegalArgumentException.class, () -> DateUtils.truncate((Calendar) null, Calendar.SECOND)); assertThrows(IllegalArgumentException.class, () -> DateUtils.truncate((Calendar) null, Calendar.SECOND));
assertThrows(IllegalArgumentException.class, () -> DateUtils.truncate((Object) null, Calendar.SECOND)); assertThrows(IllegalArgumentException.class, () -> DateUtils.truncate((Object) null, Calendar.SECOND));
assertThrows(ClassCastException.class, () -> DateUtils.truncate("", Calendar.SECOND)); assertThrows(ClassCastException.class, () -> DateUtils.truncate("", Calendar.SECOND));
@ -1389,7 +1389,7 @@ public class DateUtilsTest {
DateUtils.ceiling((Object) calAmPm4, Calendar.AM_PM), DateUtils.ceiling((Object) calAmPm4, Calendar.AM_PM),
"ceiling ampm-4 failed"); "ceiling ampm-4 failed");
assertThrows(IllegalArgumentException.class, () -> DateUtils.ceiling((Date) null, Calendar.SECOND)); assertThrows(NullPointerException.class, () -> DateUtils.ceiling((Date) null, Calendar.SECOND));
assertThrows(IllegalArgumentException.class, () -> DateUtils.ceiling((Calendar) null, Calendar.SECOND)); assertThrows(IllegalArgumentException.class, () -> DateUtils.ceiling((Calendar) null, Calendar.SECOND));
assertThrows(IllegalArgumentException.class, () -> DateUtils.ceiling((Object) null, Calendar.SECOND)); assertThrows(IllegalArgumentException.class, () -> DateUtils.ceiling((Object) null, Calendar.SECOND));
assertThrows(ClassCastException.class, () -> DateUtils.ceiling("", Calendar.SECOND)); assertThrows(ClassCastException.class, () -> DateUtils.ceiling("", Calendar.SECOND));
@ -1475,7 +1475,7 @@ public class DateUtilsTest {
public void testIteratorEx() { public void testIteratorEx() {
assertThrows(IllegalArgumentException.class, () -> DateUtils.iterator(Calendar.getInstance(), -9999)); assertThrows(IllegalArgumentException.class, () -> DateUtils.iterator(Calendar.getInstance(), -9999));
assertThrows assertThrows
(IllegalArgumentException.class, () -> DateUtils.iterator((Date) null, DateUtils.RANGE_WEEK_CENTER)); (NullPointerException.class, () -> DateUtils.iterator((Date) null, DateUtils.RANGE_WEEK_CENTER));
assertThrows assertThrows
(IllegalArgumentException.class, () -> DateUtils.iterator((Calendar) null, DateUtils.RANGE_WEEK_CENTER)); (IllegalArgumentException.class, () -> DateUtils.iterator((Calendar) null, DateUtils.RANGE_WEEK_CENTER));
assertThrows assertThrows