Remove redundant type arguments.
This commit is contained in:
parent
f4a63c4c72
commit
eef8f1a0aa
|
@ -40,14 +40,14 @@ public class BagUtils {
|
||||||
* An empty unmodifiable bag.
|
* An empty unmodifiable bag.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("rawtypes") // OK, empty bag is compatible with any type
|
@SuppressWarnings("rawtypes") // OK, empty bag is compatible with any type
|
||||||
public static final Bag EMPTY_BAG = UnmodifiableBag.unmodifiableBag(new HashBag<Object>());
|
public static final Bag EMPTY_BAG = UnmodifiableBag.unmodifiableBag(new HashBag<>());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An empty unmodifiable sorted bag.
|
* An empty unmodifiable sorted bag.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("rawtypes") // OK, empty bag is compatible with any type
|
@SuppressWarnings("rawtypes") // OK, empty bag is compatible with any type
|
||||||
public static final Bag EMPTY_SORTED_BAG =
|
public static final Bag EMPTY_SORTED_BAG =
|
||||||
UnmodifiableSortedBag.unmodifiableSortedBag(new TreeBag<Object>());
|
UnmodifiableSortedBag.unmodifiableSortedBag(new TreeBag<>());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiation of BagUtils is not intended or required.
|
* Instantiation of BagUtils is not intended or required.
|
||||||
|
|
|
@ -140,11 +140,11 @@ public class CollectionUtils {
|
||||||
*/
|
*/
|
||||||
public SetOperationCardinalityHelper(final Iterable<? extends O> a, final Iterable<? extends O> b) {
|
public SetOperationCardinalityHelper(final Iterable<? extends O> a, final Iterable<? extends O> b) {
|
||||||
super(a, b);
|
super(a, b);
|
||||||
elements = new HashSet<O>();
|
elements = new HashSet<>();
|
||||||
addAll(elements, a);
|
addAll(elements, a);
|
||||||
addAll(elements, b);
|
addAll(elements, b);
|
||||||
// the resulting list must contain at least each unique element, but may grow
|
// the resulting list must contain at least each unique element, but may grow
|
||||||
newList = new ArrayList<O>(elements.size());
|
newList = new ArrayList<>(elements.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -228,7 +228,7 @@ public class CollectionUtils {
|
||||||
* @see Collection#addAll
|
* @see Collection#addAll
|
||||||
*/
|
*/
|
||||||
public static <O> Collection<O> union(final Iterable<? extends O> a, final Iterable<? extends O> b) {
|
public static <O> Collection<O> union(final Iterable<? extends O> a, final Iterable<? extends O> b) {
|
||||||
final SetOperationCardinalityHelper<O> helper = new SetOperationCardinalityHelper<O>(a, b);
|
final SetOperationCardinalityHelper<O> helper = new SetOperationCardinalityHelper<>(a, b);
|
||||||
for (final O obj : helper) {
|
for (final O obj : helper) {
|
||||||
helper.setCardinality(obj, helper.max(obj));
|
helper.setCardinality(obj, helper.max(obj));
|
||||||
}
|
}
|
||||||
|
@ -252,7 +252,7 @@ public class CollectionUtils {
|
||||||
* @see #containsAny
|
* @see #containsAny
|
||||||
*/
|
*/
|
||||||
public static <O> Collection<O> intersection(final Iterable<? extends O> a, final Iterable<? extends O> b) {
|
public static <O> Collection<O> intersection(final Iterable<? extends O> a, final Iterable<? extends O> b) {
|
||||||
final SetOperationCardinalityHelper<O> helper = new SetOperationCardinalityHelper<O>(a, b);
|
final SetOperationCardinalityHelper<O> helper = new SetOperationCardinalityHelper<>(a, b);
|
||||||
for (final O obj : helper) {
|
for (final O obj : helper) {
|
||||||
helper.setCardinality(obj, helper.min(obj));
|
helper.setCardinality(obj, helper.min(obj));
|
||||||
}
|
}
|
||||||
|
@ -280,7 +280,7 @@ public class CollectionUtils {
|
||||||
* @return the symmetric difference of the two collections
|
* @return the symmetric difference of the two collections
|
||||||
*/
|
*/
|
||||||
public static <O> Collection<O> disjunction(final Iterable<? extends O> a, final Iterable<? extends O> b) {
|
public static <O> Collection<O> disjunction(final Iterable<? extends O> a, final Iterable<? extends O> b) {
|
||||||
final SetOperationCardinalityHelper<O> helper = new SetOperationCardinalityHelper<O>(a, b);
|
final SetOperationCardinalityHelper<O> helper = new SetOperationCardinalityHelper<>(a, b);
|
||||||
for (final O obj : helper) {
|
for (final O obj : helper) {
|
||||||
helper.setCardinality(obj, helper.max(obj) - helper.min(obj));
|
helper.setCardinality(obj, helper.max(obj) - helper.min(obj));
|
||||||
}
|
}
|
||||||
|
@ -329,8 +329,8 @@ public class CollectionUtils {
|
||||||
public static <O> Collection<O> subtract(final Iterable<? extends O> a,
|
public static <O> Collection<O> subtract(final Iterable<? extends O> a,
|
||||||
final Iterable<? extends O> b,
|
final Iterable<? extends O> b,
|
||||||
final Predicate<O> p) {
|
final Predicate<O> p) {
|
||||||
final ArrayList<O> list = new ArrayList<O>();
|
final ArrayList<O> list = new ArrayList<>();
|
||||||
final HashBag<O> bag = new HashBag<O>();
|
final HashBag<O> bag = new HashBag<>();
|
||||||
for (final O element : b) {
|
for (final O element : b) {
|
||||||
if (p.evaluate(element)) {
|
if (p.evaluate(element)) {
|
||||||
bag.add(element);
|
bag.add(element);
|
||||||
|
@ -371,7 +371,7 @@ public class CollectionUtils {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
final Iterator<?> it = coll1.iterator();
|
final Iterator<?> it = coll1.iterator();
|
||||||
final Set<Object> elementsAlreadySeen = new HashSet<Object>();
|
final Set<Object> elementsAlreadySeen = new HashSet<>();
|
||||||
for (final Object nextElement : coll2) {
|
for (final Object nextElement : coll2) {
|
||||||
if (elementsAlreadySeen.contains(nextElement)) {
|
if (elementsAlreadySeen.contains(nextElement)) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -437,7 +437,7 @@ public class CollectionUtils {
|
||||||
* @return the populated cardinality map
|
* @return the populated cardinality map
|
||||||
*/
|
*/
|
||||||
public static <O> Map<O, Integer> getCardinalityMap(final Iterable<? extends O> coll) {
|
public static <O> Map<O, Integer> getCardinalityMap(final Iterable<? extends O> coll) {
|
||||||
final Map<O, Integer> count = new HashMap<O, Integer>();
|
final Map<O, Integer> count = new HashMap<>();
|
||||||
for (final O obj : coll) {
|
for (final O obj : coll) {
|
||||||
final Integer c = count.get(obj);
|
final Integer c = count.get(obj);
|
||||||
if (c == null) {
|
if (c == null) {
|
||||||
|
@ -462,7 +462,7 @@ public class CollectionUtils {
|
||||||
* @see Collection#containsAll
|
* @see Collection#containsAll
|
||||||
*/
|
*/
|
||||||
public static boolean isSubCollection(final Collection<?> a, final Collection<?> b) {
|
public static boolean isSubCollection(final Collection<?> a, final Collection<?> b) {
|
||||||
final CardinalityHelper<Object> helper = new CardinalityHelper<Object>(a, b);
|
final CardinalityHelper<Object> helper = new CardinalityHelper<>(a, b);
|
||||||
for (final Object obj : a) {
|
for (final Object obj : a) {
|
||||||
if (helper.freqA(obj) > helper.freqB(obj)) {
|
if (helper.freqA(obj) > helper.freqB(obj)) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -512,7 +512,7 @@ public class CollectionUtils {
|
||||||
if(a.size() != b.size()) {
|
if(a.size() != b.size()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final CardinalityHelper<Object> helper = new CardinalityHelper<Object>(a, b);
|
final CardinalityHelper<Object> helper = new CardinalityHelper<>(a, b);
|
||||||
if(helper.cardinalityA.size() != helper.cardinalityB.size()) {
|
if(helper.cardinalityA.size() != helper.cardinalityB.size()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1582,11 +1582,11 @@ public class CollectionUtils {
|
||||||
final int totalSize = a instanceof Collection<?> && b instanceof Collection<?> ?
|
final int totalSize = a instanceof Collection<?> && b instanceof Collection<?> ?
|
||||||
Math.max(1, ((Collection<?>) a).size() + ((Collection<?>) b).size()) : 10;
|
Math.max(1, ((Collection<?>) a).size() + ((Collection<?>) b).size()) : 10;
|
||||||
|
|
||||||
final Iterator<O> iterator = new CollatingIterator<O>(c, a.iterator(), b.iterator());
|
final Iterator<O> iterator = new CollatingIterator<>(c, a.iterator(), b.iterator());
|
||||||
if (includeDuplicates) {
|
if (includeDuplicates) {
|
||||||
return IteratorUtils.toList(iterator, totalSize);
|
return IteratorUtils.toList(iterator, totalSize);
|
||||||
} else {
|
} else {
|
||||||
final ArrayList<O> mergedList = new ArrayList<O>(totalSize);
|
final ArrayList<O> mergedList = new ArrayList<>(totalSize);
|
||||||
|
|
||||||
O lastItem = null;
|
O lastItem = null;
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
|
@ -1623,8 +1623,8 @@ public class CollectionUtils {
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
public static <E> Collection<List<E>> permutations(final Collection<E> collection) {
|
public static <E> Collection<List<E>> permutations(final Collection<E> collection) {
|
||||||
final PermutationIterator<E> it = new PermutationIterator<E>(collection);
|
final PermutationIterator<E> it = new PermutationIterator<>(collection);
|
||||||
final Collection<List<E>> result = new ArrayList<List<E>>();
|
final Collection<List<E>> result = new ArrayList<>();
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
result.add(it.next());
|
result.add(it.next());
|
||||||
}
|
}
|
||||||
|
@ -1690,16 +1690,16 @@ public class CollectionUtils {
|
||||||
final Transformer<E, EquatorWrapper<E>> transformer = new Transformer<E, EquatorWrapper<E>>() {
|
final Transformer<E, EquatorWrapper<E>> transformer = new Transformer<E, EquatorWrapper<E>>() {
|
||||||
@Override
|
@Override
|
||||||
public EquatorWrapper<E> transform(E input) {
|
public EquatorWrapper<E> transform(E input) {
|
||||||
return new EquatorWrapper<E>(equator, input);
|
return new EquatorWrapper<>(equator, input);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
final Set<EquatorWrapper<E>> retainSet =
|
final Set<EquatorWrapper<E>> retainSet =
|
||||||
collect(retain, transformer, new HashSet<EquatorWrapper<E>>());
|
collect(retain, transformer, new HashSet<EquatorWrapper<E>>());
|
||||||
|
|
||||||
final List<E> list = new ArrayList<E>();
|
final List<E> list = new ArrayList<>();
|
||||||
for (final E element : collection) {
|
for (final E element : collection) {
|
||||||
if (retainSet.contains(new EquatorWrapper<E>(equator, element))) {
|
if (retainSet.contains(new EquatorWrapper<>(equator, element))) {
|
||||||
list.add(element);
|
list.add(element);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1766,16 +1766,16 @@ public class CollectionUtils {
|
||||||
final Transformer<E, EquatorWrapper<E>> transformer = new Transformer<E, EquatorWrapper<E>>() {
|
final Transformer<E, EquatorWrapper<E>> transformer = new Transformer<E, EquatorWrapper<E>>() {
|
||||||
@Override
|
@Override
|
||||||
public EquatorWrapper<E> transform(E input) {
|
public EquatorWrapper<E> transform(E input) {
|
||||||
return new EquatorWrapper<E>(equator, input);
|
return new EquatorWrapper<>(equator, input);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
final Set<EquatorWrapper<E>> removeSet =
|
final Set<EquatorWrapper<E>> removeSet =
|
||||||
collect(remove, transformer, new HashSet<EquatorWrapper<E>>());
|
collect(remove, transformer, new HashSet<EquatorWrapper<E>>());
|
||||||
|
|
||||||
final List<E> list = new ArrayList<E>();
|
final List<E> list = new ArrayList<>();
|
||||||
for (final E element : collection) {
|
for (final E element : collection) {
|
||||||
if (!removeSet.contains(new EquatorWrapper<E>(equator, element))) {
|
if (!removeSet.contains(new EquatorWrapper<>(equator, element))) {
|
||||||
list.add(element);
|
list.add(element);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,7 +75,7 @@ public class ComparatorUtils {
|
||||||
* @see ComparatorChain
|
* @see ComparatorChain
|
||||||
*/
|
*/
|
||||||
public static <E> Comparator<E> chainedComparator(final Comparator<E>... comparators) {
|
public static <E> Comparator<E> chainedComparator(final Comparator<E>... comparators) {
|
||||||
final ComparatorChain<E> chain = new ComparatorChain<E>();
|
final ComparatorChain<E> chain = new ComparatorChain<>();
|
||||||
for (final Comparator<E> comparator : comparators) {
|
for (final Comparator<E> comparator : comparators) {
|
||||||
if (comparator == null) {
|
if (comparator == null) {
|
||||||
throw new NullPointerException("Comparator cannot be null");
|
throw new NullPointerException("Comparator cannot be null");
|
||||||
|
@ -113,7 +113,7 @@ public class ComparatorUtils {
|
||||||
* @see ReverseComparator
|
* @see ReverseComparator
|
||||||
*/
|
*/
|
||||||
public static <E> Comparator<E> reversedComparator(final Comparator<E> comparator) {
|
public static <E> Comparator<E> reversedComparator(final Comparator<E> comparator) {
|
||||||
return new ReverseComparator<E>(comparator);
|
return new ReverseComparator<>(comparator);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -149,7 +149,7 @@ public class ComparatorUtils {
|
||||||
if (comparator == null) {
|
if (comparator == null) {
|
||||||
comparator = NATURAL_COMPARATOR;
|
comparator = NATURAL_COMPARATOR;
|
||||||
}
|
}
|
||||||
return new NullComparator<E>(comparator, false);
|
return new NullComparator<>(comparator, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -169,7 +169,7 @@ public class ComparatorUtils {
|
||||||
if (comparator == null) {
|
if (comparator == null) {
|
||||||
comparator = NATURAL_COMPARATOR;
|
comparator = NATURAL_COMPARATOR;
|
||||||
}
|
}
|
||||||
return new NullComparator<E>(comparator, true);
|
return new NullComparator<>(comparator, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -193,7 +193,7 @@ public class ComparatorUtils {
|
||||||
if (comparator == null) {
|
if (comparator == null) {
|
||||||
comparator = NATURAL_COMPARATOR;
|
comparator = NATURAL_COMPARATOR;
|
||||||
}
|
}
|
||||||
return new TransformingComparator<I, O>(transformer, comparator);
|
return new TransformingComparator<>(transformer, comparator);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -77,7 +77,7 @@ public class EnumerationUtils {
|
||||||
* @throws NullPointerException if the enumeration parameter is <code>null</code>.
|
* @throws NullPointerException if the enumeration parameter is <code>null</code>.
|
||||||
*/
|
*/
|
||||||
public static <E> List<E> toList(final Enumeration<? extends E> enumeration) {
|
public static <E> List<E> toList(final Enumeration<? extends E> enumeration) {
|
||||||
return IteratorUtils.toList(new EnumerationIterator<E>(enumeration));
|
return IteratorUtils.toList(new EnumerationIterator<>(enumeration));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -88,7 +88,7 @@ public class EnumerationUtils {
|
||||||
* @return a list containing all tokens of the given StringTokenizer
|
* @return a list containing all tokens of the given StringTokenizer
|
||||||
*/
|
*/
|
||||||
public static List<String> toList(final StringTokenizer stringTokenizer) {
|
public static List<String> toList(final StringTokenizer stringTokenizer) {
|
||||||
final List<String> result = new ArrayList<String>(stringTokenizer.countTokens());
|
final List<String> result = new ArrayList<>(stringTokenizer.countTokens());
|
||||||
while (stringTokenizer.hasMoreTokens()) {
|
while (stringTokenizer.hasMoreTokens()) {
|
||||||
result.add(stringTokenizer.nextToken());
|
result.add(stringTokenizer.nextToken());
|
||||||
}
|
}
|
||||||
|
|
|
@ -92,7 +92,7 @@ public class FluentIterable<E> implements Iterable<E> {
|
||||||
* @return a new FluentIterable containing the singleton
|
* @return a new FluentIterable containing the singleton
|
||||||
*/
|
*/
|
||||||
public static <T> FluentIterable<T> of(final T singleton) {
|
public static <T> FluentIterable<T> of(final T singleton) {
|
||||||
return of(IteratorUtils.asIterable(new SingletonIterator<T>(singleton, false)));
|
return of(IteratorUtils.asIterable(new SingletonIterator<>(singleton, false)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -126,7 +126,7 @@ public class FluentIterable<E> implements Iterable<E> {
|
||||||
if (iterable instanceof FluentIterable<?>) {
|
if (iterable instanceof FluentIterable<?>) {
|
||||||
return (FluentIterable<T>) iterable;
|
return (FluentIterable<T>) iterable;
|
||||||
} else {
|
} else {
|
||||||
return new FluentIterable<T>(iterable);
|
return new FluentIterable<>(iterable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -365,7 +365,7 @@ public class IterableUtils {
|
||||||
final List<E> list = (iterable instanceof List<?>) ?
|
final List<E> list = (iterable instanceof List<?>) ?
|
||||||
(List<E>) iterable :
|
(List<E>) iterable :
|
||||||
IteratorUtils.toList(iterable.iterator());
|
IteratorUtils.toList(iterable.iterator());
|
||||||
return new ReverseListIterator<E>(list);
|
return new ReverseListIterator<>(list);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -451,7 +451,7 @@ public class IterableUtils {
|
||||||
return new FluentIterable<E>() {
|
return new FluentIterable<E>() {
|
||||||
@Override
|
@Override
|
||||||
public Iterator<E> iterator() {
|
public Iterator<E> iterator() {
|
||||||
return new UniqueFilterIterator<E>(iterable.iterator());
|
return new UniqueFilterIterator<>(iterable.iterator());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -474,7 +474,7 @@ public class IterableUtils {
|
||||||
if (iterable instanceof UnmodifiableIterable<?>) {
|
if (iterable instanceof UnmodifiableIterable<?>) {
|
||||||
return iterable;
|
return iterable;
|
||||||
}
|
}
|
||||||
return new UnmodifiableIterable<E>(iterable);
|
return new UnmodifiableIterable<>(iterable);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -937,7 +937,7 @@ public class IterableUtils {
|
||||||
// create the empty partitions
|
// create the empty partitions
|
||||||
final int numberOfPredicates = predicates.length;
|
final int numberOfPredicates = predicates.length;
|
||||||
final int numberOfPartitions = numberOfPredicates + 1;
|
final int numberOfPartitions = numberOfPredicates + 1;
|
||||||
final List<R> partitions = new ArrayList<R>(numberOfPartitions);
|
final List<R> partitions = new ArrayList<>(numberOfPartitions);
|
||||||
for (int i = 0; i < numberOfPartitions; ++i) {
|
for (int i = 0; i < numberOfPartitions; ++i) {
|
||||||
partitions.add(partitionFactory.create());
|
partitions.add(partitionFactory.create());
|
||||||
}
|
}
|
||||||
|
|
|
@ -208,7 +208,7 @@ public class IteratorUtils {
|
||||||
* @return a singleton iterator over the object
|
* @return a singleton iterator over the object
|
||||||
*/
|
*/
|
||||||
public static <E> ResettableIterator<E> singletonIterator(final E object) {
|
public static <E> ResettableIterator<E> singletonIterator(final E object) {
|
||||||
return new SingletonIterator<E>(object);
|
return new SingletonIterator<>(object);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -222,7 +222,7 @@ public class IteratorUtils {
|
||||||
* @return a singleton list iterator over the object
|
* @return a singleton list iterator over the object
|
||||||
*/
|
*/
|
||||||
public static <E> ListIterator<E> singletonListIterator(final E object) {
|
public static <E> ListIterator<E> singletonListIterator(final E object) {
|
||||||
return new SingletonListIterator<E>(object);
|
return new SingletonListIterator<>(object);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Arrays
|
// Arrays
|
||||||
|
@ -236,7 +236,7 @@ public class IteratorUtils {
|
||||||
* @throws NullPointerException if array is null
|
* @throws NullPointerException if array is null
|
||||||
*/
|
*/
|
||||||
public static <E> ResettableIterator<E> arrayIterator(final E... array) {
|
public static <E> ResettableIterator<E> arrayIterator(final E... array) {
|
||||||
return new ObjectArrayIterator<E>(array);
|
return new ObjectArrayIterator<>(array);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -252,7 +252,7 @@ public class IteratorUtils {
|
||||||
* @throws NullPointerException if array is null
|
* @throws NullPointerException if array is null
|
||||||
*/
|
*/
|
||||||
public static <E> ResettableIterator<E> arrayIterator(final Object array) {
|
public static <E> ResettableIterator<E> arrayIterator(final Object array) {
|
||||||
return new ArrayIterator<E>(array);
|
return new ArrayIterator<>(array);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -267,7 +267,7 @@ public class IteratorUtils {
|
||||||
* @throws NullPointerException if array is null
|
* @throws NullPointerException if array is null
|
||||||
*/
|
*/
|
||||||
public static <E> ResettableIterator<E> arrayIterator(final E[] array, final int start) {
|
public static <E> ResettableIterator<E> arrayIterator(final E[] array, final int start) {
|
||||||
return new ObjectArrayIterator<E>(array, start);
|
return new ObjectArrayIterator<>(array, start);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -286,7 +286,7 @@ public class IteratorUtils {
|
||||||
* @throws NullPointerException if array is null
|
* @throws NullPointerException if array is null
|
||||||
*/
|
*/
|
||||||
public static <E> ResettableIterator<E> arrayIterator(final Object array, final int start) {
|
public static <E> ResettableIterator<E> arrayIterator(final Object array, final int start) {
|
||||||
return new ArrayIterator<E>(array, start);
|
return new ArrayIterator<>(array, start);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -302,7 +302,7 @@ public class IteratorUtils {
|
||||||
* @throws NullPointerException if array is null
|
* @throws NullPointerException if array is null
|
||||||
*/
|
*/
|
||||||
public static <E> ResettableIterator<E> arrayIterator(final E[] array, final int start, final int end) {
|
public static <E> ResettableIterator<E> arrayIterator(final E[] array, final int start, final int end) {
|
||||||
return new ObjectArrayIterator<E>(array, start, end);
|
return new ObjectArrayIterator<>(array, start, end);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -321,7 +321,7 @@ public class IteratorUtils {
|
||||||
* @throws NullPointerException if array is null
|
* @throws NullPointerException if array is null
|
||||||
*/
|
*/
|
||||||
public static <E> ResettableIterator<E> arrayIterator(final Object array, final int start, final int end) {
|
public static <E> ResettableIterator<E> arrayIterator(final Object array, final int start, final int end) {
|
||||||
return new ArrayIterator<E>(array, start, end);
|
return new ArrayIterator<>(array, start, end);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
|
@ -334,7 +334,7 @@ public class IteratorUtils {
|
||||||
* @throws NullPointerException if array is null
|
* @throws NullPointerException if array is null
|
||||||
*/
|
*/
|
||||||
public static <E> ResettableListIterator<E> arrayListIterator(final E... array) {
|
public static <E> ResettableListIterator<E> arrayListIterator(final E... array) {
|
||||||
return new ObjectArrayListIterator<E>(array);
|
return new ObjectArrayListIterator<>(array);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -350,7 +350,7 @@ public class IteratorUtils {
|
||||||
* @throws NullPointerException if array is null
|
* @throws NullPointerException if array is null
|
||||||
*/
|
*/
|
||||||
public static <E> ResettableListIterator<E> arrayListIterator(final Object array) {
|
public static <E> ResettableListIterator<E> arrayListIterator(final Object array) {
|
||||||
return new ArrayListIterator<E>(array);
|
return new ArrayListIterator<>(array);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -364,7 +364,7 @@ public class IteratorUtils {
|
||||||
* @throws NullPointerException if array is null
|
* @throws NullPointerException if array is null
|
||||||
*/
|
*/
|
||||||
public static <E> ResettableListIterator<E> arrayListIterator(final E[] array, final int start) {
|
public static <E> ResettableListIterator<E> arrayListIterator(final E[] array, final int start) {
|
||||||
return new ObjectArrayListIterator<E>(array, start);
|
return new ObjectArrayListIterator<>(array, start);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -382,7 +382,7 @@ public class IteratorUtils {
|
||||||
* @throws NullPointerException if array is null
|
* @throws NullPointerException if array is null
|
||||||
*/
|
*/
|
||||||
public static <E> ResettableListIterator<E> arrayListIterator(final Object array, final int start) {
|
public static <E> ResettableListIterator<E> arrayListIterator(final Object array, final int start) {
|
||||||
return new ArrayListIterator<E>(array, start);
|
return new ArrayListIterator<>(array, start);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -398,7 +398,7 @@ public class IteratorUtils {
|
||||||
* @throws NullPointerException if array is null
|
* @throws NullPointerException if array is null
|
||||||
*/
|
*/
|
||||||
public static <E> ResettableListIterator<E> arrayListIterator(final E[] array, final int start, final int end) {
|
public static <E> ResettableListIterator<E> arrayListIterator(final E[] array, final int start, final int end) {
|
||||||
return new ObjectArrayListIterator<E>(array, start, end);
|
return new ObjectArrayListIterator<>(array, start, end);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -417,7 +417,7 @@ public class IteratorUtils {
|
||||||
* @throws NullPointerException if array is null
|
* @throws NullPointerException if array is null
|
||||||
*/
|
*/
|
||||||
public static <E> ResettableListIterator<E> arrayListIterator(final Object array, final int start, final int end) {
|
public static <E> ResettableListIterator<E> arrayListIterator(final Object array, final int start, final int end) {
|
||||||
return new ArrayListIterator<E>(array, start, end);
|
return new ArrayListIterator<>(array, start, end);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bounded
|
// Bounded
|
||||||
|
@ -457,7 +457,7 @@ public class IteratorUtils {
|
||||||
*/
|
*/
|
||||||
public static <E> BoundedIterator<E> boundedIterator(final Iterator<? extends E> iterator,
|
public static <E> BoundedIterator<E> boundedIterator(final Iterator<? extends E> iterator,
|
||||||
long offset, long max) {
|
long offset, long max) {
|
||||||
return new BoundedIterator<E>(iterator, offset, max);
|
return new BoundedIterator<>(iterator, offset, max);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unmodifiable
|
// Unmodifiable
|
||||||
|
@ -520,7 +520,7 @@ public class IteratorUtils {
|
||||||
final Iterator<? extends E> iterator2) {
|
final Iterator<? extends E> iterator2) {
|
||||||
// keep a version with two iterators to avoid the following warning in client code (Java 5 & 6)
|
// keep a version with two iterators to avoid the following warning in client code (Java 5 & 6)
|
||||||
// "A generic array of E is created for a varargs parameter"
|
// "A generic array of E is created for a varargs parameter"
|
||||||
return new IteratorChain<E>(iterator1, iterator2);
|
return new IteratorChain<>(iterator1, iterator2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -533,7 +533,7 @@ public class IteratorUtils {
|
||||||
* @throws NullPointerException if iterators array is null or contains a null
|
* @throws NullPointerException if iterators array is null or contains a null
|
||||||
*/
|
*/
|
||||||
public static <E> Iterator<E> chainedIterator(final Iterator<? extends E>... iterators) {
|
public static <E> Iterator<E> chainedIterator(final Iterator<? extends E>... iterators) {
|
||||||
return new IteratorChain<E>(iterators);
|
return new IteratorChain<>(iterators);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -547,7 +547,7 @@ public class IteratorUtils {
|
||||||
* @throws ClassCastException if the iterators collection contains the wrong object type
|
* @throws ClassCastException if the iterators collection contains the wrong object type
|
||||||
*/
|
*/
|
||||||
public static <E> Iterator<E> chainedIterator(final Collection<Iterator<? extends E>> iterators) {
|
public static <E> Iterator<E> chainedIterator(final Collection<Iterator<? extends E>> iterators) {
|
||||||
return new IteratorChain<E>(iterators);
|
return new IteratorChain<>(iterators);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Collated
|
// Collated
|
||||||
|
@ -575,7 +575,7 @@ public class IteratorUtils {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
final Comparator<E> comp =
|
final Comparator<E> comp =
|
||||||
comparator == null ? ComparatorUtils.NATURAL_COMPARATOR : (Comparator<E>) comparator;
|
comparator == null ? ComparatorUtils.NATURAL_COMPARATOR : (Comparator<E>) comparator;
|
||||||
return new CollatingIterator<E>(comp, iterator1, iterator2);
|
return new CollatingIterator<>(comp, iterator1, iterator2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -599,7 +599,7 @@ public class IteratorUtils {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
final Comparator<E> comp =
|
final Comparator<E> comp =
|
||||||
comparator == null ? ComparatorUtils.NATURAL_COMPARATOR : (Comparator<E>) comparator;
|
comparator == null ? ComparatorUtils.NATURAL_COMPARATOR : (Comparator<E>) comparator;
|
||||||
return new CollatingIterator<E>(comp, iterators);
|
return new CollatingIterator<>(comp, iterators);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -624,7 +624,7 @@ public class IteratorUtils {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
final Comparator<E> comp =
|
final Comparator<E> comp =
|
||||||
comparator == null ? ComparatorUtils.NATURAL_COMPARATOR : (Comparator<E>) comparator;
|
comparator == null ? ComparatorUtils.NATURAL_COMPARATOR : (Comparator<E>) comparator;
|
||||||
return new CollatingIterator<E>(comp, iterators);
|
return new CollatingIterator<>(comp, iterators);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Object Graph
|
// Object Graph
|
||||||
|
@ -685,7 +685,7 @@ public class IteratorUtils {
|
||||||
*/
|
*/
|
||||||
public static <E> Iterator<E> objectGraphIterator(final E root,
|
public static <E> Iterator<E> objectGraphIterator(final E root,
|
||||||
final Transformer<? super E, ? extends E> transformer) {
|
final Transformer<? super E, ? extends E> transformer) {
|
||||||
return new ObjectGraphIterator<E>(root, transformer);
|
return new ObjectGraphIterator<>(root, transformer);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Transformed
|
// Transformed
|
||||||
|
@ -712,7 +712,7 @@ public class IteratorUtils {
|
||||||
if (transform == null) {
|
if (transform == null) {
|
||||||
throw new NullPointerException("Transformer must not be null");
|
throw new NullPointerException("Transformer must not be null");
|
||||||
}
|
}
|
||||||
return new TransformIterator<I, O>(iterator, transform);
|
return new TransformIterator<>(iterator, transform);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Filtered
|
// Filtered
|
||||||
|
@ -737,7 +737,7 @@ public class IteratorUtils {
|
||||||
if (predicate == null) {
|
if (predicate == null) {
|
||||||
throw new NullPointerException("Predicate must not be null");
|
throw new NullPointerException("Predicate must not be null");
|
||||||
}
|
}
|
||||||
return new FilterIterator<E>(iterator, predicate);
|
return new FilterIterator<>(iterator, predicate);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -761,7 +761,7 @@ public class IteratorUtils {
|
||||||
if (predicate == null) {
|
if (predicate == null) {
|
||||||
throw new NullPointerException("Predicate must not be null");
|
throw new NullPointerException("Predicate must not be null");
|
||||||
}
|
}
|
||||||
return new FilterListIterator<E>(listIterator, predicate);
|
return new FilterListIterator<>(listIterator, predicate);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Looping
|
// Looping
|
||||||
|
@ -782,7 +782,7 @@ public class IteratorUtils {
|
||||||
if (coll == null) {
|
if (coll == null) {
|
||||||
throw new NullPointerException("Collection must not be null");
|
throw new NullPointerException("Collection must not be null");
|
||||||
}
|
}
|
||||||
return new LoopingIterator<E>(coll);
|
return new LoopingIterator<>(coll);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -801,7 +801,7 @@ public class IteratorUtils {
|
||||||
if (list == null) {
|
if (list == null) {
|
||||||
throw new NullPointerException("List must not be null");
|
throw new NullPointerException("List must not be null");
|
||||||
}
|
}
|
||||||
return new LoopingListIterator<E>(list);
|
return new LoopingListIterator<>(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
// org.w3c.dom.NodeList iterators
|
// org.w3c.dom.NodeList iterators
|
||||||
|
@ -892,7 +892,7 @@ public class IteratorUtils {
|
||||||
* @since 4.1
|
* @since 4.1
|
||||||
*/
|
*/
|
||||||
public static <E> SkippingIterator<E> skippingIterator(final Iterator<E> iterator, long offset) {
|
public static <E> SkippingIterator<E> skippingIterator(final Iterator<E> iterator, long offset) {
|
||||||
return new SkippingIterator<E>(iterator, offset);
|
return new SkippingIterator<>(iterator, offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Zipping
|
// Zipping
|
||||||
|
@ -909,7 +909,7 @@ public class IteratorUtils {
|
||||||
*/
|
*/
|
||||||
public static <E> ZippingIterator<E> zippingIterator(final Iterator<? extends E> a,
|
public static <E> ZippingIterator<E> zippingIterator(final Iterator<? extends E> a,
|
||||||
final Iterator<? extends E> b) {
|
final Iterator<? extends E> b) {
|
||||||
return new ZippingIterator<E>(a, b);
|
return new ZippingIterator<>(a, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -926,7 +926,7 @@ public class IteratorUtils {
|
||||||
public static <E> ZippingIterator<E> zippingIterator(final Iterator<? extends E> a,
|
public static <E> ZippingIterator<E> zippingIterator(final Iterator<? extends E> a,
|
||||||
final Iterator<? extends E> b,
|
final Iterator<? extends E> b,
|
||||||
final Iterator<? extends E> c) {
|
final Iterator<? extends E> c) {
|
||||||
return new ZippingIterator<E>(a, b, c);
|
return new ZippingIterator<>(a, b, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -939,7 +939,7 @@ public class IteratorUtils {
|
||||||
* @since 4.1
|
* @since 4.1
|
||||||
*/
|
*/
|
||||||
public static <E> ZippingIterator<E> zippingIterator(final Iterator<? extends E>... iterators) {
|
public static <E> ZippingIterator<E> zippingIterator(final Iterator<? extends E>... iterators) {
|
||||||
return new ZippingIterator<E>(iterators);
|
return new ZippingIterator<>(iterators);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Views
|
// Views
|
||||||
|
@ -956,7 +956,7 @@ public class IteratorUtils {
|
||||||
if (enumeration == null) {
|
if (enumeration == null) {
|
||||||
throw new NullPointerException("Enumeration must not be null");
|
throw new NullPointerException("Enumeration must not be null");
|
||||||
}
|
}
|
||||||
return new EnumerationIterator<E>(enumeration);
|
return new EnumerationIterator<>(enumeration);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -977,7 +977,7 @@ public class IteratorUtils {
|
||||||
if (removeCollection == null) {
|
if (removeCollection == null) {
|
||||||
throw new NullPointerException("Collection must not be null");
|
throw new NullPointerException("Collection must not be null");
|
||||||
}
|
}
|
||||||
return new EnumerationIterator<E>(enumeration, removeCollection);
|
return new EnumerationIterator<>(enumeration, removeCollection);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -992,7 +992,7 @@ public class IteratorUtils {
|
||||||
if (iterator == null) {
|
if (iterator == null) {
|
||||||
throw new NullPointerException("Iterator must not be null");
|
throw new NullPointerException("Iterator must not be null");
|
||||||
}
|
}
|
||||||
return new IteratorEnumeration<E>(iterator);
|
return new IteratorEnumeration<>(iterator);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1008,7 +1008,7 @@ public class IteratorUtils {
|
||||||
if (iterator == null) {
|
if (iterator == null) {
|
||||||
throw new NullPointerException("Iterator must not be null");
|
throw new NullPointerException("Iterator must not be null");
|
||||||
}
|
}
|
||||||
return new IteratorIterable<E>(iterator, false);
|
return new IteratorIterable<>(iterator, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1024,7 +1024,7 @@ public class IteratorUtils {
|
||||||
if (iterator == null) {
|
if (iterator == null) {
|
||||||
throw new NullPointerException("Iterator must not be null");
|
throw new NullPointerException("Iterator must not be null");
|
||||||
}
|
}
|
||||||
return new IteratorIterable<E>(iterator, true);
|
return new IteratorIterable<>(iterator, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1042,7 +1042,7 @@ public class IteratorUtils {
|
||||||
if (iterator == null) {
|
if (iterator == null) {
|
||||||
throw new NullPointerException("Iterator must not be null");
|
throw new NullPointerException("Iterator must not be null");
|
||||||
}
|
}
|
||||||
return new ListIteratorWrapper<E>(iterator);
|
return new ListIteratorWrapper<>(iterator);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1124,7 +1124,7 @@ public class IteratorUtils {
|
||||||
if (estimatedSize < 1) {
|
if (estimatedSize < 1) {
|
||||||
throw new IllegalArgumentException("Estimated size must be greater than 0");
|
throw new IllegalArgumentException("Estimated size must be greater than 0");
|
||||||
}
|
}
|
||||||
final List<E> list = new ArrayList<E>(estimatedSize);
|
final List<E> list = new ArrayList<>(estimatedSize);
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
list.add(iterator.next());
|
list.add(iterator.next());
|
||||||
}
|
}
|
||||||
|
@ -1163,10 +1163,10 @@ public class IteratorUtils {
|
||||||
return ((Iterable<?>) obj).iterator();
|
return ((Iterable<?>) obj).iterator();
|
||||||
}
|
}
|
||||||
if (obj instanceof Object[]) {
|
if (obj instanceof Object[]) {
|
||||||
return new ObjectArrayIterator<Object>((Object[]) obj);
|
return new ObjectArrayIterator<>((Object[]) obj);
|
||||||
}
|
}
|
||||||
if (obj instanceof Enumeration) {
|
if (obj instanceof Enumeration) {
|
||||||
return new EnumerationIterator<Object>((Enumeration<?>) obj);
|
return new EnumerationIterator<>((Enumeration<?>) obj);
|
||||||
}
|
}
|
||||||
if (obj instanceof Map) {
|
if (obj instanceof Map) {
|
||||||
return ((Map<?, ?>) obj).values().iterator();
|
return ((Map<?, ?>) obj).values().iterator();
|
||||||
|
@ -1178,9 +1178,9 @@ public class IteratorUtils {
|
||||||
return new NodeListIterator((Node) obj);
|
return new NodeListIterator((Node) obj);
|
||||||
}
|
}
|
||||||
if (obj instanceof Dictionary) {
|
if (obj instanceof Dictionary) {
|
||||||
return new EnumerationIterator<Object>(((Dictionary<?, ?>) obj).elements());
|
return new EnumerationIterator<>(((Dictionary<?, ?>) obj).elements());
|
||||||
} else if (obj.getClass().isArray()) {
|
} else if (obj.getClass().isArray()) {
|
||||||
return new ArrayIterator<Object>(obj);
|
return new ArrayIterator<>(obj);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
final Method method = obj.getClass().getMethod("iterator", (Class[]) null);
|
final Method method = obj.getClass().getMethod("iterator", (Class[]) null);
|
||||||
|
|
|
@ -87,7 +87,7 @@ public class ListUtils {
|
||||||
* @throws NullPointerException if either list is null
|
* @throws NullPointerException if either list is null
|
||||||
*/
|
*/
|
||||||
public static <E> List<E> intersection(final List<? extends E> list1, final List<? extends E> list2) {
|
public static <E> List<E> intersection(final List<? extends E> list1, final List<? extends E> list2) {
|
||||||
final List<E> result = new ArrayList<E>();
|
final List<E> result = new ArrayList<>();
|
||||||
|
|
||||||
List<? extends E> smaller = list1;
|
List<? extends E> smaller = list1;
|
||||||
List<? extends E> larger = list2;
|
List<? extends E> larger = list2;
|
||||||
|
@ -96,7 +96,7 @@ public class ListUtils {
|
||||||
larger = list1;
|
larger = list1;
|
||||||
}
|
}
|
||||||
|
|
||||||
final HashSet<E> hashSet = new HashSet<E>(smaller);
|
final HashSet<E> hashSet = new HashSet<>(smaller);
|
||||||
|
|
||||||
for (final E e : larger) {
|
for (final E e : larger) {
|
||||||
if (hashSet.contains(e)) {
|
if (hashSet.contains(e)) {
|
||||||
|
@ -124,8 +124,8 @@ public class ListUtils {
|
||||||
* @throws NullPointerException if either list is null
|
* @throws NullPointerException if either list is null
|
||||||
*/
|
*/
|
||||||
public static <E> List<E> subtract(final List<E> list1, final List<? extends E> list2) {
|
public static <E> List<E> subtract(final List<E> list1, final List<? extends E> list2) {
|
||||||
final ArrayList<E> result = new ArrayList<E>();
|
final ArrayList<E> result = new ArrayList<>();
|
||||||
final HashBag<E> bag = new HashBag<E>(list2);
|
final HashBag<E> bag = new HashBag<>(list2);
|
||||||
for (final E e : list1) {
|
for (final E e : list1) {
|
||||||
if (!bag.remove(e, 1)) {
|
if (!bag.remove(e, 1)) {
|
||||||
result.add(e);
|
result.add(e);
|
||||||
|
@ -160,7 +160,7 @@ public class ListUtils {
|
||||||
* @throws NullPointerException if either list is null
|
* @throws NullPointerException if either list is null
|
||||||
*/
|
*/
|
||||||
public static <E> List<E> union(final List<? extends E> list1, final List<? extends E> list2) {
|
public static <E> List<E> union(final List<? extends E> list1, final List<? extends E> list2) {
|
||||||
final ArrayList<E> result = new ArrayList<E>(list1);
|
final ArrayList<E> result = new ArrayList<>(list1);
|
||||||
result.addAll(list2);
|
result.addAll(list2);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -309,7 +309,7 @@ public class ListUtils {
|
||||||
* @since 3.2
|
* @since 3.2
|
||||||
*/
|
*/
|
||||||
public static <E> List<E> retainAll(final Collection<E> collection, final Collection<?> retain) {
|
public static <E> List<E> retainAll(final Collection<E> collection, final Collection<?> retain) {
|
||||||
final List<E> list = new ArrayList<E>(Math.min(collection.size(), retain.size()));
|
final List<E> list = new ArrayList<>(Math.min(collection.size(), retain.size()));
|
||||||
|
|
||||||
for (final E obj : collection) {
|
for (final E obj : collection) {
|
||||||
if (retain.contains(obj)) {
|
if (retain.contains(obj)) {
|
||||||
|
@ -343,7 +343,7 @@ public class ListUtils {
|
||||||
* @since 3.2
|
* @since 3.2
|
||||||
*/
|
*/
|
||||||
public static <E> List<E> removeAll(final Collection<E> collection, final Collection<?> remove) {
|
public static <E> List<E> removeAll(final Collection<E> collection, final Collection<?> remove) {
|
||||||
final List<E> list = new ArrayList<E>();
|
final List<E> list = new ArrayList<>();
|
||||||
for (final E obj : collection) {
|
for (final E obj : collection) {
|
||||||
if (!remove.contains(obj)) {
|
if (!remove.contains(obj)) {
|
||||||
list.add(obj);
|
list.add(obj);
|
||||||
|
@ -545,9 +545,9 @@ public class ListUtils {
|
||||||
throw new NullPointerException("Equator must not be null");
|
throw new NullPointerException("Equator must not be null");
|
||||||
}
|
}
|
||||||
|
|
||||||
final SequencesComparator<E> comparator = new SequencesComparator<E>(a, b, equator);
|
final SequencesComparator<E> comparator = new SequencesComparator<>(a, b, equator);
|
||||||
final EditScript<E> script = comparator.getScript();
|
final EditScript<E> script = comparator.getScript();
|
||||||
final LcsVisitor<E> visitor = new LcsVisitor<E>();
|
final LcsVisitor<E> visitor = new LcsVisitor<>();
|
||||||
script.visit(visitor);
|
script.visit(visitor);
|
||||||
return visitor.getSubSequence();
|
return visitor.getSubSequence();
|
||||||
}
|
}
|
||||||
|
@ -583,7 +583,7 @@ public class ListUtils {
|
||||||
private final ArrayList<E> sequence;
|
private final ArrayList<E> sequence;
|
||||||
|
|
||||||
public LcsVisitor() {
|
public LcsVisitor() {
|
||||||
sequence = new ArrayList<E>();
|
sequence = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -655,7 +655,7 @@ public class ListUtils {
|
||||||
if (size <= 0) {
|
if (size <= 0) {
|
||||||
throw new IllegalArgumentException("Size must be greater than 0");
|
throw new IllegalArgumentException("Size must be greater than 0");
|
||||||
}
|
}
|
||||||
return new Partition<T>(list, size);
|
return new Partition<>(list, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -85,7 +85,7 @@ public class MapUtils {
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
public static final SortedMap EMPTY_SORTED_MAP =
|
public static final SortedMap EMPTY_SORTED_MAP =
|
||||||
UnmodifiableSortedMap.unmodifiableSortedMap(new TreeMap<Object, Object>());
|
UnmodifiableSortedMap.unmodifiableSortedMap(new TreeMap<>());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* String used to indent the verbose and debug Map prints.
|
* String used to indent the verbose and debug Map prints.
|
||||||
|
@ -888,7 +888,7 @@ public class MapUtils {
|
||||||
*/
|
*/
|
||||||
public static Map<String, Object> toMap(final ResourceBundle resourceBundle) {
|
public static Map<String, Object> toMap(final ResourceBundle resourceBundle) {
|
||||||
final Enumeration<String> enumeration = resourceBundle.getKeys();
|
final Enumeration<String> enumeration = resourceBundle.getKeys();
|
||||||
final Map<String, Object> map = new HashMap<String, Object>();
|
final Map<String, Object> map = new HashMap<>();
|
||||||
|
|
||||||
while (enumeration.hasMoreElements()) {
|
while (enumeration.hasMoreElements()) {
|
||||||
final String key = enumeration.nextElement();
|
final String key = enumeration.nextElement();
|
||||||
|
@ -1065,7 +1065,7 @@ public class MapUtils {
|
||||||
* @throws NullPointerException if the map is null
|
* @throws NullPointerException if the map is null
|
||||||
*/
|
*/
|
||||||
public static <K, V> Map<V, K> invertMap(final Map<K, V> map) {
|
public static <K, V> Map<V, K> invertMap(final Map<K, V> map) {
|
||||||
final Map<V, K> out = new HashMap<V, K>(map.size());
|
final Map<V, K> out = new HashMap<>(map.size());
|
||||||
for (final Entry<K, V> entry : map.entrySet()) {
|
for (final Entry<K, V> entry : map.entrySet()) {
|
||||||
out.put(entry.getValue(), entry.getKey());
|
out.put(entry.getValue(), entry.getKey());
|
||||||
}
|
}
|
||||||
|
|
|
@ -132,7 +132,7 @@ public class MultiMapUtils {
|
||||||
if (col instanceof List) {
|
if (col instanceof List) {
|
||||||
return (List<V>) col;
|
return (List<V>) col;
|
||||||
}
|
}
|
||||||
return new ArrayList<V>(col);
|
return new ArrayList<>(col);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -152,7 +152,7 @@ public class MultiMapUtils {
|
||||||
if (col instanceof Set) {
|
if (col instanceof Set) {
|
||||||
return (Set<V>) col;
|
return (Set<V>) col;
|
||||||
}
|
}
|
||||||
return new HashSet<V>(col);
|
return new HashSet<>(col);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -172,7 +172,7 @@ public class MultiMapUtils {
|
||||||
if (col instanceof Bag) {
|
if (col instanceof Bag) {
|
||||||
return (Bag<V>) col;
|
return (Bag<V>) col;
|
||||||
}
|
}
|
||||||
return new HashBag<V>(col);
|
return new HashBag<>(col);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -189,7 +189,7 @@ public class MultiMapUtils {
|
||||||
* @return a new <code>ListValuedMap</code>
|
* @return a new <code>ListValuedMap</code>
|
||||||
*/
|
*/
|
||||||
public static <K, V> ListValuedMap<K, V> newListValuedHashMap() {
|
public static <K, V> ListValuedMap<K, V> newListValuedHashMap() {
|
||||||
return new ArrayListValuedHashMap<K, V>();
|
return new ArrayListValuedHashMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -201,7 +201,7 @@ public class MultiMapUtils {
|
||||||
* @return a new {@link SetValuedMap}
|
* @return a new {@link SetValuedMap}
|
||||||
*/
|
*/
|
||||||
public static <K, V> SetValuedMap<K, V> newSetValuedHashMap() {
|
public static <K, V> SetValuedMap<K, V> newSetValuedHashMap() {
|
||||||
return new HashSetValuedHashMap<K, V>();
|
return new HashSetValuedHashMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
// MultiValuedMap Decorators
|
// MultiValuedMap Decorators
|
||||||
|
|
|
@ -34,7 +34,7 @@ public class MultiSetUtils {
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("rawtypes") // OK, empty multiset is compatible with any type
|
@SuppressWarnings("rawtypes") // OK, empty multiset is compatible with any type
|
||||||
public static final MultiSet EMPTY_MULTISET =
|
public static final MultiSet EMPTY_MULTISET =
|
||||||
UnmodifiableMultiSet.unmodifiableMultiSet(new HashMultiSet<Object>());
|
UnmodifiableMultiSet.unmodifiableMultiSet(new HashMultiSet<>());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiation of MultiSetUtils is not intended or required.
|
* Instantiation of MultiSetUtils is not intended or required.
|
||||||
|
|
|
@ -35,7 +35,7 @@ public class QueueUtils {
|
||||||
* An empty unmodifiable queue.
|
* An empty unmodifiable queue.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("rawtypes") // OK, empty queue is compatible with any type
|
@SuppressWarnings("rawtypes") // OK, empty queue is compatible with any type
|
||||||
public static final Queue EMPTY_QUEUE = UnmodifiableQueue.unmodifiableQueue(new LinkedList<Object>());
|
public static final Queue EMPTY_QUEUE = UnmodifiableQueue.unmodifiableQueue(new LinkedList<>());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <code>QueueUtils</code> should not normally be instantiated.
|
* <code>QueueUtils</code> should not normally be instantiated.
|
||||||
|
|
|
@ -62,7 +62,7 @@ public class SetUtils {
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
public static final SortedSet EMPTY_SORTED_SET =
|
public static final SortedSet EMPTY_SORTED_SET =
|
||||||
UnmodifiableSortedSet.unmodifiableSortedSet(new TreeSet<Object>());
|
UnmodifiableSortedSet.unmodifiableSortedSet(new TreeSet<>());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a typed empty unmodifiable sorted set.
|
* Get a typed empty unmodifiable sorted set.
|
||||||
|
@ -637,7 +637,7 @@ public class SetUtils {
|
||||||
* @return a new set containing all elements of this view
|
* @return a new set containing all elements of this view
|
||||||
*/
|
*/
|
||||||
public Set<E> toSet() {
|
public Set<E> toSet() {
|
||||||
final Set<E> set = new HashSet<E>(size());
|
final Set<E> set = new HashSet<>(size());
|
||||||
copyInto(set);
|
copyInto(set);
|
||||||
return set;
|
return set;
|
||||||
}
|
}
|
||||||
|
|
|
@ -131,7 +131,7 @@ public class SplitMapUtils {
|
||||||
if (get instanceof IterableGet) {
|
if (get instanceof IterableGet) {
|
||||||
it = ((IterableGet<K, V>) get).mapIterator();
|
it = ((IterableGet<K, V>) get).mapIterator();
|
||||||
} else {
|
} else {
|
||||||
it = new EntrySetToMapIteratorAdapter<K, V>(get.entrySet());
|
it = new EntrySetToMapIteratorAdapter<>(get.entrySet());
|
||||||
}
|
}
|
||||||
return UnmodifiableMapIterator.unmodifiableMapIterator(it);
|
return UnmodifiableMapIterator.unmodifiableMapIterator(it);
|
||||||
}
|
}
|
||||||
|
@ -242,7 +242,7 @@ public class SplitMapUtils {
|
||||||
((IterableMap<K, V>) get) :
|
((IterableMap<K, V>) get) :
|
||||||
MapUtils.iterableMap((Map<K, V>) get);
|
MapUtils.iterableMap((Map<K, V>) get);
|
||||||
}
|
}
|
||||||
return new WrappedGet<K, V>(get);
|
return new WrappedGet<>(get);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -266,7 +266,7 @@ public class SplitMapUtils {
|
||||||
if (put instanceof Map) {
|
if (put instanceof Map) {
|
||||||
return (Map<K, V>) put;
|
return (Map<K, V>) put;
|
||||||
}
|
}
|
||||||
return new WrappedPut<K, V>(put);
|
return new WrappedPut<>(put);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -141,7 +141,7 @@ public abstract class AbstractMapBag<E> implements Bag<E> {
|
||||||
if (coll instanceof Bag) {
|
if (coll instanceof Bag) {
|
||||||
return containsAll((Bag<?>) coll);
|
return containsAll((Bag<?>) coll);
|
||||||
}
|
}
|
||||||
return containsAll(new HashBag<Object>(coll));
|
return containsAll(new HashBag<>(coll));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -171,7 +171,7 @@ public abstract class AbstractMapBag<E> implements Bag<E> {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Iterator<E> iterator() {
|
public Iterator<E> iterator() {
|
||||||
return new BagIterator<E>(this);
|
return new BagIterator<>(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -379,7 +379,7 @@ public abstract class AbstractMapBag<E> implements Bag<E> {
|
||||||
if (coll instanceof Bag) {
|
if (coll instanceof Bag) {
|
||||||
return retainAll((Bag<?>) coll);
|
return retainAll((Bag<?>) coll);
|
||||||
}
|
}
|
||||||
return retainAll(new HashBag<Object>(coll));
|
return retainAll(new HashBag<>(coll));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -392,7 +392,7 @@ public abstract class AbstractMapBag<E> implements Bag<E> {
|
||||||
*/
|
*/
|
||||||
boolean retainAll(final Bag<?> other) {
|
boolean retainAll(final Bag<?> other) {
|
||||||
boolean result = false;
|
boolean result = false;
|
||||||
final Bag<E> excess = new HashBag<E>();
|
final Bag<E> excess = new HashBag<>();
|
||||||
final Iterator<E> i = uniqueSet().iterator();
|
final Iterator<E> i = uniqueSet().iterator();
|
||||||
while (i.hasNext()) {
|
while (i.hasNext()) {
|
||||||
final E current = i.next();
|
final E current = i.next();
|
||||||
|
|
|
@ -52,7 +52,7 @@ public final class CollectionBag<E> extends AbstractBagDecorator<E> {
|
||||||
* @throws NullPointerException if bag is null
|
* @throws NullPointerException if bag is null
|
||||||
*/
|
*/
|
||||||
public static <E> Bag<E> collectionBag(final Bag<E> bag) {
|
public static <E> Bag<E> collectionBag(final Bag<E> bag) {
|
||||||
return new CollectionBag<E>(bag);
|
return new CollectionBag<>(bag);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
|
|
|
@ -44,7 +44,7 @@ public final class CollectionSortedBag<E> extends AbstractSortedBagDecorator<E>
|
||||||
* @throws NullPointerException if bag is null
|
* @throws NullPointerException if bag is null
|
||||||
*/
|
*/
|
||||||
public static <E> SortedBag<E> collectionSortedBag(final SortedBag<E> bag) {
|
public static <E> SortedBag<E> collectionSortedBag(final SortedBag<E> bag) {
|
||||||
return new CollectionSortedBag<E>(bag);
|
return new CollectionSortedBag<>(bag);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
|
|
|
@ -60,7 +60,7 @@ public class PredicatedBag<E> extends PredicatedCollection<E> implements Bag<E>
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
public static <E> PredicatedBag<E> predicatedBag(final Bag<E> bag, final Predicate<? super E> predicate) {
|
public static <E> PredicatedBag<E> predicatedBag(final Bag<E> bag, final Predicate<? super E> predicate) {
|
||||||
return new PredicatedBag<E>(bag, predicate);
|
return new PredicatedBag<>(bag, predicate);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
|
|
|
@ -60,7 +60,7 @@ public class PredicatedSortedBag<E> extends PredicatedBag<E> implements SortedBa
|
||||||
*/
|
*/
|
||||||
public static <E> PredicatedSortedBag<E> predicatedSortedBag(final SortedBag<E> bag,
|
public static <E> PredicatedSortedBag<E> predicatedSortedBag(final SortedBag<E> bag,
|
||||||
final Predicate<? super E> predicate) {
|
final Predicate<? super E> predicate) {
|
||||||
return new PredicatedSortedBag<E>(bag, predicate);
|
return new PredicatedSortedBag<>(bag, predicate);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
|
|
|
@ -48,7 +48,7 @@ public class SynchronizedBag<E> extends SynchronizedCollection<E> implements Bag
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
public static <E> SynchronizedBag<E> synchronizedBag(final Bag<E> bag) {
|
public static <E> SynchronizedBag<E> synchronizedBag(final Bag<E> bag) {
|
||||||
return new SynchronizedBag<E>(bag);
|
return new SynchronizedBag<>(bag);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
|
|
|
@ -48,7 +48,7 @@ public class SynchronizedSortedBag<E> extends SynchronizedBag<E> implements Sort
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
public static <E> SynchronizedSortedBag<E> synchronizedSortedBag(final SortedBag<E> bag) {
|
public static <E> SynchronizedSortedBag<E> synchronizedSortedBag(final SortedBag<E> bag) {
|
||||||
return new SynchronizedSortedBag<E>(bag);
|
return new SynchronizedSortedBag<>(bag);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
|
|
|
@ -55,7 +55,7 @@ public class TransformedBag<E> extends TransformedCollection<E> implements Bag<E
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
public static <E> Bag<E> transformingBag(final Bag<E> bag, final Transformer<? super E, ? extends E> transformer) {
|
public static <E> Bag<E> transformingBag(final Bag<E> bag, final Transformer<? super E, ? extends E> transformer) {
|
||||||
return new TransformedBag<E>(bag, transformer);
|
return new TransformedBag<>(bag, transformer);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -74,7 +74,7 @@ public class TransformedBag<E> extends TransformedCollection<E> implements Bag<E
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
public static <E> Bag<E> transformedBag(final Bag<E> bag, final Transformer<? super E, ? extends E> transformer) {
|
public static <E> Bag<E> transformedBag(final Bag<E> bag, final Transformer<? super E, ? extends E> transformer) {
|
||||||
final TransformedBag<E> decorated = new TransformedBag<E>(bag, transformer);
|
final TransformedBag<E> decorated = new TransformedBag<>(bag, transformer);
|
||||||
if (bag.size() > 0) {
|
if (bag.size() > 0) {
|
||||||
@SuppressWarnings("unchecked") // Bag is of type E
|
@SuppressWarnings("unchecked") // Bag is of type E
|
||||||
final E[] values = (E[]) bag.toArray(); // NOPMD - false positive for generics
|
final E[] values = (E[]) bag.toArray(); // NOPMD - false positive for generics
|
||||||
|
|
|
@ -54,7 +54,7 @@ public class TransformedSortedBag<E> extends TransformedBag<E> implements Sorted
|
||||||
*/
|
*/
|
||||||
public static <E> TransformedSortedBag<E> transformingSortedBag(final SortedBag<E> bag,
|
public static <E> TransformedSortedBag<E> transformingSortedBag(final SortedBag<E> bag,
|
||||||
final Transformer<? super E, ? extends E> transformer) {
|
final Transformer<? super E, ? extends E> transformer) {
|
||||||
return new TransformedSortedBag<E>(bag, transformer);
|
return new TransformedSortedBag<>(bag, transformer);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -75,7 +75,7 @@ public class TransformedSortedBag<E> extends TransformedBag<E> implements Sorted
|
||||||
public static <E> TransformedSortedBag<E> transformedSortedBag(final SortedBag<E> bag,
|
public static <E> TransformedSortedBag<E> transformedSortedBag(final SortedBag<E> bag,
|
||||||
final Transformer<? super E, ? extends E> transformer) {
|
final Transformer<? super E, ? extends E> transformer) {
|
||||||
|
|
||||||
final TransformedSortedBag<E> decorated = new TransformedSortedBag<E>(bag, transformer);
|
final TransformedSortedBag<E> decorated = new TransformedSortedBag<>(bag, transformer);
|
||||||
if (bag.size() > 0) {
|
if (bag.size() > 0) {
|
||||||
@SuppressWarnings("unchecked") // bag is type E
|
@SuppressWarnings("unchecked") // bag is type E
|
||||||
final E[] values = (E[]) bag.toArray(); // NOPMD - false positive for generics
|
final E[] values = (E[]) bag.toArray(); // NOPMD - false positive for generics
|
||||||
|
|
|
@ -61,7 +61,7 @@ public final class UnmodifiableBag<E>
|
||||||
final Bag<E> tmpBag = (Bag<E>) bag;
|
final Bag<E> tmpBag = (Bag<E>) bag;
|
||||||
return tmpBag;
|
return tmpBag;
|
||||||
}
|
}
|
||||||
return new UnmodifiableBag<E>(bag);
|
return new UnmodifiableBag<>(bag);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
|
|
|
@ -59,7 +59,7 @@ public final class UnmodifiableSortedBag<E>
|
||||||
if (bag instanceof Unmodifiable) {
|
if (bag instanceof Unmodifiable) {
|
||||||
return bag;
|
return bag;
|
||||||
}
|
}
|
||||||
return new UnmodifiableSortedBag<E>(bag);
|
return new UnmodifiableSortedBag<>(bag);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
|
|
|
@ -225,7 +225,7 @@ public abstract class AbstractDualBidiMap<K, V> implements BidiMap<K, V> {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public MapIterator<K, V> mapIterator() {
|
public MapIterator<K, V> mapIterator() {
|
||||||
return new BidiMapIterator<K, V>(this);
|
return new BidiMapIterator<>(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -263,7 +263,7 @@ public abstract class AbstractDualBidiMap<K, V> implements BidiMap<K, V> {
|
||||||
@Override
|
@Override
|
||||||
public Set<K> keySet() {
|
public Set<K> keySet() {
|
||||||
if (keySet == null) {
|
if (keySet == null) {
|
||||||
keySet = new KeySet<K>(this);
|
keySet = new KeySet<>(this);
|
||||||
}
|
}
|
||||||
return keySet;
|
return keySet;
|
||||||
}
|
}
|
||||||
|
@ -276,7 +276,7 @@ public abstract class AbstractDualBidiMap<K, V> implements BidiMap<K, V> {
|
||||||
* @return the keySet iterator
|
* @return the keySet iterator
|
||||||
*/
|
*/
|
||||||
protected Iterator<K> createKeySetIterator(final Iterator<K> iterator) {
|
protected Iterator<K> createKeySetIterator(final Iterator<K> iterator) {
|
||||||
return new KeySetIterator<K>(iterator, this);
|
return new KeySetIterator<>(iterator, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -289,7 +289,7 @@ public abstract class AbstractDualBidiMap<K, V> implements BidiMap<K, V> {
|
||||||
@Override
|
@Override
|
||||||
public Set<V> values() {
|
public Set<V> values() {
|
||||||
if (values == null) {
|
if (values == null) {
|
||||||
values = new Values<V>(this);
|
values = new Values<>(this);
|
||||||
}
|
}
|
||||||
return values;
|
return values;
|
||||||
}
|
}
|
||||||
|
@ -302,7 +302,7 @@ public abstract class AbstractDualBidiMap<K, V> implements BidiMap<K, V> {
|
||||||
* @return the values iterator
|
* @return the values iterator
|
||||||
*/
|
*/
|
||||||
protected Iterator<V> createValuesIterator(final Iterator<V> iterator) {
|
protected Iterator<V> createValuesIterator(final Iterator<V> iterator) {
|
||||||
return new ValuesIterator<V>(iterator, this);
|
return new ValuesIterator<>(iterator, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -319,7 +319,7 @@ public abstract class AbstractDualBidiMap<K, V> implements BidiMap<K, V> {
|
||||||
@Override
|
@Override
|
||||||
public Set<Map.Entry<K, V>> entrySet() {
|
public Set<Map.Entry<K, V>> entrySet() {
|
||||||
if (entrySet == null) {
|
if (entrySet == null) {
|
||||||
entrySet = new EntrySet<K, V>(this);
|
entrySet = new EntrySet<>(this);
|
||||||
}
|
}
|
||||||
return entrySet;
|
return entrySet;
|
||||||
}
|
}
|
||||||
|
@ -332,7 +332,7 @@ public abstract class AbstractDualBidiMap<K, V> implements BidiMap<K, V> {
|
||||||
* @return the entrySet iterator
|
* @return the entrySet iterator
|
||||||
*/
|
*/
|
||||||
protected Iterator<Map.Entry<K, V>> createEntrySetIterator(final Iterator<Map.Entry<K, V>> iterator) {
|
protected Iterator<Map.Entry<K, V>> createEntrySetIterator(final Iterator<Map.Entry<K, V>> iterator) {
|
||||||
return new EntrySetIterator<K, V>(iterator, this);
|
return new EntrySetIterator<>(iterator, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
|
@ -652,7 +652,7 @@ public abstract class AbstractDualBidiMap<K, V> implements BidiMap<K, V> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map.Entry<K, V> next() {
|
public Map.Entry<K, V> next() {
|
||||||
last = new MapEntry<K, V>(super.next(), parent);
|
last = new MapEntry<>(super.next(), parent);
|
||||||
canRemove = true;
|
canRemove = true;
|
||||||
return last;
|
return last;
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,7 +85,7 @@ public class DualHashBidiMap<K, V> extends AbstractDualBidiMap<K, V> implements
|
||||||
@Override
|
@Override
|
||||||
protected BidiMap<V, K> createBidiMap(final Map<V, K> normalMap, final Map<K, V> reverseMap,
|
protected BidiMap<V, K> createBidiMap(final Map<V, K> normalMap, final Map<K, V> reverseMap,
|
||||||
final BidiMap<K, V> inverseBidiMap) {
|
final BidiMap<K, V> inverseBidiMap) {
|
||||||
return new DualHashBidiMap<V, K>(normalMap, reverseMap, inverseBidiMap);
|
return new DualHashBidiMap<>(normalMap, reverseMap, inverseBidiMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Serialization
|
// Serialization
|
||||||
|
@ -97,8 +97,8 @@ public class DualHashBidiMap<K, V> extends AbstractDualBidiMap<K, V> implements
|
||||||
|
|
||||||
private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException {
|
private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException {
|
||||||
in.defaultReadObject();
|
in.defaultReadObject();
|
||||||
normalMap = new HashMap<K, V>();
|
normalMap = new HashMap<>();
|
||||||
reverseMap = new HashMap<V, K>();
|
reverseMap = new HashMap<>();
|
||||||
@SuppressWarnings("unchecked") // will fail at runtime if stream is incorrect
|
@SuppressWarnings("unchecked") // will fail at runtime if stream is incorrect
|
||||||
final Map<K, V> map = (Map<K, V>) in.readObject();
|
final Map<K, V> map = (Map<K, V>) in.readObject();
|
||||||
putAll(map);
|
putAll(map);
|
||||||
|
|
|
@ -80,7 +80,7 @@ public class DualLinkedHashBidiMap<K, V> extends AbstractDualBidiMap<K, V> imple
|
||||||
@Override
|
@Override
|
||||||
protected BidiMap<V, K> createBidiMap(final Map<V, K> normalMap, final Map<K, V> reverseMap,
|
protected BidiMap<V, K> createBidiMap(final Map<V, K> normalMap, final Map<K, V> reverseMap,
|
||||||
final BidiMap<K, V> inverseBidiMap) {
|
final BidiMap<K, V> inverseBidiMap) {
|
||||||
return new DualLinkedHashBidiMap<V, K>(normalMap, reverseMap, inverseBidiMap);
|
return new DualLinkedHashBidiMap<>(normalMap, reverseMap, inverseBidiMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Serialization
|
// Serialization
|
||||||
|
@ -92,8 +92,8 @@ public class DualLinkedHashBidiMap<K, V> extends AbstractDualBidiMap<K, V> imple
|
||||||
|
|
||||||
private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException {
|
private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException {
|
||||||
in.defaultReadObject();
|
in.defaultReadObject();
|
||||||
normalMap = new LinkedHashMap<K, V>();
|
normalMap = new LinkedHashMap<>();
|
||||||
reverseMap = new LinkedHashMap<V, K>();
|
reverseMap = new LinkedHashMap<>();
|
||||||
@SuppressWarnings("unchecked") // will fail at runtime if stream is incorrect
|
@SuppressWarnings("unchecked") // will fail at runtime if stream is incorrect
|
||||||
final Map<K, V> map = (Map<K, V>) in.readObject();
|
final Map<K, V> map = (Map<K, V>) in.readObject();
|
||||||
putAll(map);
|
putAll(map);
|
||||||
|
|
|
@ -123,7 +123,7 @@ public class DualTreeBidiMap<K, V> extends AbstractDualBidiMap<K, V>
|
||||||
@Override
|
@Override
|
||||||
protected DualTreeBidiMap<V, K> createBidiMap(final Map<V, K> normalMap, final Map<K, V> reverseMap,
|
protected DualTreeBidiMap<V, K> createBidiMap(final Map<V, K> normalMap, final Map<K, V> reverseMap,
|
||||||
final BidiMap<K, V> inverseMap) {
|
final BidiMap<K, V> inverseMap) {
|
||||||
return new DualTreeBidiMap<V, K>(normalMap, reverseMap, inverseMap);
|
return new DualTreeBidiMap<>(normalMap, reverseMap, inverseMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
|
@ -192,7 +192,7 @@ public class DualTreeBidiMap<K, V> extends AbstractDualBidiMap<K, V>
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public OrderedMapIterator<K, V> mapIterator() {
|
public OrderedMapIterator<K, V> mapIterator() {
|
||||||
return new BidiOrderedMapIterator<K, V>(this);
|
return new BidiOrderedMapIterator<>(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SortedBidiMap<V, K> inverseSortedBidiMap() {
|
public SortedBidiMap<V, K> inverseSortedBidiMap() {
|
||||||
|
@ -208,19 +208,19 @@ public class DualTreeBidiMap<K, V> extends AbstractDualBidiMap<K, V>
|
||||||
@Override
|
@Override
|
||||||
public SortedMap<K, V> headMap(final K toKey) {
|
public SortedMap<K, V> headMap(final K toKey) {
|
||||||
final SortedMap<K, V> sub = ((SortedMap<K, V>) normalMap).headMap(toKey);
|
final SortedMap<K, V> sub = ((SortedMap<K, V>) normalMap).headMap(toKey);
|
||||||
return new ViewMap<K, V>(this, sub);
|
return new ViewMap<>(this, sub);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SortedMap<K, V> tailMap(final K fromKey) {
|
public SortedMap<K, V> tailMap(final K fromKey) {
|
||||||
final SortedMap<K, V> sub = ((SortedMap<K, V>) normalMap).tailMap(fromKey);
|
final SortedMap<K, V> sub = ((SortedMap<K, V>) normalMap).tailMap(fromKey);
|
||||||
return new ViewMap<K, V>(this, sub);
|
return new ViewMap<>(this, sub);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SortedMap<K, V> subMap(final K fromKey, final K toKey) {
|
public SortedMap<K, V> subMap(final K fromKey, final K toKey) {
|
||||||
final SortedMap<K, V> sub = ((SortedMap<K, V>) normalMap).subMap(fromKey, toKey);
|
final SortedMap<K, V> sub = ((SortedMap<K, V>) normalMap).subMap(fromKey, toKey);
|
||||||
return new ViewMap<K, V>(this, sub);
|
return new ViewMap<>(this, sub);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -242,7 +242,7 @@ public class DualTreeBidiMap<K, V> extends AbstractDualBidiMap<K, V>
|
||||||
// the implementation is not great here...
|
// the implementation is not great here...
|
||||||
// use the normalMap as the filtered map, but reverseMap as the full map
|
// use the normalMap as the filtered map, but reverseMap as the full map
|
||||||
// this forces containsValue and clear to be overridden
|
// this forces containsValue and clear to be overridden
|
||||||
super(new DualTreeBidiMap<K, V>(sm, bidi.reverseMap, bidi.inverseBidiMap));
|
super(new DualTreeBidiMap<>(sm, bidi.reverseMap, bidi.inverseBidiMap));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -262,17 +262,17 @@ public class DualTreeBidiMap<K, V> extends AbstractDualBidiMap<K, V>
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SortedMap<K, V> headMap(final K toKey) {
|
public SortedMap<K, V> headMap(final K toKey) {
|
||||||
return new ViewMap<K, V>(decorated(), super.headMap(toKey));
|
return new ViewMap<>(decorated(), super.headMap(toKey));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SortedMap<K, V> tailMap(final K fromKey) {
|
public SortedMap<K, V> tailMap(final K fromKey) {
|
||||||
return new ViewMap<K, V>(decorated(), super.tailMap(fromKey));
|
return new ViewMap<>(decorated(), super.tailMap(fromKey));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SortedMap<K, V> subMap(final K fromKey, final K toKey) {
|
public SortedMap<K, V> subMap(final K fromKey, final K toKey) {
|
||||||
return new ViewMap<K, V>(decorated(), super.subMap(fromKey, toKey));
|
return new ViewMap<>(decorated(), super.subMap(fromKey, toKey));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -313,7 +313,7 @@ public class DualTreeBidiMap<K, V> extends AbstractDualBidiMap<K, V>
|
||||||
protected BidiOrderedMapIterator(final AbstractDualBidiMap<K, V> parent) {
|
protected BidiOrderedMapIterator(final AbstractDualBidiMap<K, V> parent) {
|
||||||
super();
|
super();
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
iterator = new ArrayList<Map.Entry<K, V>>(parent.entrySet()).listIterator();
|
iterator = new ArrayList<>(parent.entrySet()).listIterator();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -384,7 +384,7 @@ public class DualTreeBidiMap<K, V> extends AbstractDualBidiMap<K, V>
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void reset() {
|
public void reset() {
|
||||||
iterator = new ArrayList<Map.Entry<K, V>>(parent.entrySet()).listIterator();
|
iterator = new ArrayList<>(parent.entrySet()).listIterator();
|
||||||
last = null;
|
last = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -406,8 +406,8 @@ public class DualTreeBidiMap<K, V> extends AbstractDualBidiMap<K, V>
|
||||||
|
|
||||||
private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException {
|
private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException {
|
||||||
in.defaultReadObject();
|
in.defaultReadObject();
|
||||||
normalMap = new TreeMap<K, V>(comparator);
|
normalMap = new TreeMap<>(comparator);
|
||||||
reverseMap = new TreeMap<V, K>(valueComparator);
|
reverseMap = new TreeMap<>(valueComparator);
|
||||||
@SuppressWarnings("unchecked") // will fail at runtime if the stream is incorrect
|
@SuppressWarnings("unchecked") // will fail at runtime if the stream is incorrect
|
||||||
final Map<K, V> map = (Map<K, V>) in.readObject();
|
final Map<K, V> map = (Map<K, V>) in.readObject();
|
||||||
putAll(map);
|
putAll(map);
|
||||||
|
|
|
@ -509,7 +509,7 @@ public class TreeBidiMap<K extends Comparable<K>, V extends Comparable<V>>
|
||||||
Node<K, V> node = rootNode[KEY.ordinal()];
|
Node<K, V> node = rootNode[KEY.ordinal()];
|
||||||
if (node == null) {
|
if (node == null) {
|
||||||
// map is empty
|
// map is empty
|
||||||
final Node<K, V> root = new Node<K, V>(key, value);
|
final Node<K, V> root = new Node<>(key, value);
|
||||||
rootNode[KEY.ordinal()] = root;
|
rootNode[KEY.ordinal()] = root;
|
||||||
rootNode[VALUE.ordinal()] = root;
|
rootNode[VALUE.ordinal()] = root;
|
||||||
grow();
|
grow();
|
||||||
|
@ -526,7 +526,7 @@ public class TreeBidiMap<K extends Comparable<K>, V extends Comparable<V>>
|
||||||
if (node.getLeft(KEY) != null) {
|
if (node.getLeft(KEY) != null) {
|
||||||
node = node.getLeft(KEY);
|
node = node.getLeft(KEY);
|
||||||
} else {
|
} else {
|
||||||
final Node<K, V> newNode = new Node<K, V>(key, value);
|
final Node<K, V> newNode = new Node<>(key, value);
|
||||||
|
|
||||||
insertValue(newNode);
|
insertValue(newNode);
|
||||||
node.setLeft(newNode, KEY);
|
node.setLeft(newNode, KEY);
|
||||||
|
@ -540,7 +540,7 @@ public class TreeBidiMap<K extends Comparable<K>, V extends Comparable<V>>
|
||||||
if (node.getRight(KEY) != null) {
|
if (node.getRight(KEY) != null) {
|
||||||
node = node.getRight(KEY);
|
node = node.getRight(KEY);
|
||||||
} else {
|
} else {
|
||||||
final Node<K, V> newNode = new Node<K, V>(key, value);
|
final Node<K, V> newNode = new Node<>(key, value);
|
||||||
|
|
||||||
insertValue(newNode);
|
insertValue(newNode);
|
||||||
node.setRight(newNode, KEY);
|
node.setRight(newNode, KEY);
|
||||||
|
@ -1847,7 +1847,7 @@ public class TreeBidiMap<K extends Comparable<K>, V extends Comparable<V>>
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map.Entry<V, K> createEntry(final Node<K, V> node) {
|
private Map.Entry<V, K> createEntry(final Node<K, V> node) {
|
||||||
return new UnmodifiableMapEntry<V, K>(node.getValue(), node.getKey());
|
return new UnmodifiableMapEntry<>(node.getValue(), node.getKey());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,7 @@ public final class UnmodifiableBidiMap<K, V>
|
||||||
final BidiMap<K, V> tmpMap = (BidiMap<K, V>) map;
|
final BidiMap<K, V> tmpMap = (BidiMap<K, V>) map;
|
||||||
return tmpMap;
|
return tmpMap;
|
||||||
}
|
}
|
||||||
return new UnmodifiableBidiMap<K, V>(map);
|
return new UnmodifiableBidiMap<>(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
|
@ -127,7 +127,7 @@ public final class UnmodifiableBidiMap<K, V>
|
||||||
@Override
|
@Override
|
||||||
public synchronized BidiMap<V, K> inverseBidiMap() {
|
public synchronized BidiMap<V, K> inverseBidiMap() {
|
||||||
if (inverse == null) {
|
if (inverse == null) {
|
||||||
inverse = new UnmodifiableBidiMap<V, K>(decorated().inverseBidiMap());
|
inverse = new UnmodifiableBidiMap<>(decorated().inverseBidiMap());
|
||||||
inverse.inverse = this;
|
inverse.inverse = this;
|
||||||
}
|
}
|
||||||
return inverse;
|
return inverse;
|
||||||
|
|
|
@ -59,7 +59,7 @@ public final class UnmodifiableOrderedBidiMap<K, V>
|
||||||
final OrderedBidiMap<K, V> tmpMap = (OrderedBidiMap<K, V>) map;
|
final OrderedBidiMap<K, V> tmpMap = (OrderedBidiMap<K, V>) map;
|
||||||
return tmpMap;
|
return tmpMap;
|
||||||
}
|
}
|
||||||
return new UnmodifiableOrderedBidiMap<K, V>(map);
|
return new UnmodifiableOrderedBidiMap<>(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
|
@ -138,7 +138,7 @@ public final class UnmodifiableOrderedBidiMap<K, V>
|
||||||
*/
|
*/
|
||||||
public OrderedBidiMap<V, K> inverseOrderedBidiMap() {
|
public OrderedBidiMap<V, K> inverseOrderedBidiMap() {
|
||||||
if (inverse == null) {
|
if (inverse == null) {
|
||||||
inverse = new UnmodifiableOrderedBidiMap<V, K>(decorated().inverseBidiMap());
|
inverse = new UnmodifiableOrderedBidiMap<>(decorated().inverseBidiMap());
|
||||||
inverse.inverse = this;
|
inverse.inverse = this;
|
||||||
}
|
}
|
||||||
return inverse;
|
return inverse;
|
||||||
|
|
|
@ -60,7 +60,7 @@ public final class UnmodifiableSortedBidiMap<K, V>
|
||||||
final SortedBidiMap<K, V> tmpMap = (SortedBidiMap<K, V>) map;
|
final SortedBidiMap<K, V> tmpMap = (SortedBidiMap<K, V>) map;
|
||||||
return tmpMap;
|
return tmpMap;
|
||||||
}
|
}
|
||||||
return new UnmodifiableSortedBidiMap<K, V>(map);
|
return new UnmodifiableSortedBidiMap<>(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
|
@ -131,7 +131,7 @@ public final class UnmodifiableSortedBidiMap<K, V>
|
||||||
@Override
|
@Override
|
||||||
public SortedBidiMap<V, K> inverseBidiMap() {
|
public SortedBidiMap<V, K> inverseBidiMap() {
|
||||||
if (inverse == null) {
|
if (inverse == null) {
|
||||||
inverse = new UnmodifiableSortedBidiMap<V, K>(decorated().inverseBidiMap());
|
inverse = new UnmodifiableSortedBidiMap<>(decorated().inverseBidiMap());
|
||||||
inverse.inverse = this;
|
inverse.inverse = this;
|
||||||
}
|
}
|
||||||
return inverse;
|
return inverse;
|
||||||
|
|
|
@ -48,7 +48,7 @@ public class CompositeCollection<E> implements Collection<E>, Serializable {
|
||||||
private CollectionMutator<E> mutator;
|
private CollectionMutator<E> mutator;
|
||||||
|
|
||||||
/** Collections in the composite */
|
/** Collections in the composite */
|
||||||
private final List<Collection<E>> all = new ArrayList<Collection<E>>();
|
private final List<Collection<E>> all = new ArrayList<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create an empty CompositeCollection.
|
* Create an empty CompositeCollection.
|
||||||
|
@ -156,7 +156,7 @@ public class CompositeCollection<E> implements Collection<E>, Serializable {
|
||||||
if (all.isEmpty()) {
|
if (all.isEmpty()) {
|
||||||
return EmptyIterator.<E>emptyIterator();
|
return EmptyIterator.<E>emptyIterator();
|
||||||
}
|
}
|
||||||
final IteratorChain<E> chain = new IteratorChain<E>();
|
final IteratorChain<E> chain = new IteratorChain<>();
|
||||||
for (final Collection<E> item : all) {
|
for (final Collection<E> item : all) {
|
||||||
chain.addIterator(item.iterator());
|
chain.addIterator(item.iterator());
|
||||||
}
|
}
|
||||||
|
@ -401,7 +401,7 @@ public class CompositeCollection<E> implements Collection<E>, Serializable {
|
||||||
* The new collection is <i>not</i> backed by this composite.
|
* The new collection is <i>not</i> backed by this composite.
|
||||||
*/
|
*/
|
||||||
public Collection<E> toCollection() {
|
public Collection<E> toCollection() {
|
||||||
return new ArrayList<E>(this);
|
return new ArrayList<>(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -71,7 +71,7 @@ public class IndexedCollection<K, C> extends AbstractCollectionDecorator<C> {
|
||||||
*/
|
*/
|
||||||
public static <K, C> IndexedCollection<K, C> uniqueIndexedCollection(final Collection<C> coll,
|
public static <K, C> IndexedCollection<K, C> uniqueIndexedCollection(final Collection<C> coll,
|
||||||
final Transformer<C, K> keyTransformer) {
|
final Transformer<C, K> keyTransformer) {
|
||||||
return new IndexedCollection<K, C>(coll, keyTransformer,
|
return new IndexedCollection<>(coll, keyTransformer,
|
||||||
MultiValueMap.<K, C>multiValueMap(new HashMap<K, Collection<C>>()),
|
MultiValueMap.<K, C>multiValueMap(new HashMap<K, Collection<C>>()),
|
||||||
true);
|
true);
|
||||||
}
|
}
|
||||||
|
@ -87,7 +87,7 @@ public class IndexedCollection<K, C> extends AbstractCollectionDecorator<C> {
|
||||||
*/
|
*/
|
||||||
public static <K, C> IndexedCollection<K, C> nonUniqueIndexedCollection(final Collection<C> coll,
|
public static <K, C> IndexedCollection<K, C> nonUniqueIndexedCollection(final Collection<C> coll,
|
||||||
final Transformer<C, K> keyTransformer) {
|
final Transformer<C, K> keyTransformer) {
|
||||||
return new IndexedCollection<K, C>(coll, keyTransformer,
|
return new IndexedCollection<>(coll, keyTransformer,
|
||||||
MultiValueMap.<K, C>multiValueMap(new HashMap<K, Collection<C>>()),
|
MultiValueMap.<K, C>multiValueMap(new HashMap<K, Collection<C>>()),
|
||||||
false);
|
false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,7 +73,7 @@ public class PredicatedCollection<E> extends AbstractCollectionDecorator<E> {
|
||||||
* @since 4.1
|
* @since 4.1
|
||||||
*/
|
*/
|
||||||
public static <E> Builder<E> builder(final Predicate<? super E> predicate) {
|
public static <E> Builder<E> builder(final Predicate<? super E> predicate) {
|
||||||
return new Builder<E>(predicate);
|
return new Builder<>(predicate);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -84,7 +84,7 @@ public class PredicatedCollection<E> extends AbstractCollectionDecorator<E> {
|
||||||
* @since 4.1
|
* @since 4.1
|
||||||
*/
|
*/
|
||||||
public static <E> Builder<E> notNullBuilder() {
|
public static <E> Builder<E> notNullBuilder() {
|
||||||
return new Builder<E>(NotNullPredicate.<E>notNullPredicate());
|
return new Builder<>(NotNullPredicate.<E>notNullPredicate());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -103,7 +103,7 @@ public class PredicatedCollection<E> extends AbstractCollectionDecorator<E> {
|
||||||
*/
|
*/
|
||||||
public static <T> PredicatedCollection<T> predicatedCollection(final Collection<T> coll,
|
public static <T> PredicatedCollection<T> predicatedCollection(final Collection<T> coll,
|
||||||
final Predicate<? super T> predicate) {
|
final Predicate<? super T> predicate) {
|
||||||
return new PredicatedCollection<T>(coll, predicate);
|
return new PredicatedCollection<>(coll, predicate);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
|
@ -209,10 +209,10 @@ public class PredicatedCollection<E> extends AbstractCollectionDecorator<E> {
|
||||||
private final Predicate<? super E> predicate;
|
private final Predicate<? super E> predicate;
|
||||||
|
|
||||||
/** The buffer containing valid elements. */
|
/** The buffer containing valid elements. */
|
||||||
private final List<E> accepted = new ArrayList<E>();
|
private final List<E> accepted = new ArrayList<>();
|
||||||
|
|
||||||
/** The buffer containing rejected elements. */
|
/** The buffer containing rejected elements. */
|
||||||
private final List<E> rejected = new ArrayList<E>();
|
private final List<E> rejected = new ArrayList<>();
|
||||||
|
|
||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -58,7 +58,7 @@ public class SynchronizedCollection<E> implements Collection<E>, Serializable {
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
public static <T> SynchronizedCollection<T> synchronizedCollection(final Collection<T> coll) {
|
public static <T> SynchronizedCollection<T> synchronizedCollection(final Collection<T> coll) {
|
||||||
return new SynchronizedCollection<T>(coll);
|
return new SynchronizedCollection<>(coll);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
|
|
|
@ -60,7 +60,7 @@ public class TransformedCollection<E> extends AbstractCollectionDecorator<E> {
|
||||||
*/
|
*/
|
||||||
public static <E> TransformedCollection<E> transformingCollection(final Collection<E> coll,
|
public static <E> TransformedCollection<E> transformingCollection(final Collection<E> coll,
|
||||||
final Transformer<? super E, ? extends E> transformer) {
|
final Transformer<? super E, ? extends E> transformer) {
|
||||||
return new TransformedCollection<E>(coll, transformer);
|
return new TransformedCollection<>(coll, transformer);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -81,7 +81,7 @@ public class TransformedCollection<E> extends AbstractCollectionDecorator<E> {
|
||||||
public static <E> TransformedCollection<E> transformedCollection(final Collection<E> collection,
|
public static <E> TransformedCollection<E> transformedCollection(final Collection<E> collection,
|
||||||
final Transformer<? super E, ? extends E> transformer) {
|
final Transformer<? super E, ? extends E> transformer) {
|
||||||
|
|
||||||
final TransformedCollection<E> decorated = new TransformedCollection<E>(collection, transformer);
|
final TransformedCollection<E> decorated = new TransformedCollection<>(collection, transformer);
|
||||||
// null collection & transformer are disallowed by the constructor call above
|
// null collection & transformer are disallowed by the constructor call above
|
||||||
if (collection.size() > 0) {
|
if (collection.size() > 0) {
|
||||||
@SuppressWarnings("unchecked") // collection is of type E
|
@SuppressWarnings("unchecked") // collection is of type E
|
||||||
|
@ -134,7 +134,7 @@ public class TransformedCollection<E> extends AbstractCollectionDecorator<E> {
|
||||||
* @return a transformed object
|
* @return a transformed object
|
||||||
*/
|
*/
|
||||||
protected Collection<E> transform(final Collection<? extends E> coll) {
|
protected Collection<E> transform(final Collection<? extends E> coll) {
|
||||||
final List<E> list = new ArrayList<E>(coll.size());
|
final List<E> list = new ArrayList<>(coll.size());
|
||||||
for (final E item : coll) {
|
for (final E item : coll) {
|
||||||
list.add(transform(item));
|
list.add(transform(item));
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,7 +61,7 @@ public final class UnmodifiableBoundedCollection<E> extends AbstractCollectionDe
|
||||||
final BoundedCollection<E> tmpColl = (BoundedCollection<E>) coll;
|
final BoundedCollection<E> tmpColl = (BoundedCollection<E>) coll;
|
||||||
return tmpColl;
|
return tmpColl;
|
||||||
}
|
}
|
||||||
return new UnmodifiableBoundedCollection<E>(coll);
|
return new UnmodifiableBoundedCollection<>(coll);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -98,7 +98,7 @@ public final class UnmodifiableBoundedCollection<E> extends AbstractCollectionDe
|
||||||
if (coll instanceof BoundedCollection == false) {
|
if (coll instanceof BoundedCollection == false) {
|
||||||
throw new IllegalArgumentException("Collection is not a bounded collection.");
|
throw new IllegalArgumentException("Collection is not a bounded collection.");
|
||||||
}
|
}
|
||||||
return new UnmodifiableBoundedCollection<E>((BoundedCollection<E>) coll);
|
return new UnmodifiableBoundedCollection<>((BoundedCollection<E>) coll);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -57,7 +57,7 @@ public final class UnmodifiableCollection<E>
|
||||||
final Collection<T> tmpColl = (Collection<T>) coll;
|
final Collection<T> tmpColl = (Collection<T>) coll;
|
||||||
return tmpColl;
|
return tmpColl;
|
||||||
}
|
}
|
||||||
return new UnmodifiableCollection<T>(coll);
|
return new UnmodifiableCollection<>(coll);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
|
|
|
@ -88,7 +88,7 @@ public class ComparatorChain<E> implements Comparator<E>, Serializable {
|
||||||
* @param reverse false = forward sort; true = reverse sort
|
* @param reverse false = forward sort; true = reverse sort
|
||||||
*/
|
*/
|
||||||
public ComparatorChain(final Comparator<E> comparator, final boolean reverse) {
|
public ComparatorChain(final Comparator<E> comparator, final boolean reverse) {
|
||||||
comparatorChain = new ArrayList<Comparator<E>>(1);
|
comparatorChain = new ArrayList<>(1);
|
||||||
comparatorChain.add(comparator);
|
comparatorChain.add(comparator);
|
||||||
orderingBits = new BitSet(1);
|
orderingBits = new BitSet(1);
|
||||||
if (reverse == true) {
|
if (reverse == true) {
|
||||||
|
|
|
@ -60,7 +60,7 @@ public class FixedOrderComparator<T> implements Comparator<T>, Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Internal map of object to position */
|
/** Internal map of object to position */
|
||||||
private final Map<T, Integer> map = new HashMap<T, Integer>();
|
private final Map<T, Integer> map = new HashMap<>();
|
||||||
|
|
||||||
/** Counter used in determining the position in the map */
|
/** Counter used in determining the position in the map */
|
||||||
private int counter = 0;
|
private int counter = 0;
|
||||||
|
|
|
@ -61,7 +61,7 @@ public final class AllPredicate<T> extends AbstractQuantifierPredicate<T> {
|
||||||
return coerce(predicates[0]);
|
return coerce(predicates[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new AllPredicate<T>(FunctorUtils.copy(predicates));
|
return new AllPredicate<>(FunctorUtils.copy(predicates));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -84,7 +84,7 @@ public final class AllPredicate<T> extends AbstractQuantifierPredicate<T> {
|
||||||
if (preds.length == 1) {
|
if (preds.length == 1) {
|
||||||
return coerce(preds[0]);
|
return coerce(preds[0]);
|
||||||
}
|
}
|
||||||
return new AllPredicate<T>(preds);
|
return new AllPredicate<>(preds);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -50,7 +50,7 @@ public final class AndPredicate<T> implements PredicateDecorator<T>, Serializabl
|
||||||
if (predicate1 == null || predicate2 == null) {
|
if (predicate1 == null || predicate2 == null) {
|
||||||
throw new NullPointerException("Predicate must not be null");
|
throw new NullPointerException("Predicate must not be null");
|
||||||
}
|
}
|
||||||
return new AndPredicate<T>(predicate1, predicate2);
|
return new AndPredicate<>(predicate1, predicate2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -57,7 +57,7 @@ public final class AnyPredicate<T> extends AbstractQuantifierPredicate<T> {
|
||||||
if (predicates.length == 1) {
|
if (predicates.length == 1) {
|
||||||
return (Predicate<T>) predicates[0];
|
return (Predicate<T>) predicates[0];
|
||||||
}
|
}
|
||||||
return new AnyPredicate<T>(FunctorUtils.copy(predicates));
|
return new AnyPredicate<>(FunctorUtils.copy(predicates));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -81,7 +81,7 @@ public final class AnyPredicate<T> extends AbstractQuantifierPredicate<T> {
|
||||||
if (preds.length == 1) {
|
if (preds.length == 1) {
|
||||||
return (Predicate<T>) preds[0];
|
return (Predicate<T>) preds[0];
|
||||||
}
|
}
|
||||||
return new AnyPredicate<T>(preds);
|
return new AnyPredicate<>(preds);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -49,7 +49,7 @@ public class ChainedClosure<E> implements Closure<E>, Serializable {
|
||||||
if (closures.length == 0) {
|
if (closures.length == 0) {
|
||||||
return NOPClosure.<E>nopClosure();
|
return NOPClosure.<E>nopClosure();
|
||||||
}
|
}
|
||||||
return new ChainedClosure<E>(closures);
|
return new ChainedClosure<>(closures);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -78,7 +78,7 @@ public class ChainedClosure<E> implements Closure<E>, Serializable {
|
||||||
cmds[i++] = closure;
|
cmds[i++] = closure;
|
||||||
}
|
}
|
||||||
FunctorUtils.validate(cmds);
|
FunctorUtils.validate(cmds);
|
||||||
return new ChainedClosure<E>(false, cmds);
|
return new ChainedClosure<>(false, cmds);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -52,7 +52,7 @@ public class ChainedTransformer<T> implements Transformer<T, T>, Serializable {
|
||||||
if (transformers.length == 0) {
|
if (transformers.length == 0) {
|
||||||
return NOPTransformer.<T>nopTransformer();
|
return NOPTransformer.<T>nopTransformer();
|
||||||
}
|
}
|
||||||
return new ChainedTransformer<T>(transformers);
|
return new ChainedTransformer<>(transformers);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -78,7 +78,7 @@ public class ChainedTransformer<T> implements Transformer<T, T>, Serializable {
|
||||||
// convert to array like this to guarantee iterator() ordering
|
// convert to array like this to guarantee iterator() ordering
|
||||||
final Transformer<T, T>[] cmds = transformers.toArray(new Transformer[transformers.size()]);
|
final Transformer<T, T>[] cmds = transformers.toArray(new Transformer[transformers.size()]);
|
||||||
FunctorUtils.validate(cmds);
|
FunctorUtils.validate(cmds);
|
||||||
return new ChainedTransformer<T>(false, cmds);
|
return new ChainedTransformer<>(false, cmds);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -35,7 +35,7 @@ public class CloneTransformer<T> implements Transformer<T, T> {
|
||||||
|
|
||||||
/** Singleton predicate instance */
|
/** Singleton predicate instance */
|
||||||
@SuppressWarnings("rawtypes") // the singleton instance works for all types
|
@SuppressWarnings("rawtypes") // the singleton instance works for all types
|
||||||
public static final Transformer INSTANCE = new CloneTransformer<Object>();
|
public static final Transformer INSTANCE = new CloneTransformer<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Factory returning the singleton instance.
|
* Factory returning the singleton instance.
|
||||||
|
|
|
@ -48,7 +48,7 @@ public class ClosureTransformer<T> implements Transformer<T, T>, Serializable {
|
||||||
if (closure == null) {
|
if (closure == null) {
|
||||||
throw new NullPointerException("Closure must not be null");
|
throw new NullPointerException("Closure must not be null");
|
||||||
}
|
}
|
||||||
return new ClosureTransformer<T>(closure);
|
return new ClosureTransformer<>(closure);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -126,7 +126,7 @@ public class ComparatorPredicate<T> implements Predicate<T>, Serializable {
|
||||||
if (criterion == null) {
|
if (criterion == null) {
|
||||||
throw new NullPointerException("Criterion must not be null.");
|
throw new NullPointerException("Criterion must not be null.");
|
||||||
}
|
}
|
||||||
return new ComparatorPredicate<T>(object, comparator, criterion);
|
return new ComparatorPredicate<>(object, comparator, criterion);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -37,7 +37,7 @@ public class ConstantFactory<T> implements Factory<T>, Serializable {
|
||||||
|
|
||||||
/** Returns null each time */
|
/** Returns null each time */
|
||||||
@SuppressWarnings("rawtypes") // The null factory works for all object types
|
@SuppressWarnings("rawtypes") // The null factory works for all object types
|
||||||
public static final Factory NULL_INSTANCE = new ConstantFactory<Object>(null);
|
public static final Factory NULL_INSTANCE = new ConstantFactory<>(null);
|
||||||
|
|
||||||
/** The closures to call in turn */
|
/** The closures to call in turn */
|
||||||
private final T iConstant;
|
private final T iConstant;
|
||||||
|
@ -54,7 +54,7 @@ public class ConstantFactory<T> implements Factory<T>, Serializable {
|
||||||
if (constantToReturn == null) {
|
if (constantToReturn == null) {
|
||||||
return (Factory<T>) NULL_INSTANCE;
|
return (Factory<T>) NULL_INSTANCE;
|
||||||
}
|
}
|
||||||
return new ConstantFactory<T>(constantToReturn);
|
return new ConstantFactory<>(constantToReturn);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -37,7 +37,7 @@ public class ConstantTransformer<I, O> implements Transformer<I, O>, Serializabl
|
||||||
|
|
||||||
/** Returns null each time */
|
/** Returns null each time */
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
public static final Transformer NULL_INSTANCE = new ConstantTransformer<Object, Object>(null);
|
public static final Transformer NULL_INSTANCE = new ConstantTransformer<>(null);
|
||||||
|
|
||||||
/** The closures to call in turn */
|
/** The closures to call in turn */
|
||||||
private final O iConstant;
|
private final O iConstant;
|
||||||
|
@ -66,7 +66,7 @@ public class ConstantTransformer<I, O> implements Transformer<I, O>, Serializabl
|
||||||
if (constantToReturn == null) {
|
if (constantToReturn == null) {
|
||||||
return nullTransformer();
|
return nullTransformer();
|
||||||
}
|
}
|
||||||
return new ConstantTransformer<I, O>(constantToReturn);
|
return new ConstantTransformer<>(constantToReturn);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -34,7 +34,7 @@ public class DefaultEquator<T> implements Equator<T>, Serializable {
|
||||||
|
|
||||||
/** Static instance */
|
/** Static instance */
|
||||||
@SuppressWarnings("rawtypes") // the static instance works for all types
|
@SuppressWarnings("rawtypes") // the static instance works for all types
|
||||||
public static final DefaultEquator INSTANCE = new DefaultEquator<Object>();
|
public static final DefaultEquator INSTANCE = new DefaultEquator<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hashcode used for <code>null</code> objects.
|
* Hashcode used for <code>null</code> objects.
|
||||||
|
|
|
@ -50,7 +50,7 @@ public final class EqualPredicate<T> implements Predicate<T>, Serializable {
|
||||||
if (object == null) {
|
if (object == null) {
|
||||||
return NullPredicate.nullPredicate();
|
return NullPredicate.nullPredicate();
|
||||||
}
|
}
|
||||||
return new EqualPredicate<T>(object);
|
return new EqualPredicate<>(object);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -66,7 +66,7 @@ public final class EqualPredicate<T> implements Predicate<T>, Serializable {
|
||||||
if (object == null) {
|
if (object == null) {
|
||||||
return NullPredicate.nullPredicate();
|
return NullPredicate.nullPredicate();
|
||||||
}
|
}
|
||||||
return new EqualPredicate<T>(object, equator);
|
return new EqualPredicate<>(object, equator);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -34,7 +34,7 @@ public final class ExceptionClosure<E> implements Closure<E>, Serializable {
|
||||||
|
|
||||||
/** Singleton predicate instance */
|
/** Singleton predicate instance */
|
||||||
@SuppressWarnings("rawtypes") // the static instance works for all types
|
@SuppressWarnings("rawtypes") // the static instance works for all types
|
||||||
public static final Closure INSTANCE = new ExceptionClosure<Object>();
|
public static final Closure INSTANCE = new ExceptionClosure<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Factory returning the singleton instance.
|
* Factory returning the singleton instance.
|
||||||
|
|
|
@ -34,7 +34,7 @@ public final class ExceptionFactory<T> implements Factory<T>, Serializable {
|
||||||
|
|
||||||
/** Singleton predicate instance */
|
/** Singleton predicate instance */
|
||||||
@SuppressWarnings("rawtypes") // the static instance works for all types
|
@SuppressWarnings("rawtypes") // the static instance works for all types
|
||||||
public static final Factory INSTANCE = new ExceptionFactory<Object>();
|
public static final Factory INSTANCE = new ExceptionFactory<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Factory returning the singleton instance.
|
* Factory returning the singleton instance.
|
||||||
|
|
|
@ -34,7 +34,7 @@ public final class ExceptionPredicate<T> implements Predicate<T>, Serializable {
|
||||||
|
|
||||||
/** Singleton predicate instance */
|
/** Singleton predicate instance */
|
||||||
@SuppressWarnings("rawtypes") // the static instance works for all types
|
@SuppressWarnings("rawtypes") // the static instance works for all types
|
||||||
public static final Predicate INSTANCE = new ExceptionPredicate<Object>();
|
public static final Predicate INSTANCE = new ExceptionPredicate<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Factory returning the singleton instance.
|
* Factory returning the singleton instance.
|
||||||
|
|
|
@ -34,7 +34,7 @@ public final class ExceptionTransformer<I, O> implements Transformer<I, O>, Seri
|
||||||
|
|
||||||
/** Singleton predicate instance */
|
/** Singleton predicate instance */
|
||||||
@SuppressWarnings("rawtypes") // the static instance works for all types
|
@SuppressWarnings("rawtypes") // the static instance works for all types
|
||||||
public static final Transformer INSTANCE = new ExceptionTransformer<Object, Object>();
|
public static final Transformer INSTANCE = new ExceptionTransformer<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Factory returning the singleton instance.
|
* Factory returning the singleton instance.
|
||||||
|
|
|
@ -48,7 +48,7 @@ public class FactoryTransformer<I, O> implements Transformer<I, O>, Serializable
|
||||||
if (factory == null) {
|
if (factory == null) {
|
||||||
throw new NullPointerException("Factory must not be null");
|
throw new NullPointerException("Factory must not be null");
|
||||||
}
|
}
|
||||||
return new FactoryTransformer<I, O>(factory);
|
return new FactoryTransformer<>(factory);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -33,7 +33,7 @@ public final class FalsePredicate<T> implements Predicate<T>, Serializable {
|
||||||
|
|
||||||
/** Singleton predicate instance */
|
/** Singleton predicate instance */
|
||||||
@SuppressWarnings("rawtypes") // the static instance works for all types
|
@SuppressWarnings("rawtypes") // the static instance works for all types
|
||||||
public static final Predicate INSTANCE = new FalsePredicate<Object>();
|
public static final Predicate INSTANCE = new FalsePredicate<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a typed instance.
|
* Get a typed instance.
|
||||||
|
|
|
@ -55,7 +55,7 @@ public class ForClosure<E> implements Closure<E> {
|
||||||
if (count == 1) {
|
if (count == 1) {
|
||||||
return (Closure<E>) closure;
|
return (Closure<E>) closure;
|
||||||
}
|
}
|
||||||
return new ForClosure<E>(count, closure);
|
return new ForClosure<>(count, closure);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -46,7 +46,7 @@ public final class IdentityPredicate<T> implements Predicate<T>, Serializable {
|
||||||
if (object == null) {
|
if (object == null) {
|
||||||
return NullPredicate.<T>nullPredicate();
|
return NullPredicate.<T>nullPredicate();
|
||||||
}
|
}
|
||||||
return new IdentityPredicate<T>(object);
|
return new IdentityPredicate<>(object);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -76,7 +76,7 @@ public class IfClosure<E> implements Closure<E>, Serializable {
|
||||||
if (trueClosure == null || falseClosure == null) {
|
if (trueClosure == null || falseClosure == null) {
|
||||||
throw new NullPointerException("Closures must not be null");
|
throw new NullPointerException("Closures must not be null");
|
||||||
}
|
}
|
||||||
return new IfClosure<E>(predicate, trueClosure, falseClosure);
|
return new IfClosure<>(predicate, trueClosure, falseClosure);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -64,7 +64,7 @@ public class IfTransformer<I, O> implements Transformer<I, O>, Serializable {
|
||||||
throw new NullPointerException("Transformers must not be null");
|
throw new NullPointerException("Transformers must not be null");
|
||||||
}
|
}
|
||||||
|
|
||||||
return new IfTransformer<I, O>(predicate, trueTransformer, falseTransformer);
|
return new IfTransformer<>(predicate, trueTransformer, falseTransformer);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -90,7 +90,7 @@ public class IfTransformer<I, O> implements Transformer<I, O>, Serializable {
|
||||||
throw new NullPointerException("Transformer must not be null");
|
throw new NullPointerException("Transformer must not be null");
|
||||||
}
|
}
|
||||||
|
|
||||||
return new IfTransformer<T, T>(predicate, trueTransformer, NOPTransformer.<T>nopTransformer());
|
return new IfTransformer<>(predicate, trueTransformer, NOPTransformer.<T>nopTransformer());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -68,9 +68,9 @@ public class InstantiateFactory<T> implements Factory<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (paramTypes == null || paramTypes.length == 0) {
|
if (paramTypes == null || paramTypes.length == 0) {
|
||||||
return new InstantiateFactory<T>(classToInstantiate);
|
return new InstantiateFactory<>(classToInstantiate);
|
||||||
}
|
}
|
||||||
return new InstantiateFactory<T>(classToInstantiate, paramTypes, args);
|
return new InstantiateFactory<>(classToInstantiate, paramTypes, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -37,7 +37,7 @@ public class InstantiateTransformer<T> implements Transformer<Class<? extends T>
|
||||||
|
|
||||||
/** Singleton instance that uses the no arg constructor */
|
/** Singleton instance that uses the no arg constructor */
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
private static final Transformer NO_ARG_INSTANCE = new InstantiateTransformer<Object>();
|
private static final Transformer NO_ARG_INSTANCE = new InstantiateTransformer<>();
|
||||||
|
|
||||||
/** The constructor parameter types */
|
/** The constructor parameter types */
|
||||||
private final Class<?>[] iParamTypes;
|
private final Class<?>[] iParamTypes;
|
||||||
|
@ -73,9 +73,9 @@ public class InstantiateTransformer<T> implements Transformer<Class<? extends T>
|
||||||
}
|
}
|
||||||
|
|
||||||
if (paramTypes == null || paramTypes.length == 0) {
|
if (paramTypes == null || paramTypes.length == 0) {
|
||||||
return new InstantiateTransformer<T>();
|
return new InstantiateTransformer<>();
|
||||||
}
|
}
|
||||||
return new InstantiateTransformer<T>(paramTypes, args);
|
return new InstantiateTransformer<>(paramTypes, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -56,7 +56,7 @@ public class InvokerTransformer<I, O> implements Transformer<I, O> {
|
||||||
if (methodName == null) {
|
if (methodName == null) {
|
||||||
throw new NullPointerException("The method to invoke must not be null");
|
throw new NullPointerException("The method to invoke must not be null");
|
||||||
}
|
}
|
||||||
return new InvokerTransformer<I, O>(methodName);
|
return new InvokerTransformer<>(methodName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -82,9 +82,9 @@ public class InvokerTransformer<I, O> implements Transformer<I, O> {
|
||||||
throw new IllegalArgumentException("The parameter types must match the arguments");
|
throw new IllegalArgumentException("The parameter types must match the arguments");
|
||||||
}
|
}
|
||||||
if (paramTypes == null || paramTypes.length == 0) {
|
if (paramTypes == null || paramTypes.length == 0) {
|
||||||
return new InvokerTransformer<I, O>(methodName);
|
return new InvokerTransformer<>(methodName);
|
||||||
}
|
}
|
||||||
return new InvokerTransformer<I, O>(methodName, paramTypes, args);
|
return new InvokerTransformer<>(methodName, paramTypes, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -50,7 +50,7 @@ public final class MapTransformer<I, O> implements Transformer<I, O>, Serializab
|
||||||
if (map == null) {
|
if (map == null) {
|
||||||
return ConstantTransformer.<I, O>nullTransformer();
|
return ConstantTransformer.<I, O>nullTransformer();
|
||||||
}
|
}
|
||||||
return new MapTransformer<I, O>(map);
|
return new MapTransformer<>(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -33,7 +33,7 @@ public final class NOPClosure<E> implements Closure<E>, Serializable {
|
||||||
|
|
||||||
/** Singleton predicate instance */
|
/** Singleton predicate instance */
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
public static final Closure INSTANCE = new NOPClosure<Object>();
|
public static final Closure INSTANCE = new NOPClosure<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Factory returning the singleton instance.
|
* Factory returning the singleton instance.
|
||||||
|
|
|
@ -33,7 +33,7 @@ public class NOPTransformer<T> implements Transformer<T, T>, Serializable {
|
||||||
|
|
||||||
/** Singleton predicate instance */
|
/** Singleton predicate instance */
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
public static final Transformer INSTANCE = new NOPTransformer<Object>();
|
public static final Transformer INSTANCE = new NOPTransformer<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Factory returning the singleton instance.
|
* Factory returning the singleton instance.
|
||||||
|
|
|
@ -52,7 +52,7 @@ public final class NonePredicate<T> extends AbstractQuantifierPredicate<T> {
|
||||||
if (predicates.length == 0) {
|
if (predicates.length == 0) {
|
||||||
return TruePredicate.<T>truePredicate();
|
return TruePredicate.<T>truePredicate();
|
||||||
}
|
}
|
||||||
return new NonePredicate<T>(FunctorUtils.copy(predicates));
|
return new NonePredicate<>(FunctorUtils.copy(predicates));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -71,7 +71,7 @@ public final class NonePredicate<T> extends AbstractQuantifierPredicate<T> {
|
||||||
if (preds.length == 0) {
|
if (preds.length == 0) {
|
||||||
return TruePredicate.<T>truePredicate();
|
return TruePredicate.<T>truePredicate();
|
||||||
}
|
}
|
||||||
return new NonePredicate<T>(preds);
|
return new NonePredicate<>(preds);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -33,7 +33,7 @@ public final class NotNullPredicate<T> implements Predicate<T>, Serializable {
|
||||||
|
|
||||||
/** Singleton predicate instance */
|
/** Singleton predicate instance */
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
public static final Predicate INSTANCE = new NotNullPredicate<Object>();
|
public static final Predicate INSTANCE = new NotNullPredicate<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Factory returning the singleton instance.
|
* Factory returning the singleton instance.
|
||||||
|
|
|
@ -46,7 +46,7 @@ public final class NotPredicate<T> implements PredicateDecorator<T>, Serializabl
|
||||||
if (predicate == null) {
|
if (predicate == null) {
|
||||||
throw new NullPointerException("Predicate must not be null");
|
throw new NullPointerException("Predicate must not be null");
|
||||||
}
|
}
|
||||||
return new NotPredicate<T>(predicate);
|
return new NotPredicate<>(predicate);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -47,7 +47,7 @@ public final class NullIsExceptionPredicate<T> implements PredicateDecorator<T>,
|
||||||
if (predicate == null) {
|
if (predicate == null) {
|
||||||
throw new NullPointerException("Predicate must not be null");
|
throw new NullPointerException("Predicate must not be null");
|
||||||
}
|
}
|
||||||
return new NullIsExceptionPredicate<T>(predicate);
|
return new NullIsExceptionPredicate<>(predicate);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -46,7 +46,7 @@ public final class NullIsFalsePredicate<T> implements PredicateDecorator<T>, Ser
|
||||||
if (predicate == null) {
|
if (predicate == null) {
|
||||||
throw new NullPointerException("Predicate must not be null");
|
throw new NullPointerException("Predicate must not be null");
|
||||||
}
|
}
|
||||||
return new NullIsFalsePredicate<T>(predicate);
|
return new NullIsFalsePredicate<>(predicate);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -46,7 +46,7 @@ public final class NullIsTruePredicate<T> implements PredicateDecorator<T>, Seri
|
||||||
if (predicate == null) {
|
if (predicate == null) {
|
||||||
throw new NullPointerException("Predicate must not be null");
|
throw new NullPointerException("Predicate must not be null");
|
||||||
}
|
}
|
||||||
return new NullIsTruePredicate<T>(predicate);
|
return new NullIsTruePredicate<>(predicate);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -33,7 +33,7 @@ public final class NullPredicate<T> implements Predicate<T>, Serializable {
|
||||||
|
|
||||||
/** Singleton predicate instance */
|
/** Singleton predicate instance */
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
public static final Predicate INSTANCE = new NullPredicate<Object>();
|
public static final Predicate INSTANCE = new NullPredicate<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Factory returning the singleton instance.
|
* Factory returning the singleton instance.
|
||||||
|
|
|
@ -57,7 +57,7 @@ public final class OnePredicate<T> extends AbstractQuantifierPredicate<T> {
|
||||||
if (predicates.length == 1) {
|
if (predicates.length == 1) {
|
||||||
return (Predicate<T>) predicates[0];
|
return (Predicate<T>) predicates[0];
|
||||||
}
|
}
|
||||||
return new OnePredicate<T>(FunctorUtils.copy(predicates));
|
return new OnePredicate<>(FunctorUtils.copy(predicates));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -71,7 +71,7 @@ public final class OnePredicate<T> extends AbstractQuantifierPredicate<T> {
|
||||||
*/
|
*/
|
||||||
public static <T> Predicate<T> onePredicate(final Collection<? extends Predicate<? super T>> predicates) {
|
public static <T> Predicate<T> onePredicate(final Collection<? extends Predicate<? super T>> predicates) {
|
||||||
final Predicate<? super T>[] preds = FunctorUtils.validate(predicates);
|
final Predicate<? super T>[] preds = FunctorUtils.validate(predicates);
|
||||||
return new OnePredicate<T>(preds);
|
return new OnePredicate<>(preds);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -50,7 +50,7 @@ public final class OrPredicate<T> implements PredicateDecorator<T>, Serializable
|
||||||
if (predicate1 == null || predicate2 == null) {
|
if (predicate1 == null || predicate2 == null) {
|
||||||
throw new NullPointerException("Predicate must not be null");
|
throw new NullPointerException("Predicate must not be null");
|
||||||
}
|
}
|
||||||
return new OrPredicate<T>(predicate1, predicate2);
|
return new OrPredicate<>(predicate1, predicate2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -48,7 +48,7 @@ public class PredicateTransformer<T> implements Transformer<T, Boolean>, Seriali
|
||||||
if (predicate == null) {
|
if (predicate == null) {
|
||||||
throw new IllegalArgumentException("Predicate must not be null");
|
throw new IllegalArgumentException("Predicate must not be null");
|
||||||
}
|
}
|
||||||
return new PredicateTransformer<T>(predicate);
|
return new PredicateTransformer<>(predicate);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -67,18 +67,18 @@ public class PrototypeFactory {
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
final Method method = prototype.getClass().getMethod("clone", (Class[]) null);
|
final Method method = prototype.getClass().getMethod("clone", (Class[]) null);
|
||||||
return new PrototypeCloneFactory<T>(prototype, method);
|
return new PrototypeCloneFactory<>(prototype, method);
|
||||||
|
|
||||||
} catch (final NoSuchMethodException ex) {
|
} catch (final NoSuchMethodException ex) {
|
||||||
try {
|
try {
|
||||||
prototype.getClass().getConstructor(new Class<?>[] { prototype.getClass() });
|
prototype.getClass().getConstructor(new Class<?>[] { prototype.getClass() });
|
||||||
return new InstantiateFactory<T>(
|
return new InstantiateFactory<>(
|
||||||
(Class<T>) prototype.getClass(),
|
(Class<T>) prototype.getClass(),
|
||||||
new Class<?>[] { prototype.getClass() },
|
new Class<?>[] { prototype.getClass() },
|
||||||
new Object[] { prototype });
|
new Object[] { prototype });
|
||||||
} catch (final NoSuchMethodException ex2) {
|
} catch (final NoSuchMethodException ex2) {
|
||||||
if (prototype instanceof Serializable) {
|
if (prototype instanceof Serializable) {
|
||||||
return (Factory<T>) new PrototypeSerializationFactory<Serializable>((Serializable) prototype);
|
return (Factory<T>) new PrototypeSerializationFactory<>((Serializable) prototype);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@ public final class StringValueTransformer<T> implements Transformer<T, String>,
|
||||||
private static final long serialVersionUID = 7511110693171758606L;
|
private static final long serialVersionUID = 7511110693171758606L;
|
||||||
|
|
||||||
/** Singleton predicate instance */
|
/** Singleton predicate instance */
|
||||||
private static final Transformer<Object, String> INSTANCE = new StringValueTransformer<Object>();
|
private static final Transformer<Object, String> INSTANCE = new StringValueTransformer<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Factory returning the singleton instance.
|
* Factory returning the singleton instance.
|
||||||
|
|
|
@ -65,7 +65,7 @@ public class SwitchClosure<E> implements Closure<E>, Serializable {
|
||||||
if (predicates.length == 0) {
|
if (predicates.length == 0) {
|
||||||
return (Closure<E>) (defaultClosure == null ? NOPClosure.<E>nopClosure(): defaultClosure);
|
return (Closure<E>) (defaultClosure == null ? NOPClosure.<E>nopClosure(): defaultClosure);
|
||||||
}
|
}
|
||||||
return new SwitchClosure<E>(predicates, closures, defaultClosure);
|
return new SwitchClosure<>(predicates, closures, defaultClosure);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -105,7 +105,7 @@ public class SwitchClosure<E> implements Closure<E>, Serializable {
|
||||||
closures[i] = entry.getValue();
|
closures[i] = entry.getValue();
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
return new SwitchClosure<E>(false, preds, closures, defaultClosure);
|
return new SwitchClosure<>(false, preds, closures, defaultClosure);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -66,7 +66,7 @@ public class SwitchTransformer<I, O> implements Transformer<I, O>, Serializable
|
||||||
return (Transformer<I, O>) (defaultTransformer == null ? ConstantTransformer.<I, O>nullTransformer() :
|
return (Transformer<I, O>) (defaultTransformer == null ? ConstantTransformer.<I, O>nullTransformer() :
|
||||||
defaultTransformer);
|
defaultTransformer);
|
||||||
}
|
}
|
||||||
return new SwitchTransformer<I, O>(predicates, transformers, defaultTransformer);
|
return new SwitchTransformer<>(predicates, transformers, defaultTransformer);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -114,7 +114,7 @@ public class SwitchTransformer<I, O> implements Transformer<I, O>, Serializable
|
||||||
transformers[i] = entry.getValue();
|
transformers[i] = entry.getValue();
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
return new SwitchTransformer<I, O>(false, preds, transformers, defaultTransformer);
|
return new SwitchTransformer<>(false, preds, transformers, defaultTransformer);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -56,7 +56,7 @@ public final class TransformedPredicate<T> implements PredicateDecorator<T>, Ser
|
||||||
if (predicate == null) {
|
if (predicate == null) {
|
||||||
throw new NullPointerException("The predicate to call must not be null");
|
throw new NullPointerException("The predicate to call must not be null");
|
||||||
}
|
}
|
||||||
return new TransformedPredicate<T>(transformer, predicate);
|
return new TransformedPredicate<>(transformer, predicate);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -49,7 +49,7 @@ public class TransformerClosure<E> implements Closure<E>, Serializable {
|
||||||
if (transformer == null) {
|
if (transformer == null) {
|
||||||
return NOPClosure.<E>nopClosure();
|
return NOPClosure.<E>nopClosure();
|
||||||
}
|
}
|
||||||
return new TransformerClosure<E>(transformer);
|
return new TransformerClosure<>(transformer);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -48,7 +48,7 @@ public final class TransformerPredicate<T> implements Predicate<T>, Serializable
|
||||||
if (transformer == null) {
|
if (transformer == null) {
|
||||||
throw new NullPointerException("The transformer to call must not be null");
|
throw new NullPointerException("The transformer to call must not be null");
|
||||||
}
|
}
|
||||||
return new TransformerPredicate<T>(transformer);
|
return new TransformerPredicate<>(transformer);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -33,7 +33,7 @@ public final class TruePredicate<T> implements Predicate<T>, Serializable {
|
||||||
|
|
||||||
/** Singleton predicate instance */
|
/** Singleton predicate instance */
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
public static final Predicate INSTANCE = new TruePredicate<Object>();
|
public static final Predicate INSTANCE = new TruePredicate<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Factory returning the singleton instance.
|
* Factory returning the singleton instance.
|
||||||
|
|
|
@ -35,7 +35,7 @@ public final class UniquePredicate<T> implements Predicate<T>, Serializable {
|
||||||
private static final long serialVersionUID = -3319417438027438040L;
|
private static final long serialVersionUID = -3319417438027438040L;
|
||||||
|
|
||||||
/** The set of previously seen objects */
|
/** The set of previously seen objects */
|
||||||
private final Set<T> iSet = new HashSet<T>();
|
private final Set<T> iSet = new HashSet<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Factory to create the predicate.
|
* Factory to create the predicate.
|
||||||
|
@ -45,7 +45,7 @@ public final class UniquePredicate<T> implements Predicate<T>, Serializable {
|
||||||
* @throws IllegalArgumentException if the predicate is null
|
* @throws IllegalArgumentException if the predicate is null
|
||||||
*/
|
*/
|
||||||
public static <T> Predicate<T> uniquePredicate() {
|
public static <T> Predicate<T> uniquePredicate() {
|
||||||
return new UniquePredicate<T>();
|
return new UniquePredicate<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -58,7 +58,7 @@ public class WhileClosure<E> implements Closure<E> {
|
||||||
if (closure == null) {
|
if (closure == null) {
|
||||||
throw new NullPointerException("Closure must not be null");
|
throw new NullPointerException("Closure must not be null");
|
||||||
}
|
}
|
||||||
return new WhileClosure<E>(predicate, closure, doLoop);
|
return new WhileClosure<>(predicate, closure, doLoop);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -95,7 +95,7 @@ public class CollatingIterator<E> implements Iterator<E> {
|
||||||
* child iterators
|
* child iterators
|
||||||
*/
|
*/
|
||||||
public CollatingIterator(final Comparator<? super E> comp, final int initIterCapacity) {
|
public CollatingIterator(final Comparator<? super E> comp, final int initIterCapacity) {
|
||||||
iterators = new ArrayList<Iterator<? extends E>>(initIterCapacity);
|
iterators = new ArrayList<>(initIterCapacity);
|
||||||
setComparator(comp);
|
setComparator(comp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -289,7 +289,7 @@ public class CollatingIterator<E> implements Iterator<E> {
|
||||||
*/
|
*/
|
||||||
private void start() {
|
private void start() {
|
||||||
if (values == null) {
|
if (values == null) {
|
||||||
values = new ArrayList<E>(iterators.size());
|
values = new ArrayList<>(iterators.size());
|
||||||
valueSet = new BitSet(iterators.size());
|
valueSet = new BitSet(iterators.size());
|
||||||
for (int i = 0; i < iterators.size(); i++) {
|
for (int i = 0; i < iterators.size(); i++) {
|
||||||
values.add(null);
|
values.add(null);
|
||||||
|
|
|
@ -37,7 +37,7 @@ public class EmptyIterator<E> extends AbstractEmptyIterator<E> implements Resett
|
||||||
* @since 3.1
|
* @since 3.1
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
public static final ResettableIterator RESETTABLE_INSTANCE = new EmptyIterator<Object>();
|
public static final ResettableIterator RESETTABLE_INSTANCE = new EmptyIterator<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Singleton instance of the iterator.
|
* Singleton instance of the iterator.
|
||||||
|
|
|
@ -38,7 +38,7 @@ public class EmptyListIterator<E> extends AbstractEmptyIterator<E> implements
|
||||||
* @since 3.1
|
* @since 3.1
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
public static final ResettableListIterator RESETTABLE_INSTANCE = new EmptyListIterator<Object>();
|
public static final ResettableListIterator RESETTABLE_INSTANCE = new EmptyListIterator<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Singleton instance of the iterator.
|
* Singleton instance of the iterator.
|
||||||
|
|
|
@ -33,7 +33,7 @@ public class EmptyMapIterator<K, V> extends AbstractEmptyMapIterator<K, V> imple
|
||||||
* @since 3.1
|
* @since 3.1
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
public static final MapIterator INSTANCE = new EmptyMapIterator<Object, Object>();
|
public static final MapIterator INSTANCE = new EmptyMapIterator<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a typed instance of the iterator.
|
* Get a typed instance of the iterator.
|
||||||
|
|
|
@ -33,7 +33,7 @@ public class EmptyOrderedIterator<E> extends AbstractEmptyIterator<E>
|
||||||
* @since 3.1
|
* @since 3.1
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
public static final OrderedIterator INSTANCE = new EmptyOrderedIterator<Object>();
|
public static final OrderedIterator INSTANCE = new EmptyOrderedIterator<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Typed instance of the iterator.
|
* Typed instance of the iterator.
|
||||||
|
|
|
@ -33,7 +33,7 @@ public class EmptyOrderedMapIterator<K, V> extends AbstractEmptyMapIterator<K, V
|
||||||
* @since 3.1
|
* @since 3.1
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
public static final OrderedMapIterator INSTANCE = new EmptyOrderedMapIterator<Object, Object>();
|
public static final OrderedMapIterator INSTANCE = new EmptyOrderedMapIterator<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a typed instance of the iterator.
|
* Get a typed instance of the iterator.
|
||||||
|
|
|
@ -51,7 +51,7 @@ import java.util.Queue;
|
||||||
public class IteratorChain<E> implements Iterator<E> {
|
public class IteratorChain<E> implements Iterator<E> {
|
||||||
|
|
||||||
/** The chain of iterators */
|
/** The chain of iterators */
|
||||||
private final Queue<Iterator<? extends E>> iteratorChain = new LinkedList<Iterator<? extends E>>();
|
private final Queue<Iterator<? extends E>> iteratorChain = new LinkedList<>();
|
||||||
|
|
||||||
/** The current iterator */
|
/** The current iterator */
|
||||||
private Iterator<? extends E> currentIterator = null;
|
private Iterator<? extends E> currentIterator = null;
|
||||||
|
|
|
@ -111,7 +111,7 @@ public class IteratorIterable<E> implements Iterable<E> {
|
||||||
public IteratorIterable(final Iterator<? extends E> iterator, final boolean multipleUse) {
|
public IteratorIterable(final Iterator<? extends E> iterator, final boolean multipleUse) {
|
||||||
super();
|
super();
|
||||||
if (multipleUse && !(iterator instanceof ResettableIterator)) {
|
if (multipleUse && !(iterator instanceof ResettableIterator)) {
|
||||||
this.iterator = new ListIteratorWrapper<E>(iterator);
|
this.iterator = new ListIteratorWrapper<>(iterator);
|
||||||
} else {
|
} else {
|
||||||
this.iterator = iterator;
|
this.iterator = iterator;
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,7 +57,7 @@ public class ListIteratorWrapper<E> implements ResettableListIterator<E> {
|
||||||
/** The underlying iterator being decorated. */
|
/** The underlying iterator being decorated. */
|
||||||
private final Iterator<? extends E> iterator;
|
private final Iterator<? extends E> iterator;
|
||||||
/** The list being used to cache the iterator. */
|
/** The list being used to cache the iterator. */
|
||||||
private final List<E> list = new ArrayList<E>();
|
private final List<E> list = new ArrayList<>();
|
||||||
|
|
||||||
/** The current index of this iterator. */
|
/** The current index of this iterator. */
|
||||||
private int currentIndex = 0;
|
private int currentIndex = 0;
|
||||||
|
|
|
@ -77,7 +77,7 @@ import org.apache.commons.collections4.Transformer;
|
||||||
public class ObjectGraphIterator<E> implements Iterator<E> {
|
public class ObjectGraphIterator<E> implements Iterator<E> {
|
||||||
|
|
||||||
/** The stack of iterators */
|
/** The stack of iterators */
|
||||||
private final Deque<Iterator<? extends E>> stack = new ArrayDeque<Iterator<? extends E>>(8);
|
private final Deque<Iterator<? extends E>> stack = new ArrayDeque<>(8);
|
||||||
/** The root object in the tree */
|
/** The root object in the tree */
|
||||||
private E root;
|
private E root;
|
||||||
/** The transformer to use */
|
/** The transformer to use */
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue