Remove redundant type arguments.
This commit is contained in:
parent
7e8df326f4
commit
4f82195afd
|
@ -239,7 +239,7 @@ public class ArrayUtils {
|
|||
if (array == 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++) {
|
||||
final Object object = array[i];
|
||||
if (object instanceof Map.Entry<?, ?>) {
|
||||
|
@ -6611,7 +6611,7 @@ public class ArrayUtils {
|
|||
if (isEmpty(array) || isEmpty(values)) {
|
||||
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) {
|
||||
final MutableInt count = occurrences.get(v);
|
||||
if (count == null) {
|
||||
|
@ -6701,7 +6701,7 @@ public class ArrayUtils {
|
|||
if (isEmpty(array) || isEmpty(values)) {
|
||||
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) {
|
||||
final Byte boxed = Byte.valueOf(v);
|
||||
final MutableInt count = occurrences.get(boxed);
|
||||
|
@ -6789,7 +6789,7 @@ public class ArrayUtils {
|
|||
if (isEmpty(array) || isEmpty(values)) {
|
||||
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) {
|
||||
final Short boxed = Short.valueOf(v);
|
||||
final MutableInt count = occurrences.get(boxed);
|
||||
|
@ -6877,7 +6877,7 @@ public class ArrayUtils {
|
|||
if (isEmpty(array) || isEmpty(values)) {
|
||||
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) {
|
||||
final Integer boxed = Integer.valueOf(v);
|
||||
final MutableInt count = occurrences.get(boxed);
|
||||
|
@ -6965,7 +6965,7 @@ public class ArrayUtils {
|
|||
if (isEmpty(array) || isEmpty(values)) {
|
||||
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) {
|
||||
final Character boxed = Character.valueOf(v);
|
||||
final MutableInt count = occurrences.get(boxed);
|
||||
|
@ -7053,7 +7053,7 @@ public class ArrayUtils {
|
|||
if (isEmpty(array) || isEmpty(values)) {
|
||||
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) {
|
||||
final Long boxed = Long.valueOf(v);
|
||||
final MutableInt count = occurrences.get(boxed);
|
||||
|
@ -7141,7 +7141,7 @@ public class ArrayUtils {
|
|||
if (isEmpty(array) || isEmpty(values)) {
|
||||
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) {
|
||||
final Float boxed = Float.valueOf(v);
|
||||
final MutableInt count = occurrences.get(boxed);
|
||||
|
@ -7229,7 +7229,7 @@ public class ArrayUtils {
|
|||
if (isEmpty(array) || isEmpty(values)) {
|
||||
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) {
|
||||
final Double boxed = Double.valueOf(v);
|
||||
final MutableInt count = occurrences.get(boxed);
|
||||
|
@ -7313,7 +7313,7 @@ public class ArrayUtils {
|
|||
if (isEmpty(array) || isEmpty(values)) {
|
||||
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) {
|
||||
final Boolean boxed = Boolean.valueOf(v);
|
||||
final MutableInt count = occurrences.get(boxed);
|
||||
|
|
|
@ -75,7 +75,7 @@ public class ClassUtils {
|
|||
/**
|
||||
* 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 {
|
||||
namePrimitiveMap.put("boolean", Boolean.TYPE);
|
||||
namePrimitiveMap.put("byte", Byte.TYPE);
|
||||
|
@ -91,7 +91,7 @@ public class ClassUtils {
|
|||
/**
|
||||
* 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 {
|
||||
primitiveWrapperMap.put(Boolean.TYPE, Boolean.class);
|
||||
primitiveWrapperMap.put(Byte.TYPE, Byte.class);
|
||||
|
@ -107,7 +107,7 @@ public class ClassUtils {
|
|||
/**
|
||||
* 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 {
|
||||
for (final Map.Entry<Class<?>, Class<?>> entry : primitiveWrapperMap.entrySet()) {
|
||||
final Class<?> primitiveClass = entry.getKey();
|
||||
|
@ -132,7 +132,7 @@ public class ClassUtils {
|
|||
* Feed abbreviation maps
|
||||
*/
|
||||
static {
|
||||
final Map<String, String> m = new HashMap<String, String>();
|
||||
final Map<String, String> m = new HashMap<>();
|
||||
m.put("int", "I");
|
||||
m.put("boolean", "Z");
|
||||
m.put("float", "F");
|
||||
|
@ -141,7 +141,7 @@ public class ClassUtils {
|
|||
m.put("byte", "B");
|
||||
m.put("double", "D");
|
||||
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()) {
|
||||
r.put(e.getValue(), e.getKey());
|
||||
}
|
||||
|
@ -423,7 +423,7 @@ public class ClassUtils {
|
|||
if (cls == null) {
|
||||
return null;
|
||||
}
|
||||
final List<Class<?>> classes = new ArrayList<Class<?>>();
|
||||
final List<Class<?>> classes = new ArrayList<>();
|
||||
Class<?> superclass = cls.getSuperclass();
|
||||
while (superclass != null) {
|
||||
classes.add(superclass);
|
||||
|
@ -450,10 +450,10 @@ public class ClassUtils {
|
|||
return null;
|
||||
}
|
||||
|
||||
final LinkedHashSet<Class<?>> interfacesFound = new LinkedHashSet<Class<?>>();
|
||||
final LinkedHashSet<Class<?>> interfacesFound = new LinkedHashSet<>();
|
||||
getAllInterfaces(cls, interfacesFound);
|
||||
|
||||
return new ArrayList<Class<?>>(interfacesFound);
|
||||
return new ArrayList<>(interfacesFound);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -494,7 +494,7 @@ public class ClassUtils {
|
|||
if (classNames == 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) {
|
||||
try {
|
||||
classes.add(Class.forName(className));
|
||||
|
@ -521,7 +521,7 @@ public class ClassUtils {
|
|||
if (classes == 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) {
|
||||
if (cls == null) {
|
||||
classNames.add(null);
|
||||
|
@ -1021,7 +1021,7 @@ public class ClassUtils {
|
|||
return declaredMethod;
|
||||
}
|
||||
|
||||
final List<Class<?>> candidateClasses = new ArrayList<Class<?>>();
|
||||
final List<Class<?>> candidateClasses = new ArrayList<>();
|
||||
candidateClasses.addAll(getAllInterfaces(cls));
|
||||
candidateClasses.addAll(getAllSuperclasses(cls));
|
||||
|
||||
|
@ -1287,7 +1287,7 @@ public class ClassUtils {
|
|||
|
||||
@Override
|
||||
public Iterator<Class<?>> iterator() {
|
||||
final Set<Class<?>> seenInterfaces = new HashSet<Class<?>>();
|
||||
final Set<Class<?>> seenInterfaces = new HashSet<>();
|
||||
final Iterator<Class<?>> wrapped = classes.iterator();
|
||||
|
||||
return new Iterator<Class<?>>() {
|
||||
|
@ -1306,7 +1306,7 @@ public class ClassUtils {
|
|||
return nextInterface;
|
||||
}
|
||||
final Class<?> nextSuperclass = wrapped.next();
|
||||
final Set<Class<?>> currentInterfaces = new LinkedHashSet<Class<?>>();
|
||||
final Set<Class<?>> currentInterfaces = new LinkedHashSet<>();
|
||||
walkInterfaces(currentInterfaces, nextSuperclass);
|
||||
interfaces = currentInterfaces.iterator();
|
||||
return nextSuperclass;
|
||||
|
|
|
@ -55,7 +55,7 @@ public class EnumUtils {
|
|||
* @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) {
|
||||
final Map<String, E> map = new LinkedHashMap<String, E>();
|
||||
final Map<String, E> map = new LinkedHashMap<>();
|
||||
for (final E e: enumClass.getEnumConstants()) {
|
||||
map.put(e.name(), e);
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ public class EnumUtils {
|
|||
* @return the modifiable list of enums, never null
|
||||
*/
|
||||
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()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -39,11 +39,11 @@ public class LocaleUtils {
|
|||
|
||||
/** Concurrent map of language locales by country. */
|
||||
private static final ConcurrentMap<String, List<Locale>> cLanguagesByCountry =
|
||||
new ConcurrentHashMap<String, List<Locale>>();
|
||||
new ConcurrentHashMap<>();
|
||||
|
||||
/** Concurrent map of country locales by language. */
|
||||
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.
|
||||
|
@ -189,7 +189,7 @@ public class LocaleUtils {
|
|||
* @return the unmodifiable list of Locale objects, 0 being locale, not null
|
||||
*/
|
||||
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) {
|
||||
list.add(locale);
|
||||
if (locale.getVariant().length() > 0) {
|
||||
|
@ -260,7 +260,7 @@ public class LocaleUtils {
|
|||
}
|
||||
List<Locale> langs = cLanguagesByCountry.get(countryCode);
|
||||
if (langs == null) {
|
||||
langs = new ArrayList<Locale>();
|
||||
langs = new ArrayList<>();
|
||||
final List<Locale> locales = availableLocaleList();
|
||||
for (int i = 0; i < locales.size(); i++) {
|
||||
final Locale locale = locales.get(i);
|
||||
|
@ -292,7 +292,7 @@ public class LocaleUtils {
|
|||
}
|
||||
List<Locale> countries = cCountriesByLanguage.get(languageCode);
|
||||
if (countries == null) {
|
||||
countries = new ArrayList<Locale>();
|
||||
countries = new ArrayList<>();
|
||||
final List<Locale> locales = availableLocaleList();
|
||||
for (int i = 0; i < locales.size(); i++) {
|
||||
final Locale locale = locales.get(i);
|
||||
|
@ -318,9 +318,9 @@ public class LocaleUtils {
|
|||
private static final Set<Locale> AVAILABLE_LOCALE_SET;
|
||||
|
||||
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_SET = Collections.unmodifiableSet(new HashSet<Locale>(list));
|
||||
AVAILABLE_LOCALE_SET = Collections.unmodifiableSet(new HashSet<>(list));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -586,7 +586,7 @@ public class ObjectUtils {
|
|||
public static <T extends Comparable<? super T>> T median(final T... items) {
|
||||
Validate.notEmpty(items);
|
||||
Validate.noNullElements(items);
|
||||
final TreeSet<T> sort = new TreeSet<T>();
|
||||
final TreeSet<T> sort = new TreeSet<>();
|
||||
Collections.addAll(sort, items);
|
||||
@SuppressWarnings("unchecked") //we know all items added were T instances
|
||||
final
|
||||
|
@ -609,7 +609,7 @@ public class ObjectUtils {
|
|||
Validate.notEmpty(items, "null/empty items");
|
||||
Validate.noNullElements(items);
|
||||
Validate.notNull(comparator, "null comparator");
|
||||
final TreeSet<T> sort = new TreeSet<T>(comparator);
|
||||
final TreeSet<T> sort = new TreeSet<>(comparator);
|
||||
Collections.addAll(sort, items);
|
||||
@SuppressWarnings("unchecked") //we know all items added were T instances
|
||||
final
|
||||
|
@ -629,7 +629,7 @@ public class ObjectUtils {
|
|||
*/
|
||||
public static <T> T mode(final T... 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) {
|
||||
final MutableInt count = occurrences.get(t);
|
||||
if (count == null) {
|
||||
|
|
|
@ -131,7 +131,7 @@ public final class Range<T> implements Serializable {
|
|||
* @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) {
|
||||
return new Range<T>(fromInclusive, toInclusive, comparator);
|
||||
return new Range<>(fromInclusive, toInclusive, comparator);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -280,7 +280,7 @@ public class SerializationUtils {
|
|||
*/
|
||||
static class ClassLoaderAwareObjectInputStream extends ObjectInputStream {
|
||||
private static final Map<String, Class<?>> primitiveTypes =
|
||||
new HashMap<String, Class<?>>();
|
||||
new HashMap<>();
|
||||
|
||||
static {
|
||||
primitiveTypes.put("byte", byte.class);
|
||||
|
|
|
@ -3002,7 +3002,7 @@ public class StringUtils {
|
|||
}
|
||||
final int closeLen = close.length();
|
||||
final int openLen = open.length();
|
||||
final List<String> list = new ArrayList<String>();
|
||||
final List<String> list = new ArrayList<>();
|
||||
int pos = 0;
|
||||
while (pos < strLen - closeLen) {
|
||||
int start = str.indexOf(open, pos);
|
||||
|
@ -3298,7 +3298,7 @@ public class StringUtils {
|
|||
|
||||
final int separatorLength = separator.length();
|
||||
|
||||
final ArrayList<String> substrings = new ArrayList<String>();
|
||||
final ArrayList<String> substrings = new ArrayList<>();
|
||||
int numberOfSubstrings = 0;
|
||||
int beg = 0;
|
||||
int end = 0;
|
||||
|
@ -3432,7 +3432,7 @@ public class StringUtils {
|
|||
if (len == 0) {
|
||||
return ArrayUtils.EMPTY_STRING_ARRAY;
|
||||
}
|
||||
final List<String> list = new ArrayList<String>();
|
||||
final List<String> list = new ArrayList<>();
|
||||
int i = 0, start = 0;
|
||||
boolean match = false;
|
||||
boolean lastMatch = false;
|
||||
|
@ -3559,7 +3559,7 @@ public class StringUtils {
|
|||
if (len == 0) {
|
||||
return ArrayUtils.EMPTY_STRING_ARRAY;
|
||||
}
|
||||
final List<String> list = new ArrayList<String>();
|
||||
final List<String> list = new ArrayList<>();
|
||||
int sizePlus1 = 1;
|
||||
int i = 0, start = 0;
|
||||
boolean match = false;
|
||||
|
@ -3705,7 +3705,7 @@ public class StringUtils {
|
|||
return ArrayUtils.EMPTY_STRING_ARRAY;
|
||||
}
|
||||
final char[] c = str.toCharArray();
|
||||
final List<String> list = new ArrayList<String>();
|
||||
final List<String> list = new ArrayList<>();
|
||||
int tokenStart = 0;
|
||||
int currentType = Character.getType(c[tokenStart]);
|
||||
for (int pos = tokenStart + 1; pos < c.length; pos++) {
|
||||
|
|
|
@ -131,7 +131,7 @@ public class ThreadUtils {
|
|||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
final Collection<Thread> result = new ArrayList<Thread>();
|
||||
final Collection<Thread> result = new ArrayList<>();
|
||||
final NamePredicate threadNamePredicate = new NamePredicate(threadName);
|
||||
for(final ThreadGroup group : threadGroups) {
|
||||
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
|
||||
} 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) {
|
||||
if (predicate.test(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
|
||||
} 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) {
|
||||
if(predicate.test(threadGroups[i])) {
|
||||
result.add(threadGroups[i]);
|
||||
|
|
|
@ -109,7 +109,7 @@ public class DiffBuilder implements Builder<DiffResult> {
|
|||
throw new IllegalArgumentException("rhs cannot be null");
|
||||
}
|
||||
|
||||
this.diffs = new ArrayList<Diff<?>>();
|
||||
this.diffs = new ArrayList<>();
|
||||
this.left = lhs;
|
||||
this.right = rhs;
|
||||
this.style = style;
|
||||
|
|
|
@ -92,7 +92,7 @@ public class EqualsBuilder implements Builder<Boolean> {
|
|||
*
|
||||
* @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()
|
||||
|
@ -174,7 +174,7 @@ public class EqualsBuilder implements Builder<Boolean> {
|
|||
private static void register(final Object lhs, final Object rhs) {
|
||||
Set<Pair<IDKey, IDKey>> registry = getRegistry();
|
||||
if (registry == null) {
|
||||
registry = new HashSet<Pair<IDKey, IDKey>>();
|
||||
registry = new HashSet<>();
|
||||
REGISTRY.set(registry);
|
||||
}
|
||||
final Pair<IDKey, IDKey> pair = getRegisterPair(lhs, rhs);
|
||||
|
|
|
@ -118,7 +118,7 @@ public class HashCodeBuilder implements Builder<Integer> {
|
|||
*
|
||||
* @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()
|
||||
|
@ -500,7 +500,7 @@ public class HashCodeBuilder implements Builder<Integer> {
|
|||
private static void register(final Object value) {
|
||||
Set<IDKey> registry = getRegistry();
|
||||
if (registry == null) {
|
||||
registry = new HashSet<IDKey>();
|
||||
registry = new HashSet<>();
|
||||
REGISTRY.set(registry);
|
||||
}
|
||||
registry.add(new IDKey(value));
|
||||
|
|
|
@ -340,7 +340,7 @@ public class ReflectionToStringBuilder extends ToStringBuilder {
|
|||
* @return The given array or a new array without null.
|
||||
*/
|
||||
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) {
|
||||
if (e != null) {
|
||||
list.add(e.toString());
|
||||
|
|
|
@ -165,7 +165,7 @@ public abstract class ToStringStyle implements Serializable {
|
|||
* </p>
|
||||
*/
|
||||
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
|
||||
* an instance variable would not be suitable here.
|
||||
|
@ -217,7 +217,7 @@ public abstract class ToStringStyle implements Serializable {
|
|||
if (value != null) {
|
||||
final Map<Object, Object> m = getRegistry();
|
||||
if (m == null) {
|
||||
REGISTRY.set(new WeakHashMap<Object, Object>());
|
||||
REGISTRY.set(new WeakHashMap<>());
|
||||
}
|
||||
getRegistry().put(value, null);
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ public abstract class AbstractCircuitBreaker<T> implements CircuitBreaker<T> {
|
|||
public static final String PROPERTY_NAME = "open";
|
||||
|
||||
/** 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. */
|
||||
private final PropertyChangeSupport changeSupport;
|
||||
|
|
|
@ -65,7 +65,7 @@ import java.util.concurrent.atomic.AtomicReference;
|
|||
*/
|
||||
public abstract class AtomicInitializer<T> implements ConcurrentInitializer<T> {
|
||||
/** 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
|
||||
|
|
|
@ -56,10 +56,10 @@ public abstract class AtomicSafeInitializer<T> implements
|
|||
ConcurrentInitializer<T> {
|
||||
/** A guard which ensures that initialize() is called only once. */
|
||||
private final AtomicReference<AtomicSafeInitializer<T>> factory =
|
||||
new AtomicReference<AtomicSafeInitializer<T>>();
|
||||
new AtomicReference<>();
|
||||
|
||||
/** 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
|
||||
|
|
|
@ -322,7 +322,7 @@ public class ConcurrentUtils {
|
|||
* @return an instance of Future that will return the value, never null
|
||||
*/
|
||||
public static <T> Future<T> constantFuture(final T value) {
|
||||
return new ConstantFuture<T>(value);
|
||||
return new ConstantFuture<>(value);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -175,7 +175,7 @@ public class EventCountCircuitBreaker extends AbstractCircuitBreaker<Integer> {
|
|||
TimeUnit openingUnit, int closingThreshold, long closingInterval,
|
||||
TimeUnit closingUnit) {
|
||||
super();
|
||||
checkIntervalData = new AtomicReference<CheckIntervalData>(new CheckIntervalData(0, 0));
|
||||
checkIntervalData = new AtomicReference<>(new CheckIntervalData(0, 0));
|
||||
this.openingThreshold = openingThreshold;
|
||||
this.openingInterval = openingUnit.toNanos(openingInterval);
|
||||
this.closingThreshold = closingThreshold;
|
||||
|
@ -416,7 +416,7 @@ public class EventCountCircuitBreaker extends AbstractCircuitBreaker<Integer> {
|
|||
* @return the strategy map
|
||||
*/
|
||||
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.OPEN, new StateStrategyOpen());
|
||||
return map;
|
||||
|
|
|
@ -98,7 +98,7 @@ public class MultiBackgroundInitializer
|
|||
BackgroundInitializer<MultiBackgroundInitializer.MultiBackgroundInitializerResults> {
|
||||
/** A map with the child initializers. */
|
||||
private final Map<String, BackgroundInitializer<?>> childInitializers =
|
||||
new HashMap<String, BackgroundInitializer<?>>();
|
||||
new HashMap<>();
|
||||
|
||||
/**
|
||||
* Creates a new instance of {@code MultiBackgroundInitializer}.
|
||||
|
@ -185,7 +185,7 @@ public class MultiBackgroundInitializer
|
|||
Map<String, BackgroundInitializer<?>> inits;
|
||||
synchronized (this) {
|
||||
// create a snapshot to operate on
|
||||
inits = new HashMap<String, BackgroundInitializer<?>>(
|
||||
inits = new HashMap<>(
|
||||
childInitializers);
|
||||
}
|
||||
|
||||
|
@ -200,8 +200,8 @@ public class MultiBackgroundInitializer
|
|||
}
|
||||
|
||||
// collect the results
|
||||
final Map<String, Object> results = new HashMap<String, Object>();
|
||||
final Map<String, ConcurrentException> excepts = new HashMap<String, ConcurrentException>();
|
||||
final Map<String, Object> results = new HashMap<>();
|
||||
final Map<String, ConcurrentException> excepts = new HashMap<>();
|
||||
for (final Map.Entry<String, BackgroundInitializer<?>> e : inits.entrySet()) {
|
||||
try {
|
||||
results.put(e.getKey(), e.getValue().get());
|
||||
|
|
|
@ -76,7 +76,7 @@ public class EventListenerSupport<L> implements Serializable {
|
|||
* intentionally a thread-safe copy-on-write-array so that traversals over
|
||||
* 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
|
||||
|
@ -106,7 +106,7 @@ public class EventListenerSupport<L> implements Serializable {
|
|||
* not an interface.
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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:
|
||||
ObjectOutputStream testObjectOutputStream = new ObjectOutputStream(new ByteArrayOutputStream());
|
||||
|
@ -271,7 +271,7 @@ public class EventListenerSupport<L> implements Serializable {
|
|||
final
|
||||
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
|
||||
final
|
||||
|
|
|
@ -93,7 +93,7 @@ public class EventUtils {
|
|||
EventBindingInvocationHandler(final Object target, final String methodName, final String[] eventTypes) {
|
||||
this.target = target;
|
||||
this.methodName = methodName;
|
||||
this.eventTypes = new HashSet<String>(Arrays.asList(eventTypes));
|
||||
this.eventTypes = new HashSet<>(Arrays.asList(eventTypes));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -44,14 +44,14 @@ public class DefaultExceptionContext implements ExceptionContext, Serializable {
|
|||
private static final long serialVersionUID = 20110706L;
|
||||
|
||||
/** 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}
|
||||
*/
|
||||
@Override
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -75,7 +75,7 @@ public class DefaultExceptionContext implements ExceptionContext, Serializable {
|
|||
*/
|
||||
@Override
|
||||
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) {
|
||||
if (StringUtils.equals(label, pair.getKey())) {
|
||||
values.add(pair.getValue());
|
||||
|
@ -102,7 +102,7 @@ public class DefaultExceptionContext implements ExceptionContext, Serializable {
|
|||
*/
|
||||
@Override
|
||||
public Set<String> getContextLabels() {
|
||||
final Set<String> labels = new HashSet<String>();
|
||||
final Set<String> labels = new HashSet<>();
|
||||
for (final Pair<String, Object> pair : contextValues) {
|
||||
labels.add(pair.getKey());
|
||||
}
|
||||
|
|
|
@ -283,7 +283,7 @@ public class ExceptionUtils {
|
|||
* @since Commons Lang 2.2
|
||||
*/
|
||||
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) {
|
||||
list.add(throwable);
|
||||
throwable = ExceptionUtils.getCause(throwable);
|
||||
|
@ -524,7 +524,7 @@ public class ExceptionUtils {
|
|||
}
|
||||
final Throwable throwables[] = getThrowables(throwable);
|
||||
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]);
|
||||
for (int i = count; --i >= 0;) {
|
||||
final List<String> trace = nextTrace;
|
||||
|
@ -623,7 +623,7 @@ public class ExceptionUtils {
|
|||
static String[] getStackFrames(final String stackTrace) {
|
||||
final String linebreak = SystemUtils.LINE_SEPARATOR;
|
||||
final StringTokenizer frames = new StringTokenizer(stackTrace, linebreak);
|
||||
final List<String> list = new ArrayList<String>();
|
||||
final List<String> list = new ArrayList<>();
|
||||
while (frames.hasMoreTokens()) {
|
||||
list.add(frames.nextToken());
|
||||
}
|
||||
|
@ -646,7 +646,7 @@ public class ExceptionUtils {
|
|||
final String stackTrace = getStackTrace(t);
|
||||
final String linebreak = SystemUtils.LINE_SEPARATOR;
|
||||
final StringTokenizer frames = new StringTokenizer(stackTrace, linebreak);
|
||||
final List<String> list = new ArrayList<String>();
|
||||
final List<String> list = new ArrayList<>();
|
||||
boolean traceStarted = false;
|
||||
while (frames.hasMoreTokens()) {
|
||||
final String token = frames.nextToken();
|
||||
|
|
|
@ -211,7 +211,7 @@ public class FieldUtils {
|
|||
*/
|
||||
public static List<Field> getAllFieldsList(final Class<?> cls) {
|
||||
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;
|
||||
while (currentClass != null) {
|
||||
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) {
|
||||
Validate.isTrue(annotationCls != null, "The annotation class must not be null");
|
||||
final List<Field> allFields = getAllFieldsList(cls);
|
||||
final List<Field> annotatedFields = new ArrayList<Field>();
|
||||
final List<Field> annotatedFields = new ArrayList<>();
|
||||
for (final Field field : allFields) {
|
||||
if (field.getAnnotation(annotationCls) != null) {
|
||||
annotatedFields.add(field);
|
||||
|
|
|
@ -781,7 +781,7 @@ public class MethodUtils {
|
|||
*/
|
||||
public static Set<Method> getOverrideHierarchy(final Method method, final Interfaces interfacesBehavior) {
|
||||
Validate.notNull(method);
|
||||
final Set<Method> result = new LinkedHashSet<Method>();
|
||||
final Set<Method> result = new LinkedHashSet<>();
|
||||
result.add(method);
|
||||
|
||||
final Class<?>[] parameterTypes = method.getParameterTypes();
|
||||
|
@ -847,7 +847,7 @@ public class MethodUtils {
|
|||
Validate.isTrue(cls != null, "The class must not be null");
|
||||
Validate.isTrue(annotationCls != null, "The annotation class must not be null");
|
||||
final Method[] allMethods = cls.getMethods();
|
||||
final List<Method> annotatedMethods = new ArrayList<Method>();
|
||||
final List<Method> annotatedMethods = new ArrayList<>();
|
||||
for (final Method method : allMethods) {
|
||||
if (method.getAnnotation(annotationCls) != null) {
|
||||
annotatedMethods.add(method);
|
||||
|
|
|
@ -865,7 +865,7 @@ public class TypeUtils {
|
|||
} else {
|
||||
// no owner, prep the type variable assignments map
|
||||
typeVarAssigns = subtypeVarAssigns == null ? new HashMap<TypeVariable<?>, Type>()
|
||||
: new HashMap<TypeVariable<?>, Type>(subtypeVarAssigns);
|
||||
: new HashMap<>(subtypeVarAssigns);
|
||||
}
|
||||
|
||||
// get the subject parameterized type's arguments
|
||||
|
@ -910,7 +910,7 @@ public class TypeUtils {
|
|||
if (toClass.isPrimitive()) {
|
||||
// dealing with widening here. No type arguments to be
|
||||
// harvested with these two types.
|
||||
return new HashMap<TypeVariable<?>, Type>();
|
||||
return new HashMap<>();
|
||||
}
|
||||
|
||||
// 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
|
||||
final HashMap<TypeVariable<?>, Type> typeVarAssigns = subtypeVarAssigns == null ? new HashMap<TypeVariable<?>, Type>()
|
||||
: new HashMap<TypeVariable<?>, Type>(subtypeVarAssigns);
|
||||
: new HashMap<>(subtypeVarAssigns);
|
||||
|
||||
// has target class been reached?
|
||||
if (toClass.equals(cls)) {
|
||||
|
@ -1132,7 +1132,7 @@ public class TypeUtils {
|
|||
return bounds;
|
||||
}
|
||||
|
||||
final Set<Type> types = new HashSet<Type>(bounds.length);
|
||||
final Set<Type> types = new HashSet<>(bounds.length);
|
||||
|
||||
for (final Type type1 : bounds) {
|
||||
boolean subtypeFound = false;
|
||||
|
@ -1377,7 +1377,7 @@ public class TypeUtils {
|
|||
if (p.getOwnerType() == null) {
|
||||
parameterizedTypeArguments = typeArguments;
|
||||
} else {
|
||||
parameterizedTypeArguments = new HashMap<TypeVariable<?>, Type>(typeArguments);
|
||||
parameterizedTypeArguments = new HashMap<>(typeArguments);
|
||||
parameterizedTypeArguments.putAll(TypeUtils.getTypeArguments(p));
|
||||
}
|
||||
final Type[] args = p.getActualTypeArguments();
|
||||
|
|
|
@ -145,8 +145,8 @@ public class ExtendedMessageFormat extends MessageFormat {
|
|||
toPattern = super.toPattern();
|
||||
return;
|
||||
}
|
||||
final ArrayList<Format> foundFormats = new ArrayList<Format>();
|
||||
final ArrayList<String> foundDescriptions = new ArrayList<String>();
|
||||
final ArrayList<Format> foundFormats = new ArrayList<>();
|
||||
final ArrayList<String> foundDescriptions = new ArrayList<>();
|
||||
final StringBuilder stripCustom = new StringBuilder(pattern.length());
|
||||
|
||||
final ParsePosition pos = new ParsePosition(0);
|
||||
|
|
|
@ -38,7 +38,7 @@ public abstract class StrLookup<V> {
|
|||
/**
|
||||
* 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.
|
||||
|
@ -81,7 +81,7 @@ public abstract class StrLookup<V> {
|
|||
* @return a lookup using the map, not null
|
||||
*/
|
||||
public static <V> StrLookup<V> mapLookup(final Map<String, V> map) {
|
||||
return new MapStrLookup<V>(map);
|
||||
return new MapStrLookup<>(map);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
|
|
@ -213,7 +213,7 @@ public class StrSubstitutor {
|
|||
if (valueProperties == null) {
|
||||
return source.toString();
|
||||
}
|
||||
final Map<String,String> valueMap = new HashMap<String,String>();
|
||||
final Map<String,String> valueMap = new HashMap<>();
|
||||
final Enumeration<?> propNames = valueProperties.propertyNames();
|
||||
while (propNames.hasMoreElements()) {
|
||||
final String propName = (String)propNames.nextElement();
|
||||
|
@ -837,7 +837,7 @@ public class StrSubstitutor {
|
|||
|
||||
// on the first call initialize priorVariables
|
||||
if (priorVariables == null) {
|
||||
priorVariables = new ArrayList<String>();
|
||||
priorVariables = new ArrayList<>();
|
||||
priorVariables.add(new String(chars,
|
||||
offset, length));
|
||||
}
|
||||
|
|
|
@ -440,7 +440,7 @@ public class StrTokenizer implements ListIterator<String>, Cloneable {
|
|||
*/
|
||||
public List<String> getTokenList() {
|
||||
checkTokenized();
|
||||
final List<String> list = new ArrayList<String>(tokens.length);
|
||||
final List<String> list = new ArrayList<>(tokens.length);
|
||||
for (final String element : tokens) {
|
||||
list.add(element);
|
||||
}
|
||||
|
@ -636,7 +636,7 @@ public class StrTokenizer implements ListIterator<String>, Cloneable {
|
|||
return Collections.emptyList();
|
||||
}
|
||||
final StrBuilder buf = new StrBuilder();
|
||||
final List<String> tokenList = new ArrayList<String>();
|
||||
final List<String> tokenList = new ArrayList<>();
|
||||
int pos = offset;
|
||||
|
||||
// loop around the entire buffer
|
||||
|
|
|
@ -43,8 +43,8 @@ public class LookupTranslator extends CharSequenceTranslator {
|
|||
* @param lookup CharSequence[][] table of size [*][2]
|
||||
*/
|
||||
public LookupTranslator(final CharSequence[]... lookup) {
|
||||
lookupMap = new HashMap<String, String>();
|
||||
prefixSet = new HashSet<Character>();
|
||||
lookupMap = new HashMap<>();
|
||||
prefixSet = new HashSet<>();
|
||||
int _shortest = Integer.MAX_VALUE;
|
||||
int _longest = 0;
|
||||
if (lookup != null) {
|
||||
|
|
|
@ -494,7 +494,7 @@ public class DurationFormatUtils {
|
|||
* @return array of Token[]
|
||||
*/
|
||||
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;
|
||||
// Although the buffer is stored in a Token, the Tokens are only
|
||||
|
|
|
@ -160,7 +160,7 @@ public class FastDateParser implements DateParser, Serializable {
|
|||
* @param definingCalendar the {@link java.util.Calendar} instance used to initialize this FastDateParser
|
||||
*/
|
||||
private void init(final Calendar definingCalendar) {
|
||||
patterns = new ArrayList<StrategyAndWidth>();
|
||||
patterns = new ArrayList<>();
|
||||
|
||||
StrategyParser fm = new StrategyParser(pattern, definingCalendar);
|
||||
for(;;) {
|
||||
|
@ -464,10 +464,10 @@ public class FastDateParser implements DateParser, Serializable {
|
|||
* @return The map of string display names to field values
|
||||
*/
|
||||
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);
|
||||
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()) {
|
||||
String key = displayName.getKey().toLowerCase(locale);
|
||||
if (sorted.add(key)) {
|
||||
|
@ -618,7 +618,7 @@ public class FastDateParser implements DateParser, Serializable {
|
|||
private static ConcurrentMap<Locale, Strategy> getCache(final int field) {
|
||||
synchronized (caches) {
|
||||
if (caches[field] == null) {
|
||||
caches[field] = new ConcurrentHashMap<Locale, Strategy>(3);
|
||||
caches[field] = new ConcurrentHashMap<>(3);
|
||||
}
|
||||
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 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 {
|
||||
TimeZone zone;
|
||||
|
@ -842,7 +842,7 @@ public class FastDateParser implements DateParser, Serializable {
|
|||
final StringBuilder sb = new StringBuilder();
|
||||
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();
|
||||
for (final String[] zoneNames : zones) {
|
||||
|
|
|
@ -180,7 +180,7 @@ public class FastDatePrinter implements DatePrinter, Serializable {
|
|||
*/
|
||||
protected List<Rule> parsePattern() {
|
||||
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[] months = symbols.getMonths();
|
||||
|
@ -1302,7 +1302,7 @@ public class FastDatePrinter implements DatePrinter, Serializable {
|
|||
//-----------------------------------------------------------------------
|
||||
|
||||
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>
|
||||
*
|
||||
|
|
|
@ -38,10 +38,10 @@ abstract class FormatCache<F extends Format> {
|
|||
static final int NONE= -1;
|
||||
|
||||
private final ConcurrentMap<MultipartKey, F> cInstanceCache
|
||||
= new ConcurrentHashMap<MultipartKey, F>(7);
|
||||
= new ConcurrentHashMap<>(7);
|
||||
|
||||
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
|
||||
|
|
|
@ -54,7 +54,7 @@ public final class ImmutablePair<L, R> extends Pair<L, R> {
|
|||
* @return a pair formed from the two parameters, not null
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -49,7 +49,7 @@ public class MutablePair<L, R> extends Pair<L, R> {
|
|||
* @return a pair formed from the two parameters, not null
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
|
|
@ -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
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
|
|
@ -302,7 +302,7 @@ public class ClassUtilsTest {
|
|||
// -------------------------------------------------------------------------
|
||||
@Test
|
||||
public void test_convertClassNamesToClasses_List() {
|
||||
final List<String> list = new ArrayList<String>();
|
||||
final List<String> list = new ArrayList<>();
|
||||
List<Class<?>> result = ClassUtils.convertClassNamesToClasses(list);
|
||||
assertEquals(0, result.size());
|
||||
|
||||
|
@ -328,7 +328,7 @@ public class ClassUtilsTest {
|
|||
|
||||
@Test
|
||||
public void test_convertClassesToClassNames_List() {
|
||||
final List<Class<?>> list = new ArrayList<Class<?>>();
|
||||
final List<Class<?>> list = new ArrayList<>();
|
||||
List<String> result = ClassUtils.convertClassesToClassNames(list);
|
||||
assertEquals(0, result.size());
|
||||
|
||||
|
@ -1103,7 +1103,7 @@ public class ClassUtilsTest {
|
|||
@Test
|
||||
public void testShowJavaBug() throws Exception {
|
||||
// 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]);
|
||||
try {
|
||||
isEmptyMethod.invoke(set, new Object[0]);
|
||||
|
@ -1116,7 +1116,7 @@ public class ClassUtilsTest {
|
|||
@Test
|
||||
public void testGetPublicMethod() throws Exception {
|
||||
// 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]);
|
||||
assertTrue(Modifier.isPublic(isEmptyMethod.getDeclaringClass().getModifiers()));
|
||||
|
||||
|
|
|
@ -80,7 +80,7 @@ public class HashSetvBitSetTest {
|
|||
|
||||
@SuppressWarnings("boxing")
|
||||
private static int[] testHashSet(final int count) {
|
||||
final HashSet<Integer> toRemove = new HashSet<Integer>();
|
||||
final HashSet<Integer> toRemove = new HashSet<>();
|
||||
int found = 0;
|
||||
for (int i = 0; i < count; i++) {
|
||||
toRemove.add(found++);
|
||||
|
|
|
@ -349,7 +349,7 @@ public class LocaleUtilsTest {
|
|||
|
||||
final Locale[] jdkLocaleArray = Locale.getAvailableLocales();
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -160,7 +160,7 @@ public class ObjectUtilsTest {
|
|||
|
||||
@Test
|
||||
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());
|
||||
|
||||
final List<Object> list1 = new ArrayList<Object>(Arrays.asList("a"));
|
||||
|
|
|
@ -56,7 +56,7 @@ public class SerializationUtilsTest {
|
|||
public void setUp() {
|
||||
iString = "foo";
|
||||
iInteger = Integer.valueOf(7);
|
||||
iMap = new HashMap<Object, Object>();
|
||||
iMap = new HashMap<>();
|
||||
iMap.put("FOO", iString);
|
||||
iMap.put("BAR", iInteger);
|
||||
}
|
||||
|
|
|
@ -186,7 +186,7 @@ public class ValidateTest {
|
|||
//-----------------------------------------------------------------------
|
||||
@Test
|
||||
public void testNotEmptyCollection1() {
|
||||
final Collection<Integer> coll = new ArrayList<Integer>();
|
||||
final Collection<Integer> coll = new ArrayList<>();
|
||||
try {
|
||||
Validate.notEmpty((Collection<?>) null);
|
||||
fail("Expecting NullPointerException");
|
||||
|
@ -209,7 +209,7 @@ public class ValidateTest {
|
|||
//-----------------------------------------------------------------------
|
||||
@Test
|
||||
public void testNotEmptyCollection2() {
|
||||
final Collection<Integer> coll = new ArrayList<Integer>();
|
||||
final Collection<Integer> coll = new ArrayList<>();
|
||||
try {
|
||||
Validate.notEmpty((Collection<?>) null, "MSG");
|
||||
fail("Expecting NullPointerException");
|
||||
|
@ -233,7 +233,7 @@ public class ValidateTest {
|
|||
//-----------------------------------------------------------------------
|
||||
@Test
|
||||
public void testNotEmptyMap1() {
|
||||
final Map<String, Integer> map = new HashMap<String, Integer>();
|
||||
final Map<String, Integer> map = new HashMap<>();
|
||||
try {
|
||||
Validate.notEmpty((Map<?, ?>) null);
|
||||
fail("Expecting NullPointerException");
|
||||
|
@ -256,7 +256,7 @@ public class ValidateTest {
|
|||
//-----------------------------------------------------------------------
|
||||
@Test
|
||||
public void testNotEmptyMap2() {
|
||||
final Map<String, Integer> map = new HashMap<String, Integer>();
|
||||
final Map<String, Integer> map = new HashMap<>();
|
||||
try {
|
||||
Validate.notEmpty((Map<?, ?>) null, "MSG");
|
||||
fail("Expecting NullPointerException");
|
||||
|
@ -590,7 +590,7 @@ public class ValidateTest {
|
|||
//-----------------------------------------------------------------------
|
||||
@Test
|
||||
public void testNoNullElementsCollection1() {
|
||||
final List<String> coll = new ArrayList<String>();
|
||||
final List<String> coll = new ArrayList<>();
|
||||
coll.add("a");
|
||||
coll.add("b");
|
||||
Validate.noNullElements(coll);
|
||||
|
@ -616,7 +616,7 @@ public class ValidateTest {
|
|||
//-----------------------------------------------------------------------
|
||||
@Test
|
||||
public void testNoNullElementsCollection2() {
|
||||
final List<String> coll = new ArrayList<String>();
|
||||
final List<String> coll = new ArrayList<>();
|
||||
coll.add("a");
|
||||
coll.add("b");
|
||||
Validate.noNullElements(coll, "MSG");
|
||||
|
@ -703,7 +703,7 @@ public class ValidateTest {
|
|||
//-----------------------------------------------------------------------
|
||||
@Test
|
||||
public void testValidIndex_withMessage_collection() {
|
||||
final Collection<String> coll = new ArrayList<String>();
|
||||
final Collection<String> coll = new ArrayList<>();
|
||||
coll.add(null);
|
||||
coll.add(null);
|
||||
Validate.validIndex(coll, 0, "Broken: ");
|
||||
|
@ -728,7 +728,7 @@ public class ValidateTest {
|
|||
|
||||
@Test
|
||||
public void testValidIndex_collection() {
|
||||
final Collection<String> coll = new ArrayList<String>();
|
||||
final Collection<String> coll = new ArrayList<>();
|
||||
coll.add(null);
|
||||
coll.add(null);
|
||||
Validate.validIndex(coll, 0);
|
||||
|
|
|
@ -71,10 +71,10 @@ public class DefaultToStringStyleTest {
|
|||
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=<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=[]]", new ToStringBuilder(base).append("a", new ArrayList<Object>(), true).toString());
|
||||
assertEquals(baseStr + "[a=<size=0>]", new ToStringBuilder(base).append("a", new HashMap<Object, Object>(), false).toString());
|
||||
assertEquals(baseStr + "[a={}]", new ToStringBuilder(base).append("a", new HashMap<Object, Object>(), true).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<>(), true).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<>(), true).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());
|
||||
}
|
||||
|
|
|
@ -154,18 +154,18 @@ public class JsonToStringStyleTest {
|
|||
}
|
||||
|
||||
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");
|
||||
} catch (UnsupportedOperationException e) {
|
||||
}
|
||||
|
||||
assertEquals(
|
||||
"{\"a\":[]}",
|
||||
new ToStringBuilder(base).append("a", new ArrayList<Object>(),
|
||||
new ToStringBuilder(base).append("a", new ArrayList<>(),
|
||||
true).toString());
|
||||
|
||||
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");
|
||||
} catch (UnsupportedOperationException e) {
|
||||
}
|
||||
|
@ -173,7 +173,7 @@ public class JsonToStringStyleTest {
|
|||
assertEquals(
|
||||
"{\"a\":{}}",
|
||||
new ToStringBuilder(base).append("a",
|
||||
new HashMap<Object, Object>(), true).toString());
|
||||
new HashMap<>(), true).toString());
|
||||
|
||||
try {
|
||||
new ToStringBuilder(base).append("a", (Object) new String[0], false).toString();
|
||||
|
|
|
@ -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 + " 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=<size=0>" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).append("a", new ArrayList<Object>(), 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=<size=0>" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).append("a", new HashMap<Object, Object>(), 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=<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<>(), true).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<>(), 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={}" + SystemUtils.LINE_SEPARATOR + "]", new ToStringBuilder(base).append("a", (Object) new String[0], true).toString());
|
||||
}
|
||||
|
|
|
@ -239,7 +239,7 @@ public class MultilineRecursiveToStringStyleTest {
|
|||
|
||||
static class Account {
|
||||
Customer owner;
|
||||
List<Transaction> transactions = new ArrayList<Transaction>();
|
||||
List<Transaction> transactions = new ArrayList<>();
|
||||
|
||||
public double getBalance() {
|
||||
double balance = 0;
|
||||
|
|
|
@ -70,10 +70,10 @@ public class NoClassNameToStringStyleTest {
|
|||
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=<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=[]]", new ToStringBuilder(base).append("a", new ArrayList<Object>(), true).toString());
|
||||
assertEquals("[a=<size=0>]", new ToStringBuilder(base).append("a", new HashMap<Object, Object>(), false).toString());
|
||||
assertEquals("[a={}]", new ToStringBuilder(base).append("a", new HashMap<Object, Object>(), true).toString());
|
||||
assertEquals("[a=<size=0>]", new ToStringBuilder(base).append("a", new ArrayList<>(), false).toString());
|
||||
assertEquals("[a=[]]", new ToStringBuilder(base).append("a", new ArrayList<>(), true).toString());
|
||||
assertEquals("[a=<size=0>]", new ToStringBuilder(base).append("a", new HashMap<>(), false).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={}]", new ToStringBuilder(base).append("a", (Object) new String[0], true).toString());
|
||||
}
|
||||
|
|
|
@ -71,10 +71,10 @@ public class NoFieldNamesToStringStyleTest {
|
|||
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 + "[<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 + "[[]]", new ToStringBuilder(base).append("a", new ArrayList<Object>(), true).toString());
|
||||
assertEquals(baseStr + "[<size=0>]", new ToStringBuilder(base).append("a", new HashMap<Object, Object>(), false).toString());
|
||||
assertEquals(baseStr + "[{}]", new ToStringBuilder(base).append("a", new HashMap<Object, Object>(), true).toString());
|
||||
assertEquals(baseStr + "[<size=0>]", new ToStringBuilder(base).append("a", new ArrayList<>(), false).toString());
|
||||
assertEquals(baseStr + "[[]]", new ToStringBuilder(base).append("a", new ArrayList<>(), true).toString());
|
||||
assertEquals(baseStr + "[<size=0>]", new ToStringBuilder(base).append("a", new HashMap<>(), false).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 + "[{}]", new ToStringBuilder(base).append("a", (Object) new String[0], true).toString());
|
||||
}
|
||||
|
|
|
@ -70,10 +70,10 @@ public class RecursiveToStringStyleTest {
|
|||
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=<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=[]]", new ToStringBuilder(base).append("a", new ArrayList<Object>(), true).toString());
|
||||
assertEquals(baseStr + "[a=<size=0>]", new ToStringBuilder(base).append("a", new HashMap<Object, Object>(), false).toString());
|
||||
assertEquals(baseStr + "[a={}]", new ToStringBuilder(base).append("a", new HashMap<Object, Object>(), true).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<>(), true).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<>(), true).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());
|
||||
}
|
||||
|
|
|
@ -108,7 +108,7 @@ public class ReflectionToStringBuilderConcurrencyTest {
|
|||
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(producer);
|
||||
final List<Future<Integer>> futures = threadPool.invokeAll(tasks);
|
||||
|
|
|
@ -72,7 +72,7 @@ public class ReflectionToStringBuilderExcludeTest {
|
|||
|
||||
@Test
|
||||
public void test_toStringExcludeCollection() {
|
||||
final List<String> excludeList = new ArrayList<String>();
|
||||
final List<String> excludeList = new ArrayList<>();
|
||||
excludeList.add(SECRET_FIELD);
|
||||
final String toString = ReflectionToStringBuilder.toStringExclude(new TestFixture(), excludeList);
|
||||
this.validateSecretFieldAbsent(toString);
|
||||
|
@ -80,7 +80,7 @@ public class ReflectionToStringBuilderExcludeTest {
|
|||
|
||||
@Test
|
||||
public void test_toStringExcludeCollectionWithNull() {
|
||||
final List<String> excludeList = new ArrayList<String>();
|
||||
final List<String> excludeList = new ArrayList<>();
|
||||
excludeList.add(null);
|
||||
final String toString = ReflectionToStringBuilder.toStringExclude(new TestFixture(), excludeList);
|
||||
this.validateSecretFieldPresent(toString);
|
||||
|
@ -88,7 +88,7 @@ public class ReflectionToStringBuilderExcludeTest {
|
|||
|
||||
@Test
|
||||
public void test_toStringExcludeCollectionWithNulls() {
|
||||
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);
|
||||
|
|
|
@ -37,7 +37,7 @@ import org.junit.Test;
|
|||
public class ReflectionToStringBuilderMutateInspectConcurrencyTest {
|
||||
|
||||
class TestFixture {
|
||||
final private LinkedList<Integer> listField = new LinkedList<Integer>();
|
||||
final private LinkedList<Integer> listField = new LinkedList<>();
|
||||
final private Random random = new Random();
|
||||
private final int N = 100;
|
||||
|
||||
|
|
|
@ -71,10 +71,10 @@ public class ShortPrefixToStringStyleTest {
|
|||
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=<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=[]]", new ToStringBuilder(base).append("a", new ArrayList<Object>(), true).toString());
|
||||
assertEquals(baseStr + "[a=<size=0>]", new ToStringBuilder(base).append("a", new HashMap<Object, Object>(), false).toString());
|
||||
assertEquals(baseStr + "[a={}]", new ToStringBuilder(base).append("a", new HashMap<Object, Object>(), true).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<>(), true).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<>(), true).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());
|
||||
}
|
||||
|
|
|
@ -70,10 +70,10 @@ public class SimpleToStringStyleTest {
|
|||
assertEquals("3", new ToStringBuilder(base).append("a", i3).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("<size=0>", new ToStringBuilder(base).append("a", new ArrayList<Object>(), false).toString());
|
||||
assertEquals("[]", new ToStringBuilder(base).append("a", new ArrayList<Object>(), true).toString());
|
||||
assertEquals("<size=0>", new ToStringBuilder(base).append("a", new HashMap<Object, Object>(), false).toString());
|
||||
assertEquals("{}", new ToStringBuilder(base).append("a", new HashMap<Object, Object>(), true).toString());
|
||||
assertEquals("<size=0>", new ToStringBuilder(base).append("a", new ArrayList<>(), false).toString());
|
||||
assertEquals("[]", new ToStringBuilder(base).append("a", new ArrayList<>(), true).toString());
|
||||
assertEquals("<size=0>", new ToStringBuilder(base).append("a", new HashMap<>(), false).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("{}", new ToStringBuilder(base).append("a", (Object) new String[0], true).toString());
|
||||
}
|
||||
|
|
|
@ -86,10 +86,10 @@ public class StandardToStringStyleTest {
|
|||
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=%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=[]]", new ToStringBuilder(base).append("a", new ArrayList<Object>(), true).toString());
|
||||
assertEquals(baseStr + "[a=%SIZE=0%]", new ToStringBuilder(base).append("a", new HashMap<Object, Object>(), false).toString());
|
||||
assertEquals(baseStr + "[a={}]", new ToStringBuilder(base).append("a", new HashMap<Object, Object>(), true).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<>(), true).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<>(), true).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());
|
||||
}
|
||||
|
|
|
@ -315,7 +315,7 @@ public class ToStringBuilderTest {
|
|||
// 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("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 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);
|
||||
|
@ -624,10 +624,10 @@ public class ToStringBuilderTest {
|
|||
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=<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=[]]", new ToStringBuilder(base).append("a", new ArrayList<Object>(), true).toString());
|
||||
assertEquals(baseStr + "[a=<size=0>]", new ToStringBuilder(base).append("a", new HashMap<Object, Object>(), false).toString());
|
||||
assertEquals(baseStr + "[a={}]", new ToStringBuilder(base).append("a", new HashMap<Object, Object>(), true).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<>(), true).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<>(), true).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());
|
||||
}
|
||||
|
@ -642,10 +642,10 @@ public class ToStringBuilderTest {
|
|||
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=<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=[]]", new ToStringBuilder(base).append("a", new ArrayList<Object>(), true).build());
|
||||
assertEquals(baseStr + "[a=<size=0>]", new ToStringBuilder(base).append("a", new HashMap<Object, Object>(), false).build());
|
||||
assertEquals(baseStr + "[a={}]", new ToStringBuilder(base).append("a", new HashMap<Object, Object>(), true).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<>(), true).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<>(), true).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());
|
||||
}
|
||||
|
|
|
@ -60,7 +60,7 @@ public class ToStringStyleConcurrencyTest {
|
|||
private static final int REPEAT = 100;
|
||||
|
||||
static {
|
||||
LIST = new ArrayList<Integer>(LIST_SIZE);
|
||||
LIST = new ArrayList<>(LIST_SIZE);
|
||||
for (int i = 0; i < LIST_SIZE; i++) {
|
||||
LIST.add(Integer.valueOf(i));
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ public class ToStringStyleConcurrencyTest {
|
|||
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);
|
||||
final List<Future<Integer>> futures = threadPool.invokeAll(tasks);
|
||||
|
|
|
@ -222,7 +222,7 @@ public class BackgroundInitializerTest {
|
|||
final CountDownLatch latch1 = new CountDownLatch(1);
|
||||
init.shouldSleep = true;
|
||||
init.start();
|
||||
final AtomicReference<InterruptedException> iex = new AtomicReference<InterruptedException>();
|
||||
final AtomicReference<InterruptedException> iex = new AtomicReference<>();
|
||||
final Thread getThread = new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
|
|
@ -38,7 +38,7 @@ public class CallableBackgroundInitializerTest {
|
|||
*/
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
public void testInitNullCallable() {
|
||||
new CallableBackgroundInitializer<Object>(null);
|
||||
new CallableBackgroundInitializer<>(null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -48,7 +48,7 @@ public class CallableBackgroundInitializerTest {
|
|||
@Test
|
||||
public void testInitExecutor() throws InterruptedException {
|
||||
final ExecutorService exec = Executors.newSingleThreadExecutor();
|
||||
final CallableBackgroundInitializer<Integer> init = new CallableBackgroundInitializer<Integer>(
|
||||
final CallableBackgroundInitializer<Integer> init = new CallableBackgroundInitializer<>(
|
||||
new TestCallable(), exec);
|
||||
assertEquals("Executor not set", exec, init.getExternalExecutor());
|
||||
exec.shutdown();
|
||||
|
@ -79,7 +79,7 @@ public class CallableBackgroundInitializerTest {
|
|||
@Test
|
||||
public void testInitialize() throws Exception {
|
||||
final TestCallable call = new TestCallable();
|
||||
final CallableBackgroundInitializer<Integer> init = new CallableBackgroundInitializer<Integer>(
|
||||
final CallableBackgroundInitializer<Integer> init = new CallableBackgroundInitializer<>(
|
||||
call);
|
||||
assertEquals("Wrong result", RESULT, init.initialize());
|
||||
assertEquals("Wrong number of invocations", 1, call.callCount);
|
||||
|
|
|
@ -434,7 +434,7 @@ public class ConcurrentUtilsTest {
|
|||
public void testPutIfAbsentKeyPresent() {
|
||||
final String key = "testKey";
|
||||
final Integer value = 42;
|
||||
final ConcurrentMap<String, Integer> map = new ConcurrentHashMap<String, Integer>();
|
||||
final ConcurrentMap<String, Integer> map = new ConcurrentHashMap<>();
|
||||
map.put(key, value);
|
||||
assertEquals("Wrong result", value,
|
||||
ConcurrentUtils.putIfAbsent(map, key, 0));
|
||||
|
@ -448,7 +448,7 @@ public class ConcurrentUtilsTest {
|
|||
public void testPutIfAbsentKeyNotPresent() {
|
||||
final String key = "testKey";
|
||||
final Integer value = 42;
|
||||
final ConcurrentMap<String, Integer> map = new ConcurrentHashMap<String, Integer>();
|
||||
final ConcurrentMap<String, Integer> map = new ConcurrentHashMap<>();
|
||||
assertEquals("Wrong result", value,
|
||||
ConcurrentUtils.putIfAbsent(map, key, value));
|
||||
assertEquals("Wrong value in map", value, map.get(key));
|
||||
|
@ -477,7 +477,7 @@ public class ConcurrentUtilsTest {
|
|||
EasyMock.replay(init);
|
||||
final String key = "testKey";
|
||||
final Integer value = 42;
|
||||
final ConcurrentMap<String, Integer> map = new ConcurrentHashMap<String, Integer>();
|
||||
final ConcurrentMap<String, Integer> map = new ConcurrentHashMap<>();
|
||||
map.put(key, value);
|
||||
assertEquals("Wrong result", value,
|
||||
ConcurrentUtils.createIfAbsent(map, key, init));
|
||||
|
@ -500,7 +500,7 @@ public class ConcurrentUtilsTest {
|
|||
final Integer value = 42;
|
||||
EasyMock.expect(init.get()).andReturn(value);
|
||||
EasyMock.replay(init);
|
||||
final ConcurrentMap<String, Integer> map = new ConcurrentHashMap<String, Integer>();
|
||||
final ConcurrentMap<String, Integer> map = new ConcurrentHashMap<>();
|
||||
assertEquals("Wrong result", value,
|
||||
ConcurrentUtils.createIfAbsent(map, key, init));
|
||||
assertEquals("Wrong value in map", value, map.get(key));
|
||||
|
@ -531,7 +531,7 @@ public class ConcurrentUtilsTest {
|
|||
*/
|
||||
@Test
|
||||
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 Integer value = 42;
|
||||
map.put(key, value);
|
||||
|
@ -547,10 +547,10 @@ public class ConcurrentUtilsTest {
|
|||
public void testCreateIfAbsentUncheckedSuccess() {
|
||||
final String key = "testKey";
|
||||
final Integer value = 42;
|
||||
final ConcurrentMap<String, Integer> map = new ConcurrentHashMap<String, Integer>();
|
||||
final ConcurrentMap<String, Integer> map = new ConcurrentHashMap<>();
|
||||
assertEquals("Wrong result", value,
|
||||
ConcurrentUtils.createIfAbsentUnchecked(map, key,
|
||||
new ConstantInitializer<Integer>(value)));
|
||||
new ConstantInitializer<>(value)));
|
||||
assertEquals("Wrong value in map", value, map.get(key));
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ public class ConstantInitializerTest {
|
|||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
init = new ConstantInitializer<Integer>(VALUE);
|
||||
init = new ConstantInitializer<>(VALUE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -80,11 +80,11 @@ public class ConstantInitializerTest {
|
|||
@Test
|
||||
public void testEqualsTrue() {
|
||||
checkEquals(init, true);
|
||||
ConstantInitializer<Integer> init2 = new ConstantInitializer<Integer>(
|
||||
ConstantInitializer<Integer> init2 = new ConstantInitializer<>(
|
||||
Integer.valueOf(VALUE.intValue()));
|
||||
checkEquals(init2, true);
|
||||
init = new ConstantInitializer<Integer>(null);
|
||||
init2 = new ConstantInitializer<Integer>(null);
|
||||
init = new ConstantInitializer<>(null);
|
||||
init2 = new ConstantInitializer<>(null);
|
||||
checkEquals(init2, true);
|
||||
}
|
||||
|
||||
|
@ -93,10 +93,10 @@ public class ConstantInitializerTest {
|
|||
*/
|
||||
@Test
|
||||
public void testEqualsFalse() {
|
||||
ConstantInitializer<Integer> init2 = new ConstantInitializer<Integer>(
|
||||
ConstantInitializer<Integer> init2 = new ConstantInitializer<>(
|
||||
null);
|
||||
checkEquals(init2, false);
|
||||
init2 = new ConstantInitializer<Integer>(VALUE + 1);
|
||||
init2 = new ConstantInitializer<>(VALUE + 1);
|
||||
checkEquals(init2, false);
|
||||
}
|
||||
|
||||
|
@ -107,7 +107,7 @@ public class ConstantInitializerTest {
|
|||
public void testEqualsWithOtherObjects() {
|
||||
checkEquals(null, false);
|
||||
checkEquals(this, false);
|
||||
checkEquals(new ConstantInitializer<String>("Test"), false);
|
||||
checkEquals(new ConstantInitializer<>("Test"), false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -127,7 +127,7 @@ public class ConstantInitializerTest {
|
|||
*/
|
||||
@Test
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -376,7 +376,7 @@ public class EventCountCircuitBreakerTest {
|
|||
*/
|
||||
public ChangeListener(Object source) {
|
||||
expectedSource = source;
|
||||
changedValues = new ArrayList<Boolean>();
|
||||
changedValues = new ArrayList<>();
|
||||
}
|
||||
|
||||
public void propertyChange(PropertyChangeEvent evt) {
|
||||
|
|
|
@ -76,7 +76,7 @@ public class EventListenerSupportTest {
|
|||
@Test
|
||||
public void testEventDispatchOrder() throws PropertyVetoException {
|
||||
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 listener2 = createListener(calledListeners);
|
||||
|
|
|
@ -200,7 +200,7 @@ public class EventUtilsTest
|
|||
|
||||
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)
|
||||
{
|
||||
|
|
|
@ -32,15 +32,15 @@ public class MutableObjectTest {
|
|||
assertEquals(null, new MutableObject<String>().getValue());
|
||||
|
||||
final Integer i = Integer.valueOf(6);
|
||||
assertSame(i, new MutableObject<Integer>(i).getValue());
|
||||
assertSame("HI", new MutableObject<String>("HI").getValue());
|
||||
assertSame(null, new MutableObject<Object>(null).getValue());
|
||||
assertSame(i, new MutableObject<>(i).getValue());
|
||||
assertSame("HI", new MutableObject<>("HI").getValue());
|
||||
assertSame(null, new MutableObject<>(null).getValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetSet() {
|
||||
final MutableObject<String> mutNum = new MutableObject<String>();
|
||||
assertEquals(null, new MutableObject<Object>().getValue());
|
||||
final MutableObject<String> mutNum = new MutableObject<>();
|
||||
assertEquals(null, new MutableObject<>().getValue());
|
||||
|
||||
mutNum.setValue("HELLO");
|
||||
assertSame("HELLO", mutNum.getValue());
|
||||
|
@ -51,10 +51,10 @@ public class MutableObjectTest {
|
|||
|
||||
@Test
|
||||
public void testEquals() {
|
||||
final MutableObject<String> mutNumA = new MutableObject<String>("ALPHA");
|
||||
final MutableObject<String> mutNumB = new MutableObject<String>("ALPHA");
|
||||
final MutableObject<String> mutNumC = new MutableObject<String>("BETA");
|
||||
final MutableObject<String> mutNumD = new MutableObject<String>(null);
|
||||
final MutableObject<String> mutNumA = new MutableObject<>("ALPHA");
|
||||
final MutableObject<String> mutNumB = new MutableObject<>("ALPHA");
|
||||
final MutableObject<String> mutNumC = new MutableObject<>("BETA");
|
||||
final MutableObject<String> mutNumD = new MutableObject<>(null);
|
||||
|
||||
assertTrue(mutNumA.equals(mutNumA));
|
||||
assertTrue(mutNumA.equals(mutNumB));
|
||||
|
@ -73,10 +73,10 @@ public class MutableObjectTest {
|
|||
|
||||
@Test
|
||||
public void testHashCode() {
|
||||
final MutableObject<String> mutNumA = new MutableObject<String>("ALPHA");
|
||||
final MutableObject<String> mutNumB = new MutableObject<String>("ALPHA");
|
||||
final MutableObject<String> mutNumC = new MutableObject<String>("BETA");
|
||||
final MutableObject<String> mutNumD = new MutableObject<String>(null);
|
||||
final MutableObject<String> mutNumA = new MutableObject<>("ALPHA");
|
||||
final MutableObject<String> mutNumB = new MutableObject<>("ALPHA");
|
||||
final MutableObject<String> mutNumC = new MutableObject<>("BETA");
|
||||
final MutableObject<String> mutNumD = new MutableObject<>(null);
|
||||
|
||||
assertTrue(mutNumA.hashCode() == mutNumA.hashCode());
|
||||
assertTrue(mutNumA.hashCode() == mutNumB.hashCode());
|
||||
|
@ -88,9 +88,9 @@ public class MutableObjectTest {
|
|||
|
||||
@Test
|
||||
public void testToString() {
|
||||
assertEquals("HI", new MutableObject<String>("HI").toString());
|
||||
assertEquals("10.0", new MutableObject<Double>(Double.valueOf(10)).toString());
|
||||
assertEquals("null", new MutableObject<Object>(null).toString());
|
||||
assertEquals("HI", new MutableObject<>("HI").toString());
|
||||
assertEquals("10.0", new MutableObject<>(Double.valueOf(10)).toString());
|
||||
assertEquals("null", new MutableObject<>(null).toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -116,7 +116,7 @@ public class ConstructorUtilsTest {
|
|||
private final Map<Class<?>, Class<?>[]> classCache;
|
||||
|
||||
public ConstructorUtilsTest() {
|
||||
classCache = new HashMap<Class<?>, Class<?>[]>();
|
||||
classCache = new HashMap<>();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -160,7 +160,7 @@ public class FieldUtilsTest {
|
|||
final List<Field> fieldsNumber = Arrays.asList(Number.class.getDeclaredFields());
|
||||
assertEquals(fieldsNumber, FieldUtils.getAllFieldsList(Number.class));
|
||||
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);
|
||||
assertEquals(allFieldsInteger, FieldUtils.getAllFieldsList(Integer.class));
|
||||
assertEquals(5, FieldUtils.getAllFieldsList(PublicChild.class).size());
|
||||
|
|
|
@ -249,7 +249,7 @@ public class MethodUtilsTest {
|
|||
}
|
||||
|
||||
private TestBean testBean;
|
||||
private final Map<Class<?>, Class<?>[]> classCache = new HashMap<Class<?>, Class<?>[]>();
|
||||
private final Map<Class<?>, Class<?>[]> classCache = new HashMap<>();
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
|
|
|
@ -525,7 +525,7 @@ public class TypeUtilsTest<B> {
|
|||
@Test
|
||||
public void testTypesSatisfyVariables() throws SecurityException, NoSuchFieldException,
|
||||
NoSuchMethodException {
|
||||
final Map<TypeVariable<?>, Type> typeVarAssigns = new HashMap<TypeVariable<?>, Type>();
|
||||
final Map<TypeVariable<?>, Type> typeVarAssigns = new HashMap<>();
|
||||
final Integer max = TypeUtilsTest.<Integer> stub();
|
||||
typeVarAssigns.put(getClass().getMethod("stub").getTypeParameters()[0], Integer.class);
|
||||
Assert.assertTrue(TypeUtils.typesSatisfyVariables(typeVarAssigns));
|
||||
|
|
|
@ -45,7 +45,7 @@ import org.apache.commons.lang3.SystemUtils;
|
|||
*/
|
||||
public class ExtendedMessageFormatTest {
|
||||
|
||||
private final Map<String, FormatFactory> registry = new HashMap<String, FormatFactory>();
|
||||
private final Map<String, FormatFactory> registry = new HashMap<>();
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
|
@ -116,7 +116,7 @@ public class ExtendedMessageFormatTest {
|
|||
final String extendedPattern = "Name: {0,upper} ";
|
||||
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.retainAll(Arrays.asList(NumberFormat.getAvailableLocales()));
|
||||
testLocales.add(null);
|
||||
|
|
|
@ -95,7 +95,7 @@ public class StrLookupTest {
|
|||
|
||||
@Test
|
||||
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("number", Integer.valueOf(2));
|
||||
assertEquals("value", StrLookup.mapLookup(map).lookup("key"));
|
||||
|
|
|
@ -42,7 +42,7 @@ public class StrSubstitutorTest {
|
|||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
values = new HashMap<String, String>();
|
||||
values = new HashMap<>();
|
||||
values.put("animal", "quick brown fox");
|
||||
values.put("target", "lazy dog");
|
||||
}
|
||||
|
@ -235,7 +235,7 @@ public class StrSubstitutorTest {
|
|||
*/
|
||||
@Test
|
||||
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("target", "${pet}");
|
||||
map.put("pet", "${petCharacteristic} dog");
|
||||
|
@ -364,7 +364,7 @@ public class StrSubstitutorTest {
|
|||
|
||||
@Test
|
||||
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("target", "dog");
|
||||
|
||||
|
@ -402,7 +402,7 @@ public class StrSubstitutorTest {
|
|||
@Test
|
||||
public void testResolveVariable() {
|
||||
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");
|
||||
final StrSubstitutor sub = new StrSubstitutor(map) {
|
||||
@Override
|
||||
|
@ -433,7 +433,7 @@ public class StrSubstitutorTest {
|
|||
*/
|
||||
@Test
|
||||
public void testConstructorMapPrefixSuffix() {
|
||||
final Map<String, String> map = new HashMap<String, String>();
|
||||
final Map<String, String> map = new HashMap<>();
|
||||
map.put("name", "commons");
|
||||
final StrSubstitutor sub = new StrSubstitutor(map, "<", ">");
|
||||
assertEquals("Hi < commons", sub.replace("Hi $< <name>"));
|
||||
|
@ -444,7 +444,7 @@ public class StrSubstitutorTest {
|
|||
*/
|
||||
@Test
|
||||
public void testConstructorMapFull() {
|
||||
final Map<String, String> map = new HashMap<String, String>();
|
||||
final Map<String, String> map = new HashMap<>();
|
||||
map.put("name", "commons");
|
||||
StrSubstitutor sub = new StrSubstitutor(map, "<", ">", '!');
|
||||
assertEquals("Hi < commons", sub.replace("Hi !< <name>"));
|
||||
|
@ -556,7 +556,7 @@ public class StrSubstitutorTest {
|
|||
*/
|
||||
@Test
|
||||
public void testStaticReplace() {
|
||||
final Map<String, String> map = new HashMap<String, String>();
|
||||
final Map<String, String> map = new HashMap<>();
|
||||
map.put("name", "commons");
|
||||
assertEquals("Hi commons!", StrSubstitutor.replace("Hi ${name}!", map));
|
||||
}
|
||||
|
@ -566,7 +566,7 @@ public class StrSubstitutorTest {
|
|||
*/
|
||||
@Test
|
||||
public void testStaticReplacePrefixSuffix() {
|
||||
final Map<String, String> map = new HashMap<String, String>();
|
||||
final Map<String, String> map = new HashMap<>();
|
||||
map.put("name", "commons");
|
||||
assertEquals("Hi commons!", StrSubstitutor.replace("Hi <name>!", map, "<", ">"));
|
||||
}
|
||||
|
@ -615,7 +615,7 @@ public class StrSubstitutorTest {
|
|||
|
||||
@Test
|
||||
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(" there ", "XXX");
|
||||
map.put("name", "commons");
|
||||
|
@ -626,7 +626,7 @@ public class StrSubstitutorTest {
|
|||
@Test
|
||||
public void testSubstitutePreserveEscape() {
|
||||
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");
|
||||
|
||||
StrSubstitutor sub = new StrSubstitutor(map, "${", "}", '$');
|
||||
|
@ -678,7 +678,7 @@ public class StrSubstitutorTest {
|
|||
}
|
||||
|
||||
// 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));
|
||||
|
||||
// replace in StringBuffer
|
||||
|
|
|
@ -37,8 +37,8 @@ public class EntityArraysTest {
|
|||
// LANG-659 - check arrays for duplicate entries
|
||||
@Test
|
||||
public void testHTML40_EXTENDED_ESCAPE(){
|
||||
final Set<String> col0 = new HashSet<String>();
|
||||
final Set<String> col1 = new HashSet<String>();
|
||||
final Set<String> col0 = new HashSet<>();
|
||||
final Set<String> col1 = new HashSet<>();
|
||||
final String [][] sa = EntityArrays.HTML40_EXTENDED_ESCAPE();
|
||||
for(int i =0; i <sa.length; i++){
|
||||
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
|
||||
@Test
|
||||
public void testISO8859_1_ESCAPE(){
|
||||
final Set<String> col0 = new HashSet<String>();
|
||||
final Set<String> col1 = new HashSet<String>();
|
||||
final Set<String> col0 = new HashSet<>();
|
||||
final Set<String> col1 = new HashSet<>();
|
||||
final String [][] sa = EntityArrays.ISO8859_1_ESCAPE();
|
||||
boolean success = true;
|
||||
for(int i =0; i <sa.length; i++){
|
||||
|
|
|
@ -102,7 +102,7 @@ public class FastDateParserTest {
|
|||
getInstance(MDY_SLASH, REYKJAVIK, SWEDEN)
|
||||
};
|
||||
|
||||
final Map<DateParser,Integer> map= new HashMap<DateParser,Integer>();
|
||||
final Map<DateParser,Integer> map= new HashMap<>();
|
||||
int i= 0;
|
||||
for(final DateParser parser:parsers) {
|
||||
map.put(parser, Integer.valueOf(i++));
|
||||
|
|
|
@ -37,7 +37,7 @@ public class FastDatePrinterTimeZonesTest {
|
|||
@Parameterized.Parameters
|
||||
public static Collection<TimeZone> data() {
|
||||
final String[] zoneIds = TimeZone.getAvailableIDs();
|
||||
List<TimeZone> timeZones = new ArrayList<TimeZone>();
|
||||
List<TimeZone> timeZones = new ArrayList<>();
|
||||
for (String zoneId : zoneIds) {
|
||||
timeZones.add(TimeZone.getTimeZone(zoneId));
|
||||
}
|
||||
|
|
|
@ -35,12 +35,12 @@ public class ImmutablePairTest {
|
|||
|
||||
@Test
|
||||
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.getLeft().intValue());
|
||||
assertEquals("foo", pair.right);
|
||||
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.getLeft());
|
||||
assertEquals("bar", pair2.right);
|
||||
|
|
|
@ -35,14 +35,14 @@ public class ImmutableTripleTest {
|
|||
|
||||
@Test
|
||||
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.getLeft().intValue());
|
||||
assertEquals("foo", triple.middle);
|
||||
assertEquals("foo", triple.getMiddle());
|
||||
assertEquals(Boolean.TRUE, triple.right);
|
||||
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.getLeft());
|
||||
assertEquals("bar", triple2.middle);
|
||||
|
|
|
@ -35,24 +35,24 @@ public class MutablePairTest {
|
|||
|
||||
@Test
|
||||
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("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());
|
||||
assertEquals("bar", pair2.getRight());
|
||||
}
|
||||
|
||||
@Test
|
||||
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.getRight());
|
||||
}
|
||||
|
||||
@Test
|
||||
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.setRight("bar");
|
||||
assertEquals(42, pair.getLeft().intValue());
|
||||
|
|
|
@ -35,11 +35,11 @@ public class MutableTripleTest {
|
|||
|
||||
@Test
|
||||
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("foo", triple.getMiddle());
|
||||
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());
|
||||
assertEquals("bar", triple2.getMiddle());
|
||||
assertEquals("hello", triple2.getRight());
|
||||
|
@ -47,7 +47,7 @@ public class MutableTripleTest {
|
|||
|
||||
@Test
|
||||
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.getMiddle());
|
||||
assertNull(triple.getRight());
|
||||
|
@ -55,7 +55,7 @@ public class MutableTripleTest {
|
|||
|
||||
@Test
|
||||
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.setMiddle("bar");
|
||||
triple.setRight(Boolean.FALSE);
|
||||
|
|
|
@ -51,7 +51,7 @@ public class PairTest {
|
|||
final Pair<Integer, String> pair2 = MutablePair.of(0, "foo");
|
||||
assertEquals(pair, pair2);
|
||||
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);
|
||||
assertTrue(set.contains(pair2));
|
||||
|
||||
|
@ -63,7 +63,7 @@ public class PairTest {
|
|||
@Test
|
||||
public void testMapEntry() throws Exception {
|
||||
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");
|
||||
final Entry<Integer, String> entry = map.entrySet().iterator().next();
|
||||
assertEquals(pair, entry);
|
||||
|
|
|
@ -50,7 +50,7 @@ public class TripleTest {
|
|||
final Triple<Integer, String, Boolean> triple2 = MutableTriple.of(0, "foo", Boolean.TRUE);
|
||||
assertEquals(triple, triple2);
|
||||
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);
|
||||
assertTrue(set.contains(triple2));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue