Remove redundant type arguments.

This commit is contained in:
Gary Gregory 2016-10-23 10:52:50 -07:00
parent 7e8df326f4
commit 4f82195afd
87 changed files with 259 additions and 259 deletions

View File

@ -239,7 +239,7 @@ public class ArrayUtils {
if (array == null) { if (array == null) {
return null; return null;
} }
final Map<Object, Object> map = new HashMap<Object, Object>((int) (array.length * 1.5)); final Map<Object, Object> map = new HashMap<>((int) (array.length * 1.5));
for (int i = 0; i < array.length; i++) { for (int i = 0; i < array.length; i++) {
final Object object = array[i]; final Object object = array[i];
if (object instanceof Map.Entry<?, ?>) { if (object instanceof Map.Entry<?, ?>) {
@ -6611,7 +6611,7 @@ public class ArrayUtils {
if (isEmpty(array) || isEmpty(values)) { if (isEmpty(array) || isEmpty(values)) {
return clone(array); return clone(array);
} }
final HashMap<T, MutableInt> occurrences = new HashMap<T, MutableInt>(values.length); final HashMap<T, MutableInt> occurrences = new HashMap<>(values.length);
for (final T v : values) { for (final T v : values) {
final MutableInt count = occurrences.get(v); final MutableInt count = occurrences.get(v);
if (count == null) { if (count == null) {
@ -6701,7 +6701,7 @@ public class ArrayUtils {
if (isEmpty(array) || isEmpty(values)) { if (isEmpty(array) || isEmpty(values)) {
return clone(array); return clone(array);
} }
final Map<Byte, MutableInt> occurrences = new HashMap<Byte, MutableInt>(values.length); final Map<Byte, MutableInt> occurrences = new HashMap<>(values.length);
for (final byte v : values) { for (final byte v : values) {
final Byte boxed = Byte.valueOf(v); final Byte boxed = Byte.valueOf(v);
final MutableInt count = occurrences.get(boxed); final MutableInt count = occurrences.get(boxed);
@ -6789,7 +6789,7 @@ public class ArrayUtils {
if (isEmpty(array) || isEmpty(values)) { if (isEmpty(array) || isEmpty(values)) {
return clone(array); return clone(array);
} }
final HashMap<Short, MutableInt> occurrences = new HashMap<Short, MutableInt>(values.length); final HashMap<Short, MutableInt> occurrences = new HashMap<>(values.length);
for (final short v : values) { for (final short v : values) {
final Short boxed = Short.valueOf(v); final Short boxed = Short.valueOf(v);
final MutableInt count = occurrences.get(boxed); final MutableInt count = occurrences.get(boxed);
@ -6877,7 +6877,7 @@ public class ArrayUtils {
if (isEmpty(array) || isEmpty(values)) { if (isEmpty(array) || isEmpty(values)) {
return clone(array); return clone(array);
} }
final HashMap<Integer, MutableInt> occurrences = new HashMap<Integer, MutableInt>(values.length); final HashMap<Integer, MutableInt> occurrences = new HashMap<>(values.length);
for (final int v : values) { for (final int v : values) {
final Integer boxed = Integer.valueOf(v); final Integer boxed = Integer.valueOf(v);
final MutableInt count = occurrences.get(boxed); final MutableInt count = occurrences.get(boxed);
@ -6965,7 +6965,7 @@ public class ArrayUtils {
if (isEmpty(array) || isEmpty(values)) { if (isEmpty(array) || isEmpty(values)) {
return clone(array); return clone(array);
} }
final HashMap<Character, MutableInt> occurrences = new HashMap<Character, MutableInt>(values.length); final HashMap<Character, MutableInt> occurrences = new HashMap<>(values.length);
for (final char v : values) { for (final char v : values) {
final Character boxed = Character.valueOf(v); final Character boxed = Character.valueOf(v);
final MutableInt count = occurrences.get(boxed); final MutableInt count = occurrences.get(boxed);
@ -7053,7 +7053,7 @@ public class ArrayUtils {
if (isEmpty(array) || isEmpty(values)) { if (isEmpty(array) || isEmpty(values)) {
return clone(array); return clone(array);
} }
final HashMap<Long, MutableInt> occurrences = new HashMap<Long, MutableInt>(values.length); final HashMap<Long, MutableInt> occurrences = new HashMap<>(values.length);
for (final long v : values) { for (final long v : values) {
final Long boxed = Long.valueOf(v); final Long boxed = Long.valueOf(v);
final MutableInt count = occurrences.get(boxed); final MutableInt count = occurrences.get(boxed);
@ -7141,7 +7141,7 @@ public class ArrayUtils {
if (isEmpty(array) || isEmpty(values)) { if (isEmpty(array) || isEmpty(values)) {
return clone(array); return clone(array);
} }
final HashMap<Float, MutableInt> occurrences = new HashMap<Float, MutableInt>(values.length); final HashMap<Float, MutableInt> occurrences = new HashMap<>(values.length);
for (final float v : values) { for (final float v : values) {
final Float boxed = Float.valueOf(v); final Float boxed = Float.valueOf(v);
final MutableInt count = occurrences.get(boxed); final MutableInt count = occurrences.get(boxed);
@ -7229,7 +7229,7 @@ public class ArrayUtils {
if (isEmpty(array) || isEmpty(values)) { if (isEmpty(array) || isEmpty(values)) {
return clone(array); return clone(array);
} }
final HashMap<Double, MutableInt> occurrences = new HashMap<Double, MutableInt>(values.length); final HashMap<Double, MutableInt> occurrences = new HashMap<>(values.length);
for (final double v : values) { for (final double v : values) {
final Double boxed = Double.valueOf(v); final Double boxed = Double.valueOf(v);
final MutableInt count = occurrences.get(boxed); final MutableInt count = occurrences.get(boxed);
@ -7313,7 +7313,7 @@ public class ArrayUtils {
if (isEmpty(array) || isEmpty(values)) { if (isEmpty(array) || isEmpty(values)) {
return clone(array); return clone(array);
} }
final HashMap<Boolean, MutableInt> occurrences = new HashMap<Boolean, MutableInt>(2); // only two possible values here final HashMap<Boolean, MutableInt> occurrences = new HashMap<>(2); // only two possible values here
for (final boolean v : values) { for (final boolean v : values) {
final Boolean boxed = Boolean.valueOf(v); final Boolean boxed = Boolean.valueOf(v);
final MutableInt count = occurrences.get(boxed); final MutableInt count = occurrences.get(boxed);

View File

@ -75,7 +75,7 @@ public class ClassUtils {
/** /**
* Maps names of primitives to their corresponding primitive {@code Class}es. * Maps names of primitives to their corresponding primitive {@code Class}es.
*/ */
private static final Map<String, Class<?>> namePrimitiveMap = new HashMap<String, Class<?>>(); private static final Map<String, Class<?>> namePrimitiveMap = new HashMap<>();
static { static {
namePrimitiveMap.put("boolean", Boolean.TYPE); namePrimitiveMap.put("boolean", Boolean.TYPE);
namePrimitiveMap.put("byte", Byte.TYPE); namePrimitiveMap.put("byte", Byte.TYPE);
@ -91,7 +91,7 @@ public class ClassUtils {
/** /**
* Maps primitive {@code Class}es to their corresponding wrapper {@code Class}. * Maps primitive {@code Class}es to their corresponding wrapper {@code Class}.
*/ */
private static final Map<Class<?>, Class<?>> primitiveWrapperMap = new HashMap<Class<?>, Class<?>>(); private static final Map<Class<?>, Class<?>> primitiveWrapperMap = new HashMap<>();
static { static {
primitiveWrapperMap.put(Boolean.TYPE, Boolean.class); primitiveWrapperMap.put(Boolean.TYPE, Boolean.class);
primitiveWrapperMap.put(Byte.TYPE, Byte.class); primitiveWrapperMap.put(Byte.TYPE, Byte.class);
@ -107,7 +107,7 @@ public class ClassUtils {
/** /**
* Maps wrapper {@code Class}es to their corresponding primitive types. * Maps wrapper {@code Class}es to their corresponding primitive types.
*/ */
private static final Map<Class<?>, Class<?>> wrapperPrimitiveMap = new HashMap<Class<?>, Class<?>>(); private static final Map<Class<?>, Class<?>> wrapperPrimitiveMap = new HashMap<>();
static { static {
for (final Map.Entry<Class<?>, Class<?>> entry : primitiveWrapperMap.entrySet()) { for (final Map.Entry<Class<?>, Class<?>> entry : primitiveWrapperMap.entrySet()) {
final Class<?> primitiveClass = entry.getKey(); final Class<?> primitiveClass = entry.getKey();
@ -132,7 +132,7 @@ public class ClassUtils {
* Feed abbreviation maps * Feed abbreviation maps
*/ */
static { static {
final Map<String, String> m = new HashMap<String, String>(); final Map<String, String> m = new HashMap<>();
m.put("int", "I"); m.put("int", "I");
m.put("boolean", "Z"); m.put("boolean", "Z");
m.put("float", "F"); m.put("float", "F");
@ -141,7 +141,7 @@ public class ClassUtils {
m.put("byte", "B"); m.put("byte", "B");
m.put("double", "D"); m.put("double", "D");
m.put("char", "C"); m.put("char", "C");
final Map<String, String> r = new HashMap<String, String>(); final Map<String, String> r = new HashMap<>();
for (final Map.Entry<String, String> e : m.entrySet()) { for (final Map.Entry<String, String> e : m.entrySet()) {
r.put(e.getValue(), e.getKey()); r.put(e.getValue(), e.getKey());
} }
@ -423,7 +423,7 @@ public class ClassUtils {
if (cls == null) { if (cls == null) {
return null; return null;
} }
final List<Class<?>> classes = new ArrayList<Class<?>>(); final List<Class<?>> classes = new ArrayList<>();
Class<?> superclass = cls.getSuperclass(); Class<?> superclass = cls.getSuperclass();
while (superclass != null) { while (superclass != null) {
classes.add(superclass); classes.add(superclass);
@ -450,10 +450,10 @@ public class ClassUtils {
return null; return null;
} }
final LinkedHashSet<Class<?>> interfacesFound = new LinkedHashSet<Class<?>>(); final LinkedHashSet<Class<?>> interfacesFound = new LinkedHashSet<>();
getAllInterfaces(cls, interfacesFound); getAllInterfaces(cls, interfacesFound);
return new ArrayList<Class<?>>(interfacesFound); return new ArrayList<>(interfacesFound);
} }
/** /**
@ -494,7 +494,7 @@ public class ClassUtils {
if (classNames == null) { if (classNames == null) {
return null; return null;
} }
final List<Class<?>> classes = new ArrayList<Class<?>>(classNames.size()); final List<Class<?>> classes = new ArrayList<>(classNames.size());
for (final String className : classNames) { for (final String className : classNames) {
try { try {
classes.add(Class.forName(className)); classes.add(Class.forName(className));
@ -521,7 +521,7 @@ public class ClassUtils {
if (classes == null) { if (classes == null) {
return null; return null;
} }
final List<String> classNames = new ArrayList<String>(classes.size()); final List<String> classNames = new ArrayList<>(classes.size());
for (final Class<?> cls : classes) { for (final Class<?> cls : classes) {
if (cls == null) { if (cls == null) {
classNames.add(null); classNames.add(null);
@ -1021,7 +1021,7 @@ public class ClassUtils {
return declaredMethod; return declaredMethod;
} }
final List<Class<?>> candidateClasses = new ArrayList<Class<?>>(); final List<Class<?>> candidateClasses = new ArrayList<>();
candidateClasses.addAll(getAllInterfaces(cls)); candidateClasses.addAll(getAllInterfaces(cls));
candidateClasses.addAll(getAllSuperclasses(cls)); candidateClasses.addAll(getAllSuperclasses(cls));
@ -1287,7 +1287,7 @@ public class ClassUtils {
@Override @Override
public Iterator<Class<?>> iterator() { public Iterator<Class<?>> iterator() {
final Set<Class<?>> seenInterfaces = new HashSet<Class<?>>(); final Set<Class<?>> seenInterfaces = new HashSet<>();
final Iterator<Class<?>> wrapped = classes.iterator(); final Iterator<Class<?>> wrapped = classes.iterator();
return new Iterator<Class<?>>() { return new Iterator<Class<?>>() {
@ -1306,7 +1306,7 @@ public class ClassUtils {
return nextInterface; return nextInterface;
} }
final Class<?> nextSuperclass = wrapped.next(); final Class<?> nextSuperclass = wrapped.next();
final Set<Class<?>> currentInterfaces = new LinkedHashSet<Class<?>>(); final Set<Class<?>> currentInterfaces = new LinkedHashSet<>();
walkInterfaces(currentInterfaces, nextSuperclass); walkInterfaces(currentInterfaces, nextSuperclass);
interfaces = currentInterfaces.iterator(); interfaces = currentInterfaces.iterator();
return nextSuperclass; return nextSuperclass;

View File

@ -55,7 +55,7 @@ public class EnumUtils {
* @return the modifiable map of enum names to enums, never null * @return the modifiable map of enum names to enums, never null
*/ */
public static <E extends Enum<E>> Map<String, E> getEnumMap(final Class<E> enumClass) { public static <E extends Enum<E>> Map<String, E> getEnumMap(final Class<E> enumClass) {
final Map<String, E> map = new LinkedHashMap<String, E>(); final Map<String, E> map = new LinkedHashMap<>();
for (final E e: enumClass.getEnumConstants()) { for (final E e: enumClass.getEnumConstants()) {
map.put(e.name(), e); map.put(e.name(), e);
} }
@ -72,7 +72,7 @@ public class EnumUtils {
* @return the modifiable list of enums, never null * @return the modifiable list of enums, never null
*/ */
public static <E extends Enum<E>> List<E> getEnumList(final Class<E> enumClass) { public static <E extends Enum<E>> List<E> getEnumList(final Class<E> enumClass) {
return new ArrayList<E>(Arrays.asList(enumClass.getEnumConstants())); return new ArrayList<>(Arrays.asList(enumClass.getEnumConstants()));
} }
/** /**

View File

@ -39,11 +39,11 @@ public class LocaleUtils {
/** Concurrent map of language locales by country. */ /** Concurrent map of language locales by country. */
private static final ConcurrentMap<String, List<Locale>> cLanguagesByCountry = private static final ConcurrentMap<String, List<Locale>> cLanguagesByCountry =
new ConcurrentHashMap<String, List<Locale>>(); new ConcurrentHashMap<>();
/** Concurrent map of country locales by language. */ /** Concurrent map of country locales by language. */
private static final ConcurrentMap<String, List<Locale>> cCountriesByLanguage = private static final ConcurrentMap<String, List<Locale>> cCountriesByLanguage =
new ConcurrentHashMap<String, List<Locale>>(); new ConcurrentHashMap<>();
/** /**
* <p>{@code LocaleUtils} instances should NOT be constructed in standard programming. * <p>{@code LocaleUtils} instances should NOT be constructed in standard programming.
@ -189,7 +189,7 @@ public class LocaleUtils {
* @return the unmodifiable list of Locale objects, 0 being locale, not null * @return the unmodifiable list of Locale objects, 0 being locale, not null
*/ */
public static List<Locale> localeLookupList(final Locale locale, final Locale defaultLocale) { public static List<Locale> localeLookupList(final Locale locale, final Locale defaultLocale) {
final List<Locale> list = new ArrayList<Locale>(4); final List<Locale> list = new ArrayList<>(4);
if (locale != null) { if (locale != null) {
list.add(locale); list.add(locale);
if (locale.getVariant().length() > 0) { if (locale.getVariant().length() > 0) {
@ -260,7 +260,7 @@ public class LocaleUtils {
} }
List<Locale> langs = cLanguagesByCountry.get(countryCode); List<Locale> langs = cLanguagesByCountry.get(countryCode);
if (langs == null) { if (langs == null) {
langs = new ArrayList<Locale>(); langs = new ArrayList<>();
final List<Locale> locales = availableLocaleList(); final List<Locale> locales = availableLocaleList();
for (int i = 0; i < locales.size(); i++) { for (int i = 0; i < locales.size(); i++) {
final Locale locale = locales.get(i); final Locale locale = locales.get(i);
@ -292,7 +292,7 @@ public class LocaleUtils {
} }
List<Locale> countries = cCountriesByLanguage.get(languageCode); List<Locale> countries = cCountriesByLanguage.get(languageCode);
if (countries == null) { if (countries == null) {
countries = new ArrayList<Locale>(); countries = new ArrayList<>();
final List<Locale> locales = availableLocaleList(); final List<Locale> locales = availableLocaleList();
for (int i = 0; i < locales.size(); i++) { for (int i = 0; i < locales.size(); i++) {
final Locale locale = locales.get(i); final Locale locale = locales.get(i);
@ -318,9 +318,9 @@ public class LocaleUtils {
private static final Set<Locale> AVAILABLE_LOCALE_SET; private static final Set<Locale> AVAILABLE_LOCALE_SET;
static { static {
final List<Locale> list = new ArrayList<Locale>(Arrays.asList(Locale.getAvailableLocales())); // extra safe final List<Locale> list = new ArrayList<>(Arrays.asList(Locale.getAvailableLocales())); // extra safe
AVAILABLE_LOCALE_LIST = Collections.unmodifiableList(list); AVAILABLE_LOCALE_LIST = Collections.unmodifiableList(list);
AVAILABLE_LOCALE_SET = Collections.unmodifiableSet(new HashSet<Locale>(list)); AVAILABLE_LOCALE_SET = Collections.unmodifiableSet(new HashSet<>(list));
} }
} }

View File

@ -586,7 +586,7 @@ public class ObjectUtils {
public static <T extends Comparable<? super T>> T median(final T... items) { public static <T extends Comparable<? super T>> T median(final T... items) {
Validate.notEmpty(items); Validate.notEmpty(items);
Validate.noNullElements(items); Validate.noNullElements(items);
final TreeSet<T> sort = new TreeSet<T>(); final TreeSet<T> sort = new TreeSet<>();
Collections.addAll(sort, items); Collections.addAll(sort, items);
@SuppressWarnings("unchecked") //we know all items added were T instances @SuppressWarnings("unchecked") //we know all items added were T instances
final final
@ -609,7 +609,7 @@ public class ObjectUtils {
Validate.notEmpty(items, "null/empty items"); Validate.notEmpty(items, "null/empty items");
Validate.noNullElements(items); Validate.noNullElements(items);
Validate.notNull(comparator, "null comparator"); Validate.notNull(comparator, "null comparator");
final TreeSet<T> sort = new TreeSet<T>(comparator); final TreeSet<T> sort = new TreeSet<>(comparator);
Collections.addAll(sort, items); Collections.addAll(sort, items);
@SuppressWarnings("unchecked") //we know all items added were T instances @SuppressWarnings("unchecked") //we know all items added were T instances
final final
@ -629,7 +629,7 @@ public class ObjectUtils {
*/ */
public static <T> T mode(final T... items) { public static <T> T mode(final T... items) {
if (ArrayUtils.isNotEmpty(items)) { if (ArrayUtils.isNotEmpty(items)) {
final HashMap<T, MutableInt> occurrences = new HashMap<T, MutableInt>(items.length); final HashMap<T, MutableInt> occurrences = new HashMap<>(items.length);
for (final T t : items) { for (final T t : items) {
final MutableInt count = occurrences.get(t); final MutableInt count = occurrences.get(t);
if (count == null) { if (count == null) {

View File

@ -131,7 +131,7 @@ public final class Range<T> implements Serializable {
* @throws ClassCastException if using natural ordering and the elements are not {@code Comparable} * @throws ClassCastException if using natural ordering and the elements are not {@code Comparable}
*/ */
public static <T> Range<T> between(final T fromInclusive, final T toInclusive, final Comparator<T> comparator) { public static <T> Range<T> between(final T fromInclusive, final T toInclusive, final Comparator<T> comparator) {
return new Range<T>(fromInclusive, toInclusive, comparator); return new Range<>(fromInclusive, toInclusive, comparator);
} }
/** /**

View File

@ -280,7 +280,7 @@ public class SerializationUtils {
*/ */
static class ClassLoaderAwareObjectInputStream extends ObjectInputStream { static class ClassLoaderAwareObjectInputStream extends ObjectInputStream {
private static final Map<String, Class<?>> primitiveTypes = private static final Map<String, Class<?>> primitiveTypes =
new HashMap<String, Class<?>>(); new HashMap<>();
static { static {
primitiveTypes.put("byte", byte.class); primitiveTypes.put("byte", byte.class);

View File

@ -3002,7 +3002,7 @@ public class StringUtils {
} }
final int closeLen = close.length(); final int closeLen = close.length();
final int openLen = open.length(); final int openLen = open.length();
final List<String> list = new ArrayList<String>(); final List<String> list = new ArrayList<>();
int pos = 0; int pos = 0;
while (pos < strLen - closeLen) { while (pos < strLen - closeLen) {
int start = str.indexOf(open, pos); int start = str.indexOf(open, pos);
@ -3298,7 +3298,7 @@ public class StringUtils {
final int separatorLength = separator.length(); final int separatorLength = separator.length();
final ArrayList<String> substrings = new ArrayList<String>(); final ArrayList<String> substrings = new ArrayList<>();
int numberOfSubstrings = 0; int numberOfSubstrings = 0;
int beg = 0; int beg = 0;
int end = 0; int end = 0;
@ -3432,7 +3432,7 @@ public class StringUtils {
if (len == 0) { if (len == 0) {
return ArrayUtils.EMPTY_STRING_ARRAY; return ArrayUtils.EMPTY_STRING_ARRAY;
} }
final List<String> list = new ArrayList<String>(); final List<String> list = new ArrayList<>();
int i = 0, start = 0; int i = 0, start = 0;
boolean match = false; boolean match = false;
boolean lastMatch = false; boolean lastMatch = false;
@ -3559,7 +3559,7 @@ public class StringUtils {
if (len == 0) { if (len == 0) {
return ArrayUtils.EMPTY_STRING_ARRAY; return ArrayUtils.EMPTY_STRING_ARRAY;
} }
final List<String> list = new ArrayList<String>(); final List<String> list = new ArrayList<>();
int sizePlus1 = 1; int sizePlus1 = 1;
int i = 0, start = 0; int i = 0, start = 0;
boolean match = false; boolean match = false;
@ -3705,7 +3705,7 @@ public class StringUtils {
return ArrayUtils.EMPTY_STRING_ARRAY; return ArrayUtils.EMPTY_STRING_ARRAY;
} }
final char[] c = str.toCharArray(); final char[] c = str.toCharArray();
final List<String> list = new ArrayList<String>(); final List<String> list = new ArrayList<>();
int tokenStart = 0; int tokenStart = 0;
int currentType = Character.getType(c[tokenStart]); int currentType = Character.getType(c[tokenStart]);
for (int pos = tokenStart + 1; pos < c.length; pos++) { for (int pos = tokenStart + 1; pos < c.length; pos++) {

View File

@ -131,7 +131,7 @@ public class ThreadUtils {
return Collections.emptyList(); return Collections.emptyList();
} }
final Collection<Thread> result = new ArrayList<Thread>(); final Collection<Thread> result = new ArrayList<>();
final NamePredicate threadNamePredicate = new NamePredicate(threadName); final NamePredicate threadNamePredicate = new NamePredicate(threadName);
for(final ThreadGroup group : threadGroups) { for(final ThreadGroup group : threadGroups) {
result.addAll(findThreads(group, false, threadNamePredicate)); result.addAll(findThreads(group, false, threadNamePredicate));
@ -413,7 +413,7 @@ public class ThreadUtils {
//return value of enumerate() must be strictly less than the array size according to javadoc //return value of enumerate() must be strictly less than the array size according to javadoc
} while (count >= threads.length); } while (count >= threads.length);
final List<Thread> result = new ArrayList<Thread>(count); final List<Thread> result = new ArrayList<>(count);
for (int i = 0; i < count; ++i) { for (int i = 0; i < count; ++i) {
if (predicate.test(threads[i])) { if (predicate.test(threads[i])) {
result.add(threads[i]); result.add(threads[i]);
@ -449,7 +449,7 @@ public class ThreadUtils {
//return value of enumerate() must be strictly less than the array size according to javadoc //return value of enumerate() must be strictly less than the array size according to javadoc
} while(count >= threadGroups.length); } while(count >= threadGroups.length);
final List<ThreadGroup> result = new ArrayList<ThreadGroup>(count); final List<ThreadGroup> result = new ArrayList<>(count);
for(int i = 0; i < count; ++i) { for(int i = 0; i < count; ++i) {
if(predicate.test(threadGroups[i])) { if(predicate.test(threadGroups[i])) {
result.add(threadGroups[i]); result.add(threadGroups[i]);

View File

@ -109,7 +109,7 @@ public class DiffBuilder implements Builder<DiffResult> {
throw new IllegalArgumentException("rhs cannot be null"); throw new IllegalArgumentException("rhs cannot be null");
} }
this.diffs = new ArrayList<Diff<?>>(); this.diffs = new ArrayList<>();
this.left = lhs; this.left = lhs;
this.right = rhs; this.right = rhs;
this.style = style; this.style = style;

View File

@ -92,7 +92,7 @@ public class EqualsBuilder implements Builder<Boolean> {
* *
* @since 3.0 * @since 3.0
*/ */
private static final ThreadLocal<Set<Pair<IDKey, IDKey>>> REGISTRY = new ThreadLocal<Set<Pair<IDKey, IDKey>>>(); private static final ThreadLocal<Set<Pair<IDKey, IDKey>>> REGISTRY = new ThreadLocal<>();
/* /*
* NOTE: we cannot store the actual objects in a HashSet, as that would use the very hashCode() * NOTE: we cannot store the actual objects in a HashSet, as that would use the very hashCode()
@ -174,7 +174,7 @@ public class EqualsBuilder implements Builder<Boolean> {
private static void register(final Object lhs, final Object rhs) { private static void register(final Object lhs, final Object rhs) {
Set<Pair<IDKey, IDKey>> registry = getRegistry(); Set<Pair<IDKey, IDKey>> registry = getRegistry();
if (registry == null) { if (registry == null) {
registry = new HashSet<Pair<IDKey, IDKey>>(); registry = new HashSet<>();
REGISTRY.set(registry); REGISTRY.set(registry);
} }
final Pair<IDKey, IDKey> pair = getRegisterPair(lhs, rhs); final Pair<IDKey, IDKey> pair = getRegisterPair(lhs, rhs);

View File

@ -118,7 +118,7 @@ public class HashCodeBuilder implements Builder<Integer> {
* *
* @since 2.3 * @since 2.3
*/ */
private static final ThreadLocal<Set<IDKey>> REGISTRY = new ThreadLocal<Set<IDKey>>(); private static final ThreadLocal<Set<IDKey>> REGISTRY = new ThreadLocal<>();
/* /*
* NOTE: we cannot store the actual objects in a HashSet, as that would use the very hashCode() * NOTE: we cannot store the actual objects in a HashSet, as that would use the very hashCode()
@ -500,7 +500,7 @@ public class HashCodeBuilder implements Builder<Integer> {
private static void register(final Object value) { private static void register(final Object value) {
Set<IDKey> registry = getRegistry(); Set<IDKey> registry = getRegistry();
if (registry == null) { if (registry == null) {
registry = new HashSet<IDKey>(); registry = new HashSet<>();
REGISTRY.set(registry); REGISTRY.set(registry);
} }
registry.add(new IDKey(value)); registry.add(new IDKey(value));

View File

@ -340,7 +340,7 @@ public class ReflectionToStringBuilder extends ToStringBuilder {
* @return The given array or a new array without null. * @return The given array or a new array without null.
*/ */
static String[] toNoNullStringArray(final Object[] array) { static String[] toNoNullStringArray(final Object[] array) {
final List<String> list = new ArrayList<String>(array.length); final List<String> list = new ArrayList<>(array.length);
for (final Object e : array) { for (final Object e : array) {
if (e != null) { if (e != null) {
list.add(e.toString()); list.add(e.toString());

View File

@ -165,7 +165,7 @@ public abstract class ToStringStyle implements Serializable {
* </p> * </p>
*/ */
private static final ThreadLocal<WeakHashMap<Object, Object>> REGISTRY = private static final ThreadLocal<WeakHashMap<Object, Object>> REGISTRY =
new ThreadLocal<WeakHashMap<Object,Object>>(); new ThreadLocal<>();
/* /*
* Note that objects of this class are generally shared between threads, so * Note that objects of this class are generally shared between threads, so
* an instance variable would not be suitable here. * an instance variable would not be suitable here.
@ -217,7 +217,7 @@ public abstract class ToStringStyle implements Serializable {
if (value != null) { if (value != null) {
final Map<Object, Object> m = getRegistry(); final Map<Object, Object> m = getRegistry();
if (m == null) { if (m == null) {
REGISTRY.set(new WeakHashMap<Object, Object>()); REGISTRY.set(new WeakHashMap<>());
} }
getRegistry().put(value, null); getRegistry().put(value, null);
} }

View File

@ -34,7 +34,7 @@ public abstract class AbstractCircuitBreaker<T> implements CircuitBreaker<T> {
public static final String PROPERTY_NAME = "open"; public static final String PROPERTY_NAME = "open";
/** The current state of this circuit breaker. */ /** The current state of this circuit breaker. */
protected final AtomicReference<State> state = new AtomicReference<State>(State.CLOSED); protected final AtomicReference<State> state = new AtomicReference<>(State.CLOSED);
/** An object for managing change listeners registered at this instance. */ /** An object for managing change listeners registered at this instance. */
private final PropertyChangeSupport changeSupport; private final PropertyChangeSupport changeSupport;

View File

@ -65,7 +65,7 @@ import java.util.concurrent.atomic.AtomicReference;
*/ */
public abstract class AtomicInitializer<T> implements ConcurrentInitializer<T> { public abstract class AtomicInitializer<T> implements ConcurrentInitializer<T> {
/** Holds the reference to the managed object. */ /** Holds the reference to the managed object. */
private final AtomicReference<T> reference = new AtomicReference<T>(); private final AtomicReference<T> reference = new AtomicReference<>();
/** /**
* Returns the object managed by this initializer. The object is created if * Returns the object managed by this initializer. The object is created if

View File

@ -56,10 +56,10 @@ public abstract class AtomicSafeInitializer<T> implements
ConcurrentInitializer<T> { ConcurrentInitializer<T> {
/** A guard which ensures that initialize() is called only once. */ /** A guard which ensures that initialize() is called only once. */
private final AtomicReference<AtomicSafeInitializer<T>> factory = private final AtomicReference<AtomicSafeInitializer<T>> factory =
new AtomicReference<AtomicSafeInitializer<T>>(); new AtomicReference<>();
/** Holds the reference to the managed object. */ /** Holds the reference to the managed object. */
private final AtomicReference<T> reference = new AtomicReference<T>(); private final AtomicReference<T> reference = new AtomicReference<>();
/** /**
* Get (and initialize, if not initialized yet) the required object * Get (and initialize, if not initialized yet) the required object

View File

@ -322,7 +322,7 @@ public class ConcurrentUtils {
* @return an instance of Future that will return the value, never null * @return an instance of Future that will return the value, never null
*/ */
public static <T> Future<T> constantFuture(final T value) { public static <T> Future<T> constantFuture(final T value) {
return new ConstantFuture<T>(value); return new ConstantFuture<>(value);
} }
/** /**

View File

@ -175,7 +175,7 @@ public class EventCountCircuitBreaker extends AbstractCircuitBreaker<Integer> {
TimeUnit openingUnit, int closingThreshold, long closingInterval, TimeUnit openingUnit, int closingThreshold, long closingInterval,
TimeUnit closingUnit) { TimeUnit closingUnit) {
super(); super();
checkIntervalData = new AtomicReference<CheckIntervalData>(new CheckIntervalData(0, 0)); checkIntervalData = new AtomicReference<>(new CheckIntervalData(0, 0));
this.openingThreshold = openingThreshold; this.openingThreshold = openingThreshold;
this.openingInterval = openingUnit.toNanos(openingInterval); this.openingInterval = openingUnit.toNanos(openingInterval);
this.closingThreshold = closingThreshold; this.closingThreshold = closingThreshold;
@ -416,7 +416,7 @@ public class EventCountCircuitBreaker extends AbstractCircuitBreaker<Integer> {
* @return the strategy map * @return the strategy map
*/ */
private static Map<State, StateStrategy> createStrategyMap() { private static Map<State, StateStrategy> createStrategyMap() {
Map<State, StateStrategy> map = new EnumMap<State, StateStrategy>(State.class); Map<State, StateStrategy> map = new EnumMap<>(State.class);
map.put(State.CLOSED, new StateStrategyClosed()); map.put(State.CLOSED, new StateStrategyClosed());
map.put(State.OPEN, new StateStrategyOpen()); map.put(State.OPEN, new StateStrategyOpen());
return map; return map;

View File

@ -98,7 +98,7 @@ public class MultiBackgroundInitializer
BackgroundInitializer<MultiBackgroundInitializer.MultiBackgroundInitializerResults> { BackgroundInitializer<MultiBackgroundInitializer.MultiBackgroundInitializerResults> {
/** A map with the child initializers. */ /** A map with the child initializers. */
private final Map<String, BackgroundInitializer<?>> childInitializers = private final Map<String, BackgroundInitializer<?>> childInitializers =
new HashMap<String, BackgroundInitializer<?>>(); new HashMap<>();
/** /**
* Creates a new instance of {@code MultiBackgroundInitializer}. * Creates a new instance of {@code MultiBackgroundInitializer}.
@ -185,7 +185,7 @@ public class MultiBackgroundInitializer
Map<String, BackgroundInitializer<?>> inits; Map<String, BackgroundInitializer<?>> inits;
synchronized (this) { synchronized (this) {
// create a snapshot to operate on // create a snapshot to operate on
inits = new HashMap<String, BackgroundInitializer<?>>( inits = new HashMap<>(
childInitializers); childInitializers);
} }
@ -200,8 +200,8 @@ public class MultiBackgroundInitializer
} }
// collect the results // collect the results
final Map<String, Object> results = new HashMap<String, Object>(); final Map<String, Object> results = new HashMap<>();
final Map<String, ConcurrentException> excepts = new HashMap<String, ConcurrentException>(); final Map<String, ConcurrentException> excepts = new HashMap<>();
for (final Map.Entry<String, BackgroundInitializer<?>> e : inits.entrySet()) { for (final Map.Entry<String, BackgroundInitializer<?>> e : inits.entrySet()) {
try { try {
results.put(e.getKey(), e.getValue().get()); results.put(e.getKey(), e.getValue().get());

View File

@ -76,7 +76,7 @@ public class EventListenerSupport<L> implements Serializable {
* intentionally a thread-safe copy-on-write-array so that traversals over * intentionally a thread-safe copy-on-write-array so that traversals over
* the list of listeners will be atomic. * the list of listeners will be atomic.
*/ */
private List<L> listeners = new CopyOnWriteArrayList<L>(); private List<L> listeners = new CopyOnWriteArrayList<>();
/** /**
* The proxy representing the collection of listeners. Calls to this proxy * The proxy representing the collection of listeners. Calls to this proxy
@ -106,7 +106,7 @@ public class EventListenerSupport<L> implements Serializable {
* not an interface. * not an interface.
*/ */
public static <T> EventListenerSupport<T> create(final Class<T> listenerInterface) { public static <T> EventListenerSupport<T> create(final Class<T> listenerInterface) {
return new EventListenerSupport<T>(listenerInterface); return new EventListenerSupport<>(listenerInterface);
} }
/** /**
@ -240,7 +240,7 @@ public class EventListenerSupport<L> implements Serializable {
* @throws IOException if an IO error occurs * @throws IOException if an IO error occurs
*/ */
private void writeObject(final ObjectOutputStream objectOutputStream) throws IOException { private void writeObject(final ObjectOutputStream objectOutputStream) throws IOException {
final ArrayList<L> serializableListeners = new ArrayList<L>(); final ArrayList<L> serializableListeners = new ArrayList<>();
// don't just rely on instanceof Serializable: // don't just rely on instanceof Serializable:
ObjectOutputStream testObjectOutputStream = new ObjectOutputStream(new ByteArrayOutputStream()); ObjectOutputStream testObjectOutputStream = new ObjectOutputStream(new ByteArrayOutputStream());
@ -271,7 +271,7 @@ public class EventListenerSupport<L> implements Serializable {
final final
L[] srcListeners = (L[]) objectInputStream.readObject(); L[] srcListeners = (L[]) objectInputStream.readObject();
this.listeners = new CopyOnWriteArrayList<L>(srcListeners); this.listeners = new CopyOnWriteArrayList<>(srcListeners);
@SuppressWarnings("unchecked") // Will throw CCE here if not correct @SuppressWarnings("unchecked") // Will throw CCE here if not correct
final final

View File

@ -93,7 +93,7 @@ public class EventUtils {
EventBindingInvocationHandler(final Object target, final String methodName, final String[] eventTypes) { EventBindingInvocationHandler(final Object target, final String methodName, final String[] eventTypes) {
this.target = target; this.target = target;
this.methodName = methodName; this.methodName = methodName;
this.eventTypes = new HashSet<String>(Arrays.asList(eventTypes)); this.eventTypes = new HashSet<>(Arrays.asList(eventTypes));
} }
/** /**

View File

@ -44,14 +44,14 @@ public class DefaultExceptionContext implements ExceptionContext, Serializable {
private static final long serialVersionUID = 20110706L; private static final long serialVersionUID = 20110706L;
/** The list storing the label-data pairs. */ /** The list storing the label-data pairs. */
private final List<Pair<String, Object>> contextValues = new ArrayList<Pair<String,Object>>(); private final List<Pair<String, Object>> contextValues = new ArrayList<>();
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override @Override
public DefaultExceptionContext addContextValue(final String label, final Object value) { public DefaultExceptionContext addContextValue(final String label, final Object value) {
contextValues.add(new ImmutablePair<String, Object>(label, value)); contextValues.add(new ImmutablePair<>(label, value));
return this; return this;
} }
@ -75,7 +75,7 @@ public class DefaultExceptionContext implements ExceptionContext, Serializable {
*/ */
@Override @Override
public List<Object> getContextValues(final String label) { public List<Object> getContextValues(final String label) {
final List<Object> values = new ArrayList<Object>(); final List<Object> values = new ArrayList<>();
for (final Pair<String, Object> pair : contextValues) { for (final Pair<String, Object> pair : contextValues) {
if (StringUtils.equals(label, pair.getKey())) { if (StringUtils.equals(label, pair.getKey())) {
values.add(pair.getValue()); values.add(pair.getValue());
@ -102,7 +102,7 @@ public class DefaultExceptionContext implements ExceptionContext, Serializable {
*/ */
@Override @Override
public Set<String> getContextLabels() { public Set<String> getContextLabels() {
final Set<String> labels = new HashSet<String>(); final Set<String> labels = new HashSet<>();
for (final Pair<String, Object> pair : contextValues) { for (final Pair<String, Object> pair : contextValues) {
labels.add(pair.getKey()); labels.add(pair.getKey());
} }

View File

@ -283,7 +283,7 @@ public class ExceptionUtils {
* @since Commons Lang 2.2 * @since Commons Lang 2.2
*/ */
public static List<Throwable> getThrowableList(Throwable throwable) { public static List<Throwable> getThrowableList(Throwable throwable) {
final List<Throwable> list = new ArrayList<Throwable>(); final List<Throwable> list = new ArrayList<>();
while (throwable != null && list.contains(throwable) == false) { while (throwable != null && list.contains(throwable) == false) {
list.add(throwable); list.add(throwable);
throwable = ExceptionUtils.getCause(throwable); throwable = ExceptionUtils.getCause(throwable);
@ -524,7 +524,7 @@ public class ExceptionUtils {
} }
final Throwable throwables[] = getThrowables(throwable); final Throwable throwables[] = getThrowables(throwable);
final int count = throwables.length; final int count = throwables.length;
final List<String> frames = new ArrayList<String>(); final List<String> frames = new ArrayList<>();
List<String> nextTrace = getStackFrameList(throwables[count - 1]); List<String> nextTrace = getStackFrameList(throwables[count - 1]);
for (int i = count; --i >= 0;) { for (int i = count; --i >= 0;) {
final List<String> trace = nextTrace; final List<String> trace = nextTrace;
@ -623,7 +623,7 @@ public class ExceptionUtils {
static String[] getStackFrames(final String stackTrace) { static String[] getStackFrames(final String stackTrace) {
final String linebreak = SystemUtils.LINE_SEPARATOR; final String linebreak = SystemUtils.LINE_SEPARATOR;
final StringTokenizer frames = new StringTokenizer(stackTrace, linebreak); final StringTokenizer frames = new StringTokenizer(stackTrace, linebreak);
final List<String> list = new ArrayList<String>(); final List<String> list = new ArrayList<>();
while (frames.hasMoreTokens()) { while (frames.hasMoreTokens()) {
list.add(frames.nextToken()); list.add(frames.nextToken());
} }
@ -646,7 +646,7 @@ public class ExceptionUtils {
final String stackTrace = getStackTrace(t); final String stackTrace = getStackTrace(t);
final String linebreak = SystemUtils.LINE_SEPARATOR; final String linebreak = SystemUtils.LINE_SEPARATOR;
final StringTokenizer frames = new StringTokenizer(stackTrace, linebreak); final StringTokenizer frames = new StringTokenizer(stackTrace, linebreak);
final List<String> list = new ArrayList<String>(); final List<String> list = new ArrayList<>();
boolean traceStarted = false; boolean traceStarted = false;
while (frames.hasMoreTokens()) { while (frames.hasMoreTokens()) {
final String token = frames.nextToken(); final String token = frames.nextToken();

View File

@ -211,7 +211,7 @@ public class FieldUtils {
*/ */
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.isTrue(cls != null, "The class must not be null");
final List<Field> allFields = new ArrayList<Field>(); final List<Field> allFields = new ArrayList<>();
Class<?> currentClass = cls; Class<?> currentClass = cls;
while (currentClass != null) { while (currentClass != null) {
final Field[] declaredFields = currentClass.getDeclaredFields(); final Field[] declaredFields = currentClass.getDeclaredFields();
@ -253,7 +253,7 @@ public class FieldUtils {
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.isTrue(annotationCls != null, "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<Field>(); final List<Field> annotatedFields = new ArrayList<>();
for (final Field field : allFields) { for (final Field field : allFields) {
if (field.getAnnotation(annotationCls) != null) { if (field.getAnnotation(annotationCls) != null) {
annotatedFields.add(field); annotatedFields.add(field);

View File

@ -781,7 +781,7 @@ public class MethodUtils {
*/ */
public static Set<Method> getOverrideHierarchy(final Method method, final Interfaces interfacesBehavior) { public static Set<Method> getOverrideHierarchy(final Method method, final Interfaces interfacesBehavior) {
Validate.notNull(method); Validate.notNull(method);
final Set<Method> result = new LinkedHashSet<Method>(); final Set<Method> result = new LinkedHashSet<>();
result.add(method); result.add(method);
final Class<?>[] parameterTypes = method.getParameterTypes(); final Class<?>[] parameterTypes = method.getParameterTypes();
@ -847,7 +847,7 @@ public class MethodUtils {
Validate.isTrue(cls != null, "The class must not be null"); Validate.isTrue(cls != null, "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 Method[] allMethods = cls.getMethods(); final Method[] allMethods = cls.getMethods();
final List<Method> annotatedMethods = new ArrayList<Method>(); final List<Method> annotatedMethods = new ArrayList<>();
for (final Method method : allMethods) { for (final Method method : allMethods) {
if (method.getAnnotation(annotationCls) != null) { if (method.getAnnotation(annotationCls) != null) {
annotatedMethods.add(method); annotatedMethods.add(method);

View File

@ -865,7 +865,7 @@ public class TypeUtils {
} else { } else {
// no owner, prep the type variable assignments map // no owner, prep the type variable assignments map
typeVarAssigns = subtypeVarAssigns == null ? new HashMap<TypeVariable<?>, Type>() typeVarAssigns = subtypeVarAssigns == null ? new HashMap<TypeVariable<?>, Type>()
: new HashMap<TypeVariable<?>, Type>(subtypeVarAssigns); : new HashMap<>(subtypeVarAssigns);
} }
// get the subject parameterized type's arguments // get the subject parameterized type's arguments
@ -910,7 +910,7 @@ public class TypeUtils {
if (toClass.isPrimitive()) { if (toClass.isPrimitive()) {
// dealing with widening here. No type arguments to be // dealing with widening here. No type arguments to be
// harvested with these two types. // harvested with these two types.
return new HashMap<TypeVariable<?>, Type>(); return new HashMap<>();
} }
// work with wrapper the wrapper class instead of the primitive // work with wrapper the wrapper class instead of the primitive
@ -919,7 +919,7 @@ public class TypeUtils {
// create a copy of the incoming map, or an empty one if it's null // create a copy of the incoming map, or an empty one if it's null
final HashMap<TypeVariable<?>, Type> typeVarAssigns = subtypeVarAssigns == null ? new HashMap<TypeVariable<?>, Type>() final HashMap<TypeVariable<?>, Type> typeVarAssigns = subtypeVarAssigns == null ? new HashMap<TypeVariable<?>, Type>()
: new HashMap<TypeVariable<?>, Type>(subtypeVarAssigns); : new HashMap<>(subtypeVarAssigns);
// has target class been reached? // has target class been reached?
if (toClass.equals(cls)) { if (toClass.equals(cls)) {
@ -1132,7 +1132,7 @@ public class TypeUtils {
return bounds; return bounds;
} }
final Set<Type> types = new HashSet<Type>(bounds.length); final Set<Type> types = new HashSet<>(bounds.length);
for (final Type type1 : bounds) { for (final Type type1 : bounds) {
boolean subtypeFound = false; boolean subtypeFound = false;
@ -1377,7 +1377,7 @@ public class TypeUtils {
if (p.getOwnerType() == null) { if (p.getOwnerType() == null) {
parameterizedTypeArguments = typeArguments; parameterizedTypeArguments = typeArguments;
} else { } else {
parameterizedTypeArguments = new HashMap<TypeVariable<?>, Type>(typeArguments); parameterizedTypeArguments = new HashMap<>(typeArguments);
parameterizedTypeArguments.putAll(TypeUtils.getTypeArguments(p)); parameterizedTypeArguments.putAll(TypeUtils.getTypeArguments(p));
} }
final Type[] args = p.getActualTypeArguments(); final Type[] args = p.getActualTypeArguments();

View File

@ -145,8 +145,8 @@ public class ExtendedMessageFormat extends MessageFormat {
toPattern = super.toPattern(); toPattern = super.toPattern();
return; return;
} }
final ArrayList<Format> foundFormats = new ArrayList<Format>(); final ArrayList<Format> foundFormats = new ArrayList<>();
final ArrayList<String> foundDescriptions = new ArrayList<String>(); final ArrayList<String> foundDescriptions = new ArrayList<>();
final StringBuilder stripCustom = new StringBuilder(pattern.length()); final StringBuilder stripCustom = new StringBuilder(pattern.length());
final ParsePosition pos = new ParsePosition(0); final ParsePosition pos = new ParsePosition(0);

View File

@ -38,7 +38,7 @@ public abstract class StrLookup<V> {
/** /**
* Lookup that always returns null. * Lookup that always returns null.
*/ */
private static final StrLookup<String> NONE_LOOKUP = new MapStrLookup<String>(null); private static final StrLookup<String> NONE_LOOKUP = new MapStrLookup<>(null);
/** /**
* Lookup based on system properties. * Lookup based on system properties.
@ -81,7 +81,7 @@ public abstract class StrLookup<V> {
* @return a lookup using the map, not null * @return a lookup using the map, not null
*/ */
public static <V> StrLookup<V> mapLookup(final Map<String, V> map) { public static <V> StrLookup<V> mapLookup(final Map<String, V> map) {
return new MapStrLookup<V>(map); return new MapStrLookup<>(map);
} }
//----------------------------------------------------------------------- //-----------------------------------------------------------------------

View File

@ -213,7 +213,7 @@ public class StrSubstitutor {
if (valueProperties == null) { if (valueProperties == null) {
return source.toString(); return source.toString();
} }
final Map<String,String> valueMap = new HashMap<String,String>(); final Map<String,String> valueMap = new HashMap<>();
final Enumeration<?> propNames = valueProperties.propertyNames(); final Enumeration<?> propNames = valueProperties.propertyNames();
while (propNames.hasMoreElements()) { while (propNames.hasMoreElements()) {
final String propName = (String)propNames.nextElement(); final String propName = (String)propNames.nextElement();
@ -837,7 +837,7 @@ public class StrSubstitutor {
// on the first call initialize priorVariables // on the first call initialize priorVariables
if (priorVariables == null) { if (priorVariables == null) {
priorVariables = new ArrayList<String>(); priorVariables = new ArrayList<>();
priorVariables.add(new String(chars, priorVariables.add(new String(chars,
offset, length)); offset, length));
} }

View File

@ -440,7 +440,7 @@ public class StrTokenizer implements ListIterator<String>, Cloneable {
*/ */
public List<String> getTokenList() { public List<String> getTokenList() {
checkTokenized(); checkTokenized();
final List<String> list = new ArrayList<String>(tokens.length); final List<String> list = new ArrayList<>(tokens.length);
for (final String element : tokens) { for (final String element : tokens) {
list.add(element); list.add(element);
} }
@ -636,7 +636,7 @@ public class StrTokenizer implements ListIterator<String>, Cloneable {
return Collections.emptyList(); return Collections.emptyList();
} }
final StrBuilder buf = new StrBuilder(); final StrBuilder buf = new StrBuilder();
final List<String> tokenList = new ArrayList<String>(); final List<String> tokenList = new ArrayList<>();
int pos = offset; int pos = offset;
// loop around the entire buffer // loop around the entire buffer

View File

@ -43,8 +43,8 @@ public class LookupTranslator extends CharSequenceTranslator {
* @param lookup CharSequence[][] table of size [*][2] * @param lookup CharSequence[][] table of size [*][2]
*/ */
public LookupTranslator(final CharSequence[]... lookup) { public LookupTranslator(final CharSequence[]... lookup) {
lookupMap = new HashMap<String, String>(); lookupMap = new HashMap<>();
prefixSet = new HashSet<Character>(); prefixSet = new HashSet<>();
int _shortest = Integer.MAX_VALUE; int _shortest = Integer.MAX_VALUE;
int _longest = 0; int _longest = 0;
if (lookup != null) { if (lookup != null) {

View File

@ -494,7 +494,7 @@ public class DurationFormatUtils {
* @return array of Token[] * @return array of Token[]
*/ */
static Token[] lexx(final String format) { static Token[] lexx(final String format) {
final ArrayList<Token> list = new ArrayList<Token>(format.length()); final ArrayList<Token> list = new ArrayList<>(format.length());
boolean inLiteral = false; boolean inLiteral = false;
// Although the buffer is stored in a Token, the Tokens are only // Although the buffer is stored in a Token, the Tokens are only

View File

@ -160,7 +160,7 @@ public class FastDateParser implements DateParser, Serializable {
* @param definingCalendar the {@link java.util.Calendar} instance used to initialize this FastDateParser * @param definingCalendar the {@link java.util.Calendar} instance used to initialize this FastDateParser
*/ */
private void init(final Calendar definingCalendar) { private void init(final Calendar definingCalendar) {
patterns = new ArrayList<StrategyAndWidth>(); patterns = new ArrayList<>();
StrategyParser fm = new StrategyParser(pattern, definingCalendar); StrategyParser fm = new StrategyParser(pattern, definingCalendar);
for(;;) { for(;;) {
@ -464,10 +464,10 @@ public class FastDateParser implements DateParser, Serializable {
* @return The map of string display names to field values * @return The map of string display names to field values
*/ */
private static Map<String, Integer> appendDisplayNames(Calendar cal, Locale locale, int field, StringBuilder regex) { private static Map<String, Integer> appendDisplayNames(Calendar cal, Locale locale, int field, StringBuilder regex) {
Map<String, Integer> values = new HashMap<String, Integer>(); Map<String, Integer> values = new HashMap<>();
Map<String, Integer> displayNames = cal.getDisplayNames(field, Calendar.ALL_STYLES, locale); Map<String, Integer> displayNames = cal.getDisplayNames(field, Calendar.ALL_STYLES, locale);
TreeSet<String> sorted = new TreeSet<String>(LONGER_FIRST_LOWERCASE); TreeSet<String> sorted = new TreeSet<>(LONGER_FIRST_LOWERCASE);
for (Map.Entry<String, Integer> displayName : displayNames.entrySet()) { for (Map.Entry<String, Integer> displayName : displayNames.entrySet()) {
String key = displayName.getKey().toLowerCase(locale); String key = displayName.getKey().toLowerCase(locale);
if (sorted.add(key)) { if (sorted.add(key)) {
@ -618,7 +618,7 @@ public class FastDateParser implements DateParser, Serializable {
private static ConcurrentMap<Locale, Strategy> getCache(final int field) { private static ConcurrentMap<Locale, Strategy> getCache(final int field) {
synchronized (caches) { synchronized (caches) {
if (caches[field] == null) { if (caches[field] == null) {
caches[field] = new ConcurrentHashMap<Locale, Strategy>(3); caches[field] = new ConcurrentHashMap<>(3);
} }
return caches[field]; return caches[field];
} }
@ -815,7 +815,7 @@ public class FastDateParser implements DateParser, Serializable {
private static final String GMT_OPTION= "GMT[+-]\\d{1,2}:\\d{2}"; private static final String GMT_OPTION= "GMT[+-]\\d{1,2}:\\d{2}";
private final Locale locale; private final Locale locale;
private final Map<String, TzInfo> tzNames= new HashMap<String, TzInfo>(); private final Map<String, TzInfo> tzNames= new HashMap<>();
private static class TzInfo { private static class TzInfo {
TimeZone zone; TimeZone zone;
@ -842,7 +842,7 @@ public class FastDateParser implements DateParser, Serializable {
final StringBuilder sb = new StringBuilder(); final StringBuilder sb = new StringBuilder();
sb.append("((?iu)" + RFC_822_TIME_ZONE + "|" + GMT_OPTION ); sb.append("((?iu)" + RFC_822_TIME_ZONE + "|" + GMT_OPTION );
final Set<String> sorted = new TreeSet<String>(LONGER_FIRST_LOWERCASE); final Set<String> sorted = new TreeSet<>(LONGER_FIRST_LOWERCASE);
final String[][] zones = DateFormatSymbols.getInstance(locale).getZoneStrings(); final String[][] zones = DateFormatSymbols.getInstance(locale).getZoneStrings();
for (final String[] zoneNames : zones) { for (final String[] zoneNames : zones) {

View File

@ -180,7 +180,7 @@ public class FastDatePrinter implements DatePrinter, Serializable {
*/ */
protected List<Rule> parsePattern() { protected List<Rule> parsePattern() {
final DateFormatSymbols symbols = new DateFormatSymbols(mLocale); final DateFormatSymbols symbols = new DateFormatSymbols(mLocale);
final List<Rule> rules = new ArrayList<Rule>(); final List<Rule> rules = new ArrayList<>();
final String[] ERAs = symbols.getEras(); final String[] ERAs = symbols.getEras();
final String[] months = symbols.getMonths(); final String[] months = symbols.getMonths();
@ -1302,7 +1302,7 @@ public class FastDatePrinter implements DatePrinter, Serializable {
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
private static final ConcurrentMap<TimeZoneDisplayKey, String> cTimeZoneDisplayCache = private static final ConcurrentMap<TimeZoneDisplayKey, String> cTimeZoneDisplayCache =
new ConcurrentHashMap<TimeZoneDisplayKey, String>(7); new ConcurrentHashMap<>(7);
/** /**
* <p>Gets the time zone display name, using a cache for performance.</p> * <p>Gets the time zone display name, using a cache for performance.</p>
* *

View File

@ -38,10 +38,10 @@ abstract class FormatCache<F extends Format> {
static final int NONE= -1; static final int NONE= -1;
private final ConcurrentMap<MultipartKey, F> cInstanceCache private final ConcurrentMap<MultipartKey, F> cInstanceCache
= new ConcurrentHashMap<MultipartKey, F>(7); = new ConcurrentHashMap<>(7);
private static final ConcurrentMap<MultipartKey, String> cDateTimeInstanceCache private static final ConcurrentMap<MultipartKey, String> cDateTimeInstanceCache
= new ConcurrentHashMap<MultipartKey, String>(7); = new ConcurrentHashMap<>(7);
/** /**
* <p>Gets a formatter instance using the default pattern in the * <p>Gets a formatter instance using the default pattern in the

View File

@ -54,7 +54,7 @@ public final class ImmutablePair<L, R> extends Pair<L, R> {
* @return a pair formed from the two parameters, not null * @return a pair formed from the two parameters, not null
*/ */
public static <L, R> ImmutablePair<L, R> of(final L left, final R right) { public static <L, R> ImmutablePair<L, R> of(final L left, final R right) {
return new ImmutablePair<L, R>(left, right); return new ImmutablePair<>(left, right);
} }
/** /**

View File

@ -59,7 +59,7 @@ public final class ImmutableTriple<L, M, R> extends Triple<L, M, R> {
* @return a triple formed from the three parameters, not null * @return a triple formed from the three parameters, not null
*/ */
public static <L, M, R> ImmutableTriple<L, M, R> of(final L left, final M middle, final R right) { public static <L, M, R> ImmutableTriple<L, M, R> of(final L left, final M middle, final R right) {
return new ImmutableTriple<L, M, R>(left, middle, right); return new ImmutableTriple<>(left, middle, right);
} }
/** /**

View File

@ -49,7 +49,7 @@ public class MutablePair<L, R> extends Pair<L, R> {
* @return a pair formed from the two parameters, not null * @return a pair formed from the two parameters, not null
*/ */
public static <L, R> MutablePair<L, R> of(final L left, final R right) { public static <L, R> MutablePair<L, R> of(final L left, final R right) {
return new MutablePair<L, R>(left, right); return new MutablePair<>(left, right);
} }
/** /**

View File

@ -54,7 +54,7 @@ public class MutableTriple<L, M, R> extends Triple<L, M, R> {
* @return a triple formed from the three parameters, not null * @return a triple formed from the three parameters, not null
*/ */
public static <L, M, R> MutableTriple<L, M, R> of(final L left, final M middle, final R right) { public static <L, M, R> MutableTriple<L, M, R> of(final L left, final M middle, final R right) {
return new MutableTriple<L, M, R>(left, middle, right); return new MutableTriple<>(left, middle, right);
} }
/** /**

View File

@ -56,7 +56,7 @@ public abstract class Pair<L, R> implements Map.Entry<L, R>, Comparable<Pair<L,
* @return a pair formed from the two parameters, not null * @return a pair formed from the two parameters, not null
*/ */
public static <L, R> Pair<L, R> of(final L left, final R right) { public static <L, R> Pair<L, R> of(final L left, final R right) {
return new ImmutablePair<L, R>(left, right); return new ImmutablePair<>(left, right);
} }
//----------------------------------------------------------------------- //-----------------------------------------------------------------------

View File

@ -57,7 +57,7 @@ public abstract class Triple<L, M, R> implements Comparable<Triple<L, M, R>>, Se
* @return a triple formed from the three parameters, not null * @return a triple formed from the three parameters, not null
*/ */
public static <L, M, R> Triple<L, M, R> of(final L left, final M middle, final R right) { public static <L, M, R> Triple<L, M, R> of(final L left, final M middle, final R right) {
return new ImmutableTriple<L, M, R>(left, middle, right); return new ImmutableTriple<>(left, middle, right);
} }
//----------------------------------------------------------------------- //-----------------------------------------------------------------------

View File

@ -302,7 +302,7 @@ public class ClassUtilsTest {
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
@Test @Test
public void test_convertClassNamesToClasses_List() { public void test_convertClassNamesToClasses_List() {
final List<String> list = new ArrayList<String>(); final List<String> list = new ArrayList<>();
List<Class<?>> result = ClassUtils.convertClassNamesToClasses(list); List<Class<?>> result = ClassUtils.convertClassNamesToClasses(list);
assertEquals(0, result.size()); assertEquals(0, result.size());
@ -328,7 +328,7 @@ public class ClassUtilsTest {
@Test @Test
public void test_convertClassesToClassNames_List() { public void test_convertClassesToClassNames_List() {
final List<Class<?>> list = new ArrayList<Class<?>>(); final List<Class<?>> list = new ArrayList<>();
List<String> result = ClassUtils.convertClassesToClassNames(list); List<String> result = ClassUtils.convertClassesToClassNames(list);
assertEquals(0, result.size()); assertEquals(0, result.size());
@ -1103,7 +1103,7 @@ public class ClassUtilsTest {
@Test @Test
public void testShowJavaBug() throws Exception { public void testShowJavaBug() throws Exception {
// Tests with Collections$UnmodifiableSet // Tests with Collections$UnmodifiableSet
final Set<?> set = Collections.unmodifiableSet(new HashSet<Object>()); final Set<?> set = Collections.unmodifiableSet(new HashSet<>());
final Method isEmptyMethod = set.getClass().getMethod("isEmpty", new Class[0]); final Method isEmptyMethod = set.getClass().getMethod("isEmpty", new Class[0]);
try { try {
isEmptyMethod.invoke(set, new Object[0]); isEmptyMethod.invoke(set, new Object[0]);
@ -1116,7 +1116,7 @@ public class ClassUtilsTest {
@Test @Test
public void testGetPublicMethod() throws Exception { public void testGetPublicMethod() throws Exception {
// Tests with Collections$UnmodifiableSet // Tests with Collections$UnmodifiableSet
final Set<?> set = Collections.unmodifiableSet(new HashSet<Object>()); final Set<?> set = Collections.unmodifiableSet(new HashSet<>());
final Method isEmptyMethod = ClassUtils.getPublicMethod(set.getClass(), "isEmpty", new Class[0]); final Method isEmptyMethod = ClassUtils.getPublicMethod(set.getClass(), "isEmpty", new Class[0]);
assertTrue(Modifier.isPublic(isEmptyMethod.getDeclaringClass().getModifiers())); assertTrue(Modifier.isPublic(isEmptyMethod.getDeclaringClass().getModifiers()));

View File

@ -80,7 +80,7 @@ public class HashSetvBitSetTest {
@SuppressWarnings("boxing") @SuppressWarnings("boxing")
private static int[] testHashSet(final int count) { private static int[] testHashSet(final int count) {
final HashSet<Integer> toRemove = new HashSet<Integer>(); final HashSet<Integer> toRemove = new HashSet<>();
int found = 0; int found = 0;
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
toRemove.add(found++); toRemove.add(found++);

View File

@ -349,7 +349,7 @@ public class LocaleUtilsTest {
final Locale[] jdkLocaleArray = Locale.getAvailableLocales(); final Locale[] jdkLocaleArray = Locale.getAvailableLocales();
final List<Locale> jdkLocaleList = Arrays.asList(jdkLocaleArray); final List<Locale> jdkLocaleList = Arrays.asList(jdkLocaleArray);
final Set<Locale> jdkLocaleSet = new HashSet<Locale>(jdkLocaleList); final Set<Locale> jdkLocaleSet = new HashSet<>(jdkLocaleList);
assertEquals(jdkLocaleSet, set); assertEquals(jdkLocaleSet, set);
} }

View File

@ -160,7 +160,7 @@ public class ObjectUtilsTest {
@Test @Test
public void testHashCodeMulti_multiple_likeList() { public void testHashCodeMulti_multiple_likeList() {
final List<Object> list0 = new ArrayList<Object>(Arrays.asList(new Object[0])); final List<Object> list0 = new ArrayList<>(Arrays.asList(new Object[0]));
assertEquals(list0.hashCode(), ObjectUtils.hashCodeMulti()); assertEquals(list0.hashCode(), ObjectUtils.hashCodeMulti());
final List<Object> list1 = new ArrayList<Object>(Arrays.asList("a")); final List<Object> list1 = new ArrayList<Object>(Arrays.asList("a"));

View File

@ -56,7 +56,7 @@ public class SerializationUtilsTest {
public void setUp() { public void setUp() {
iString = "foo"; iString = "foo";
iInteger = Integer.valueOf(7); iInteger = Integer.valueOf(7);
iMap = new HashMap<Object, Object>(); iMap = new HashMap<>();
iMap.put("FOO", iString); iMap.put("FOO", iString);
iMap.put("BAR", iInteger); iMap.put("BAR", iInteger);
} }

View File

@ -186,7 +186,7 @@ public class ValidateTest {
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
@Test @Test
public void testNotEmptyCollection1() { public void testNotEmptyCollection1() {
final Collection<Integer> coll = new ArrayList<Integer>(); final Collection<Integer> coll = new ArrayList<>();
try { try {
Validate.notEmpty((Collection<?>) null); Validate.notEmpty((Collection<?>) null);
fail("Expecting NullPointerException"); fail("Expecting NullPointerException");
@ -209,7 +209,7 @@ public class ValidateTest {
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
@Test @Test
public void testNotEmptyCollection2() { public void testNotEmptyCollection2() {
final Collection<Integer> coll = new ArrayList<Integer>(); final Collection<Integer> coll = new ArrayList<>();
try { try {
Validate.notEmpty((Collection<?>) null, "MSG"); Validate.notEmpty((Collection<?>) null, "MSG");
fail("Expecting NullPointerException"); fail("Expecting NullPointerException");
@ -233,7 +233,7 @@ public class ValidateTest {
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
@Test @Test
public void testNotEmptyMap1() { public void testNotEmptyMap1() {
final Map<String, Integer> map = new HashMap<String, Integer>(); final Map<String, Integer> map = new HashMap<>();
try { try {
Validate.notEmpty((Map<?, ?>) null); Validate.notEmpty((Map<?, ?>) null);
fail("Expecting NullPointerException"); fail("Expecting NullPointerException");
@ -256,7 +256,7 @@ public class ValidateTest {
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
@Test @Test
public void testNotEmptyMap2() { public void testNotEmptyMap2() {
final Map<String, Integer> map = new HashMap<String, Integer>(); final Map<String, Integer> map = new HashMap<>();
try { try {
Validate.notEmpty((Map<?, ?>) null, "MSG"); Validate.notEmpty((Map<?, ?>) null, "MSG");
fail("Expecting NullPointerException"); fail("Expecting NullPointerException");
@ -590,7 +590,7 @@ public class ValidateTest {
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
@Test @Test
public void testNoNullElementsCollection1() { public void testNoNullElementsCollection1() {
final List<String> coll = new ArrayList<String>(); final List<String> coll = new ArrayList<>();
coll.add("a"); coll.add("a");
coll.add("b"); coll.add("b");
Validate.noNullElements(coll); Validate.noNullElements(coll);
@ -616,7 +616,7 @@ public class ValidateTest {
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
@Test @Test
public void testNoNullElementsCollection2() { public void testNoNullElementsCollection2() {
final List<String> coll = new ArrayList<String>(); final List<String> coll = new ArrayList<>();
coll.add("a"); coll.add("a");
coll.add("b"); coll.add("b");
Validate.noNullElements(coll, "MSG"); Validate.noNullElements(coll, "MSG");
@ -703,7 +703,7 @@ public class ValidateTest {
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
@Test @Test
public void testValidIndex_withMessage_collection() { public void testValidIndex_withMessage_collection() {
final Collection<String> coll = new ArrayList<String>(); final Collection<String> coll = new ArrayList<>();
coll.add(null); coll.add(null);
coll.add(null); coll.add(null);
Validate.validIndex(coll, 0, "Broken: "); Validate.validIndex(coll, 0, "Broken: ");
@ -728,7 +728,7 @@ public class ValidateTest {
@Test @Test
public void testValidIndex_collection() { public void testValidIndex_collection() {
final Collection<String> coll = new ArrayList<String>(); final Collection<String> coll = new ArrayList<>();
coll.add(null); coll.add(null);
coll.add(null); coll.add(null);
Validate.validIndex(coll, 0); Validate.validIndex(coll, 0);

View File

@ -71,10 +71,10 @@ public class DefaultToStringStyleTest {
assertEquals(baseStr + "[a=3]", new ToStringBuilder(base).append("a", i3).toString()); assertEquals(baseStr + "[a=3]", new ToStringBuilder(base).append("a", i3).toString());
assertEquals(baseStr + "[a=3,b=4]", new ToStringBuilder(base).append("a", i3).append("b", i4).toString()); assertEquals(baseStr + "[a=3,b=4]", new ToStringBuilder(base).append("a", i3).append("b", i4).toString());
assertEquals(baseStr + "[a=<Integer>]", new ToStringBuilder(base).append("a", i3, false).toString()); assertEquals(baseStr + "[a=<Integer>]", new ToStringBuilder(base).append("a", i3, false).toString());
assertEquals(baseStr + "[a=<size=0>]", new ToStringBuilder(base).append("a", new ArrayList<Object>(), false).toString()); assertEquals(baseStr + "[a=<size=0>]", new ToStringBuilder(base).append("a", new ArrayList<>(), false).toString());
assertEquals(baseStr + "[a=[]]", new ToStringBuilder(base).append("a", new ArrayList<Object>(), true).toString()); assertEquals(baseStr + "[a=[]]", new ToStringBuilder(base).append("a", new ArrayList<>(), true).toString());
assertEquals(baseStr + "[a=<size=0>]", new ToStringBuilder(base).append("a", new HashMap<Object, Object>(), false).toString()); assertEquals(baseStr + "[a=<size=0>]", new ToStringBuilder(base).append("a", new HashMap<>(), false).toString());
assertEquals(baseStr + "[a={}]", new ToStringBuilder(base).append("a", new HashMap<Object, Object>(), true).toString()); assertEquals(baseStr + "[a={}]", new ToStringBuilder(base).append("a", new HashMap<>(), true).toString());
assertEquals(baseStr + "[a=<size=0>]", new ToStringBuilder(base).append("a", (Object) new String[0], false).toString()); assertEquals(baseStr + "[a=<size=0>]", new ToStringBuilder(base).append("a", (Object) new String[0], false).toString());
assertEquals(baseStr + "[a={}]", new ToStringBuilder(base).append("a", (Object) new String[0], true).toString()); assertEquals(baseStr + "[a={}]", new ToStringBuilder(base).append("a", (Object) new String[0], true).toString());
} }

View File

@ -154,18 +154,18 @@ public class JsonToStringStyleTest {
} }
try { try {
new ToStringBuilder(base).append("a", new ArrayList<Object>(), false).toString(); new ToStringBuilder(base).append("a", new ArrayList<>(), false).toString();
fail("Should have generated UnsupportedOperationException"); fail("Should have generated UnsupportedOperationException");
} catch (UnsupportedOperationException e) { } catch (UnsupportedOperationException e) {
} }
assertEquals( assertEquals(
"{\"a\":[]}", "{\"a\":[]}",
new ToStringBuilder(base).append("a", new ArrayList<Object>(), new ToStringBuilder(base).append("a", new ArrayList<>(),
true).toString()); true).toString());
try { try {
new ToStringBuilder(base).append("a", new HashMap<Object, Object>(), false).toString(); new ToStringBuilder(base).append("a", new HashMap<>(), false).toString();
fail("Should have generated UnsupportedOperationException"); fail("Should have generated UnsupportedOperationException");
} catch (UnsupportedOperationException e) { } catch (UnsupportedOperationException e) {
} }
@ -173,7 +173,7 @@ public class JsonToStringStyleTest {
assertEquals( assertEquals(
"{\"a\":{}}", "{\"a\":{}}",
new ToStringBuilder(base).append("a", new ToStringBuilder(base).append("a",
new HashMap<Object, Object>(), true).toString()); new HashMap<>(), true).toString());
try { try {
new ToStringBuilder(base).append("a", (Object) new String[0], false).toString(); new ToStringBuilder(base).append("a", (Object) new String[0], false).toString();

View File

@ -72,10 +72,10 @@ public class MultiLineToStringStyleTest {
assertEquals(baseStr + "[" + SystemUtils.LINE_SEPARATOR + " a=3" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).append("a", i3).toString()); assertEquals(baseStr + "[" + SystemUtils.LINE_SEPARATOR + " a=3" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).append("a", i3).toString());
assertEquals(baseStr + "[" + SystemUtils.LINE_SEPARATOR + " a=3" + SystemUtils.LINE_SEPARATOR + " b=4" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).append("a", i3).append("b", i4).toString()); assertEquals(baseStr + "[" + SystemUtils.LINE_SEPARATOR + " a=3" + SystemUtils.LINE_SEPARATOR + " b=4" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).append("a", i3).append("b", i4).toString());
assertEquals(baseStr + "[" + SystemUtils.LINE_SEPARATOR + " a=<Integer>" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).append("a", i3, false).toString()); assertEquals(baseStr + "[" + SystemUtils.LINE_SEPARATOR + " a=<Integer>" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).append("a", i3, false).toString());
assertEquals(baseStr + "[" + SystemUtils.LINE_SEPARATOR + " a=<size=0>" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).append("a", new ArrayList<Object>(), false).toString()); assertEquals(baseStr + "[" + SystemUtils.LINE_SEPARATOR + " a=<size=0>" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).append("a", new ArrayList<>(), false).toString());
assertEquals(baseStr + "[" + SystemUtils.LINE_SEPARATOR + " a=[]" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).append("a", new ArrayList<Object>(), true).toString()); assertEquals(baseStr + "[" + SystemUtils.LINE_SEPARATOR + " a=[]" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).append("a", new ArrayList<>(), true).toString());
assertEquals(baseStr + "[" + SystemUtils.LINE_SEPARATOR + " a=<size=0>" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).append("a", new HashMap<Object, Object>(), false).toString()); assertEquals(baseStr + "[" + SystemUtils.LINE_SEPARATOR + " a=<size=0>" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).append("a", new HashMap<>(), false).toString());
assertEquals(baseStr + "[" + SystemUtils.LINE_SEPARATOR + " a={}" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).append("a", new HashMap<Object, Object>(), true).toString()); assertEquals(baseStr + "[" + SystemUtils.LINE_SEPARATOR + " a={}" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).append("a", new HashMap<>(), true).toString());
assertEquals(baseStr + "[" + SystemUtils.LINE_SEPARATOR + " a=<size=0>" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).append("a", (Object) new String[0], false).toString()); assertEquals(baseStr + "[" + SystemUtils.LINE_SEPARATOR + " a=<size=0>" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).append("a", (Object) new String[0], false).toString());
assertEquals(baseStr + "[" + SystemUtils.LINE_SEPARATOR + " a={}" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).append("a", (Object) new String[0], true).toString()); assertEquals(baseStr + "[" + SystemUtils.LINE_SEPARATOR + " a={}" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).append("a", (Object) new String[0], true).toString());
} }

View File

@ -239,7 +239,7 @@ public class MultilineRecursiveToStringStyleTest {
static class Account { static class Account {
Customer owner; Customer owner;
List<Transaction> transactions = new ArrayList<Transaction>(); List<Transaction> transactions = new ArrayList<>();
public double getBalance() { public double getBalance() {
double balance = 0; double balance = 0;

View File

@ -70,10 +70,10 @@ public class NoClassNameToStringStyleTest {
assertEquals("[a=3]", new ToStringBuilder(base).append("a", i3).toString()); assertEquals("[a=3]", new ToStringBuilder(base).append("a", i3).toString());
assertEquals("[a=3,b=4]", new ToStringBuilder(base).append("a", i3).append("b", i4).toString()); assertEquals("[a=3,b=4]", new ToStringBuilder(base).append("a", i3).append("b", i4).toString());
assertEquals("[a=<Integer>]", new ToStringBuilder(base).append("a", i3, false).toString()); assertEquals("[a=<Integer>]", new ToStringBuilder(base).append("a", i3, false).toString());
assertEquals("[a=<size=0>]", new ToStringBuilder(base).append("a", new ArrayList<Object>(), false).toString()); assertEquals("[a=<size=0>]", new ToStringBuilder(base).append("a", new ArrayList<>(), false).toString());
assertEquals("[a=[]]", new ToStringBuilder(base).append("a", new ArrayList<Object>(), true).toString()); assertEquals("[a=[]]", new ToStringBuilder(base).append("a", new ArrayList<>(), true).toString());
assertEquals("[a=<size=0>]", new ToStringBuilder(base).append("a", new HashMap<Object, Object>(), false).toString()); assertEquals("[a=<size=0>]", new ToStringBuilder(base).append("a", new HashMap<>(), false).toString());
assertEquals("[a={}]", new ToStringBuilder(base).append("a", new HashMap<Object, Object>(), true).toString()); assertEquals("[a={}]", new ToStringBuilder(base).append("a", new HashMap<>(), true).toString());
assertEquals("[a=<size=0>]", new ToStringBuilder(base).append("a", (Object) new String[0], false).toString()); assertEquals("[a=<size=0>]", new ToStringBuilder(base).append("a", (Object) new String[0], false).toString());
assertEquals("[a={}]", new ToStringBuilder(base).append("a", (Object) new String[0], true).toString()); assertEquals("[a={}]", new ToStringBuilder(base).append("a", (Object) new String[0], true).toString());
} }

View File

@ -71,10 +71,10 @@ public class NoFieldNamesToStringStyleTest {
assertEquals(baseStr + "[3]", new ToStringBuilder(base).append("a", i3).toString()); assertEquals(baseStr + "[3]", new ToStringBuilder(base).append("a", i3).toString());
assertEquals(baseStr + "[3,4]", new ToStringBuilder(base).append("a", i3).append("b", i4).toString()); assertEquals(baseStr + "[3,4]", new ToStringBuilder(base).append("a", i3).append("b", i4).toString());
assertEquals(baseStr + "[<Integer>]", new ToStringBuilder(base).append("a", i3, false).toString()); assertEquals(baseStr + "[<Integer>]", new ToStringBuilder(base).append("a", i3, false).toString());
assertEquals(baseStr + "[<size=0>]", new ToStringBuilder(base).append("a", new ArrayList<Object>(), false).toString()); assertEquals(baseStr + "[<size=0>]", new ToStringBuilder(base).append("a", new ArrayList<>(), false).toString());
assertEquals(baseStr + "[[]]", new ToStringBuilder(base).append("a", new ArrayList<Object>(), true).toString()); assertEquals(baseStr + "[[]]", new ToStringBuilder(base).append("a", new ArrayList<>(), true).toString());
assertEquals(baseStr + "[<size=0>]", new ToStringBuilder(base).append("a", new HashMap<Object, Object>(), false).toString()); assertEquals(baseStr + "[<size=0>]", new ToStringBuilder(base).append("a", new HashMap<>(), false).toString());
assertEquals(baseStr + "[{}]", new ToStringBuilder(base).append("a", new HashMap<Object, Object>(), true).toString()); assertEquals(baseStr + "[{}]", new ToStringBuilder(base).append("a", new HashMap<>(), true).toString());
assertEquals(baseStr + "[<size=0>]", new ToStringBuilder(base).append("a", (Object) new String[0], false).toString()); assertEquals(baseStr + "[<size=0>]", new ToStringBuilder(base).append("a", (Object) new String[0], false).toString());
assertEquals(baseStr + "[{}]", new ToStringBuilder(base).append("a", (Object) new String[0], true).toString()); assertEquals(baseStr + "[{}]", new ToStringBuilder(base).append("a", (Object) new String[0], true).toString());
} }

View File

@ -70,10 +70,10 @@ public class RecursiveToStringStyleTest {
assertEquals(baseStr + "[a=3]", new ToStringBuilder(base).append("a", i3).toString()); assertEquals(baseStr + "[a=3]", new ToStringBuilder(base).append("a", i3).toString());
assertEquals(baseStr + "[a=3,b=4]", new ToStringBuilder(base).append("a", i3).append("b", i4).toString()); assertEquals(baseStr + "[a=3,b=4]", new ToStringBuilder(base).append("a", i3).append("b", i4).toString());
assertEquals(baseStr + "[a=<Integer>]", new ToStringBuilder(base).append("a", i3, false).toString()); assertEquals(baseStr + "[a=<Integer>]", new ToStringBuilder(base).append("a", i3, false).toString());
assertEquals(baseStr + "[a=<size=0>]", new ToStringBuilder(base).append("a", new ArrayList<Object>(), false).toString()); assertEquals(baseStr + "[a=<size=0>]", new ToStringBuilder(base).append("a", new ArrayList<>(), false).toString());
assertEquals(baseStr + "[a=[]]", new ToStringBuilder(base).append("a", new ArrayList<Object>(), true).toString()); assertEquals(baseStr + "[a=[]]", new ToStringBuilder(base).append("a", new ArrayList<>(), true).toString());
assertEquals(baseStr + "[a=<size=0>]", new ToStringBuilder(base).append("a", new HashMap<Object, Object>(), false).toString()); assertEquals(baseStr + "[a=<size=0>]", new ToStringBuilder(base).append("a", new HashMap<>(), false).toString());
assertEquals(baseStr + "[a={}]", new ToStringBuilder(base).append("a", new HashMap<Object, Object>(), true).toString()); assertEquals(baseStr + "[a={}]", new ToStringBuilder(base).append("a", new HashMap<>(), true).toString());
assertEquals(baseStr + "[a=<size=0>]", new ToStringBuilder(base).append("a", (Object) new String[0], false).toString()); assertEquals(baseStr + "[a=<size=0>]", new ToStringBuilder(base).append("a", (Object) new String[0], false).toString());
assertEquals(baseStr + "[a={}]", new ToStringBuilder(base).append("a", (Object) new String[0], true).toString()); assertEquals(baseStr + "[a={}]", new ToStringBuilder(base).append("a", (Object) new String[0], true).toString());
} }

View File

@ -108,7 +108,7 @@ public class ReflectionToStringBuilderConcurrencyTest {
return Integer.valueOf(REPEAT); return Integer.valueOf(REPEAT);
} }
}; };
final Collection<Callable<Integer>> tasks = new ArrayList<Callable<Integer>>(); final Collection<Callable<Integer>> tasks = new ArrayList<>();
tasks.add(consumer); tasks.add(consumer);
tasks.add(producer); tasks.add(producer);
final List<Future<Integer>> futures = threadPool.invokeAll(tasks); final List<Future<Integer>> futures = threadPool.invokeAll(tasks);

View File

@ -72,7 +72,7 @@ public class ReflectionToStringBuilderExcludeTest {
@Test @Test
public void test_toStringExcludeCollection() { public void test_toStringExcludeCollection() {
final List<String> excludeList = new ArrayList<String>(); final List<String> excludeList = new ArrayList<>();
excludeList.add(SECRET_FIELD); excludeList.add(SECRET_FIELD);
final String toString = ReflectionToStringBuilder.toStringExclude(new TestFixture(), excludeList); final String toString = ReflectionToStringBuilder.toStringExclude(new TestFixture(), excludeList);
this.validateSecretFieldAbsent(toString); this.validateSecretFieldAbsent(toString);
@ -80,7 +80,7 @@ public class ReflectionToStringBuilderExcludeTest {
@Test @Test
public void test_toStringExcludeCollectionWithNull() { public void test_toStringExcludeCollectionWithNull() {
final List<String> excludeList = new ArrayList<String>(); final List<String> excludeList = new ArrayList<>();
excludeList.add(null); excludeList.add(null);
final String toString = ReflectionToStringBuilder.toStringExclude(new TestFixture(), excludeList); final String toString = ReflectionToStringBuilder.toStringExclude(new TestFixture(), excludeList);
this.validateSecretFieldPresent(toString); this.validateSecretFieldPresent(toString);
@ -88,7 +88,7 @@ public class ReflectionToStringBuilderExcludeTest {
@Test @Test
public void test_toStringExcludeCollectionWithNulls() { public void test_toStringExcludeCollectionWithNulls() {
final List<String> excludeList = new ArrayList<String>(); final List<String> excludeList = new ArrayList<>();
excludeList.add(null); excludeList.add(null);
excludeList.add(null); excludeList.add(null);
final String toString = ReflectionToStringBuilder.toStringExclude(new TestFixture(), excludeList); final String toString = ReflectionToStringBuilder.toStringExclude(new TestFixture(), excludeList);

View File

@ -37,7 +37,7 @@ import org.junit.Test;
public class ReflectionToStringBuilderMutateInspectConcurrencyTest { public class ReflectionToStringBuilderMutateInspectConcurrencyTest {
class TestFixture { class TestFixture {
final private LinkedList<Integer> listField = new LinkedList<Integer>(); final private LinkedList<Integer> listField = new LinkedList<>();
final private Random random = new Random(); final private Random random = new Random();
private final int N = 100; private final int N = 100;

View File

@ -71,10 +71,10 @@ public class ShortPrefixToStringStyleTest {
assertEquals(baseStr + "[a=3]", new ToStringBuilder(base).append("a", i3).toString()); assertEquals(baseStr + "[a=3]", new ToStringBuilder(base).append("a", i3).toString());
assertEquals(baseStr + "[a=3,b=4]", new ToStringBuilder(base).append("a", i3).append("b", i4).toString()); assertEquals(baseStr + "[a=3,b=4]", new ToStringBuilder(base).append("a", i3).append("b", i4).toString());
assertEquals(baseStr + "[a=<Integer>]", new ToStringBuilder(base).append("a", i3, false).toString()); assertEquals(baseStr + "[a=<Integer>]", new ToStringBuilder(base).append("a", i3, false).toString());
assertEquals(baseStr + "[a=<size=0>]", new ToStringBuilder(base).append("a", new ArrayList<Object>(), false).toString()); assertEquals(baseStr + "[a=<size=0>]", new ToStringBuilder(base).append("a", new ArrayList<>(), false).toString());
assertEquals(baseStr + "[a=[]]", new ToStringBuilder(base).append("a", new ArrayList<Object>(), true).toString()); assertEquals(baseStr + "[a=[]]", new ToStringBuilder(base).append("a", new ArrayList<>(), true).toString());
assertEquals(baseStr + "[a=<size=0>]", new ToStringBuilder(base).append("a", new HashMap<Object, Object>(), false).toString()); assertEquals(baseStr + "[a=<size=0>]", new ToStringBuilder(base).append("a", new HashMap<>(), false).toString());
assertEquals(baseStr + "[a={}]", new ToStringBuilder(base).append("a", new HashMap<Object, Object>(), true).toString()); assertEquals(baseStr + "[a={}]", new ToStringBuilder(base).append("a", new HashMap<>(), true).toString());
assertEquals(baseStr + "[a=<size=0>]", new ToStringBuilder(base).append("a", (Object) new String[0], false).toString()); assertEquals(baseStr + "[a=<size=0>]", new ToStringBuilder(base).append("a", (Object) new String[0], false).toString());
assertEquals(baseStr + "[a={}]", new ToStringBuilder(base).append("a", (Object) new String[0], true).toString()); assertEquals(baseStr + "[a={}]", new ToStringBuilder(base).append("a", (Object) new String[0], true).toString());
} }

View File

@ -70,10 +70,10 @@ public class SimpleToStringStyleTest {
assertEquals("3", new ToStringBuilder(base).append("a", i3).toString()); assertEquals("3", new ToStringBuilder(base).append("a", i3).toString());
assertEquals("3,4", new ToStringBuilder(base).append("a", i3).append("b", i4).toString()); assertEquals("3,4", new ToStringBuilder(base).append("a", i3).append("b", i4).toString());
assertEquals("<Integer>", new ToStringBuilder(base).append("a", i3, false).toString()); assertEquals("<Integer>", new ToStringBuilder(base).append("a", i3, false).toString());
assertEquals("<size=0>", new ToStringBuilder(base).append("a", new ArrayList<Object>(), false).toString()); assertEquals("<size=0>", new ToStringBuilder(base).append("a", new ArrayList<>(), false).toString());
assertEquals("[]", new ToStringBuilder(base).append("a", new ArrayList<Object>(), true).toString()); assertEquals("[]", new ToStringBuilder(base).append("a", new ArrayList<>(), true).toString());
assertEquals("<size=0>", new ToStringBuilder(base).append("a", new HashMap<Object, Object>(), false).toString()); assertEquals("<size=0>", new ToStringBuilder(base).append("a", new HashMap<>(), false).toString());
assertEquals("{}", new ToStringBuilder(base).append("a", new HashMap<Object, Object>(), true).toString()); assertEquals("{}", new ToStringBuilder(base).append("a", new HashMap<>(), true).toString());
assertEquals("<size=0>", new ToStringBuilder(base).append("a", (Object) new String[0], false).toString()); assertEquals("<size=0>", new ToStringBuilder(base).append("a", (Object) new String[0], false).toString());
assertEquals("{}", new ToStringBuilder(base).append("a", (Object) new String[0], true).toString()); assertEquals("{}", new ToStringBuilder(base).append("a", (Object) new String[0], true).toString());
} }

View File

@ -86,10 +86,10 @@ public class StandardToStringStyleTest {
assertEquals(baseStr + "[a=3]", new ToStringBuilder(base).append("a", i3).toString()); assertEquals(baseStr + "[a=3]", new ToStringBuilder(base).append("a", i3).toString());
assertEquals(baseStr + "[a=3,b=4]", new ToStringBuilder(base).append("a", i3).append("b", i4).toString()); assertEquals(baseStr + "[a=3,b=4]", new ToStringBuilder(base).append("a", i3).append("b", i4).toString());
assertEquals(baseStr + "[a=%Integer%]", new ToStringBuilder(base).append("a", i3, false).toString()); assertEquals(baseStr + "[a=%Integer%]", new ToStringBuilder(base).append("a", i3, false).toString());
assertEquals(baseStr + "[a=%SIZE=0%]", new ToStringBuilder(base).append("a", new ArrayList<Object>(), false).toString()); assertEquals(baseStr + "[a=%SIZE=0%]", new ToStringBuilder(base).append("a", new ArrayList<>(), false).toString());
assertEquals(baseStr + "[a=[]]", new ToStringBuilder(base).append("a", new ArrayList<Object>(), true).toString()); assertEquals(baseStr + "[a=[]]", new ToStringBuilder(base).append("a", new ArrayList<>(), true).toString());
assertEquals(baseStr + "[a=%SIZE=0%]", new ToStringBuilder(base).append("a", new HashMap<Object, Object>(), false).toString()); assertEquals(baseStr + "[a=%SIZE=0%]", new ToStringBuilder(base).append("a", new HashMap<>(), false).toString());
assertEquals(baseStr + "[a={}]", new ToStringBuilder(base).append("a", new HashMap<Object, Object>(), true).toString()); assertEquals(baseStr + "[a={}]", new ToStringBuilder(base).append("a", new HashMap<>(), true).toString());
assertEquals(baseStr + "[a=%SIZE=0%]", new ToStringBuilder(base).append("a", (Object) new String[0], false).toString()); assertEquals(baseStr + "[a=%SIZE=0%]", new ToStringBuilder(base).append("a", (Object) new String[0], false).toString());
assertEquals(baseStr + "[a=[]]", new ToStringBuilder(base).append("a", (Object) new String[0], true).toString()); assertEquals(baseStr + "[a=[]]", new ToStringBuilder(base).append("a", (Object) new String[0], true).toString());
} }

View File

@ -315,7 +315,7 @@ public class ToStringBuilderTest {
// representation different for IBM JDK 1.6.0, LANG-727 // representation different for IBM JDK 1.6.0, LANG-727
assumeFalse("IBM Corporation".equals(SystemUtils.JAVA_VENDOR) && "1.6".equals(SystemUtils.JAVA_SPECIFICATION_VERSION)); assumeFalse("IBM Corporation".equals(SystemUtils.JAVA_VENDOR) && "1.6".equals(SystemUtils.JAVA_SPECIFICATION_VERSION));
assumeFalse("Oracle Corporation".equals(SystemUtils.JAVA_VENDOR) && "1.6".compareTo(SystemUtils.JAVA_SPECIFICATION_VERSION) < 0); assumeFalse("Oracle Corporation".equals(SystemUtils.JAVA_VENDOR) && "1.6".compareTo(SystemUtils.JAVA_SPECIFICATION_VERSION) < 0);
final List<Object> list = new ArrayList<Object>(); final List<Object> list = new ArrayList<>();
final String baseString = this.toBaseString(list); final String baseString = this.toBaseString(list);
final String expectedWithTransients = baseString + "[elementData={<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>},size=0,modCount=0]"; final String expectedWithTransients = baseString + "[elementData={<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>,<null>},size=0,modCount=0]";
final String toStringWithTransients = ToStringBuilder.reflectionToString(list, null, true); final String toStringWithTransients = ToStringBuilder.reflectionToString(list, null, true);
@ -624,10 +624,10 @@ public class ToStringBuilderTest {
assertEquals(baseStr + "[a=3]", new ToStringBuilder(base).append("a", i3).toString()); assertEquals(baseStr + "[a=3]", new ToStringBuilder(base).append("a", i3).toString());
assertEquals(baseStr + "[a=3,b=4]", new ToStringBuilder(base).append("a", i3).append("b", i4).toString()); assertEquals(baseStr + "[a=3,b=4]", new ToStringBuilder(base).append("a", i3).append("b", i4).toString());
assertEquals(baseStr + "[a=<Integer>]", new ToStringBuilder(base).append("a", i3, false).toString()); assertEquals(baseStr + "[a=<Integer>]", new ToStringBuilder(base).append("a", i3, false).toString());
assertEquals(baseStr + "[a=<size=0>]", new ToStringBuilder(base).append("a", new ArrayList<Object>(), false).toString()); assertEquals(baseStr + "[a=<size=0>]", new ToStringBuilder(base).append("a", new ArrayList<>(), false).toString());
assertEquals(baseStr + "[a=[]]", new ToStringBuilder(base).append("a", new ArrayList<Object>(), true).toString()); assertEquals(baseStr + "[a=[]]", new ToStringBuilder(base).append("a", new ArrayList<>(), true).toString());
assertEquals(baseStr + "[a=<size=0>]", new ToStringBuilder(base).append("a", new HashMap<Object, Object>(), false).toString()); assertEquals(baseStr + "[a=<size=0>]", new ToStringBuilder(base).append("a", new HashMap<>(), false).toString());
assertEquals(baseStr + "[a={}]", new ToStringBuilder(base).append("a", new HashMap<Object, Object>(), true).toString()); assertEquals(baseStr + "[a={}]", new ToStringBuilder(base).append("a", new HashMap<>(), true).toString());
assertEquals(baseStr + "[a=<size=0>]", new ToStringBuilder(base).append("a", (Object) new String[0], false).toString()); assertEquals(baseStr + "[a=<size=0>]", new ToStringBuilder(base).append("a", (Object) new String[0], false).toString());
assertEquals(baseStr + "[a={}]", new ToStringBuilder(base).append("a", (Object) new String[0], true).toString()); assertEquals(baseStr + "[a={}]", new ToStringBuilder(base).append("a", (Object) new String[0], true).toString());
} }
@ -642,10 +642,10 @@ public class ToStringBuilderTest {
assertEquals(baseStr + "[a=3]", new ToStringBuilder(base).append("a", i3).build()); assertEquals(baseStr + "[a=3]", new ToStringBuilder(base).append("a", i3).build());
assertEquals(baseStr + "[a=3,b=4]", new ToStringBuilder(base).append("a", i3).append("b", i4).build()); assertEquals(baseStr + "[a=3,b=4]", new ToStringBuilder(base).append("a", i3).append("b", i4).build());
assertEquals(baseStr + "[a=<Integer>]", new ToStringBuilder(base).append("a", i3, false).build()); assertEquals(baseStr + "[a=<Integer>]", new ToStringBuilder(base).append("a", i3, false).build());
assertEquals(baseStr + "[a=<size=0>]", new ToStringBuilder(base).append("a", new ArrayList<Object>(), false).build()); assertEquals(baseStr + "[a=<size=0>]", new ToStringBuilder(base).append("a", new ArrayList<>(), false).build());
assertEquals(baseStr + "[a=[]]", new ToStringBuilder(base).append("a", new ArrayList<Object>(), true).build()); assertEquals(baseStr + "[a=[]]", new ToStringBuilder(base).append("a", new ArrayList<>(), true).build());
assertEquals(baseStr + "[a=<size=0>]", new ToStringBuilder(base).append("a", new HashMap<Object, Object>(), false).build()); assertEquals(baseStr + "[a=<size=0>]", new ToStringBuilder(base).append("a", new HashMap<>(), false).build());
assertEquals(baseStr + "[a={}]", new ToStringBuilder(base).append("a", new HashMap<Object, Object>(), true).build()); assertEquals(baseStr + "[a={}]", new ToStringBuilder(base).append("a", new HashMap<>(), true).build());
assertEquals(baseStr + "[a=<size=0>]", new ToStringBuilder(base).append("a", (Object) new String[0], false).build()); assertEquals(baseStr + "[a=<size=0>]", new ToStringBuilder(base).append("a", (Object) new String[0], false).build());
assertEquals(baseStr + "[a={}]", new ToStringBuilder(base).append("a", (Object) new String[0], true).build()); assertEquals(baseStr + "[a={}]", new ToStringBuilder(base).append("a", (Object) new String[0], true).build());
} }

View File

@ -60,7 +60,7 @@ public class ToStringStyleConcurrencyTest {
private static final int REPEAT = 100; private static final int REPEAT = 100;
static { static {
LIST = new ArrayList<Integer>(LIST_SIZE); LIST = new ArrayList<>(LIST_SIZE);
for (int i = 0; i < LIST_SIZE; i++) { for (int i = 0; i < LIST_SIZE; i++) {
LIST.add(Integer.valueOf(i)); LIST.add(Integer.valueOf(i));
} }
@ -99,7 +99,7 @@ public class ToStringStyleConcurrencyTest {
return Integer.valueOf(REPEAT); return Integer.valueOf(REPEAT);
} }
}; };
final Collection<Callable<Integer>> tasks = new ArrayList<Callable<Integer>>(); final Collection<Callable<Integer>> tasks = new ArrayList<>();
tasks.add(consumer); tasks.add(consumer);
tasks.add(consumer); tasks.add(consumer);
final List<Future<Integer>> futures = threadPool.invokeAll(tasks); final List<Future<Integer>> futures = threadPool.invokeAll(tasks);

View File

@ -222,7 +222,7 @@ public class BackgroundInitializerTest {
final CountDownLatch latch1 = new CountDownLatch(1); final CountDownLatch latch1 = new CountDownLatch(1);
init.shouldSleep = true; init.shouldSleep = true;
init.start(); init.start();
final AtomicReference<InterruptedException> iex = new AtomicReference<InterruptedException>(); final AtomicReference<InterruptedException> iex = new AtomicReference<>();
final Thread getThread = new Thread() { final Thread getThread = new Thread() {
@Override @Override
public void run() { public void run() {

View File

@ -38,7 +38,7 @@ public class CallableBackgroundInitializerTest {
*/ */
@Test(expected=IllegalArgumentException.class) @Test(expected=IllegalArgumentException.class)
public void testInitNullCallable() { public void testInitNullCallable() {
new CallableBackgroundInitializer<Object>(null); new CallableBackgroundInitializer<>(null);
} }
/** /**
@ -48,7 +48,7 @@ public class CallableBackgroundInitializerTest {
@Test @Test
public void testInitExecutor() throws InterruptedException { public void testInitExecutor() throws InterruptedException {
final ExecutorService exec = Executors.newSingleThreadExecutor(); final ExecutorService exec = Executors.newSingleThreadExecutor();
final CallableBackgroundInitializer<Integer> init = new CallableBackgroundInitializer<Integer>( final CallableBackgroundInitializer<Integer> init = new CallableBackgroundInitializer<>(
new TestCallable(), exec); new TestCallable(), exec);
assertEquals("Executor not set", exec, init.getExternalExecutor()); assertEquals("Executor not set", exec, init.getExternalExecutor());
exec.shutdown(); exec.shutdown();
@ -79,7 +79,7 @@ public class CallableBackgroundInitializerTest {
@Test @Test
public void testInitialize() throws Exception { public void testInitialize() throws Exception {
final TestCallable call = new TestCallable(); final TestCallable call = new TestCallable();
final CallableBackgroundInitializer<Integer> init = new CallableBackgroundInitializer<Integer>( final CallableBackgroundInitializer<Integer> init = new CallableBackgroundInitializer<>(
call); call);
assertEquals("Wrong result", RESULT, init.initialize()); assertEquals("Wrong result", RESULT, init.initialize());
assertEquals("Wrong number of invocations", 1, call.callCount); assertEquals("Wrong number of invocations", 1, call.callCount);

View File

@ -434,7 +434,7 @@ public class ConcurrentUtilsTest {
public void testPutIfAbsentKeyPresent() { public void testPutIfAbsentKeyPresent() {
final String key = "testKey"; final String key = "testKey";
final Integer value = 42; final Integer value = 42;
final ConcurrentMap<String, Integer> map = new ConcurrentHashMap<String, Integer>(); final ConcurrentMap<String, Integer> map = new ConcurrentHashMap<>();
map.put(key, value); map.put(key, value);
assertEquals("Wrong result", value, assertEquals("Wrong result", value,
ConcurrentUtils.putIfAbsent(map, key, 0)); ConcurrentUtils.putIfAbsent(map, key, 0));
@ -448,7 +448,7 @@ public class ConcurrentUtilsTest {
public void testPutIfAbsentKeyNotPresent() { public void testPutIfAbsentKeyNotPresent() {
final String key = "testKey"; final String key = "testKey";
final Integer value = 42; final Integer value = 42;
final ConcurrentMap<String, Integer> map = new ConcurrentHashMap<String, Integer>(); final ConcurrentMap<String, Integer> map = new ConcurrentHashMap<>();
assertEquals("Wrong result", value, assertEquals("Wrong result", value,
ConcurrentUtils.putIfAbsent(map, key, value)); ConcurrentUtils.putIfAbsent(map, key, value));
assertEquals("Wrong value in map", value, map.get(key)); assertEquals("Wrong value in map", value, map.get(key));
@ -477,7 +477,7 @@ public class ConcurrentUtilsTest {
EasyMock.replay(init); EasyMock.replay(init);
final String key = "testKey"; final String key = "testKey";
final Integer value = 42; final Integer value = 42;
final ConcurrentMap<String, Integer> map = new ConcurrentHashMap<String, Integer>(); final ConcurrentMap<String, Integer> map = new ConcurrentHashMap<>();
map.put(key, value); map.put(key, value);
assertEquals("Wrong result", value, assertEquals("Wrong result", value,
ConcurrentUtils.createIfAbsent(map, key, init)); ConcurrentUtils.createIfAbsent(map, key, init));
@ -500,7 +500,7 @@ public class ConcurrentUtilsTest {
final Integer value = 42; final Integer value = 42;
EasyMock.expect(init.get()).andReturn(value); EasyMock.expect(init.get()).andReturn(value);
EasyMock.replay(init); EasyMock.replay(init);
final ConcurrentMap<String, Integer> map = new ConcurrentHashMap<String, Integer>(); final ConcurrentMap<String, Integer> map = new ConcurrentHashMap<>();
assertEquals("Wrong result", value, assertEquals("Wrong result", value,
ConcurrentUtils.createIfAbsent(map, key, init)); ConcurrentUtils.createIfAbsent(map, key, init));
assertEquals("Wrong value in map", value, map.get(key)); assertEquals("Wrong value in map", value, map.get(key));
@ -531,7 +531,7 @@ public class ConcurrentUtilsTest {
*/ */
@Test @Test
public void testCreateIfAbsentNullInit() throws ConcurrentException { public void testCreateIfAbsentNullInit() throws ConcurrentException {
final ConcurrentMap<String, Integer> map = new ConcurrentHashMap<String, Integer>(); final ConcurrentMap<String, Integer> map = new ConcurrentHashMap<>();
final String key = "testKey"; final String key = "testKey";
final Integer value = 42; final Integer value = 42;
map.put(key, value); map.put(key, value);
@ -547,10 +547,10 @@ public class ConcurrentUtilsTest {
public void testCreateIfAbsentUncheckedSuccess() { public void testCreateIfAbsentUncheckedSuccess() {
final String key = "testKey"; final String key = "testKey";
final Integer value = 42; final Integer value = 42;
final ConcurrentMap<String, Integer> map = new ConcurrentHashMap<String, Integer>(); final ConcurrentMap<String, Integer> map = new ConcurrentHashMap<>();
assertEquals("Wrong result", value, assertEquals("Wrong result", value,
ConcurrentUtils.createIfAbsentUnchecked(map, key, ConcurrentUtils.createIfAbsentUnchecked(map, key,
new ConstantInitializer<Integer>(value))); new ConstantInitializer<>(value)));
assertEquals("Wrong value in map", value, map.get(key)); assertEquals("Wrong value in map", value, map.get(key));
} }

View File

@ -36,7 +36,7 @@ public class ConstantInitializerTest {
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {
init = new ConstantInitializer<Integer>(VALUE); init = new ConstantInitializer<>(VALUE);
} }
/** /**
@ -80,11 +80,11 @@ public class ConstantInitializerTest {
@Test @Test
public void testEqualsTrue() { public void testEqualsTrue() {
checkEquals(init, true); checkEquals(init, true);
ConstantInitializer<Integer> init2 = new ConstantInitializer<Integer>( ConstantInitializer<Integer> init2 = new ConstantInitializer<>(
Integer.valueOf(VALUE.intValue())); Integer.valueOf(VALUE.intValue()));
checkEquals(init2, true); checkEquals(init2, true);
init = new ConstantInitializer<Integer>(null); init = new ConstantInitializer<>(null);
init2 = new ConstantInitializer<Integer>(null); init2 = new ConstantInitializer<>(null);
checkEquals(init2, true); checkEquals(init2, true);
} }
@ -93,10 +93,10 @@ public class ConstantInitializerTest {
*/ */
@Test @Test
public void testEqualsFalse() { public void testEqualsFalse() {
ConstantInitializer<Integer> init2 = new ConstantInitializer<Integer>( ConstantInitializer<Integer> init2 = new ConstantInitializer<>(
null); null);
checkEquals(init2, false); checkEquals(init2, false);
init2 = new ConstantInitializer<Integer>(VALUE + 1); init2 = new ConstantInitializer<>(VALUE + 1);
checkEquals(init2, false); checkEquals(init2, false);
} }
@ -107,7 +107,7 @@ public class ConstantInitializerTest {
public void testEqualsWithOtherObjects() { public void testEqualsWithOtherObjects() {
checkEquals(null, false); checkEquals(null, false);
checkEquals(this, false); checkEquals(this, false);
checkEquals(new ConstantInitializer<String>("Test"), false); checkEquals(new ConstantInitializer<>("Test"), false);
} }
/** /**
@ -127,7 +127,7 @@ public class ConstantInitializerTest {
*/ */
@Test @Test
public void testToStringNull() { public void testToStringNull() {
final String s = new ConstantInitializer<Object>(null).toString(); final String s = new ConstantInitializer<>(null).toString();
assertTrue("Object not found: " + s, s.indexOf("object = null") > 0); assertTrue("Object not found: " + s, s.indexOf("object = null") > 0);
} }
} }

View File

@ -376,7 +376,7 @@ public class EventCountCircuitBreakerTest {
*/ */
public ChangeListener(Object source) { public ChangeListener(Object source) {
expectedSource = source; expectedSource = source;
changedValues = new ArrayList<Boolean>(); changedValues = new ArrayList<>();
} }
public void propertyChange(PropertyChangeEvent evt) { public void propertyChange(PropertyChangeEvent evt) {

View File

@ -76,7 +76,7 @@ public class EventListenerSupportTest {
@Test @Test
public void testEventDispatchOrder() throws PropertyVetoException { public void testEventDispatchOrder() throws PropertyVetoException {
final EventListenerSupport<VetoableChangeListener> listenerSupport = EventListenerSupport.create(VetoableChangeListener.class); final EventListenerSupport<VetoableChangeListener> listenerSupport = EventListenerSupport.create(VetoableChangeListener.class);
final List<VetoableChangeListener> calledListeners = new ArrayList<VetoableChangeListener>(); final List<VetoableChangeListener> calledListeners = new ArrayList<>();
final VetoableChangeListener listener1 = createListener(calledListeners); final VetoableChangeListener listener1 = createListener(calledListeners);
final VetoableChangeListener listener2 = createListener(calledListeners); final VetoableChangeListener listener2 = createListener(calledListeners);

View File

@ -200,7 +200,7 @@ public class EventUtilsTest
private static class EventCountingInvociationHandler implements InvocationHandler private static class EventCountingInvociationHandler implements InvocationHandler
{ {
private final Map<String, Integer> eventCounts = new TreeMap<String, Integer>(); private final Map<String, Integer> eventCounts = new TreeMap<>();
public <L> L createListener(final Class<L> listenerType) public <L> L createListener(final Class<L> listenerType)
{ {

View File

@ -32,15 +32,15 @@ public class MutableObjectTest {
assertEquals(null, new MutableObject<String>().getValue()); assertEquals(null, new MutableObject<String>().getValue());
final Integer i = Integer.valueOf(6); final Integer i = Integer.valueOf(6);
assertSame(i, new MutableObject<Integer>(i).getValue()); assertSame(i, new MutableObject<>(i).getValue());
assertSame("HI", new MutableObject<String>("HI").getValue()); assertSame("HI", new MutableObject<>("HI").getValue());
assertSame(null, new MutableObject<Object>(null).getValue()); assertSame(null, new MutableObject<>(null).getValue());
} }
@Test @Test
public void testGetSet() { public void testGetSet() {
final MutableObject<String> mutNum = new MutableObject<String>(); final MutableObject<String> mutNum = new MutableObject<>();
assertEquals(null, new MutableObject<Object>().getValue()); assertEquals(null, new MutableObject<>().getValue());
mutNum.setValue("HELLO"); mutNum.setValue("HELLO");
assertSame("HELLO", mutNum.getValue()); assertSame("HELLO", mutNum.getValue());
@ -51,10 +51,10 @@ public class MutableObjectTest {
@Test @Test
public void testEquals() { public void testEquals() {
final MutableObject<String> mutNumA = new MutableObject<String>("ALPHA"); final MutableObject<String> mutNumA = new MutableObject<>("ALPHA");
final MutableObject<String> mutNumB = new MutableObject<String>("ALPHA"); final MutableObject<String> mutNumB = new MutableObject<>("ALPHA");
final MutableObject<String> mutNumC = new MutableObject<String>("BETA"); final MutableObject<String> mutNumC = new MutableObject<>("BETA");
final MutableObject<String> mutNumD = new MutableObject<String>(null); final MutableObject<String> mutNumD = new MutableObject<>(null);
assertTrue(mutNumA.equals(mutNumA)); assertTrue(mutNumA.equals(mutNumA));
assertTrue(mutNumA.equals(mutNumB)); assertTrue(mutNumA.equals(mutNumB));
@ -73,10 +73,10 @@ public class MutableObjectTest {
@Test @Test
public void testHashCode() { public void testHashCode() {
final MutableObject<String> mutNumA = new MutableObject<String>("ALPHA"); final MutableObject<String> mutNumA = new MutableObject<>("ALPHA");
final MutableObject<String> mutNumB = new MutableObject<String>("ALPHA"); final MutableObject<String> mutNumB = new MutableObject<>("ALPHA");
final MutableObject<String> mutNumC = new MutableObject<String>("BETA"); final MutableObject<String> mutNumC = new MutableObject<>("BETA");
final MutableObject<String> mutNumD = new MutableObject<String>(null); final MutableObject<String> mutNumD = new MutableObject<>(null);
assertTrue(mutNumA.hashCode() == mutNumA.hashCode()); assertTrue(mutNumA.hashCode() == mutNumA.hashCode());
assertTrue(mutNumA.hashCode() == mutNumB.hashCode()); assertTrue(mutNumA.hashCode() == mutNumB.hashCode());
@ -88,9 +88,9 @@ public class MutableObjectTest {
@Test @Test
public void testToString() { public void testToString() {
assertEquals("HI", new MutableObject<String>("HI").toString()); assertEquals("HI", new MutableObject<>("HI").toString());
assertEquals("10.0", new MutableObject<Double>(Double.valueOf(10)).toString()); assertEquals("10.0", new MutableObject<>(Double.valueOf(10)).toString());
assertEquals("null", new MutableObject<Object>(null).toString()); assertEquals("null", new MutableObject<>(null).toString());
} }
} }

View File

@ -116,7 +116,7 @@ public class ConstructorUtilsTest {
private final Map<Class<?>, Class<?>[]> classCache; private final Map<Class<?>, Class<?>[]> classCache;
public ConstructorUtilsTest() { public ConstructorUtilsTest() {
classCache = new HashMap<Class<?>, Class<?>[]>(); classCache = new HashMap<>();
} }

View File

@ -160,7 +160,7 @@ public class FieldUtilsTest {
final List<Field> fieldsNumber = Arrays.asList(Number.class.getDeclaredFields()); final List<Field> fieldsNumber = Arrays.asList(Number.class.getDeclaredFields());
assertEquals(fieldsNumber, FieldUtils.getAllFieldsList(Number.class)); assertEquals(fieldsNumber, FieldUtils.getAllFieldsList(Number.class));
final List<Field> fieldsInteger = Arrays.asList(Integer.class.getDeclaredFields()); final List<Field> fieldsInteger = Arrays.asList(Integer.class.getDeclaredFields());
final List<Field> allFieldsInteger = new ArrayList<Field>(fieldsInteger); final List<Field> allFieldsInteger = new ArrayList<>(fieldsInteger);
allFieldsInteger.addAll(fieldsNumber); allFieldsInteger.addAll(fieldsNumber);
assertEquals(allFieldsInteger, FieldUtils.getAllFieldsList(Integer.class)); assertEquals(allFieldsInteger, FieldUtils.getAllFieldsList(Integer.class));
assertEquals(5, FieldUtils.getAllFieldsList(PublicChild.class).size()); assertEquals(5, FieldUtils.getAllFieldsList(PublicChild.class).size());

View File

@ -249,7 +249,7 @@ public class MethodUtilsTest {
} }
private TestBean testBean; private TestBean testBean;
private final Map<Class<?>, Class<?>[]> classCache = new HashMap<Class<?>, Class<?>[]>(); private final Map<Class<?>, Class<?>[]> classCache = new HashMap<>();
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {

View File

@ -525,7 +525,7 @@ public class TypeUtilsTest<B> {
@Test @Test
public void testTypesSatisfyVariables() throws SecurityException, NoSuchFieldException, public void testTypesSatisfyVariables() throws SecurityException, NoSuchFieldException,
NoSuchMethodException { NoSuchMethodException {
final Map<TypeVariable<?>, Type> typeVarAssigns = new HashMap<TypeVariable<?>, Type>(); final Map<TypeVariable<?>, Type> typeVarAssigns = new HashMap<>();
final Integer max = TypeUtilsTest.<Integer> stub(); final Integer max = TypeUtilsTest.<Integer> stub();
typeVarAssigns.put(getClass().getMethod("stub").getTypeParameters()[0], Integer.class); typeVarAssigns.put(getClass().getMethod("stub").getTypeParameters()[0], Integer.class);
Assert.assertTrue(TypeUtils.typesSatisfyVariables(typeVarAssigns)); Assert.assertTrue(TypeUtils.typesSatisfyVariables(typeVarAssigns));

View File

@ -45,7 +45,7 @@ import org.apache.commons.lang3.SystemUtils;
*/ */
public class ExtendedMessageFormatTest { public class ExtendedMessageFormatTest {
private final Map<String, FormatFactory> registry = new HashMap<String, FormatFactory>(); private final Map<String, FormatFactory> registry = new HashMap<>();
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {
@ -116,7 +116,7 @@ public class ExtendedMessageFormatTest {
final String extendedPattern = "Name: {0,upper} "; final String extendedPattern = "Name: {0,upper} ";
final String pattern = extendedPattern + builtinsPattern; final String pattern = extendedPattern + builtinsPattern;
final HashSet<Locale> testLocales = new HashSet<Locale>(); final HashSet<Locale> testLocales = new HashSet<>();
testLocales.addAll(Arrays.asList(DateFormat.getAvailableLocales())); testLocales.addAll(Arrays.asList(DateFormat.getAvailableLocales()));
testLocales.retainAll(Arrays.asList(NumberFormat.getAvailableLocales())); testLocales.retainAll(Arrays.asList(NumberFormat.getAvailableLocales()));
testLocales.add(null); testLocales.add(null);

View File

@ -95,7 +95,7 @@ public class StrLookupTest {
@Test @Test
public void testMapLookup() { public void testMapLookup() {
final Map<String, Object> map = new HashMap<String, Object>(); final Map<String, Object> map = new HashMap<>();
map.put("key", "value"); map.put("key", "value");
map.put("number", Integer.valueOf(2)); map.put("number", Integer.valueOf(2));
assertEquals("value", StrLookup.mapLookup(map).lookup("key")); assertEquals("value", StrLookup.mapLookup(map).lookup("key"));

View File

@ -42,7 +42,7 @@ public class StrSubstitutorTest {
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {
values = new HashMap<String, String>(); values = new HashMap<>();
values.put("animal", "quick brown fox"); values.put("animal", "quick brown fox");
values.put("target", "lazy dog"); values.put("target", "lazy dog");
} }
@ -235,7 +235,7 @@ public class StrSubstitutorTest {
*/ */
@Test @Test
public void testCyclicReplacement() { public void testCyclicReplacement() {
final Map<String, String> map = new HashMap<String, String>(); final Map<String, String> map = new HashMap<>();
map.put("animal", "${critter}"); map.put("animal", "${critter}");
map.put("target", "${pet}"); map.put("target", "${pet}");
map.put("pet", "${petCharacteristic} dog"); map.put("pet", "${petCharacteristic} dog");
@ -364,7 +364,7 @@ public class StrSubstitutorTest {
@Test @Test
public void testDefaultValueDelimiters() { public void testDefaultValueDelimiters() {
final Map<String, String> map = new HashMap<String, String>(); final Map<String, String> map = new HashMap<>();
map.put("animal", "fox"); map.put("animal", "fox");
map.put("target", "dog"); map.put("target", "dog");
@ -402,7 +402,7 @@ public class StrSubstitutorTest {
@Test @Test
public void testResolveVariable() { public void testResolveVariable() {
final StrBuilder builder = new StrBuilder("Hi ${name}!"); final StrBuilder builder = new StrBuilder("Hi ${name}!");
final Map<String, String> map = new HashMap<String, String>(); final Map<String, String> map = new HashMap<>();
map.put("name", "commons"); map.put("name", "commons");
final StrSubstitutor sub = new StrSubstitutor(map) { final StrSubstitutor sub = new StrSubstitutor(map) {
@Override @Override
@ -433,7 +433,7 @@ public class StrSubstitutorTest {
*/ */
@Test @Test
public void testConstructorMapPrefixSuffix() { public void testConstructorMapPrefixSuffix() {
final Map<String, String> map = new HashMap<String, String>(); final Map<String, String> map = new HashMap<>();
map.put("name", "commons"); map.put("name", "commons");
final StrSubstitutor sub = new StrSubstitutor(map, "<", ">"); final StrSubstitutor sub = new StrSubstitutor(map, "<", ">");
assertEquals("Hi < commons", sub.replace("Hi $< <name>")); assertEquals("Hi < commons", sub.replace("Hi $< <name>"));
@ -444,7 +444,7 @@ public class StrSubstitutorTest {
*/ */
@Test @Test
public void testConstructorMapFull() { public void testConstructorMapFull() {
final Map<String, String> map = new HashMap<String, String>(); final Map<String, String> map = new HashMap<>();
map.put("name", "commons"); map.put("name", "commons");
StrSubstitutor sub = new StrSubstitutor(map, "<", ">", '!'); StrSubstitutor sub = new StrSubstitutor(map, "<", ">", '!');
assertEquals("Hi < commons", sub.replace("Hi !< <name>")); assertEquals("Hi < commons", sub.replace("Hi !< <name>"));
@ -556,7 +556,7 @@ public class StrSubstitutorTest {
*/ */
@Test @Test
public void testStaticReplace() { public void testStaticReplace() {
final Map<String, String> map = new HashMap<String, String>(); final Map<String, String> map = new HashMap<>();
map.put("name", "commons"); map.put("name", "commons");
assertEquals("Hi commons!", StrSubstitutor.replace("Hi ${name}!", map)); assertEquals("Hi commons!", StrSubstitutor.replace("Hi ${name}!", map));
} }
@ -566,7 +566,7 @@ public class StrSubstitutorTest {
*/ */
@Test @Test
public void testStaticReplacePrefixSuffix() { public void testStaticReplacePrefixSuffix() {
final Map<String, String> map = new HashMap<String, String>(); final Map<String, String> map = new HashMap<>();
map.put("name", "commons"); map.put("name", "commons");
assertEquals("Hi commons!", StrSubstitutor.replace("Hi <name>!", map, "<", ">")); assertEquals("Hi commons!", StrSubstitutor.replace("Hi <name>!", map, "<", ">"));
} }
@ -615,7 +615,7 @@ public class StrSubstitutorTest {
@Test @Test
public void testSamePrefixAndSuffix() { public void testSamePrefixAndSuffix() {
final Map<String, String> map = new HashMap<String, String>(); final Map<String, String> map = new HashMap<>();
map.put("greeting", "Hello"); map.put("greeting", "Hello");
map.put(" there ", "XXX"); map.put(" there ", "XXX");
map.put("name", "commons"); map.put("name", "commons");
@ -626,7 +626,7 @@ public class StrSubstitutorTest {
@Test @Test
public void testSubstitutePreserveEscape() { public void testSubstitutePreserveEscape() {
final String org = "${not-escaped} $${escaped}"; final String org = "${not-escaped} $${escaped}";
final Map<String, String> map = new HashMap<String, String>(); final Map<String, String> map = new HashMap<>();
map.put("not-escaped", "value"); map.put("not-escaped", "value");
StrSubstitutor sub = new StrSubstitutor(map, "${", "}", '$'); StrSubstitutor sub = new StrSubstitutor(map, "${", "}", '$');
@ -678,7 +678,7 @@ public class StrSubstitutorTest {
} }
// replace using object // replace using object
final MutableObject<String> obj = new MutableObject<String>(replaceTemplate); // toString returns template final MutableObject<String> obj = new MutableObject<>(replaceTemplate); // toString returns template
assertEquals(expectedResult, sub.replace(obj)); assertEquals(expectedResult, sub.replace(obj));
// replace in StringBuffer // replace in StringBuffer

View File

@ -37,8 +37,8 @@ public class EntityArraysTest {
// LANG-659 - check arrays for duplicate entries // LANG-659 - check arrays for duplicate entries
@Test @Test
public void testHTML40_EXTENDED_ESCAPE(){ public void testHTML40_EXTENDED_ESCAPE(){
final Set<String> col0 = new HashSet<String>(); final Set<String> col0 = new HashSet<>();
final Set<String> col1 = new HashSet<String>(); final Set<String> col1 = new HashSet<>();
final String [][] sa = EntityArrays.HTML40_EXTENDED_ESCAPE(); final String [][] sa = EntityArrays.HTML40_EXTENDED_ESCAPE();
for(int i =0; i <sa.length; i++){ for(int i =0; i <sa.length; i++){
assertTrue("Already added entry 0: "+i+" "+sa[i][0],col0.add(sa[i][0])); assertTrue("Already added entry 0: "+i+" "+sa[i][0],col0.add(sa[i][0]));
@ -49,8 +49,8 @@ public class EntityArraysTest {
// LANG-658 - check arrays for duplicate entries // LANG-658 - check arrays for duplicate entries
@Test @Test
public void testISO8859_1_ESCAPE(){ public void testISO8859_1_ESCAPE(){
final Set<String> col0 = new HashSet<String>(); final Set<String> col0 = new HashSet<>();
final Set<String> col1 = new HashSet<String>(); final Set<String> col1 = new HashSet<>();
final String [][] sa = EntityArrays.ISO8859_1_ESCAPE(); final String [][] sa = EntityArrays.ISO8859_1_ESCAPE();
boolean success = true; boolean success = true;
for(int i =0; i <sa.length; i++){ for(int i =0; i <sa.length; i++){

View File

@ -102,7 +102,7 @@ public class FastDateParserTest {
getInstance(MDY_SLASH, REYKJAVIK, SWEDEN) getInstance(MDY_SLASH, REYKJAVIK, SWEDEN)
}; };
final Map<DateParser,Integer> map= new HashMap<DateParser,Integer>(); final Map<DateParser,Integer> map= new HashMap<>();
int i= 0; int i= 0;
for(final DateParser parser:parsers) { for(final DateParser parser:parsers) {
map.put(parser, Integer.valueOf(i++)); map.put(parser, Integer.valueOf(i++));

View File

@ -37,7 +37,7 @@ public class FastDatePrinterTimeZonesTest {
@Parameterized.Parameters @Parameterized.Parameters
public static Collection<TimeZone> data() { public static Collection<TimeZone> data() {
final String[] zoneIds = TimeZone.getAvailableIDs(); final String[] zoneIds = TimeZone.getAvailableIDs();
List<TimeZone> timeZones = new ArrayList<TimeZone>(); List<TimeZone> timeZones = new ArrayList<>();
for (String zoneId : zoneIds) { for (String zoneId : zoneIds) {
timeZones.add(TimeZone.getTimeZone(zoneId)); timeZones.add(TimeZone.getTimeZone(zoneId));
} }

View File

@ -35,12 +35,12 @@ public class ImmutablePairTest {
@Test @Test
public void testBasic() throws Exception { public void testBasic() throws Exception {
final ImmutablePair<Integer, String> pair = new ImmutablePair<Integer, String>(0, "foo"); final ImmutablePair<Integer, String> pair = new ImmutablePair<>(0, "foo");
assertEquals(0, pair.left.intValue()); assertEquals(0, pair.left.intValue());
assertEquals(0, pair.getLeft().intValue()); assertEquals(0, pair.getLeft().intValue());
assertEquals("foo", pair.right); assertEquals("foo", pair.right);
assertEquals("foo", pair.getRight()); assertEquals("foo", pair.getRight());
final ImmutablePair<Object, String> pair2 = new ImmutablePair<Object, String>(null, "bar"); final ImmutablePair<Object, String> pair2 = new ImmutablePair<>(null, "bar");
assertNull(pair2.left); assertNull(pair2.left);
assertNull(pair2.getLeft()); assertNull(pair2.getLeft());
assertEquals("bar", pair2.right); assertEquals("bar", pair2.right);

View File

@ -35,14 +35,14 @@ public class ImmutableTripleTest {
@Test @Test
public void testBasic() throws Exception { public void testBasic() throws Exception {
final ImmutableTriple<Integer, String, Boolean> triple = new ImmutableTriple<Integer, String, Boolean>(0, "foo", Boolean.TRUE); final ImmutableTriple<Integer, String, Boolean> triple = new ImmutableTriple<>(0, "foo", Boolean.TRUE);
assertEquals(0, triple.left.intValue()); assertEquals(0, triple.left.intValue());
assertEquals(0, triple.getLeft().intValue()); assertEquals(0, triple.getLeft().intValue());
assertEquals("foo", triple.middle); assertEquals("foo", triple.middle);
assertEquals("foo", triple.getMiddle()); assertEquals("foo", triple.getMiddle());
assertEquals(Boolean.TRUE, triple.right); assertEquals(Boolean.TRUE, triple.right);
assertEquals(Boolean.TRUE, triple.getRight()); assertEquals(Boolean.TRUE, triple.getRight());
final ImmutableTriple<Object, String, Integer> triple2 = new ImmutableTriple<Object, String, Integer>(null, "bar", 42); final ImmutableTriple<Object, String, Integer> triple2 = new ImmutableTriple<>(null, "bar", 42);
assertNull(triple2.left); assertNull(triple2.left);
assertNull(triple2.getLeft()); assertNull(triple2.getLeft());
assertEquals("bar", triple2.middle); assertEquals("bar", triple2.middle);

View File

@ -35,24 +35,24 @@ public class MutablePairTest {
@Test @Test
public void testBasic() throws Exception { public void testBasic() throws Exception {
final MutablePair<Integer, String> pair = new MutablePair<Integer, String>(0, "foo"); final MutablePair<Integer, String> pair = new MutablePair<>(0, "foo");
assertEquals(0, pair.getLeft().intValue()); assertEquals(0, pair.getLeft().intValue());
assertEquals("foo", pair.getRight()); assertEquals("foo", pair.getRight());
final MutablePair<Object, String> pair2 = new MutablePair<Object, String>(null, "bar"); final MutablePair<Object, String> pair2 = new MutablePair<>(null, "bar");
assertNull(pair2.getLeft()); assertNull(pair2.getLeft());
assertEquals("bar", pair2.getRight()); assertEquals("bar", pair2.getRight());
} }
@Test @Test
public void testDefault() throws Exception { public void testDefault() throws Exception {
final MutablePair<Integer, String> pair = new MutablePair<Integer, String>(); final MutablePair<Integer, String> pair = new MutablePair<>();
assertNull(pair.getLeft()); assertNull(pair.getLeft());
assertNull(pair.getRight()); assertNull(pair.getRight());
} }
@Test @Test
public void testMutate() throws Exception { public void testMutate() throws Exception {
final MutablePair<Integer, String> pair = new MutablePair<Integer, String>(0, "foo"); final MutablePair<Integer, String> pair = new MutablePair<>(0, "foo");
pair.setLeft(42); pair.setLeft(42);
pair.setRight("bar"); pair.setRight("bar");
assertEquals(42, pair.getLeft().intValue()); assertEquals(42, pair.getLeft().intValue());

View File

@ -35,11 +35,11 @@ public class MutableTripleTest {
@Test @Test
public void testBasic() throws Exception { public void testBasic() throws Exception {
final MutableTriple<Integer, String, Boolean> triple = new MutableTriple<Integer, String, Boolean>(0, "foo", Boolean.FALSE); final MutableTriple<Integer, String, Boolean> triple = new MutableTriple<>(0, "foo", Boolean.FALSE);
assertEquals(0, triple.getLeft().intValue()); assertEquals(0, triple.getLeft().intValue());
assertEquals("foo", triple.getMiddle()); assertEquals("foo", triple.getMiddle());
assertEquals(Boolean.FALSE, triple.getRight()); assertEquals(Boolean.FALSE, triple.getRight());
final MutableTriple<Object, String, String> triple2 = new MutableTriple<Object, String, String>(null, "bar", "hello"); final MutableTriple<Object, String, String> triple2 = new MutableTriple<>(null, "bar", "hello");
assertNull(triple2.getLeft()); assertNull(triple2.getLeft());
assertEquals("bar", triple2.getMiddle()); assertEquals("bar", triple2.getMiddle());
assertEquals("hello", triple2.getRight()); assertEquals("hello", triple2.getRight());
@ -47,7 +47,7 @@ public class MutableTripleTest {
@Test @Test
public void testDefault() throws Exception { public void testDefault() throws Exception {
final MutableTriple<Integer, String, Boolean> triple = new MutableTriple<Integer, String, Boolean>(); final MutableTriple<Integer, String, Boolean> triple = new MutableTriple<>();
assertNull(triple.getLeft()); assertNull(triple.getLeft());
assertNull(triple.getMiddle()); assertNull(triple.getMiddle());
assertNull(triple.getRight()); assertNull(triple.getRight());
@ -55,7 +55,7 @@ public class MutableTripleTest {
@Test @Test
public void testMutate() throws Exception { public void testMutate() throws Exception {
final MutableTriple<Integer, String, Boolean> triple = new MutableTriple<Integer, String, Boolean>(0, "foo", Boolean.TRUE); final MutableTriple<Integer, String, Boolean> triple = new MutableTriple<>(0, "foo", Boolean.TRUE);
triple.setLeft(42); triple.setLeft(42);
triple.setMiddle("bar"); triple.setMiddle("bar");
triple.setRight(Boolean.FALSE); triple.setRight(Boolean.FALSE);

View File

@ -51,7 +51,7 @@ public class PairTest {
final Pair<Integer, String> pair2 = MutablePair.of(0, "foo"); final Pair<Integer, String> pair2 = MutablePair.of(0, "foo");
assertEquals(pair, pair2); assertEquals(pair, pair2);
assertEquals(pair.hashCode(), pair2.hashCode()); assertEquals(pair.hashCode(), pair2.hashCode());
final HashSet<Pair<Integer, String>> set = new HashSet<Pair<Integer, String>>(); final HashSet<Pair<Integer, String>> set = new HashSet<>();
set.add(pair); set.add(pair);
assertTrue(set.contains(pair2)); assertTrue(set.contains(pair2));
@ -63,7 +63,7 @@ public class PairTest {
@Test @Test
public void testMapEntry() throws Exception { public void testMapEntry() throws Exception {
final Pair<Integer, String> pair = ImmutablePair.of(0, "foo"); final Pair<Integer, String> pair = ImmutablePair.of(0, "foo");
final HashMap<Integer, String> map = new HashMap<Integer, String>(); final HashMap<Integer, String> map = new HashMap<>();
map.put(0, "foo"); map.put(0, "foo");
final Entry<Integer, String> entry = map.entrySet().iterator().next(); final Entry<Integer, String> entry = map.entrySet().iterator().next();
assertEquals(pair, entry); assertEquals(pair, entry);

View File

@ -50,7 +50,7 @@ public class TripleTest {
final Triple<Integer, String, Boolean> triple2 = MutableTriple.of(0, "foo", Boolean.TRUE); final Triple<Integer, String, Boolean> triple2 = MutableTriple.of(0, "foo", Boolean.TRUE);
assertEquals(triple, triple2); assertEquals(triple, triple2);
assertEquals(triple.hashCode(), triple2.hashCode()); assertEquals(triple.hashCode(), triple2.hashCode());
final HashSet<Triple<Integer, String, Boolean>> set = new HashSet<Triple<Integer, String, Boolean>>(); final HashSet<Triple<Integer, String, Boolean>> set = new HashSet<>();
set.add(triple); set.add(triple);
assertTrue(set.contains(triple2)); assertTrue(set.contains(triple2));
} }