[COLLECTIONS-251] improving static factory methods for static importability, conistency
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/collections/trunk@1148801 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
4499cf0862
commit
5a2fc90746
|
@ -45,12 +45,12 @@ public class BagUtils {
|
||||||
/**
|
/**
|
||||||
* An empty unmodifiable bag.
|
* An empty unmodifiable bag.
|
||||||
*/
|
*/
|
||||||
public static final Bag<Object> EMPTY_BAG = UnmodifiableBag.decorate(new HashBag<Object>());
|
public static final Bag<Object> EMPTY_BAG = UnmodifiableBag.unmodifiableBag(new HashBag<Object>());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An empty unmodifiable sorted bag.
|
* An empty unmodifiable sorted bag.
|
||||||
*/
|
*/
|
||||||
public static final Bag<Object> EMPTY_SORTED_BAG = UnmodifiableSortedBag.decorate(new TreeBag<Object>());
|
public static final Bag<Object> EMPTY_SORTED_BAG = UnmodifiableSortedBag.unmodifiableSortedBag(new TreeBag<Object>());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiation of BagUtils is not intended or required. However, some
|
* Instantiation of BagUtils is not intended or required. However, some
|
||||||
|
@ -86,7 +86,7 @@ public class BagUtils {
|
||||||
* @throws IllegalArgumentException if the Bag is null
|
* @throws IllegalArgumentException if the Bag is null
|
||||||
*/
|
*/
|
||||||
public static <E> Bag<E> synchronizedBag(Bag<E> bag) {
|
public static <E> Bag<E> synchronizedBag(Bag<E> bag) {
|
||||||
return SynchronizedBag.decorate(bag);
|
return SynchronizedBag.synchronizedBag(bag);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -99,7 +99,7 @@ public class BagUtils {
|
||||||
* @throws IllegalArgumentException if the Bag is null
|
* @throws IllegalArgumentException if the Bag is null
|
||||||
*/
|
*/
|
||||||
public static <E> Bag<E> unmodifiableBag(Bag<E> bag) {
|
public static <E> Bag<E> unmodifiableBag(Bag<E> bag) {
|
||||||
return UnmodifiableBag.decorate(bag);
|
return UnmodifiableBag.unmodifiableBag(bag);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -117,7 +117,7 @@ public class BagUtils {
|
||||||
* @throws IllegalArgumentException if the Bag or Predicate is null
|
* @throws IllegalArgumentException if the Bag or Predicate is null
|
||||||
*/
|
*/
|
||||||
public static <E> Bag<E> predicatedBag(Bag<E> bag, Predicate<? super E> predicate) {
|
public static <E> Bag<E> predicatedBag(Bag<E> bag, Predicate<? super E> predicate) {
|
||||||
return PredicatedBag.decorate(bag, predicate);
|
return PredicatedBag.predicatedBag(bag, predicate);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -128,15 +128,15 @@ public class BagUtils {
|
||||||
* as it is a backdoor for adding untransformed objects.
|
* as it is a backdoor for adding untransformed objects.
|
||||||
* <p>
|
* <p>
|
||||||
* Existing entries in the specified bag will not be transformed.
|
* Existing entries in the specified bag will not be transformed.
|
||||||
* If you want that behaviour, see {@link TransformedBag#decorateTransform}.
|
* If you want that behaviour, see {@link TransformedBag#transformedBag(Bag, Transformer)}.
|
||||||
*
|
*
|
||||||
* @param bag the bag to predicate, must not be null
|
* @param bag the bag to predicate, must not be null
|
||||||
* @param transformer the transformer for the bag, must not be null
|
* @param transformer the transformer for the bag, must not be null
|
||||||
* @return a transformed bag backed by the given bag
|
* @return a transformed bag backed by the given bag
|
||||||
* @throws IllegalArgumentException if the Bag or Transformer is null
|
* @throws IllegalArgumentException if the Bag or Transformer is null
|
||||||
*/
|
*/
|
||||||
public static <E> Bag<E> transformedBag(Bag<E> bag, Transformer<? super E, ? extends E> transformer) {
|
public static <E> Bag<E> transformingBag(Bag<E> bag, Transformer<? super E, ? extends E> transformer) {
|
||||||
return TransformedBag.decorate(bag, transformer);
|
return TransformedBag.transformingBag(bag, transformer);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
|
@ -166,7 +166,7 @@ public class BagUtils {
|
||||||
* @throws IllegalArgumentException if the SortedBag is null
|
* @throws IllegalArgumentException if the SortedBag is null
|
||||||
*/
|
*/
|
||||||
public static <E> SortedBag<E> synchronizedSortedBag(SortedBag<E> bag) {
|
public static <E> SortedBag<E> synchronizedSortedBag(SortedBag<E> bag) {
|
||||||
return SynchronizedSortedBag.decorate(bag);
|
return SynchronizedSortedBag.synchronizedSortedBag(bag);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -180,7 +180,7 @@ public class BagUtils {
|
||||||
* @throws IllegalArgumentException if the SortedBag is null
|
* @throws IllegalArgumentException if the SortedBag is null
|
||||||
*/
|
*/
|
||||||
public static <E> SortedBag<E> unmodifiableSortedBag(SortedBag<E> bag) {
|
public static <E> SortedBag<E> unmodifiableSortedBag(SortedBag<E> bag) {
|
||||||
return UnmodifiableSortedBag.decorate(bag);
|
return UnmodifiableSortedBag.unmodifiableSortedBag(bag);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -200,7 +200,7 @@ public class BagUtils {
|
||||||
*/
|
*/
|
||||||
public static <E> SortedBag<E> predicatedSortedBag(SortedBag<E> bag,
|
public static <E> SortedBag<E> predicatedSortedBag(SortedBag<E> bag,
|
||||||
Predicate<? super E> predicate) {
|
Predicate<? super E> predicate) {
|
||||||
return PredicatedSortedBag.decorate(bag, predicate);
|
return PredicatedSortedBag.predicatedSortedBag(bag, predicate);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -211,15 +211,15 @@ public class BagUtils {
|
||||||
* as it is a backdoor for adding untransformed objects.
|
* as it is a backdoor for adding untransformed objects.
|
||||||
* <p>
|
* <p>
|
||||||
* Existing entries in the specified bag will not be transformed.
|
* Existing entries in the specified bag will not be transformed.
|
||||||
* If you want that behaviour, see {@link TransformedSortedBag#decorateTransform}.
|
* If you want that behaviour, see {@link TransformedSortedBag#transformedSortedBag(SortedBag, Transformer)}.
|
||||||
*
|
*
|
||||||
* @param bag the bag to predicate, must not be null
|
* @param bag the bag to predicate, must not be null
|
||||||
* @param transformer the transformer for the bag, must not be null
|
* @param transformer the transformer for the bag, must not be null
|
||||||
* @return a transformed bag backed by the given bag
|
* @return a transformed bag backed by the given bag
|
||||||
* @throws IllegalArgumentException if the Bag or Transformer is null
|
* @throws IllegalArgumentException if the Bag or Transformer is null
|
||||||
*/
|
*/
|
||||||
public static <E> SortedBag<E> transformedSortedBag(SortedBag<E> bag, Transformer<? super E, ? extends E> transformer) {
|
public static <E> SortedBag<E> transformingSortedBag(SortedBag<E> bag, Transformer<? super E, ? extends E> transformer) {
|
||||||
return TransformedSortedBag.decorate(bag, transformer);
|
return TransformedSortedBag.transformingSortedBag(bag, transformer);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -37,7 +37,7 @@ public class BufferUtils {
|
||||||
/**
|
/**
|
||||||
* An empty unmodifiable buffer.
|
* An empty unmodifiable buffer.
|
||||||
*/
|
*/
|
||||||
public static final Buffer<Object> EMPTY_BUFFER = UnmodifiableBuffer.decorate(new ArrayStack<Object>(1));
|
public static final Buffer<Object> EMPTY_BUFFER = UnmodifiableBuffer.unmodifiableBuffer(new ArrayStack<Object>(1));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <code>BufferUtils</code> should not normally be instantiated.
|
* <code>BufferUtils</code> should not normally be instantiated.
|
||||||
|
@ -67,7 +67,7 @@ public class BufferUtils {
|
||||||
* @throws IllegalArgumentException if the Buffer is null
|
* @throws IllegalArgumentException if the Buffer is null
|
||||||
*/
|
*/
|
||||||
public static <E> Buffer<E> synchronizedBuffer(Buffer<E> buffer) {
|
public static <E> Buffer<E> synchronizedBuffer(Buffer<E> buffer) {
|
||||||
return SynchronizedBuffer.decorate(buffer);
|
return SynchronizedBuffer.synchronizedBuffer(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -83,7 +83,7 @@ public class BufferUtils {
|
||||||
* @throws IllegalArgumentException if the Buffer is null
|
* @throws IllegalArgumentException if the Buffer is null
|
||||||
*/
|
*/
|
||||||
public static <E> Buffer<E> blockingBuffer(Buffer<E> buffer) {
|
public static <E> Buffer<E> blockingBuffer(Buffer<E> buffer) {
|
||||||
return BlockingBuffer.decorate(buffer);
|
return BlockingBuffer.blockingBuffer(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -101,7 +101,7 @@ public class BufferUtils {
|
||||||
* @since Commons Collections 3.2
|
* @since Commons Collections 3.2
|
||||||
*/
|
*/
|
||||||
public static <E> Buffer<E> blockingBuffer(Buffer<E> buffer, long timeoutMillis) {
|
public static <E> Buffer<E> blockingBuffer(Buffer<E> buffer, long timeoutMillis) {
|
||||||
return BlockingBuffer.decorate(buffer, timeoutMillis);
|
return BlockingBuffer.blockingBuffer(buffer, timeoutMillis);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -118,7 +118,7 @@ public class BufferUtils {
|
||||||
* @since Commons Collections 3.2
|
* @since Commons Collections 3.2
|
||||||
*/
|
*/
|
||||||
public static <E> Buffer<E> boundedBuffer(Buffer<E> buffer, int maximumSize) {
|
public static <E> Buffer<E> boundedBuffer(Buffer<E> buffer, int maximumSize) {
|
||||||
return BoundedBuffer.decorate(buffer, maximumSize);
|
return BoundedBuffer.boundedBuffer(buffer, maximumSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -136,7 +136,7 @@ public class BufferUtils {
|
||||||
* @since Commons Collections 3.2
|
* @since Commons Collections 3.2
|
||||||
*/
|
*/
|
||||||
public static <E> Buffer<E> boundedBuffer(Buffer<E> buffer, int maximumSize, long timeoutMillis) {
|
public static <E> Buffer<E> boundedBuffer(Buffer<E> buffer, int maximumSize, long timeoutMillis) {
|
||||||
return BoundedBuffer.decorate(buffer, maximumSize, timeoutMillis);
|
return BoundedBuffer.boundedBuffer(buffer, maximumSize, timeoutMillis);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -147,7 +147,7 @@ public class BufferUtils {
|
||||||
* @throws IllegalArgumentException if the Buffer is null
|
* @throws IllegalArgumentException if the Buffer is null
|
||||||
*/
|
*/
|
||||||
public static <E> Buffer<E> unmodifiableBuffer(Buffer<E> buffer) {
|
public static <E> Buffer<E> unmodifiableBuffer(Buffer<E> buffer) {
|
||||||
return UnmodifiableBuffer.decorate(buffer);
|
return UnmodifiableBuffer.unmodifiableBuffer(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -164,7 +164,7 @@ public class BufferUtils {
|
||||||
* @throws IllegalArgumentException if the Buffer or Predicate is null
|
* @throws IllegalArgumentException if the Buffer or Predicate is null
|
||||||
*/
|
*/
|
||||||
public static <E> Buffer<E> predicatedBuffer(Buffer<E> buffer, Predicate<? super E> predicate) {
|
public static <E> Buffer<E> predicatedBuffer(Buffer<E> buffer, Predicate<? super E> predicate) {
|
||||||
return PredicatedBuffer.decorate(buffer, predicate);
|
return PredicatedBuffer.predicatedBuffer(buffer, predicate);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -182,8 +182,8 @@ public class BufferUtils {
|
||||||
* @return a transformed buffer backed by the given buffer
|
* @return a transformed buffer backed by the given buffer
|
||||||
* @throws IllegalArgumentException if the Buffer or Transformer is null
|
* @throws IllegalArgumentException if the Buffer or Transformer is null
|
||||||
*/
|
*/
|
||||||
public static <E> Buffer<E> transformedBuffer(Buffer<E> buffer, Transformer<? super E, ? extends E> transformer) {
|
public static <E> Buffer<E> transformingBuffer(Buffer<E> buffer, Transformer<? super E, ? extends E> transformer) {
|
||||||
return TransformedBuffer.decorate(buffer, transformer);
|
return TransformedBuffer.transformingBuffer(buffer, transformer);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -71,7 +71,7 @@ public class ClosureUtils {
|
||||||
* @return the closure
|
* @return the closure
|
||||||
*/
|
*/
|
||||||
public static <E> Closure<E> exceptionClosure() {
|
public static <E> Closure<E> exceptionClosure() {
|
||||||
return ExceptionClosure.<E>getInstance();
|
return ExceptionClosure.<E>exceptionClosure();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -83,7 +83,7 @@ public class ClosureUtils {
|
||||||
* @return the closure
|
* @return the closure
|
||||||
*/
|
*/
|
||||||
public static <E> Closure<E> nopClosure() {
|
public static <E> Closure<E> nopClosure() {
|
||||||
return NOPClosure.<E>getInstance();
|
return NOPClosure.<E>nopClosure();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -97,7 +97,7 @@ public class ClosureUtils {
|
||||||
* @return the closure
|
* @return the closure
|
||||||
*/
|
*/
|
||||||
public static <E> Closure<E> asClosure(Transformer<? super E, ?> transformer) {
|
public static <E> Closure<E> asClosure(Transformer<? super E, ?> transformer) {
|
||||||
return TransformerClosure.getInstance(transformer);
|
return TransformerClosure.transformerClosure(transformer);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -112,7 +112,7 @@ public class ClosureUtils {
|
||||||
* @return the <code>for</code> closure
|
* @return the <code>for</code> closure
|
||||||
*/
|
*/
|
||||||
public static <E> Closure<E> forClosure(int count, Closure<? super E> closure) {
|
public static <E> Closure<E> forClosure(int count, Closure<? super E> closure) {
|
||||||
return ForClosure.getInstance(count, closure);
|
return ForClosure.forClosure(count, closure);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -127,7 +127,7 @@ public class ClosureUtils {
|
||||||
* @throws IllegalArgumentException if either argument is null
|
* @throws IllegalArgumentException if either argument is null
|
||||||
*/
|
*/
|
||||||
public static <E> Closure<E> whileClosure(Predicate<? super E> predicate, Closure<? super E> closure) {
|
public static <E> Closure<E> whileClosure(Predicate<? super E> predicate, Closure<? super E> closure) {
|
||||||
return WhileClosure.<E>getInstance(predicate, closure, false);
|
return WhileClosure.<E>whileClosure(predicate, closure, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -142,7 +142,7 @@ public class ClosureUtils {
|
||||||
* @throws IllegalArgumentException if either argument is null
|
* @throws IllegalArgumentException if either argument is null
|
||||||
*/
|
*/
|
||||||
public static <E> Closure<E> doWhileClosure(Closure<? super E> closure, Predicate<? super E> predicate) {
|
public static <E> Closure<E> doWhileClosure(Closure<? super E> closure, Predicate<? super E> predicate) {
|
||||||
return WhileClosure.<E>getInstance(predicate, closure, true);
|
return WhileClosure.<E>whileClosure(predicate, closure, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -158,7 +158,7 @@ public class ClosureUtils {
|
||||||
*/
|
*/
|
||||||
public static <E> Closure<E> invokerClosure(String methodName) {
|
public static <E> Closure<E> invokerClosure(String methodName) {
|
||||||
// reuse transformer as it has caching - this is lazy really, should have inner class here
|
// reuse transformer as it has caching - this is lazy really, should have inner class here
|
||||||
return asClosure(InvokerTransformer.<E, Object>getInstance(methodName));
|
return asClosure(InvokerTransformer.<E, Object>invokerTransformer(methodName));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -177,7 +177,7 @@ public class ClosureUtils {
|
||||||
*/
|
*/
|
||||||
public static <E> Closure<E> invokerClosure(String methodName, Class<?>[] paramTypes, Object[] args) {
|
public static <E> Closure<E> invokerClosure(String methodName, Class<?>[] paramTypes, Object[] args) {
|
||||||
// reuse transformer as it has caching - this is lazy really, should have inner class here
|
// reuse transformer as it has caching - this is lazy really, should have inner class here
|
||||||
return asClosure(InvokerTransformer.<E, Object>getInstance(methodName, paramTypes, args));
|
return asClosure(InvokerTransformer.<E, Object>invokerTransformer(methodName, paramTypes, args));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -192,7 +192,7 @@ public class ClosureUtils {
|
||||||
* @throws IllegalArgumentException if either closure is null
|
* @throws IllegalArgumentException if either closure is null
|
||||||
*/
|
*/
|
||||||
public static <E> Closure<E> chainedClosure(Closure<? super E> closure1, Closure<? super E> closure2) {
|
public static <E> Closure<E> chainedClosure(Closure<? super E> closure1, Closure<? super E> closure2) {
|
||||||
return ChainedClosure.<E>getInstance(closure1, closure2);
|
return ChainedClosure.<E>chainedClosure(closure1, closure2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -207,7 +207,7 @@ public class ClosureUtils {
|
||||||
* @throws IllegalArgumentException if any closure in the array is null
|
* @throws IllegalArgumentException if any closure in the array is null
|
||||||
*/
|
*/
|
||||||
public static <E> Closure<E> chainedClosure(Closure<? super E>[] closures) {
|
public static <E> Closure<E> chainedClosure(Closure<? super E>[] closures) {
|
||||||
return ChainedClosure.getInstance(closures);
|
return ChainedClosure.chainedClosure(closures);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -224,7 +224,7 @@ public class ClosureUtils {
|
||||||
* @throws IllegalArgumentException if any closure in the collection is null
|
* @throws IllegalArgumentException if any closure in the collection is null
|
||||||
*/
|
*/
|
||||||
public static <E> Closure<E> chainedClosure(Collection<Closure<E>> closures) {
|
public static <E> Closure<E> chainedClosure(Collection<Closure<E>> closures) {
|
||||||
return ChainedClosure.getInstance(closures);
|
return ChainedClosure.chainedClosure(closures);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -241,7 +241,7 @@ public class ClosureUtils {
|
||||||
* @since Commons Collections 3.2
|
* @since Commons Collections 3.2
|
||||||
*/
|
*/
|
||||||
public static <E> Closure<E> ifClosure(Predicate<? super E> predicate, Closure<? super E> trueClosure) {
|
public static <E> Closure<E> ifClosure(Predicate<? super E> predicate, Closure<? super E> trueClosure) {
|
||||||
return IfClosure.<E>getInstance(predicate, trueClosure);
|
return IfClosure.<E>ifClosure(predicate, trueClosure);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -258,7 +258,7 @@ public class ClosureUtils {
|
||||||
* @throws IllegalArgumentException if either closure is null
|
* @throws IllegalArgumentException if either closure is null
|
||||||
*/
|
*/
|
||||||
public static <E> Closure<E> ifClosure(Predicate<? super E> predicate, Closure<? super E> trueClosure, Closure<? super E> falseClosure) {
|
public static <E> Closure<E> ifClosure(Predicate<? super E> predicate, Closure<? super E> trueClosure, Closure<? super E> falseClosure) {
|
||||||
return IfClosure.<E>getInstance(predicate, trueClosure, falseClosure);
|
return IfClosure.<E>ifClosure(predicate, trueClosure, falseClosure);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -279,7 +279,7 @@ public class ClosureUtils {
|
||||||
* @throws IllegalArgumentException if the arrays are different sizes
|
* @throws IllegalArgumentException if the arrays are different sizes
|
||||||
*/
|
*/
|
||||||
public static <E> Closure<E> switchClosure(Predicate<? super E>[] predicates, Closure<? super E>[] closures) {
|
public static <E> Closure<E> switchClosure(Predicate<? super E>[] predicates, Closure<? super E>[] closures) {
|
||||||
return SwitchClosure.<E>getInstance(predicates, closures, null);
|
return SwitchClosure.<E>switchClosure(predicates, closures, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -302,7 +302,7 @@ public class ClosureUtils {
|
||||||
* @throws IllegalArgumentException if the arrays are different sizes
|
* @throws IllegalArgumentException if the arrays are different sizes
|
||||||
*/
|
*/
|
||||||
public static <E> Closure<E> switchClosure(Predicate<? super E>[] predicates, Closure<? super E>[] closures, Closure<? super E> defaultClosure) {
|
public static <E> Closure<E> switchClosure(Predicate<? super E>[] predicates, Closure<? super E>[] closures, Closure<? super E> defaultClosure) {
|
||||||
return SwitchClosure.<E>getInstance(predicates, closures, defaultClosure);
|
return SwitchClosure.<E>switchClosure(predicates, closures, defaultClosure);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -326,7 +326,7 @@ public class ClosureUtils {
|
||||||
* @throws ClassCastException if the map elements are of the wrong type
|
* @throws ClassCastException if the map elements are of the wrong type
|
||||||
*/
|
*/
|
||||||
public static <E> Closure<E> switchClosure(Map<Predicate<E>, Closure<E>> predicatesAndClosures) {
|
public static <E> Closure<E> switchClosure(Map<Predicate<E>, Closure<E>> predicatesAndClosures) {
|
||||||
return SwitchClosure.getInstance(predicatesAndClosures);
|
return SwitchClosure.switchClosure(predicatesAndClosures);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -128,7 +128,7 @@ public class CollectionUtils {
|
||||||
* this purpose. However they could be cast to Set or List which might be
|
* this purpose. However they could be cast to Set or List which might be
|
||||||
* undesirable. This implementation only implements Collection.
|
* undesirable. This implementation only implements Collection.
|
||||||
*/
|
*/
|
||||||
public static final Collection EMPTY_COLLECTION = UnmodifiableCollection.decorate(new ArrayList<Object>());
|
public static final Collection EMPTY_COLLECTION = UnmodifiableCollection.unmodifiableCollection(new ArrayList<Object>());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <code>CollectionUtils</code> should not normally be instantiated.
|
* <code>CollectionUtils</code> should not normally be instantiated.
|
||||||
|
@ -1167,7 +1167,7 @@ public class CollectionUtils {
|
||||||
return ((BoundedCollection<?>) coll).isFull();
|
return ((BoundedCollection<?>) coll).isFull();
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
BoundedCollection<?> bcoll = UnmodifiableBoundedCollection.decorateUsing((Collection<Object>) coll);
|
BoundedCollection<?> bcoll = UnmodifiableBoundedCollection.unmodifiableBoundedCollection((Collection<Object>) coll);
|
||||||
return bcoll.isFull();
|
return bcoll.isFull();
|
||||||
} catch (IllegalArgumentException ex) {
|
} catch (IllegalArgumentException ex) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -1198,7 +1198,7 @@ public class CollectionUtils {
|
||||||
return ((BoundedCollection<?>) coll).maxSize();
|
return ((BoundedCollection<?>) coll).maxSize();
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
BoundedCollection<?> bcoll = UnmodifiableBoundedCollection.decorateUsing((Collection<Object>) coll);
|
BoundedCollection<?> bcoll = UnmodifiableBoundedCollection.unmodifiableBoundedCollection((Collection<Object>) coll);
|
||||||
return bcoll.maxSize();
|
return bcoll.maxSize();
|
||||||
} catch (IllegalArgumentException ex) {
|
} catch (IllegalArgumentException ex) {
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -1269,7 +1269,7 @@ public class CollectionUtils {
|
||||||
* @throws IllegalArgumentException if the collection is null
|
* @throws IllegalArgumentException if the collection is null
|
||||||
*/
|
*/
|
||||||
public static <C> Collection<C> synchronizedCollection(Collection<C> collection) {
|
public static <C> Collection<C> synchronizedCollection(Collection<C> collection) {
|
||||||
return SynchronizedCollection.decorate(collection);
|
return SynchronizedCollection.synchronizedCollection(collection);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1282,7 +1282,7 @@ public class CollectionUtils {
|
||||||
* @throws IllegalArgumentException if the collection is null
|
* @throws IllegalArgumentException if the collection is null
|
||||||
*/
|
*/
|
||||||
public static <C> Collection<C> unmodifiableCollection(Collection<C> collection) {
|
public static <C> Collection<C> unmodifiableCollection(Collection<C> collection) {
|
||||||
return UnmodifiableCollection.decorate(collection);
|
return UnmodifiableCollection.unmodifiableCollection(collection);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1300,7 +1300,7 @@ public class CollectionUtils {
|
||||||
* @throws IllegalArgumentException if the Collection is null
|
* @throws IllegalArgumentException if the Collection is null
|
||||||
*/
|
*/
|
||||||
public static <C> Collection<C> predicatedCollection(Collection<C> collection, Predicate<? super C> predicate) {
|
public static <C> Collection<C> predicatedCollection(Collection<C> collection, Predicate<? super C> predicate) {
|
||||||
return PredicatedCollection.decorate(collection, predicate);
|
return PredicatedCollection.predicatedCollection(collection, predicate);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1318,8 +1318,8 @@ public class CollectionUtils {
|
||||||
* @return a transformed collection backed by the given collection
|
* @return a transformed collection backed by the given collection
|
||||||
* @throws IllegalArgumentException if the Collection or Transformer is null
|
* @throws IllegalArgumentException if the Collection or Transformer is null
|
||||||
*/
|
*/
|
||||||
public static <E> Collection<E> transformedCollection(Collection<E> collection, Transformer<? super E, ? extends E> transformer) {
|
public static <E> Collection<E> transformingCollection(Collection<E> collection, Transformer<? super E, ? extends E> transformer) {
|
||||||
return TransformedCollection.decorate(collection, transformer);
|
return TransformedCollection.transformingCollection(collection, transformer);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -55,7 +55,7 @@ public class ComparatorUtils {
|
||||||
* @see ComparableComparator#getInstance
|
* @see ComparableComparator#getInstance
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static final Comparator NATURAL_COMPARATOR = ComparableComparator.<Comparable>getInstance();
|
public static final Comparator NATURAL_COMPARATOR = ComparableComparator.<Comparable>comparableComparator();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a comparator that uses the natural order of the objects.
|
* Gets a comparator that uses the natural order of the objects.
|
||||||
|
@ -145,7 +145,7 @@ public class ComparatorUtils {
|
||||||
* @return a comparator that sorts booleans
|
* @return a comparator that sorts booleans
|
||||||
*/
|
*/
|
||||||
public static Comparator<Boolean> booleanComparator(boolean trueFirst) {
|
public static Comparator<Boolean> booleanComparator(boolean trueFirst) {
|
||||||
return BooleanComparator.getBooleanComparator(trueFirst);
|
return BooleanComparator.booleanComparator(trueFirst);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -56,7 +56,7 @@ public class FactoryUtils {
|
||||||
* @return the factory
|
* @return the factory
|
||||||
*/
|
*/
|
||||||
public static <T> Factory<T> exceptionFactory() {
|
public static <T> Factory<T> exceptionFactory() {
|
||||||
return ExceptionFactory.<T>getInstance();
|
return ExceptionFactory.<T>exceptionFactory();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -68,7 +68,7 @@ public class FactoryUtils {
|
||||||
* @return the factory
|
* @return the factory
|
||||||
*/
|
*/
|
||||||
public static <T> Factory<T> nullFactory() {
|
public static <T> Factory<T> nullFactory() {
|
||||||
return ConstantFactory.<T>getInstance(null);
|
return ConstantFactory.<T>constantFactory(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -83,7 +83,7 @@ public class FactoryUtils {
|
||||||
* @return the <code>constant</code> factory.
|
* @return the <code>constant</code> factory.
|
||||||
*/
|
*/
|
||||||
public static <T> Factory<T> constantFactory(T constantToReturn) {
|
public static <T> Factory<T> constantFactory(T constantToReturn) {
|
||||||
return ConstantFactory.getInstance(constantToReturn);
|
return ConstantFactory.constantFactory(constantToReturn);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -104,7 +104,7 @@ public class FactoryUtils {
|
||||||
* @throws IllegalArgumentException if the prototype cannot be cloned
|
* @throws IllegalArgumentException if the prototype cannot be cloned
|
||||||
*/
|
*/
|
||||||
public static <T> Factory<T> prototypeFactory(T prototype) {
|
public static <T> Factory<T> prototypeFactory(T prototype) {
|
||||||
return PrototypeFactory.<T>getInstance(prototype);
|
return PrototypeFactory.<T>prototypeFactory(prototype);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -118,7 +118,7 @@ public class FactoryUtils {
|
||||||
* @throws IllegalArgumentException if the classToInstantiate is null
|
* @throws IllegalArgumentException if the classToInstantiate is null
|
||||||
*/
|
*/
|
||||||
public static <T> Factory<T> instantiateFactory(Class<T> classToInstantiate) {
|
public static <T> Factory<T> instantiateFactory(Class<T> classToInstantiate) {
|
||||||
return InstantiateFactory.getInstance(classToInstantiate, null, null);
|
return InstantiateFactory.instantiateFactory(classToInstantiate, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -136,7 +136,7 @@ public class FactoryUtils {
|
||||||
* @throws IllegalArgumentException if the constructor doesn't exist
|
* @throws IllegalArgumentException if the constructor doesn't exist
|
||||||
*/
|
*/
|
||||||
public static <T> Factory<T> instantiateFactory(Class<T> classToInstantiate, Class<?>[] paramTypes, Object[] args) {
|
public static <T> Factory<T> instantiateFactory(Class<T> classToInstantiate, Class<?>[] paramTypes, Object[] args) {
|
||||||
return InstantiateFactory.getInstance(classToInstantiate, paramTypes, args);
|
return InstantiateFactory.instantiateFactory(classToInstantiate, paramTypes, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -127,7 +127,7 @@ public class IteratorUtils {
|
||||||
* @return an iterator over nothing
|
* @return an iterator over nothing
|
||||||
*/
|
*/
|
||||||
public static <E> ResettableIterator<E> emptyIterator() {
|
public static <E> ResettableIterator<E> emptyIterator() {
|
||||||
return EmptyIterator.<E>getResettableInstance();
|
return EmptyIterator.<E>resettableEmptyIterator();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -142,7 +142,7 @@ public class IteratorUtils {
|
||||||
* @return a list iterator over nothing
|
* @return a list iterator over nothing
|
||||||
*/
|
*/
|
||||||
public static <E> ResettableListIterator<E> emptyListIterator() {
|
public static <E> ResettableListIterator<E> emptyListIterator() {
|
||||||
return EmptyListIterator.<E>getResettableInstance();
|
return EmptyListIterator.<E>resettableEmptyListIterator();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -154,7 +154,7 @@ public class IteratorUtils {
|
||||||
* @return an ordered iterator over nothing
|
* @return an ordered iterator over nothing
|
||||||
*/
|
*/
|
||||||
public static <E> OrderedIterator<E> emptyOrderedIterator() {
|
public static <E> OrderedIterator<E> emptyOrderedIterator() {
|
||||||
return EmptyOrderedIterator.<E>getInstance();
|
return EmptyOrderedIterator.<E>emptyOrderedIterator();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -166,7 +166,7 @@ public class IteratorUtils {
|
||||||
* @return a map iterator over nothing
|
* @return a map iterator over nothing
|
||||||
*/
|
*/
|
||||||
public static <K, V> MapIterator<K, V> emptyMapIterator() {
|
public static <K, V> MapIterator<K, V> emptyMapIterator() {
|
||||||
return EmptyMapIterator.<K, V>getInstance();
|
return EmptyMapIterator.<K, V>emptyMapIterator();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -178,7 +178,7 @@ public class IteratorUtils {
|
||||||
* @return a map iterator over nothing
|
* @return a map iterator over nothing
|
||||||
*/
|
*/
|
||||||
public static <K, V> OrderedMapIterator<K, V> emptyOrderedMapIterator() {
|
public static <K, V> OrderedMapIterator<K, V> emptyOrderedMapIterator() {
|
||||||
return EmptyOrderedMapIterator.<K, V>getInstance();
|
return EmptyOrderedMapIterator.<K, V>emptyOrderedMapIterator();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Singleton
|
// Singleton
|
||||||
|
@ -417,7 +417,7 @@ public class IteratorUtils {
|
||||||
* @return an immutable version of the iterator
|
* @return an immutable version of the iterator
|
||||||
*/
|
*/
|
||||||
public static <E> Iterator<E> unmodifiableIterator(Iterator<E> iterator) {
|
public static <E> Iterator<E> unmodifiableIterator(Iterator<E> iterator) {
|
||||||
return UnmodifiableIterator.decorate(iterator);
|
return UnmodifiableIterator.unmodifiableIterator(iterator);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -430,7 +430,7 @@ public class IteratorUtils {
|
||||||
* @return an immutable version of the iterator
|
* @return an immutable version of the iterator
|
||||||
*/
|
*/
|
||||||
public static <E> ListIterator<E> unmodifiableListIterator(ListIterator<E> listIterator) {
|
public static <E> ListIterator<E> unmodifiableListIterator(ListIterator<E> listIterator) {
|
||||||
return UnmodifiableListIterator.decorate(listIterator);
|
return UnmodifiableListIterator.umodifiableListIterator(listIterator);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -442,7 +442,7 @@ public class IteratorUtils {
|
||||||
* @return an immutable version of the iterator
|
* @return an immutable version of the iterator
|
||||||
*/
|
*/
|
||||||
public static <K, V> MapIterator<K, V> unmodifiableMapIterator(MapIterator<K, V> mapIterator) {
|
public static <K, V> MapIterator<K, V> unmodifiableMapIterator(MapIterator<K, V> mapIterator) {
|
||||||
return UnmodifiableMapIterator.decorate(mapIterator);
|
return UnmodifiableMapIterator.unmodifiableMapIterator(mapIterator);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Chained
|
// Chained
|
||||||
|
|
|
@ -299,7 +299,7 @@ public class ListUtils {
|
||||||
* @throws IllegalArgumentException if the list is null
|
* @throws IllegalArgumentException if the list is null
|
||||||
*/
|
*/
|
||||||
public static <E> List<E> synchronizedList(List<E> list) {
|
public static <E> List<E> synchronizedList(List<E> list) {
|
||||||
return SynchronizedList.decorate(list);
|
return SynchronizedList.synchronizedList(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -312,7 +312,7 @@ public class ListUtils {
|
||||||
* @throws IllegalArgumentException if the list is null
|
* @throws IllegalArgumentException if the list is null
|
||||||
*/
|
*/
|
||||||
public static <E> List<E> unmodifiableList(List<E> list) {
|
public static <E> List<E> unmodifiableList(List<E> list) {
|
||||||
return UnmodifiableList.decorate(list);
|
return UnmodifiableList.unmodifiableList(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -329,7 +329,7 @@ public class ListUtils {
|
||||||
* @throws IllegalArgumentException if the List or Predicate is null
|
* @throws IllegalArgumentException if the List or Predicate is null
|
||||||
*/
|
*/
|
||||||
public static <E> List<E> predicatedList(List<E> list, Predicate<E> predicate) {
|
public static <E> List<E> predicatedList(List<E> list, Predicate<E> predicate) {
|
||||||
return PredicatedList.decorate(list, predicate);
|
return PredicatedList.predicatedList(list, predicate);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -352,7 +352,7 @@ public class ListUtils {
|
||||||
* @throws IllegalArgumentException if the List or Transformer is null
|
* @throws IllegalArgumentException if the List or Transformer is null
|
||||||
*/
|
*/
|
||||||
public static <E> List<E> transformedList(List<E> list, Transformer<? super E, ? extends E> transformer) {
|
public static <E> List<E> transformedList(List<E> list, Transformer<? super E, ? extends E> transformer) {
|
||||||
return TransformedList.decorate(list, transformer);
|
return TransformedList.transformingList(list, transformer);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -385,7 +385,7 @@ public class ListUtils {
|
||||||
* @throws IllegalArgumentException if the List or Factory is null
|
* @throws IllegalArgumentException if the List or Factory is null
|
||||||
*/
|
*/
|
||||||
public static <E> List<E> lazyList(List<E> list, Factory<? extends E> factory) {
|
public static <E> List<E> lazyList(List<E> list, Factory<? extends E> factory) {
|
||||||
return LazyList.decorate(list, factory);
|
return LazyList.lazyList(list, factory);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -399,7 +399,7 @@ public class ListUtils {
|
||||||
* @throws IllegalArgumentException if the List is null
|
* @throws IllegalArgumentException if the List is null
|
||||||
*/
|
*/
|
||||||
public static <E> List<E> fixedSizeList(List<E> list) {
|
public static <E> List<E> fixedSizeList(List<E> list) {
|
||||||
return FixedSizeList.decorate(list);
|
return FixedSizeList.fixedSizeList(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -92,13 +92,13 @@ public class MapUtils {
|
||||||
* An empty unmodifiable map.
|
* An empty unmodifiable map.
|
||||||
* This was not provided in JDK1.2.
|
* This was not provided in JDK1.2.
|
||||||
*/
|
*/
|
||||||
public static final Map<Object, Object> EMPTY_MAP = UnmodifiableMap.decorate(new HashMap<Object, Object>(1));
|
public static final Map<Object, Object> EMPTY_MAP = UnmodifiableMap.unmodifiableMap(new HashMap<Object, Object>(1));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An empty unmodifiable sorted map.
|
* An empty unmodifiable sorted map.
|
||||||
* This is not provided in the JDK.
|
* This is not provided in the JDK.
|
||||||
*/
|
*/
|
||||||
public static final SortedMap<Object, Object> EMPTY_SORTED_MAP = UnmodifiableSortedMap.decorate(new TreeMap<Object, Object>());
|
public static final SortedMap<Object, Object> EMPTY_SORTED_MAP = UnmodifiableSortedMap.unmodifiableSortedMap(new TreeMap<Object, Object>());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* String used to indent the verbose and debug Map prints.
|
* String used to indent the verbose and debug Map prints.
|
||||||
|
@ -1239,7 +1239,7 @@ public class MapUtils {
|
||||||
* @throws IllegalArgumentException if the map is null
|
* @throws IllegalArgumentException if the map is null
|
||||||
*/
|
*/
|
||||||
public static <K, V> Map<K, V> unmodifiableMap(Map<K, V> map) {
|
public static <K, V> Map<K, V> unmodifiableMap(Map<K, V> map) {
|
||||||
return UnmodifiableMap.decorate(map);
|
return UnmodifiableMap.unmodifiableMap(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1258,7 +1258,7 @@ public class MapUtils {
|
||||||
* @throws IllegalArgumentException if the Map is null
|
* @throws IllegalArgumentException if the Map is null
|
||||||
*/
|
*/
|
||||||
public static <K, V> IterableMap<K, V> predicatedMap(Map<K, V> map, Predicate<? super K> keyPred, Predicate<? super V> valuePred) {
|
public static <K, V> IterableMap<K, V> predicatedMap(Map<K, V> map, Predicate<? super K> keyPred, Predicate<? super V> valuePred) {
|
||||||
return PredicatedMap.decorate(map, keyPred, valuePred);
|
return PredicatedMap.predicatedMap(map, keyPred, valuePred);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1285,7 +1285,7 @@ public class MapUtils {
|
||||||
public static <K, V> IterableMap<K, V> transformedMap(Map<K, V> map,
|
public static <K, V> IterableMap<K, V> transformedMap(Map<K, V> map,
|
||||||
Transformer<? super K, ? extends K> keyTransformer,
|
Transformer<? super K, ? extends K> keyTransformer,
|
||||||
Transformer<? super V, ? extends V> valueTransformer) {
|
Transformer<? super V, ? extends V> valueTransformer) {
|
||||||
return TransformedMap.decorate(map, keyTransformer, valueTransformer);
|
return TransformedMap.transformingMap(map, keyTransformer, valueTransformer);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1299,7 +1299,7 @@ public class MapUtils {
|
||||||
* @throws IllegalArgumentException if the Map is null
|
* @throws IllegalArgumentException if the Map is null
|
||||||
*/
|
*/
|
||||||
public static <K, V> IterableMap<K, V> fixedSizeMap(Map<K, V> map) {
|
public static <K, V> IterableMap<K, V> fixedSizeMap(Map<K, V> map) {
|
||||||
return FixedSizeMap.decorate(map);
|
return FixedSizeMap.fixedSizeMap(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1331,7 +1331,7 @@ public class MapUtils {
|
||||||
* @throws IllegalArgumentException if the Map or Factory is null
|
* @throws IllegalArgumentException if the Map or Factory is null
|
||||||
*/
|
*/
|
||||||
public static <K, V> IterableMap<K, V> lazyMap(Map<K, V> map, Factory<? extends V> factory) {
|
public static <K, V> IterableMap<K, V> lazyMap(Map<K, V> map, Factory<? extends V> factory) {
|
||||||
return LazyMap.getLazyMap(map, factory);
|
return LazyMap.lazyMap(map, factory);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1370,7 +1370,7 @@ public class MapUtils {
|
||||||
* @throws IllegalArgumentException if the Map or Transformer is null
|
* @throws IllegalArgumentException if the Map or Transformer is null
|
||||||
*/
|
*/
|
||||||
public static <K, V> IterableMap<K, V> lazyMap(Map<K, V> map, Transformer<? super K, ? extends V> transformerFactory) {
|
public static <K, V> IterableMap<K, V> lazyMap(Map<K, V> map, Transformer<? super K, ? extends V> transformerFactory) {
|
||||||
return LazyMap.getLazyMap(map, transformerFactory);
|
return LazyMap.lazyMap(map, transformerFactory);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1385,7 +1385,7 @@ public class MapUtils {
|
||||||
* @throws IllegalArgumentException if the Map is null
|
* @throws IllegalArgumentException if the Map is null
|
||||||
*/
|
*/
|
||||||
public static <K, V> OrderedMap<K, V> orderedMap(Map<K, V> map) {
|
public static <K, V> OrderedMap<K, V> orderedMap(Map<K, V> map) {
|
||||||
return ListOrderedMap.decorate(map);
|
return ListOrderedMap.listOrderedMap(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1398,7 +1398,7 @@ public class MapUtils {
|
||||||
* @since Commons Collections 3.2
|
* @since Commons Collections 3.2
|
||||||
*/
|
*/
|
||||||
public static <K, V> MultiValueMap<K, V> multiValueMap(Map<K, ? super Collection<V>> map) {
|
public static <K, V> MultiValueMap<K, V> multiValueMap(Map<K, ? super Collection<V>> map) {
|
||||||
return MultiValueMap.<K, V>decorate(map);
|
return MultiValueMap.<K, V>multiValueMap(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1413,7 +1413,7 @@ public class MapUtils {
|
||||||
* @since Commons Collections 3.2
|
* @since Commons Collections 3.2
|
||||||
*/
|
*/
|
||||||
public static <K, V, C extends Collection<V>> MultiValueMap<K, V> multiValueMap(Map<K, C> map, Class<C> collectionClass) {
|
public static <K, V, C extends Collection<V>> MultiValueMap<K, V> multiValueMap(Map<K, C> map, Class<C> collectionClass) {
|
||||||
return MultiValueMap.decorate(map, collectionClass);
|
return MultiValueMap.multiValueMap(map, collectionClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1428,7 +1428,7 @@ public class MapUtils {
|
||||||
* @since Commons Collections 3.2
|
* @since Commons Collections 3.2
|
||||||
*/
|
*/
|
||||||
public static <K, V, C extends Collection<V>> MultiValueMap<K, V> multiValueMap(Map<K, C> map, Factory<C> collectionFactory) {
|
public static <K, V, C extends Collection<V>> MultiValueMap<K, V> multiValueMap(Map<K, C> map, Factory<C> collectionFactory) {
|
||||||
return MultiValueMap.decorate(map, collectionFactory);
|
return MultiValueMap.multiValueMap(map, collectionFactory);
|
||||||
}
|
}
|
||||||
|
|
||||||
// SortedMap decorators
|
// SortedMap decorators
|
||||||
|
@ -1470,7 +1470,7 @@ public class MapUtils {
|
||||||
* @throws IllegalArgumentException if the map is null
|
* @throws IllegalArgumentException if the map is null
|
||||||
*/
|
*/
|
||||||
public static <K, V> SortedMap<K, V> unmodifiableSortedMap(SortedMap<K, V> map) {
|
public static <K, V> SortedMap<K, V> unmodifiableSortedMap(SortedMap<K, V> map) {
|
||||||
return UnmodifiableSortedMap.decorate(map);
|
return UnmodifiableSortedMap.unmodifiableSortedMap(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1490,7 +1490,7 @@ public class MapUtils {
|
||||||
*/
|
*/
|
||||||
public static <K, V> SortedMap<K, V> predicatedSortedMap(SortedMap<K, V> map,
|
public static <K, V> SortedMap<K, V> predicatedSortedMap(SortedMap<K, V> map,
|
||||||
Predicate<? super K> keyPred, Predicate<? super V> valuePred) {
|
Predicate<? super K> keyPred, Predicate<? super V> valuePred) {
|
||||||
return PredicatedSortedMap.decorate(map, keyPred, valuePred);
|
return PredicatedSortedMap.predicatedSortedMap(map, keyPred, valuePred);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1517,7 +1517,7 @@ public class MapUtils {
|
||||||
public static <K, V> SortedMap<K, V> transformedSortedMap(SortedMap<K, V> map,
|
public static <K, V> SortedMap<K, V> transformedSortedMap(SortedMap<K, V> map,
|
||||||
Transformer<? super K, ? extends K> keyTransformer,
|
Transformer<? super K, ? extends K> keyTransformer,
|
||||||
Transformer<? super V, ? extends V> valueTransformer) {
|
Transformer<? super V, ? extends V> valueTransformer) {
|
||||||
return TransformedSortedMap.decorate(map, keyTransformer, valueTransformer);
|
return TransformedSortedMap.transformingSortedMap(map, keyTransformer, valueTransformer);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1531,7 +1531,7 @@ public class MapUtils {
|
||||||
* @throws IllegalArgumentException if the SortedMap is null
|
* @throws IllegalArgumentException if the SortedMap is null
|
||||||
*/
|
*/
|
||||||
public static <K, V> SortedMap<K, V> fixedSizeSortedMap(SortedMap<K, V> map) {
|
public static <K, V> SortedMap<K, V> fixedSizeSortedMap(SortedMap<K, V> map) {
|
||||||
return FixedSizeSortedMap.decorate(map);
|
return FixedSizeSortedMap.fixedSizeSortedMap(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1565,7 +1565,7 @@ public class MapUtils {
|
||||||
*/
|
*/
|
||||||
public static <K, V> SortedMap<K, V> lazySortedMap(SortedMap<K, V> map,
|
public static <K, V> SortedMap<K, V> lazySortedMap(SortedMap<K, V> map,
|
||||||
Factory<? extends V> factory) {
|
Factory<? extends V> factory) {
|
||||||
return LazySortedMap.getLazySortedMap(map, factory);
|
return LazySortedMap.lazySortedMap(map, factory);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1605,7 +1605,7 @@ public class MapUtils {
|
||||||
*/
|
*/
|
||||||
public static <K, V> SortedMap<K, V> lazySortedMap(SortedMap<K, V> map,
|
public static <K, V> SortedMap<K, V> lazySortedMap(SortedMap<K, V> map,
|
||||||
Transformer<? super K, ? extends V> transformerFactory) {
|
Transformer<? super K, ? extends V> transformerFactory) {
|
||||||
return LazySortedMap.getLazySortedMap(map, transformerFactory);
|
return LazySortedMap.lazySortedMap(map, transformerFactory);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -21,7 +21,9 @@ import java.util.Collection;
|
||||||
import org.apache.commons.collections.functors.AllPredicate;
|
import org.apache.commons.collections.functors.AllPredicate;
|
||||||
import org.apache.commons.collections.functors.AndPredicate;
|
import org.apache.commons.collections.functors.AndPredicate;
|
||||||
import org.apache.commons.collections.functors.AnyPredicate;
|
import org.apache.commons.collections.functors.AnyPredicate;
|
||||||
|
import org.apache.commons.collections.functors.EqualPredicate;
|
||||||
import org.apache.commons.collections.functors.ExceptionPredicate;
|
import org.apache.commons.collections.functors.ExceptionPredicate;
|
||||||
|
import org.apache.commons.collections.functors.FalsePredicate;
|
||||||
import org.apache.commons.collections.functors.IdentityPredicate;
|
import org.apache.commons.collections.functors.IdentityPredicate;
|
||||||
import org.apache.commons.collections.functors.InstanceofPredicate;
|
import org.apache.commons.collections.functors.InstanceofPredicate;
|
||||||
import org.apache.commons.collections.functors.InvokerTransformer;
|
import org.apache.commons.collections.functors.InvokerTransformer;
|
||||||
|
@ -31,10 +33,12 @@ import org.apache.commons.collections.functors.NotPredicate;
|
||||||
import org.apache.commons.collections.functors.NullIsExceptionPredicate;
|
import org.apache.commons.collections.functors.NullIsExceptionPredicate;
|
||||||
import org.apache.commons.collections.functors.NullIsFalsePredicate;
|
import org.apache.commons.collections.functors.NullIsFalsePredicate;
|
||||||
import org.apache.commons.collections.functors.NullIsTruePredicate;
|
import org.apache.commons.collections.functors.NullIsTruePredicate;
|
||||||
|
import org.apache.commons.collections.functors.NullPredicate;
|
||||||
import org.apache.commons.collections.functors.OnePredicate;
|
import org.apache.commons.collections.functors.OnePredicate;
|
||||||
import org.apache.commons.collections.functors.OrPredicate;
|
import org.apache.commons.collections.functors.OrPredicate;
|
||||||
import org.apache.commons.collections.functors.TransformedPredicate;
|
import org.apache.commons.collections.functors.TransformedPredicate;
|
||||||
import org.apache.commons.collections.functors.TransformerPredicate;
|
import org.apache.commons.collections.functors.TransformerPredicate;
|
||||||
|
import org.apache.commons.collections.functors.TruePredicate;
|
||||||
import org.apache.commons.collections.functors.UniquePredicate;
|
import org.apache.commons.collections.functors.UniquePredicate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -89,7 +93,46 @@ public class PredicateUtils {
|
||||||
* @return the predicate
|
* @return the predicate
|
||||||
*/
|
*/
|
||||||
public static <T> Predicate<T> exceptionPredicate() {
|
public static <T> Predicate<T> exceptionPredicate() {
|
||||||
return ExceptionPredicate.<T>getInstance();
|
return ExceptionPredicate.<T>exceptionPredicate();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a Predicate that always returns true.
|
||||||
|
*
|
||||||
|
* @see org.apache.commons.collections.functors.TruePredicate
|
||||||
|
*
|
||||||
|
* @return the predicate
|
||||||
|
* @deprecated use {@link TruePredicate#truePredicate()} instead.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public static <T> Predicate<T> truePredicate() {
|
||||||
|
return TruePredicate.truePredicate();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a Predicate that always returns false.
|
||||||
|
*
|
||||||
|
* @see org.apache.commons.collections.functors.FalsePredicate
|
||||||
|
*
|
||||||
|
* @return the predicate
|
||||||
|
* @deprecated use {@link FalsePredicate#falsePredicate()} instead.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public static <T> Predicate<T> falsePredicate() {
|
||||||
|
return FalsePredicate.<T> falsePredicate();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a Predicate that checks if the input object passed in is null.
|
||||||
|
*
|
||||||
|
* @see org.apache.commons.collections.functors.NullPredicate
|
||||||
|
*
|
||||||
|
* @return the predicate
|
||||||
|
* @deprecated use {@link NullPredicate#nullPredicate()} instead
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public static <T> Predicate<T> nullPredicate() {
|
||||||
|
return NullPredicate.nullPredicate();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -100,7 +143,22 @@ public class PredicateUtils {
|
||||||
* @return the predicate
|
* @return the predicate
|
||||||
*/
|
*/
|
||||||
public static <T> Predicate<T> notNullPredicate() {
|
public static <T> Predicate<T> notNullPredicate() {
|
||||||
return NotNullPredicate.<T>getInstance();
|
return NotNullPredicate.<T>notNullPredicate();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a Predicate that checks if the input object is equal to the
|
||||||
|
* specified object using equals().
|
||||||
|
*
|
||||||
|
* @see org.apache.commons.collections.functors.EqualPredicate
|
||||||
|
*
|
||||||
|
* @param value the value to compare against
|
||||||
|
* @return the predicate
|
||||||
|
* @deprecated use {@link EqualPredicate#equalPredicate(Object)} instead.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public static <T> Predicate<T> equalPredicate(T value) {
|
||||||
|
return EqualPredicate.equalPredicate(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -113,7 +171,7 @@ public class PredicateUtils {
|
||||||
* @return the predicate
|
* @return the predicate
|
||||||
*/
|
*/
|
||||||
public static <T> Predicate<T> identityPredicate(T value) {
|
public static <T> Predicate<T> identityPredicate(T value) {
|
||||||
return IdentityPredicate.<T>getInstance(value);
|
return IdentityPredicate.<T>identityPredicate(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -128,7 +186,7 @@ public class PredicateUtils {
|
||||||
* @throws IllegalArgumentException if the class is null
|
* @throws IllegalArgumentException if the class is null
|
||||||
*/
|
*/
|
||||||
public static Predicate<Object> instanceofPredicate(Class<?> type) {
|
public static Predicate<Object> instanceofPredicate(Class<?> type) {
|
||||||
return InstanceofPredicate.getInstance(type);
|
return InstanceofPredicate.instanceOfPredicate(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -144,7 +202,7 @@ public class PredicateUtils {
|
||||||
*/
|
*/
|
||||||
public static <T> Predicate<T> uniquePredicate() {
|
public static <T> Predicate<T> uniquePredicate() {
|
||||||
// must return new instance each time
|
// must return new instance each time
|
||||||
return UniquePredicate.<T>getInstance();
|
return UniquePredicate.<T>uniquePredicate();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -166,7 +224,7 @@ public class PredicateUtils {
|
||||||
*/
|
*/
|
||||||
public static <T> Predicate<T> invokerPredicate(String methodName){
|
public static <T> Predicate<T> invokerPredicate(String methodName){
|
||||||
// reuse transformer as it has caching - this is lazy really, should have inner class here
|
// reuse transformer as it has caching - this is lazy really, should have inner class here
|
||||||
return asPredicate(InvokerTransformer.<Object, Boolean>getInstance(methodName));
|
return asPredicate(InvokerTransformer.<Object, Boolean>invokerTransformer(methodName));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -191,7 +249,7 @@ public class PredicateUtils {
|
||||||
*/
|
*/
|
||||||
public static <T> Predicate<T> invokerPredicate(String methodName, Class<?>[] paramTypes, Object[] args){
|
public static <T> Predicate<T> invokerPredicate(String methodName, Class<?>[] paramTypes, Object[] args){
|
||||||
// reuse transformer as it has caching - this is lazy really, should have inner class here
|
// reuse transformer as it has caching - this is lazy really, should have inner class here
|
||||||
return asPredicate(InvokerTransformer.<Object, Boolean>getInstance(methodName, paramTypes, args));
|
return asPredicate(InvokerTransformer.<Object, Boolean>invokerTransformer(methodName, paramTypes, args));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Boolean combinations
|
// Boolean combinations
|
||||||
|
@ -209,7 +267,25 @@ public class PredicateUtils {
|
||||||
* @throws IllegalArgumentException if either predicate is null
|
* @throws IllegalArgumentException if either predicate is null
|
||||||
*/
|
*/
|
||||||
public static <T> Predicate<T> andPredicate(Predicate<? super T> predicate1, Predicate<? super T> predicate2) {
|
public static <T> Predicate<T> andPredicate(Predicate<? super T> predicate1, Predicate<? super T> predicate2) {
|
||||||
return AndPredicate.<T>getInstance(predicate1, predicate2);
|
return AndPredicate.<T>andPredicate(predicate1, predicate2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new Predicate that returns true only if all of the specified
|
||||||
|
* predicates are true.
|
||||||
|
* If the array of predicates is empty, then this predicate returns true.
|
||||||
|
*
|
||||||
|
* @see org.apache.commons.collections.functors.AllPredicate
|
||||||
|
*
|
||||||
|
* @param predicates an array of predicates to check, may not be null
|
||||||
|
* @return the <code>all</code> predicate
|
||||||
|
* @throws IllegalArgumentException if the predicates array is null
|
||||||
|
* @throws IllegalArgumentException if any predicate in the array is null
|
||||||
|
* @deprecated use {@link AllPredicate#allPredicate(Predicate...)} instead.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public static <T> Predicate<T> allPredicate(Predicate<? super T>[] predicates) {
|
||||||
|
return AllPredicate.allPredicate(predicates);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -240,7 +316,7 @@ public class PredicateUtils {
|
||||||
* @throws IllegalArgumentException if either predicate is null
|
* @throws IllegalArgumentException if either predicate is null
|
||||||
*/
|
*/
|
||||||
public static <T> Predicate<T> orPredicate(Predicate<? super T> predicate1, Predicate<? super T> predicate2) {
|
public static <T> Predicate<T> orPredicate(Predicate<? super T> predicate1, Predicate<? super T> predicate2) {
|
||||||
return OrPredicate.<T>getInstance(predicate1, predicate2);
|
return OrPredicate.<T>orPredicate(predicate1, predicate2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -256,7 +332,7 @@ public class PredicateUtils {
|
||||||
* @throws IllegalArgumentException if any predicate in the array is null
|
* @throws IllegalArgumentException if any predicate in the array is null
|
||||||
*/
|
*/
|
||||||
public static <T> Predicate<T> anyPredicate(Predicate<? super T>[] predicates) {
|
public static <T> Predicate<T> anyPredicate(Predicate<? super T>[] predicates) {
|
||||||
return AnyPredicate.getInstance(predicates);
|
return AnyPredicate.anyPredicate(predicates);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -272,7 +348,7 @@ public class PredicateUtils {
|
||||||
* @throws IllegalArgumentException if any predicate in the collection is null
|
* @throws IllegalArgumentException if any predicate in the collection is null
|
||||||
*/
|
*/
|
||||||
public static <T> Predicate<T> anyPredicate(Collection<? extends Predicate<T>> predicates) {
|
public static <T> Predicate<T> anyPredicate(Collection<? extends Predicate<T>> predicates) {
|
||||||
return AnyPredicate.getInstance(predicates);
|
return AnyPredicate.anyPredicate(predicates);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -304,7 +380,7 @@ public class PredicateUtils {
|
||||||
* @throws IllegalArgumentException if any predicate in the array is null
|
* @throws IllegalArgumentException if any predicate in the array is null
|
||||||
*/
|
*/
|
||||||
public static <T> Predicate<T> onePredicate(Predicate<? super T>[] predicates) {
|
public static <T> Predicate<T> onePredicate(Predicate<? super T>[] predicates) {
|
||||||
return OnePredicate.getInstance(predicates);
|
return OnePredicate.onePredicate(predicates);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -320,7 +396,7 @@ public class PredicateUtils {
|
||||||
* @throws IllegalArgumentException if any predicate in the collection is null
|
* @throws IllegalArgumentException if any predicate in the collection is null
|
||||||
*/
|
*/
|
||||||
public static <T> Predicate<T> onePredicate(Collection<Predicate<T>> predicates) {
|
public static <T> Predicate<T> onePredicate(Collection<Predicate<T>> predicates) {
|
||||||
return OnePredicate.getInstance(predicates);
|
return OnePredicate.onePredicate(predicates);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -352,7 +428,7 @@ public class PredicateUtils {
|
||||||
* @throws IllegalArgumentException if any predicate in the array is null
|
* @throws IllegalArgumentException if any predicate in the array is null
|
||||||
*/
|
*/
|
||||||
public static <T> Predicate<T> nonePredicate(Predicate<? super T>[] predicates) {
|
public static <T> Predicate<T> nonePredicate(Predicate<? super T>[] predicates) {
|
||||||
return NonePredicate.getInstance(predicates);
|
return NonePredicate.nonePredicate(predicates);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -368,7 +444,7 @@ public class PredicateUtils {
|
||||||
* @throws IllegalArgumentException if any predicate in the collection is null
|
* @throws IllegalArgumentException if any predicate in the collection is null
|
||||||
*/
|
*/
|
||||||
public static <T> Predicate<T> nonePredicate(Collection<? extends Predicate<T>> predicates) {
|
public static <T> Predicate<T> nonePredicate(Collection<? extends Predicate<T>> predicates) {
|
||||||
return NonePredicate.getInstance(predicates);
|
return NonePredicate.nonePredicate(predicates);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -382,7 +458,7 @@ public class PredicateUtils {
|
||||||
* @throws IllegalArgumentException if the predicate is null
|
* @throws IllegalArgumentException if the predicate is null
|
||||||
*/
|
*/
|
||||||
public static <T> Predicate<T> notPredicate(Predicate<? super T> predicate) {
|
public static <T> Predicate<T> notPredicate(Predicate<? super T> predicate) {
|
||||||
return NotPredicate.getInstance(predicate);
|
return NotPredicate.notPredicate(predicate);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Adaptors
|
// Adaptors
|
||||||
|
@ -400,7 +476,7 @@ public class PredicateUtils {
|
||||||
* @throws IllegalArgumentException if the transformer is null
|
* @throws IllegalArgumentException if the transformer is null
|
||||||
*/
|
*/
|
||||||
public static <T> Predicate<T> asPredicate(Transformer<? super T, Boolean> transformer) {
|
public static <T> Predicate<T> asPredicate(Transformer<? super T, Boolean> transformer) {
|
||||||
return TransformerPredicate.getInstance(transformer);
|
return TransformerPredicate.transformerPredicate(transformer);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Null handlers
|
// Null handlers
|
||||||
|
@ -418,7 +494,7 @@ public class PredicateUtils {
|
||||||
* @throws IllegalArgumentException if the predicate is null.
|
* @throws IllegalArgumentException if the predicate is null.
|
||||||
*/
|
*/
|
||||||
public static <T> Predicate<T> nullIsExceptionPredicate(Predicate<? super T> predicate){
|
public static <T> Predicate<T> nullIsExceptionPredicate(Predicate<? super T> predicate){
|
||||||
return NullIsExceptionPredicate.getInstance(predicate);
|
return NullIsExceptionPredicate.nullIsExceptionPredicate(predicate);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -433,7 +509,7 @@ public class PredicateUtils {
|
||||||
* @throws IllegalArgumentException if the predicate is null.
|
* @throws IllegalArgumentException if the predicate is null.
|
||||||
*/
|
*/
|
||||||
public static <T> Predicate<T> nullIsFalsePredicate(Predicate<? super T> predicate){
|
public static <T> Predicate<T> nullIsFalsePredicate(Predicate<? super T> predicate){
|
||||||
return NullIsFalsePredicate.getInstance(predicate);
|
return NullIsFalsePredicate.nullIsFalsePredicate(predicate);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -448,7 +524,7 @@ public class PredicateUtils {
|
||||||
* @throws IllegalArgumentException if the predicate is null.
|
* @throws IllegalArgumentException if the predicate is null.
|
||||||
*/
|
*/
|
||||||
public static <T> Predicate<T> nullIsTruePredicate(Predicate<? super T> predicate){
|
public static <T> Predicate<T> nullIsTruePredicate(Predicate<? super T> predicate){
|
||||||
return NullIsTruePredicate.getInstance(predicate);
|
return NullIsTruePredicate.nullIsTruePredicate(predicate);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Transformed
|
// Transformed
|
||||||
|
@ -467,7 +543,7 @@ public class PredicateUtils {
|
||||||
*/
|
*/
|
||||||
public static <T> Predicate<T> transformedPredicate(
|
public static <T> Predicate<T> transformedPredicate(
|
||||||
Transformer<? super T, ? extends T> transformer, Predicate<? super T> predicate) {
|
Transformer<? super T, ? extends T> transformer, Predicate<? super T> predicate) {
|
||||||
return TransformedPredicate.<T>getInstance(transformer, predicate);
|
return TransformedPredicate.<T>transformedPredicate(transformer, predicate);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,7 +66,7 @@ public class SetUtils {
|
||||||
* An empty unmodifiable sorted set.
|
* An empty unmodifiable sorted set.
|
||||||
* This is not provided in the JDK.
|
* This is not provided in the JDK.
|
||||||
*/
|
*/
|
||||||
public static final SortedSet<?> EMPTY_SORTED_SET = UnmodifiableSortedSet.decorate(new TreeSet<Object>());
|
public static final SortedSet<?> EMPTY_SORTED_SET = UnmodifiableSortedSet.unmodifiableSortedSet(new TreeSet<Object>());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a typed empty unmodifiable sorted set.
|
* Get a typed empty unmodifiable sorted set.
|
||||||
|
@ -174,7 +174,7 @@ public class SetUtils {
|
||||||
* @throws IllegalArgumentException if the set is null
|
* @throws IllegalArgumentException if the set is null
|
||||||
*/
|
*/
|
||||||
public static <T> Set<T> synchronizedSet(Set<T> set) {
|
public static <T> Set<T> synchronizedSet(Set<T> set) {
|
||||||
return SynchronizedSet.decorate(set);
|
return SynchronizedSet.synchronizedSet(set);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -187,7 +187,7 @@ public class SetUtils {
|
||||||
* @throws IllegalArgumentException if the set is null
|
* @throws IllegalArgumentException if the set is null
|
||||||
*/
|
*/
|
||||||
public static <E> Set<E> unmodifiableSet(Set<E> set) {
|
public static <E> Set<E> unmodifiableSet(Set<E> set) {
|
||||||
return UnmodifiableSet.decorate(set);
|
return UnmodifiableSet.unmodifiableSet(set);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -204,7 +204,7 @@ public class SetUtils {
|
||||||
* @throws IllegalArgumentException if the Set or Predicate is null
|
* @throws IllegalArgumentException if the Set or Predicate is null
|
||||||
*/
|
*/
|
||||||
public static <T> Set<T> predicatedSet(Set<T> set, Predicate<? super T> predicate) {
|
public static <T> Set<T> predicatedSet(Set<T> set, Predicate<? super T> predicate) {
|
||||||
return PredicatedSet.decorate(set, predicate);
|
return PredicatedSet.predicatedSet(set, predicate);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -223,7 +223,7 @@ public class SetUtils {
|
||||||
* @throws IllegalArgumentException if the Set or Transformer is null
|
* @throws IllegalArgumentException if the Set or Transformer is null
|
||||||
*/
|
*/
|
||||||
public static <E> Set<E> transformedSet(Set<E> set, Transformer<? super E, ? extends E> transformer) {
|
public static <E> Set<E> transformedSet(Set<E> set, Transformer<? super E, ? extends E> transformer) {
|
||||||
return TransformedSet.decorate(set, transformer);
|
return TransformedSet.transformingSet(set, transformer);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -238,7 +238,7 @@ public class SetUtils {
|
||||||
* @throws IllegalArgumentException if the Set is null
|
* @throws IllegalArgumentException if the Set is null
|
||||||
*/
|
*/
|
||||||
public static <E> Set<E> orderedSet(Set<E> set) {
|
public static <E> Set<E> orderedSet(Set<E> set) {
|
||||||
return ListOrderedSet.decorate(set);
|
return ListOrderedSet.listOrderedSet(set);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
|
@ -265,7 +265,7 @@ public class SetUtils {
|
||||||
* @throws IllegalArgumentException if the set is null
|
* @throws IllegalArgumentException if the set is null
|
||||||
*/
|
*/
|
||||||
public static <T> SortedSet<T> synchronizedSortedSet(SortedSet<T> set) {
|
public static <T> SortedSet<T> synchronizedSortedSet(SortedSet<T> set) {
|
||||||
return SynchronizedSortedSet.decorate(set);
|
return SynchronizedSortedSet.synchronizedSortedSet(set);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -278,7 +278,7 @@ public class SetUtils {
|
||||||
* @throws IllegalArgumentException if the set is null
|
* @throws IllegalArgumentException if the set is null
|
||||||
*/
|
*/
|
||||||
public static <T> SortedSet<T> unmodifiableSortedSet(SortedSet<T> set) {
|
public static <T> SortedSet<T> unmodifiableSortedSet(SortedSet<T> set) {
|
||||||
return UnmodifiableSortedSet.decorate(set);
|
return UnmodifiableSortedSet.unmodifiableSortedSet(set);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -295,7 +295,7 @@ public class SetUtils {
|
||||||
* @throws IllegalArgumentException if the Set or Predicate is null
|
* @throws IllegalArgumentException if the Set or Predicate is null
|
||||||
*/
|
*/
|
||||||
public static <T> SortedSet<T> predicatedSortedSet(SortedSet<T> set, Predicate<? super T> predicate) {
|
public static <T> SortedSet<T> predicatedSortedSet(SortedSet<T> set, Predicate<? super T> predicate) {
|
||||||
return PredicatedSortedSet.decorate(set, predicate);
|
return PredicatedSortedSet.predicatedSortedSet(set, predicate);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -314,7 +314,7 @@ public class SetUtils {
|
||||||
* @throws IllegalArgumentException if the Set or Transformer is null
|
* @throws IllegalArgumentException if the Set or Transformer is null
|
||||||
*/
|
*/
|
||||||
public static <E> SortedSet<E> transformedSortedSet(SortedSet<E> set, Transformer<? super E, ? extends E> transformer) {
|
public static <E> SortedSet<E> transformedSortedSet(SortedSet<E> set, Transformer<? super E, ? extends E> transformer) {
|
||||||
return TransformedSortedSet.decorate(set, transformer);
|
return TransformedSortedSet.transformingSortedSet(set, transformer);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,7 +80,7 @@ public class TransformerUtils {
|
||||||
* @return the transformer
|
* @return the transformer
|
||||||
*/
|
*/
|
||||||
public static <I, O> Transformer<I, O> exceptionTransformer() {
|
public static <I, O> Transformer<I, O> exceptionTransformer() {
|
||||||
return ExceptionTransformer.<I, O>getInstance();
|
return ExceptionTransformer.<I, O>exceptionTransformer();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -91,7 +91,7 @@ public class TransformerUtils {
|
||||||
* @return the transformer
|
* @return the transformer
|
||||||
*/
|
*/
|
||||||
public static <I, O> Transformer<I, O> nullTransformer() {
|
public static <I, O> Transformer<I, O> nullTransformer() {
|
||||||
return ConstantTransformer.<I, O>getNullInstance();
|
return ConstantTransformer.<I, O>nullTransformer();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -104,7 +104,7 @@ public class TransformerUtils {
|
||||||
* @return the transformer
|
* @return the transformer
|
||||||
*/
|
*/
|
||||||
public static <T> Transformer<T, T> nopTransformer() {
|
public static <T> Transformer<T, T> nopTransformer() {
|
||||||
return NOPTransformer.<T>getInstance();
|
return NOPTransformer.<T>nopTransformer();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -122,7 +122,7 @@ public class TransformerUtils {
|
||||||
* @return the transformer
|
* @return the transformer
|
||||||
*/
|
*/
|
||||||
public static <T> Transformer<T, T> cloneTransformer() {
|
public static <T> Transformer<T, T> cloneTransformer() {
|
||||||
return CloneTransformer.<T>getInstance();
|
return CloneTransformer.<T>cloneTransformer();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -135,7 +135,7 @@ public class TransformerUtils {
|
||||||
* @return the transformer.
|
* @return the transformer.
|
||||||
*/
|
*/
|
||||||
public static <I, O> Transformer<I, O> constantTransformer(O constantToReturn) {
|
public static <I, O> Transformer<I, O> constantTransformer(O constantToReturn) {
|
||||||
return ConstantTransformer.getInstance(constantToReturn);
|
return ConstantTransformer.constantTransformer(constantToReturn);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -149,7 +149,7 @@ public class TransformerUtils {
|
||||||
* @throws IllegalArgumentException if the closure is null
|
* @throws IllegalArgumentException if the closure is null
|
||||||
*/
|
*/
|
||||||
public static <T> Transformer<T, T> asTransformer(Closure<? super T> closure) {
|
public static <T> Transformer<T, T> asTransformer(Closure<? super T> closure) {
|
||||||
return ClosureTransformer.getInstance(closure);
|
return ClosureTransformer.closureTransformer(closure);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -163,7 +163,7 @@ public class TransformerUtils {
|
||||||
* @throws IllegalArgumentException if the predicate is null
|
* @throws IllegalArgumentException if the predicate is null
|
||||||
*/
|
*/
|
||||||
public static <T> Transformer<T, Boolean> asTransformer(Predicate<? super T> predicate) {
|
public static <T> Transformer<T, Boolean> asTransformer(Predicate<? super T> predicate) {
|
||||||
return PredicateTransformer.getInstance(predicate);
|
return PredicateTransformer.predicateTransformer(predicate);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -177,7 +177,7 @@ public class TransformerUtils {
|
||||||
* @throws IllegalArgumentException if the factory is null
|
* @throws IllegalArgumentException if the factory is null
|
||||||
*/
|
*/
|
||||||
public static <I, O> Transformer<I, O> asTransformer(Factory<? extends O> factory) {
|
public static <I, O> Transformer<I, O> asTransformer(Factory<? extends O> factory) {
|
||||||
return FactoryTransformer.getInstance(factory);
|
return FactoryTransformer.factoryTransformer(factory);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -191,10 +191,11 @@ public class TransformerUtils {
|
||||||
* @return the transformer
|
* @return the transformer
|
||||||
* @throws IllegalArgumentException if either transformer is null
|
* @throws IllegalArgumentException if either transformer is null
|
||||||
*/
|
*/
|
||||||
public static <T> Transformer<T, T> chainedTransformer(
|
@SuppressWarnings("unchecked")
|
||||||
|
public static <T> Transformer<T, T> chainedTransformer(
|
||||||
Transformer<? super T, ? extends T> transformer1,
|
Transformer<? super T, ? extends T> transformer1,
|
||||||
Transformer<? super T, ? extends T> transformer2) {
|
Transformer<? super T, ? extends T> transformer2) {
|
||||||
return ChainedTransformer.<T>getInstance(transformer1, transformer2);
|
return ChainedTransformer.<T> chainedTransformer(transformer1, transformer2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -209,7 +210,7 @@ public class TransformerUtils {
|
||||||
* @throws IllegalArgumentException if any transformer in the array is null
|
* @throws IllegalArgumentException if any transformer in the array is null
|
||||||
*/
|
*/
|
||||||
public static <T> Transformer<T, T> chainedTransformer(Transformer<? super T, ? extends T>[] transformers) {
|
public static <T> Transformer<T, T> chainedTransformer(Transformer<? super T, ? extends T>[] transformers) {
|
||||||
return ChainedTransformer.getInstance(transformers);
|
return ChainedTransformer.chainedTransformer(transformers);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -226,7 +227,7 @@ public class TransformerUtils {
|
||||||
*/
|
*/
|
||||||
public static <T> Transformer<T, T> chainedTransformer(
|
public static <T> Transformer<T, T> chainedTransformer(
|
||||||
Collection<? extends Transformer<T, T>> transformers) {
|
Collection<? extends Transformer<T, T>> transformers) {
|
||||||
return ChainedTransformer.getInstance(transformers);
|
return ChainedTransformer.chainedTransformer(transformers);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -246,7 +247,7 @@ public class TransformerUtils {
|
||||||
public static <I, O> Transformer<I, O> switchTransformer(Predicate<? super I> predicate,
|
public static <I, O> Transformer<I, O> switchTransformer(Predicate<? super I> predicate,
|
||||||
Transformer<? super I, ? extends O> trueTransformer,
|
Transformer<? super I, ? extends O> trueTransformer,
|
||||||
Transformer<? super I, ? extends O> falseTransformer) {
|
Transformer<? super I, ? extends O> falseTransformer) {
|
||||||
return SwitchTransformer.getInstance(new Predicate[] { predicate },
|
return SwitchTransformer.switchTransformer(new Predicate[] { predicate },
|
||||||
new Transformer[] { trueTransformer }, falseTransformer);
|
new Transformer[] { trueTransformer }, falseTransformer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -268,7 +269,7 @@ public class TransformerUtils {
|
||||||
*/
|
*/
|
||||||
public static <I, O> Transformer<I, O> switchTransformer(Predicate<? super I>[] predicates,
|
public static <I, O> Transformer<I, O> switchTransformer(Predicate<? super I>[] predicates,
|
||||||
Transformer<? super I, ? extends O>[] transformers) {
|
Transformer<? super I, ? extends O>[] transformers) {
|
||||||
return SwitchTransformer.<I, O>getInstance(predicates, transformers, null);
|
return SwitchTransformer.<I, O>switchTransformer(predicates, transformers, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -292,7 +293,7 @@ public class TransformerUtils {
|
||||||
public static <I, O> Transformer<I, O> switchTransformer(Predicate<? super I>[] predicates,
|
public static <I, O> Transformer<I, O> switchTransformer(Predicate<? super I>[] predicates,
|
||||||
Transformer<? super I, ? extends O>[] transformers,
|
Transformer<? super I, ? extends O>[] transformers,
|
||||||
Transformer<? super I, ? extends O> defaultTransformer) {
|
Transformer<? super I, ? extends O> defaultTransformer) {
|
||||||
return SwitchTransformer.<I, O>getInstance(predicates, transformers, defaultTransformer);
|
return SwitchTransformer.<I, O>switchTransformer(predicates, transformers, defaultTransformer);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -318,7 +319,7 @@ public class TransformerUtils {
|
||||||
*/
|
*/
|
||||||
public static <I, O> Transformer<I, O> switchTransformer(
|
public static <I, O> Transformer<I, O> switchTransformer(
|
||||||
Map<Predicate<I>, Transformer<I, O>> predicatesAndTransformers) {
|
Map<Predicate<I>, Transformer<I, O>> predicatesAndTransformers) {
|
||||||
return SwitchTransformer.<I, O>getInstance(predicatesAndTransformers);
|
return SwitchTransformer.<I, O>switchTransformer(predicatesAndTransformers);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -365,7 +366,7 @@ public class TransformerUtils {
|
||||||
* @return the transformer
|
* @return the transformer
|
||||||
*/
|
*/
|
||||||
public static <T> Transformer<Class<? extends T>, T> instantiateTransformer() {
|
public static <T> Transformer<Class<? extends T>, T> instantiateTransformer() {
|
||||||
return InstantiateTransformer.<T>getInstance();
|
return InstantiateTransformer.<T>instantiateTransformer();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -382,7 +383,7 @@ public class TransformerUtils {
|
||||||
*/
|
*/
|
||||||
public static <T> Transformer<Class<? extends T>, T> instantiateTransformer(
|
public static <T> Transformer<Class<? extends T>, T> instantiateTransformer(
|
||||||
Class<?>[] paramTypes, Object[] args) {
|
Class<?>[] paramTypes, Object[] args) {
|
||||||
return InstantiateTransformer.<T>getInstance(paramTypes, args);
|
return InstantiateTransformer.<T>instantiateTransformer(paramTypes, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -396,7 +397,7 @@ public class TransformerUtils {
|
||||||
* @throws IllegalArgumentException if the map is null
|
* @throws IllegalArgumentException if the map is null
|
||||||
*/
|
*/
|
||||||
public static <I, O> Transformer<I, O> mapTransformer(Map<? super I, ? extends O> map) {
|
public static <I, O> Transformer<I, O> mapTransformer(Map<? super I, ? extends O> map) {
|
||||||
return MapTransformer.getInstance(map);
|
return MapTransformer.mapTransformer(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -415,7 +416,7 @@ public class TransformerUtils {
|
||||||
* @throws IllegalArgumentException if the methodName is null.
|
* @throws IllegalArgumentException if the methodName is null.
|
||||||
*/
|
*/
|
||||||
public static <I, O> Transformer<I, O> invokerTransformer(String methodName){
|
public static <I, O> Transformer<I, O> invokerTransformer(String methodName){
|
||||||
return InvokerTransformer.<I, O>getInstance(methodName, null, null);
|
return InvokerTransformer.<I, O>invokerTransformer(methodName, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -433,7 +434,7 @@ public class TransformerUtils {
|
||||||
* @throws IllegalArgumentException if the paramTypes and args don't match
|
* @throws IllegalArgumentException if the paramTypes and args don't match
|
||||||
*/
|
*/
|
||||||
public static <I, O> Transformer<I, O> invokerTransformer(String methodName, Class<?>[] paramTypes, Object[] args){
|
public static <I, O> Transformer<I, O> invokerTransformer(String methodName, Class<?>[] paramTypes, Object[] args){
|
||||||
return InvokerTransformer.<I, O>getInstance(methodName, paramTypes, args);
|
return InvokerTransformer.<I, O>invokerTransformer(methodName, paramTypes, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -446,7 +447,7 @@ public class TransformerUtils {
|
||||||
* @return the transformer
|
* @return the transformer
|
||||||
*/
|
*/
|
||||||
public static <T> Transformer<T, String> stringValueTransformer() {
|
public static <T> Transformer<T, String> stringValueTransformer() {
|
||||||
return StringValueTransformer.<T>getInstance();
|
return StringValueTransformer.<T>stringValueTransformer();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -482,7 +482,7 @@ public abstract class AbstractMapBag<E> implements Bag<E> {
|
||||||
*/
|
*/
|
||||||
public Set<E> uniqueSet() {
|
public Set<E> uniqueSet() {
|
||||||
if (uniqueSet == null) {
|
if (uniqueSet == null) {
|
||||||
uniqueSet = UnmodifiableSet.<E> decorate(map.keySet());
|
uniqueSet = UnmodifiableSet.<E> unmodifiableSet(map.keySet());
|
||||||
}
|
}
|
||||||
return uniqueSet;
|
return uniqueSet;
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,7 +59,7 @@ public class PredicatedBag<E>
|
||||||
* @throws IllegalArgumentException if bag or predicate is null
|
* @throws IllegalArgumentException if bag or predicate is null
|
||||||
* @throws IllegalArgumentException if the bag contains invalid elements
|
* @throws IllegalArgumentException if the bag contains invalid elements
|
||||||
*/
|
*/
|
||||||
public static <T> Bag<T> decorate(Bag<T> bag, Predicate<? super T> predicate) {
|
public static <T> Bag<T> predicatedBag(Bag<T> bag, Predicate<? super T> predicate) {
|
||||||
return new PredicatedBag<T>(bag, predicate);
|
return new PredicatedBag<T>(bag, predicate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,7 @@ public class PredicatedSortedBag<E>
|
||||||
* @throws IllegalArgumentException if bag or predicate is null
|
* @throws IllegalArgumentException if bag or predicate is null
|
||||||
* @throws IllegalArgumentException if the bag contains invalid elements
|
* @throws IllegalArgumentException if the bag contains invalid elements
|
||||||
*/
|
*/
|
||||||
public static <T> SortedBag<T> decorate(SortedBag<T> bag, Predicate<? super T> predicate) {
|
public static <T> SortedBag<T> predicatedSortedBag(SortedBag<T> bag, Predicate<? super T> predicate) {
|
||||||
return new PredicatedSortedBag<T>(bag, predicate);
|
return new PredicatedSortedBag<T>(bag, predicate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ public class SynchronizedBag<E>
|
||||||
* @return a new synchronized Bag
|
* @return a new synchronized Bag
|
||||||
* @throws IllegalArgumentException if bag is null
|
* @throws IllegalArgumentException if bag is null
|
||||||
*/
|
*/
|
||||||
public static <T> Bag<T> decorate(Bag<T> bag) {
|
public static <T> Bag<T> synchronizedBag(Bag<T> bag) {
|
||||||
return new SynchronizedBag<T>(bag);
|
return new SynchronizedBag<T>(bag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,7 @@ public class SynchronizedSortedBag<E>
|
||||||
* @return a new synchronized SortedBag
|
* @return a new synchronized SortedBag
|
||||||
* @throws IllegalArgumentException if bag is null
|
* @throws IllegalArgumentException if bag is null
|
||||||
*/
|
*/
|
||||||
public static <E> SortedBag<E> decorate(SortedBag<E> bag) {
|
public static <E> SortedBag<E> synchronizedSortedBag(SortedBag<E> bag) {
|
||||||
return new SynchronizedSortedBag<E>(bag);
|
return new SynchronizedSortedBag<E>(bag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,14 +49,14 @@ public class TransformedBag<E>
|
||||||
* <p>
|
* <p>
|
||||||
* If there are any elements already in the bag being decorated, they
|
* If there are any elements already in the bag being decorated, they
|
||||||
* are NOT transformed.
|
* are NOT transformed.
|
||||||
* Constrast this with {@link #decorateTransform}.
|
* Contrast this with {@link #transformedBag(Bag, Transformer)}.
|
||||||
*
|
*
|
||||||
* @param bag the bag to decorate, must not be null
|
* @param bag the bag to decorate, must not be null
|
||||||
* @param transformer the transformer to use for conversion, must not be null
|
* @param transformer the transformer to use for conversion, must not be null
|
||||||
* @return a new transformed Bag
|
* @return a new transformed Bag
|
||||||
* @throws IllegalArgumentException if bag or transformer is null
|
* @throws IllegalArgumentException if bag or transformer is null
|
||||||
*/
|
*/
|
||||||
public static <E> Bag<E> decorate(Bag<E> bag, Transformer<? super E, ? extends E> transformer) {
|
public static <E> Bag<E> transformingBag(Bag<E> bag, Transformer<? super E, ? extends E> transformer) {
|
||||||
return new TransformedBag<E>(bag, transformer);
|
return new TransformedBag<E>(bag, transformer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ public class TransformedBag<E>
|
||||||
* <p>
|
* <p>
|
||||||
* If there are any elements already in the bag being decorated, they
|
* If there are any elements already in the bag being decorated, they
|
||||||
* will be transformed by this method.
|
* will be transformed by this method.
|
||||||
* Constrast this with {@link #decorate}.
|
* Contrast this with {@link #transformingBag(Bag, Transformer)}.
|
||||||
*
|
*
|
||||||
* @param bag the bag to decorate, must not be null
|
* @param bag the bag to decorate, must not be null
|
||||||
* @param transformer the transformer to use for conversion, must not be null
|
* @param transformer the transformer to use for conversion, must not be null
|
||||||
|
@ -74,13 +74,13 @@ public class TransformedBag<E>
|
||||||
* @throws IllegalArgumentException if bag or transformer is null
|
* @throws IllegalArgumentException if bag or transformer is null
|
||||||
* @since Commons Collections 3.3
|
* @since Commons Collections 3.3
|
||||||
*/
|
*/
|
||||||
public static <E> Bag<E> decorateTransform(Bag<E> bag, Transformer<? super E, ? extends E> transformer) {
|
public static <E> Bag<E> transformedBag(Bag<E> bag, Transformer<? super E, ? extends E> transformer) {
|
||||||
TransformedBag<E> decorated = new TransformedBag<E>(bag, transformer);
|
TransformedBag<E> decorated = new TransformedBag<E>(bag, transformer);
|
||||||
if (transformer != null && bag != null && bag.size() > 0) {
|
if (transformer != null && bag != null && bag.size() > 0) {
|
||||||
@SuppressWarnings("unchecked") // Bag is of type E
|
@SuppressWarnings("unchecked") // Bag is of type E
|
||||||
E[] values = (E[]) bag.toArray();
|
E[] values = (E[]) bag.toArray();
|
||||||
bag.clear();
|
bag.clear();
|
||||||
for(int i=0; i<values.length; i++) {
|
for (int i = 0; i < values.length; i++) {
|
||||||
decorated.decorated().add(transformer.transform(values[i]));
|
decorated.decorated().add(transformer.transform(values[i]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -127,7 +127,7 @@ public class TransformedBag<E>
|
||||||
|
|
||||||
public Set<E> uniqueSet() {
|
public Set<E> uniqueSet() {
|
||||||
Set<E> set = getBag().uniqueSet();
|
Set<E> set = getBag().uniqueSet();
|
||||||
return TransformedSet.<E>decorate(set, transformer);
|
return TransformedSet.<E>transformingSet(set, transformer);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,14 +47,14 @@ public class TransformedSortedBag<E>
|
||||||
* <p>
|
* <p>
|
||||||
* If there are any elements already in the bag being decorated, they
|
* If there are any elements already in the bag being decorated, they
|
||||||
* are NOT transformed.
|
* are NOT transformed.
|
||||||
* Constrast this with {@link #decorateTransform}.
|
* Contrast this with {@link #transformedSortedBag(SortedBag, Transformer)}.
|
||||||
*
|
*
|
||||||
* @param bag the bag to decorate, must not be null
|
* @param bag the bag to decorate, must not be null
|
||||||
* @param transformer the transformer to use for conversion, must not be null
|
* @param transformer the transformer to use for conversion, must not be null
|
||||||
* @return a new transformed SortedBag
|
* @return a new transformed SortedBag
|
||||||
* @throws IllegalArgumentException if bag or transformer is null
|
* @throws IllegalArgumentException if bag or transformer is null
|
||||||
*/
|
*/
|
||||||
public static <E> SortedBag<E> decorate(SortedBag<E> bag, Transformer<? super E, ? extends E> transformer) {
|
public static <E> SortedBag<E> transformingSortedBag(SortedBag<E> bag, Transformer<? super E, ? extends E> transformer) {
|
||||||
return new TransformedSortedBag<E>(bag, transformer);
|
return new TransformedSortedBag<E>(bag, transformer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ public class TransformedSortedBag<E>
|
||||||
* <p>
|
* <p>
|
||||||
* If there are any elements already in the bag being decorated, they
|
* If there are any elements already in the bag being decorated, they
|
||||||
* will be transformed by this method.
|
* will be transformed by this method.
|
||||||
* Constrast this with {@link #decorate}.
|
* Contrast this with {@link #transformingSortedBag(SortedBag, Transformer)}.
|
||||||
*
|
*
|
||||||
* @param bag the bag to decorate, must not be null
|
* @param bag the bag to decorate, must not be null
|
||||||
* @param transformer the transformer to use for conversion, must not be null
|
* @param transformer the transformer to use for conversion, must not be null
|
||||||
|
@ -72,7 +72,7 @@ public class TransformedSortedBag<E>
|
||||||
* @throws IllegalArgumentException if bag or transformer is null
|
* @throws IllegalArgumentException if bag or transformer is null
|
||||||
* @since Commons Collections 3.3
|
* @since Commons Collections 3.3
|
||||||
*/
|
*/
|
||||||
public static <E> SortedBag<E> decorateTransform(SortedBag<E> bag, Transformer<? super E, ? extends E> transformer) {
|
public static <E> SortedBag<E> transformedSortedBag(SortedBag<E> bag, Transformer<? super E, ? extends E> transformer) {
|
||||||
TransformedSortedBag<E> decorated = new TransformedSortedBag<E>(bag, transformer);
|
TransformedSortedBag<E> decorated = new TransformedSortedBag<E>(bag, transformer);
|
||||||
if (transformer != null && bag != null && bag.size() > 0) {
|
if (transformer != null && bag != null && bag.size() > 0) {
|
||||||
@SuppressWarnings("unchecked") // bag is type E
|
@SuppressWarnings("unchecked") // bag is type E
|
||||||
|
|
|
@ -56,7 +56,7 @@ public final class UnmodifiableBag<E>
|
||||||
* @return an unmodifiable Bag
|
* @return an unmodifiable Bag
|
||||||
* @throws IllegalArgumentException if bag is null
|
* @throws IllegalArgumentException if bag is null
|
||||||
*/
|
*/
|
||||||
public static <E> Bag<E> decorate(Bag<E> bag) {
|
public static <E> Bag<E> unmodifiableBag(Bag<E> bag) {
|
||||||
if (bag instanceof Unmodifiable) {
|
if (bag instanceof Unmodifiable) {
|
||||||
return bag;
|
return bag;
|
||||||
}
|
}
|
||||||
|
@ -102,7 +102,8 @@ public final class UnmodifiableBag<E>
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
@Override
|
@Override
|
||||||
public Iterator<E> iterator() {
|
public Iterator<E> iterator() {
|
||||||
return UnmodifiableIterator.<E>decorate(decorated().iterator());
|
return UnmodifiableIterator.<E> unmodifiableIterator(decorated()
|
||||||
|
.iterator());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -149,7 +150,7 @@ public final class UnmodifiableBag<E>
|
||||||
@Override
|
@Override
|
||||||
public Set<E> uniqueSet() {
|
public Set<E> uniqueSet() {
|
||||||
Set<E> set = decorated().uniqueSet();
|
Set<E> set = decorated().uniqueSet();
|
||||||
return UnmodifiableSet.<E>decorate(set);
|
return UnmodifiableSet.<E> unmodifiableSet(set);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,7 +56,7 @@ public final class UnmodifiableSortedBag<E>
|
||||||
* @return an unmodifiable SortedBag
|
* @return an unmodifiable SortedBag
|
||||||
* @throws IllegalArgumentException if bag is null
|
* @throws IllegalArgumentException if bag is null
|
||||||
*/
|
*/
|
||||||
public static <E> SortedBag<E> decorate(SortedBag<E> bag) {
|
public static <E> SortedBag<E> unmodifiableSortedBag(SortedBag<E> bag) {
|
||||||
if (bag instanceof Unmodifiable) {
|
if (bag instanceof Unmodifiable) {
|
||||||
return bag;
|
return bag;
|
||||||
}
|
}
|
||||||
|
@ -102,7 +102,7 @@ public final class UnmodifiableSortedBag<E>
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
@Override
|
@Override
|
||||||
public Iterator<E> iterator() {
|
public Iterator<E> iterator() {
|
||||||
return UnmodifiableIterator.decorate(decorated().iterator());
|
return UnmodifiableIterator.unmodifiableIterator(decorated().iterator());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -149,7 +149,7 @@ public final class UnmodifiableSortedBag<E>
|
||||||
@Override
|
@Override
|
||||||
public Set<E> uniqueSet() {
|
public Set<E> uniqueSet() {
|
||||||
Set<E> set = decorated().uniqueSet();
|
Set<E> set = decorated().uniqueSet();
|
||||||
return UnmodifiableSet.decorate(set);
|
return UnmodifiableSet.unmodifiableSet(set);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -422,7 +422,7 @@ public class TreeBidiMap<K extends Comparable<K>, V extends Comparable<V>> imple
|
||||||
*/
|
*/
|
||||||
public OrderedMapIterator<K, V> mapIterator() {
|
public OrderedMapIterator<K, V> mapIterator() {
|
||||||
if (isEmpty()) {
|
if (isEmpty()) {
|
||||||
return EmptyOrderedMapIterator.<K, V>getInstance();
|
return EmptyOrderedMapIterator.<K, V>emptyOrderedMapIterator();
|
||||||
}
|
}
|
||||||
return new ViewMapIterator(KEY);
|
return new ViewMapIterator(KEY);
|
||||||
}
|
}
|
||||||
|
@ -2110,7 +2110,7 @@ public class TreeBidiMap<K extends Comparable<K>, V extends Comparable<V>> imple
|
||||||
|
|
||||||
public OrderedMapIterator<V, K> mapIterator() {
|
public OrderedMapIterator<V, K> mapIterator() {
|
||||||
if (isEmpty()) {
|
if (isEmpty()) {
|
||||||
return EmptyOrderedMapIterator.<V, K>getInstance();
|
return EmptyOrderedMapIterator.<V, K>emptyOrderedMapIterator();
|
||||||
}
|
}
|
||||||
return new InverseViewMapIterator(VALUE);
|
return new InverseViewMapIterator(VALUE);
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,7 @@ public final class UnmodifiableBidiMap<K, V>
|
||||||
* @return an unmodifiable BidiMap
|
* @return an unmodifiable BidiMap
|
||||||
* @throws IllegalArgumentException if map is null
|
* @throws IllegalArgumentException if map is null
|
||||||
*/
|
*/
|
||||||
public static <K, V> BidiMap<K, V> decorate(BidiMap<K, V> map) {
|
public static <K, V> BidiMap<K, V> unmodifiableBidiMap(BidiMap<K, V> map) {
|
||||||
if (map instanceof Unmodifiable) {
|
if (map instanceof Unmodifiable) {
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
@ -95,19 +95,19 @@ public final class UnmodifiableBidiMap<K, V>
|
||||||
@Override
|
@Override
|
||||||
public Set<Map.Entry<K, V>> entrySet() {
|
public Set<Map.Entry<K, V>> entrySet() {
|
||||||
Set<Map.Entry<K, V>> set = super.entrySet();
|
Set<Map.Entry<K, V>> set = super.entrySet();
|
||||||
return UnmodifiableEntrySet.decorate(set);
|
return UnmodifiableEntrySet.unmodifiableEntrySet(set);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<K> keySet() {
|
public Set<K> keySet() {
|
||||||
Set<K> set = super.keySet();
|
Set<K> set = super.keySet();
|
||||||
return UnmodifiableSet.decorate(set);
|
return UnmodifiableSet.unmodifiableSet(set);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<V> values() {
|
public Collection<V> values() {
|
||||||
Collection<V> coll = super.values();
|
Collection<V> coll = super.values();
|
||||||
return UnmodifiableCollection.decorate(coll);
|
return UnmodifiableCollection.unmodifiableCollection(coll);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
|
@ -119,7 +119,7 @@ public final class UnmodifiableBidiMap<K, V>
|
||||||
@Override
|
@Override
|
||||||
public MapIterator<K, V> mapIterator() {
|
public MapIterator<K, V> mapIterator() {
|
||||||
MapIterator<K, V> it = decorated().mapIterator();
|
MapIterator<K, V> it = decorated().mapIterator();
|
||||||
return UnmodifiableMapIterator.decorate(it);
|
return UnmodifiableMapIterator.unmodifiableMapIterator(it);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -53,7 +53,7 @@ public final class UnmodifiableOrderedBidiMap<K, V>
|
||||||
* @return an unmodifiable OrderedBidiMap
|
* @return an unmodifiable OrderedBidiMap
|
||||||
* @throws IllegalArgumentException if map is null
|
* @throws IllegalArgumentException if map is null
|
||||||
*/
|
*/
|
||||||
public static <K, V> OrderedBidiMap<K, V> decorate(OrderedBidiMap<K, V> map) {
|
public static <K, V> OrderedBidiMap<K, V> unmodifiableOrderedBidiMap(OrderedBidiMap<K, V> map) {
|
||||||
if (map instanceof Unmodifiable) {
|
if (map instanceof Unmodifiable) {
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
@ -95,19 +95,19 @@ public final class UnmodifiableOrderedBidiMap<K, V>
|
||||||
@Override
|
@Override
|
||||||
public Set<Map.Entry<K, V>> entrySet() {
|
public Set<Map.Entry<K, V>> entrySet() {
|
||||||
Set<Map.Entry<K, V>> set = super.entrySet();
|
Set<Map.Entry<K, V>> set = super.entrySet();
|
||||||
return UnmodifiableEntrySet.decorate(set);
|
return UnmodifiableEntrySet.unmodifiableEntrySet(set);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<K> keySet() {
|
public Set<K> keySet() {
|
||||||
Set<K> set = super.keySet();
|
Set<K> set = super.keySet();
|
||||||
return UnmodifiableSet.decorate(set);
|
return UnmodifiableSet.unmodifiableSet(set);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<V> values() {
|
public Collection<V> values() {
|
||||||
Collection<V> coll = super.values();
|
Collection<V> coll = super.values();
|
||||||
return UnmodifiableCollection.decorate(coll);
|
return UnmodifiableCollection.unmodifiableCollection(coll);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
|
@ -125,7 +125,7 @@ public final class UnmodifiableOrderedBidiMap<K, V>
|
||||||
@Override
|
@Override
|
||||||
public OrderedMapIterator<K, V> mapIterator() {
|
public OrderedMapIterator<K, V> mapIterator() {
|
||||||
OrderedMapIterator<K, V> it = decorated().mapIterator();
|
OrderedMapIterator<K, V> it = decorated().mapIterator();
|
||||||
return UnmodifiableOrderedMapIterator.decorate(it);
|
return UnmodifiableOrderedMapIterator.unmodifiableOrderedMapIterator(it);
|
||||||
}
|
}
|
||||||
|
|
||||||
public OrderedBidiMap<V, K> inverseOrderedBidiMap() {
|
public OrderedBidiMap<V, K> inverseOrderedBidiMap() {
|
||||||
|
|
|
@ -55,7 +55,7 @@ public final class UnmodifiableSortedBidiMap<K, V>
|
||||||
* @return an unmodifiable SortedBidiMap
|
* @return an unmodifiable SortedBidiMap
|
||||||
* @throws IllegalArgumentException if map is null
|
* @throws IllegalArgumentException if map is null
|
||||||
*/
|
*/
|
||||||
public static <K, V> SortedBidiMap<K, V> decorate(SortedBidiMap<K, V> map) {
|
public static <K, V> SortedBidiMap<K, V> unmodifiableSortedBidiMap(SortedBidiMap<K, V> map) {
|
||||||
if (map instanceof Unmodifiable) {
|
if (map instanceof Unmodifiable) {
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
@ -97,19 +97,19 @@ public final class UnmodifiableSortedBidiMap<K, V>
|
||||||
@Override
|
@Override
|
||||||
public Set<Map.Entry<K, V>> entrySet() {
|
public Set<Map.Entry<K, V>> entrySet() {
|
||||||
Set<Map.Entry<K, V>> set = super.entrySet();
|
Set<Map.Entry<K, V>> set = super.entrySet();
|
||||||
return UnmodifiableEntrySet.decorate(set);
|
return UnmodifiableEntrySet.unmodifiableEntrySet(set);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<K> keySet() {
|
public Set<K> keySet() {
|
||||||
Set<K> set = super.keySet();
|
Set<K> set = super.keySet();
|
||||||
return UnmodifiableSet.decorate(set);
|
return UnmodifiableSet.unmodifiableSet(set);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<V> values() {
|
public Collection<V> values() {
|
||||||
Collection<V> coll = super.values();
|
Collection<V> coll = super.values();
|
||||||
return UnmodifiableCollection.decorate(coll);
|
return UnmodifiableCollection.unmodifiableCollection(coll);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
|
@ -122,7 +122,7 @@ public final class UnmodifiableSortedBidiMap<K, V>
|
||||||
@Override
|
@Override
|
||||||
public OrderedMapIterator<K, V> mapIterator() {
|
public OrderedMapIterator<K, V> mapIterator() {
|
||||||
OrderedMapIterator<K, V> it = decorated().mapIterator();
|
OrderedMapIterator<K, V> it = decorated().mapIterator();
|
||||||
return UnmodifiableOrderedMapIterator.decorate(it);
|
return UnmodifiableOrderedMapIterator.unmodifiableOrderedMapIterator(it);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
|
@ -138,19 +138,19 @@ public final class UnmodifiableSortedBidiMap<K, V>
|
||||||
@Override
|
@Override
|
||||||
public SortedMap<K, V> subMap(K fromKey, K toKey) {
|
public SortedMap<K, V> subMap(K fromKey, K toKey) {
|
||||||
SortedMap<K, V> sm = decorated().subMap(fromKey, toKey);
|
SortedMap<K, V> sm = decorated().subMap(fromKey, toKey);
|
||||||
return UnmodifiableSortedMap.decorate(sm);
|
return UnmodifiableSortedMap.unmodifiableSortedMap(sm);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SortedMap<K, V> headMap(K toKey) {
|
public SortedMap<K, V> headMap(K toKey) {
|
||||||
SortedMap<K, V> sm = decorated().headMap(toKey);
|
SortedMap<K, V> sm = decorated().headMap(toKey);
|
||||||
return UnmodifiableSortedMap.decorate(sm);
|
return UnmodifiableSortedMap.unmodifiableSortedMap(sm);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SortedMap<K, V> tailMap(K fromKey) {
|
public SortedMap<K, V> tailMap(K fromKey) {
|
||||||
SortedMap<K, V> sm = decorated().tailMap(fromKey);
|
SortedMap<K, V> sm = decorated().tailMap(fromKey);
|
||||||
return UnmodifiableSortedMap.decorate(sm);
|
return UnmodifiableSortedMap.unmodifiableSortedMap(sm);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,7 +64,7 @@ public class BlockingBuffer<E> extends SynchronizedBuffer<E> {
|
||||||
* @return a new blocking Buffer
|
* @return a new blocking Buffer
|
||||||
* @throws IllegalArgumentException if buffer is null
|
* @throws IllegalArgumentException if buffer is null
|
||||||
*/
|
*/
|
||||||
public static <T> Buffer<T> decorate(Buffer<T> buffer) {
|
public static <T> Buffer<T> blockingBuffer(Buffer<T> buffer) {
|
||||||
return new BlockingBuffer<T>(buffer);
|
return new BlockingBuffer<T>(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ public class BlockingBuffer<E> extends SynchronizedBuffer<E> {
|
||||||
* @throws IllegalArgumentException if the buffer is null
|
* @throws IllegalArgumentException if the buffer is null
|
||||||
* @since Commons Collections 3.2
|
* @since Commons Collections 3.2
|
||||||
*/
|
*/
|
||||||
public static <T> Buffer<T> decorate(Buffer<T> buffer, long timeoutMillis) {
|
public static <T> Buffer<T> blockingBuffer(Buffer<T> buffer, long timeoutMillis) {
|
||||||
return new BlockingBuffer<T>(buffer, timeoutMillis);
|
return new BlockingBuffer<T>(buffer, timeoutMillis);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -67,7 +67,7 @@ public class BoundedBuffer<E> extends SynchronizedBuffer<E> implements BoundedCo
|
||||||
* @throws IllegalArgumentException if the buffer is null
|
* @throws IllegalArgumentException if the buffer is null
|
||||||
* @throws IllegalArgumentException if the maximum size is zero or less
|
* @throws IllegalArgumentException if the maximum size is zero or less
|
||||||
*/
|
*/
|
||||||
public static <E> BoundedBuffer<E> decorate(Buffer<E> buffer, int maximumSize) {
|
public static <E> BoundedBuffer<E> boundedBuffer(Buffer<E> buffer, int maximumSize) {
|
||||||
return new BoundedBuffer<E>(buffer, maximumSize, 0L);
|
return new BoundedBuffer<E>(buffer, maximumSize, 0L);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ public class BoundedBuffer<E> extends SynchronizedBuffer<E> implements BoundedCo
|
||||||
* @throws IllegalArgumentException if the buffer is null
|
* @throws IllegalArgumentException if the buffer is null
|
||||||
* @throws IllegalArgumentException if the maximum size is zero or less
|
* @throws IllegalArgumentException if the maximum size is zero or less
|
||||||
*/
|
*/
|
||||||
public static <E> BoundedBuffer<E> decorate(Buffer<E> buffer, int maximumSize, long timeout) {
|
public static <E> BoundedBuffer<E> boundedBuffer(Buffer<E> buffer, int maximumSize, long timeout) {
|
||||||
return new BoundedBuffer<E>(buffer, maximumSize, timeout);
|
return new BoundedBuffer<E>(buffer, maximumSize, timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -56,7 +56,7 @@ public class PredicatedBuffer<E> extends PredicatedCollection<E> implements Buff
|
||||||
* @throws IllegalArgumentException if buffer or predicate is null
|
* @throws IllegalArgumentException if buffer or predicate is null
|
||||||
* @throws IllegalArgumentException if the buffer contains invalid elements
|
* @throws IllegalArgumentException if the buffer contains invalid elements
|
||||||
*/
|
*/
|
||||||
public static <T> Buffer<T> decorate(Buffer<T> buffer, Predicate<? super T> predicate) {
|
public static <T> Buffer<T> predicatedBuffer(Buffer<T> buffer, Predicate<? super T> predicate) {
|
||||||
return new PredicatedBuffer<T>(buffer, predicate);
|
return new PredicatedBuffer<T>(buffer, predicate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ import org.apache.commons.collections.comparators.ComparableComparator;
|
||||||
* <p>
|
* <p>
|
||||||
* Note that this implementation is not synchronized. Use
|
* Note that this implementation is not synchronized. Use
|
||||||
* {@link org.apache.commons.collections.BufferUtils#synchronizedBuffer(Buffer)} or
|
* {@link org.apache.commons.collections.BufferUtils#synchronizedBuffer(Buffer)} or
|
||||||
* {@link org.apache.commons.collections.buffer.SynchronizedBuffer#decorate(Buffer)}
|
* {@link org.apache.commons.collections.buffer.SynchronizedBuffer#synchronizedBuffer(Buffer)}
|
||||||
* to provide synchronized access to a <code>PriorityBuffer</code>:
|
* to provide synchronized access to a <code>PriorityBuffer</code>:
|
||||||
* <pre>
|
* <pre>
|
||||||
* Buffer heap = SynchronizedBuffer.decorate(new PriorityBuffer());
|
* Buffer heap = SynchronizedBuffer.decorate(new PriorityBuffer());
|
||||||
|
|
|
@ -48,7 +48,7 @@ public class SynchronizedBuffer<E>
|
||||||
* @return a new synchronized Buffer
|
* @return a new synchronized Buffer
|
||||||
* @throws IllegalArgumentException if buffer is null
|
* @throws IllegalArgumentException if buffer is null
|
||||||
*/
|
*/
|
||||||
public static <T> Buffer<T> decorate(Buffer<T> buffer) {
|
public static <T> Buffer<T> synchronizedBuffer(Buffer<T> buffer) {
|
||||||
return new SynchronizedBuffer<T>(buffer);
|
return new SynchronizedBuffer<T>(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,14 +45,14 @@ public class TransformedBuffer<E> extends TransformedCollection<E> implements Bu
|
||||||
* <p>
|
* <p>
|
||||||
* If there are any elements already in the buffer being decorated, they
|
* If there are any elements already in the buffer being decorated, they
|
||||||
* are NOT transformed.
|
* are NOT transformed.
|
||||||
* Constrast this with {@link #decorateTransform}.
|
* Contrast this with {@link #transformedBuffer(Buffer, Transformer)}.
|
||||||
*
|
*
|
||||||
* @param buffer the buffer to decorate, must not be null
|
* @param buffer the buffer to decorate, must not be null
|
||||||
* @param transformer the transformer to use for conversion, must not be null
|
* @param transformer the transformer to use for conversion, must not be null
|
||||||
* @return a new transformed Buffer
|
* @return a new transformed Buffer
|
||||||
* @throws IllegalArgumentException if buffer or transformer is null
|
* @throws IllegalArgumentException if buffer or transformer is null
|
||||||
*/
|
*/
|
||||||
public static <E> Buffer<E> decorate(Buffer<E> buffer, Transformer<? super E, ? extends E> transformer) {
|
public static <E> Buffer<E> transformingBuffer(Buffer<E> buffer, Transformer<? super E, ? extends E> transformer) {
|
||||||
return new TransformedBuffer<E>(buffer, transformer);
|
return new TransformedBuffer<E>(buffer, transformer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ public class TransformedBuffer<E> extends TransformedCollection<E> implements Bu
|
||||||
* <p>
|
* <p>
|
||||||
* If there are any elements already in the buffer being decorated, they
|
* If there are any elements already in the buffer being decorated, they
|
||||||
* will be transformed by this method.
|
* will be transformed by this method.
|
||||||
* Constrast this with {@link #decorate}.
|
* Contrast this with {@link #transformingBuffer(Buffer, Transformer)}.
|
||||||
*
|
*
|
||||||
* @param buffer the buffer to decorate, must not be null
|
* @param buffer the buffer to decorate, must not be null
|
||||||
* @param transformer the transformer to use for conversion, must not be null
|
* @param transformer the transformer to use for conversion, must not be null
|
||||||
|
@ -70,7 +70,7 @@ public class TransformedBuffer<E> extends TransformedCollection<E> implements Bu
|
||||||
* @throws IllegalArgumentException if buffer or transformer is null
|
* @throws IllegalArgumentException if buffer or transformer is null
|
||||||
* @since Commons Collections 3.3
|
* @since Commons Collections 3.3
|
||||||
*/
|
*/
|
||||||
public static <E> Buffer<E> decorateTransform(Buffer<E> buffer, Transformer<? super E, ? extends E> transformer) {
|
public static <E> Buffer<E> transformedBuffer(Buffer<E> buffer, Transformer<? super E, ? extends E> transformer) {
|
||||||
TransformedBuffer<E> decorated = new TransformedBuffer<E>(buffer, transformer); // throws IAE if buffer or transformer is null
|
TransformedBuffer<E> decorated = new TransformedBuffer<E>(buffer, transformer); // throws IAE if buffer or transformer is null
|
||||||
if (buffer.size() > 0) {
|
if (buffer.size() > 0) {
|
||||||
@SuppressWarnings("unchecked") // buffer is type <E>
|
@SuppressWarnings("unchecked") // buffer is type <E>
|
||||||
|
|
|
@ -55,7 +55,7 @@ public final class UnmodifiableBuffer<E>
|
||||||
* @return an unmodifiable Buffer
|
* @return an unmodifiable Buffer
|
||||||
* @throws IllegalArgumentException if buffer is null
|
* @throws IllegalArgumentException if buffer is null
|
||||||
*/
|
*/
|
||||||
public static <E> Buffer<E> decorate(Buffer<E> buffer) {
|
public static <E> Buffer<E> unmodifiableBuffer(Buffer<E> buffer) {
|
||||||
if (buffer instanceof Unmodifiable) {
|
if (buffer instanceof Unmodifiable) {
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
@ -101,7 +101,7 @@ public final class UnmodifiableBuffer<E>
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
@Override
|
@Override
|
||||||
public Iterator<E> iterator() {
|
public Iterator<E> iterator() {
|
||||||
return UnmodifiableIterator.decorate(decorated().iterator());
|
return UnmodifiableIterator.unmodifiableIterator(decorated().iterator());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -163,7 +163,7 @@ public class CompositeCollection<E> implements Collection<E>, Serializable {
|
||||||
*/
|
*/
|
||||||
public Iterator<E> iterator() {
|
public Iterator<E> iterator() {
|
||||||
if (all.isEmpty()) {
|
if (all.isEmpty()) {
|
||||||
return EmptyIterator.<E>getInstance();
|
return EmptyIterator.<E>emptyIterator();
|
||||||
}
|
}
|
||||||
IteratorChain<E> chain = new IteratorChain<E>();
|
IteratorChain<E> chain = new IteratorChain<E>();
|
||||||
for (Collection<? extends E> item : all) {
|
for (Collection<? extends E> item : all) {
|
||||||
|
@ -419,7 +419,7 @@ public class CompositeCollection<E> implements Collection<E>, Serializable {
|
||||||
* @return Unmodifiable list of all collections in this composite.
|
* @return Unmodifiable list of all collections in this composite.
|
||||||
*/
|
*/
|
||||||
public List<? extends Collection<E>> getCollections() {
|
public List<? extends Collection<E>> getCollections() {
|
||||||
return UnmodifiableList.decorate(all);
|
return UnmodifiableList.unmodifiableList(all);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -61,7 +61,7 @@ public class PredicatedCollection<E> extends AbstractCollectionDecorator<E> {
|
||||||
* @throws IllegalArgumentException if collection or predicate is null
|
* @throws IllegalArgumentException if collection or predicate is null
|
||||||
* @throws IllegalArgumentException if the collection contains invalid elements
|
* @throws IllegalArgumentException if the collection contains invalid elements
|
||||||
*/
|
*/
|
||||||
public static <T> Collection<T> decorate(Collection<T> coll, Predicate<? super T> predicate) {
|
public static <T> Collection<T> predicatedCollection(Collection<T> coll, Predicate<? super T> predicate) {
|
||||||
return new PredicatedCollection<T>(coll, predicate);
|
return new PredicatedCollection<T>(coll, predicate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,7 @@ public class SynchronizedCollection<E> implements Collection<E>, Serializable {
|
||||||
* @return a new synchronized collection
|
* @return a new synchronized collection
|
||||||
* @throws IllegalArgumentException if collection is null
|
* @throws IllegalArgumentException if collection is null
|
||||||
*/
|
*/
|
||||||
public static <T> Collection<T> decorate(Collection<T> coll) {
|
public static <T> Collection<T> synchronizedCollection(Collection<T> coll) {
|
||||||
return new SynchronizedCollection<T>(coll);
|
return new SynchronizedCollection<T>(coll);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,14 +51,14 @@ public class TransformedCollection<E> extends AbstractCollectionDecorator<E> {
|
||||||
* <p>
|
* <p>
|
||||||
* If there are any elements already in the collection being decorated, they
|
* If there are any elements already in the collection being decorated, they
|
||||||
* are NOT transformed.
|
* are NOT transformed.
|
||||||
* Constrast this with {@link #decorateTransform}.
|
* Contrast this with {@link #transformedCollection(Collection, Transformer)}.
|
||||||
*
|
*
|
||||||
* @param coll the collection to decorate, must not be null
|
* @param coll the collection to decorate, must not be null
|
||||||
* @param transformer the transformer to use for conversion, must not be null
|
* @param transformer the transformer to use for conversion, must not be null
|
||||||
* @return a new transformed collection
|
* @return a new transformed collection
|
||||||
* @throws IllegalArgumentException if collection or transformer is null
|
* @throws IllegalArgumentException if collection or transformer is null
|
||||||
*/
|
*/
|
||||||
public static <E> Collection<E> decorate(Collection<E> coll, Transformer<? super E, ? extends E> transformer) {
|
public static <E> Collection<E> transformingCollection(Collection<E> coll, Transformer<? super E, ? extends E> transformer) {
|
||||||
return new TransformedCollection<E>(coll, transformer);
|
return new TransformedCollection<E>(coll, transformer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ public class TransformedCollection<E> extends AbstractCollectionDecorator<E> {
|
||||||
* <p>
|
* <p>
|
||||||
* If there are any elements already in the collection being decorated, they
|
* If there are any elements already in the collection being decorated, they
|
||||||
* will be transformed by this method.
|
* will be transformed by this method.
|
||||||
* Constrast this with {@link #decorate}.
|
* Contrast this with {@link #transformingCollection(Collection, Transformer)}.
|
||||||
*
|
*
|
||||||
* @param collection the collection to decorate, must not be null
|
* @param collection the collection to decorate, must not be null
|
||||||
* @param transformer the transformer to use for conversion, must not be null
|
* @param transformer the transformer to use for conversion, must not be null
|
||||||
|
@ -76,7 +76,7 @@ public class TransformedCollection<E> extends AbstractCollectionDecorator<E> {
|
||||||
* @throws IllegalArgumentException if collection or transformer is null
|
* @throws IllegalArgumentException if collection or transformer is null
|
||||||
* @since Commons Collections 3.3
|
* @since Commons Collections 3.3
|
||||||
*/
|
*/
|
||||||
public static <E> Collection<E> decorateTransform(Collection<E> collection, Transformer<? super E, ? extends E> transformer) {
|
public static <E> Collection<E> transformedCollection(Collection<E> collection, Transformer<? super E, ? extends E> transformer) {
|
||||||
TransformedCollection<E> decorated = new TransformedCollection<E>(collection, transformer);
|
TransformedCollection<E> decorated = new TransformedCollection<E>(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) {
|
||||||
|
|
|
@ -54,8 +54,8 @@ public final class UnmodifiableBoundedCollection<E> extends AbstractCollectionDe
|
||||||
* @return a new unmodifiable bounded collection
|
* @return a new unmodifiable bounded collection
|
||||||
* @throws IllegalArgumentException if bag is null
|
* @throws IllegalArgumentException if bag is null
|
||||||
*/
|
*/
|
||||||
public static <E> BoundedCollection<E> decorate(BoundedCollection<E> coll) {
|
public static <E> BoundedCollection<E> unmodifiableBoundedCollection(BoundedCollection<E> coll) {
|
||||||
return new UnmodifiableBoundedCollection<E>(coll);
|
return unmodifiableBoundedCollection(coll);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -69,7 +69,7 @@ public final class UnmodifiableBoundedCollection<E> extends AbstractCollectionDe
|
||||||
* @throws IllegalArgumentException if bag is null
|
* @throws IllegalArgumentException if bag is null
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static <E> BoundedCollection<E> decorateUsing(Collection<? super E> coll) {
|
public static <E> BoundedCollection<E> unmodifiableBoundedCollection(Collection<? extends E> coll) {
|
||||||
if (coll == null) {
|
if (coll == null) {
|
||||||
throw new IllegalArgumentException("The collection must not be null");
|
throw new IllegalArgumentException("The collection must not be null");
|
||||||
}
|
}
|
||||||
|
@ -105,7 +105,7 @@ public final class UnmodifiableBoundedCollection<E> extends AbstractCollectionDe
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
@Override
|
@Override
|
||||||
public Iterator<E> iterator() {
|
public Iterator<E> iterator() {
|
||||||
return UnmodifiableIterator.decorate(decorated().iterator());
|
return UnmodifiableIterator.unmodifiableIterator(decorated().iterator());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -52,7 +52,7 @@ public final class UnmodifiableCollection<E>
|
||||||
* @return an unmodifiable collection
|
* @return an unmodifiable collection
|
||||||
* @throws IllegalArgumentException if collection is null
|
* @throws IllegalArgumentException if collection is null
|
||||||
*/
|
*/
|
||||||
public static <T> Collection<T> decorate(Collection<T> coll) {
|
public static <T> Collection<T> unmodifiableCollection(Collection<T> coll) {
|
||||||
if (coll instanceof Unmodifiable) {
|
if (coll instanceof Unmodifiable) {
|
||||||
return coll;
|
return coll;
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,7 @@ public final class UnmodifiableCollection<E>
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
@Override
|
@Override
|
||||||
public Iterator<E> iterator() {
|
public Iterator<E> iterator() {
|
||||||
return UnmodifiableIterator.decorate(decorated().iterator());
|
return UnmodifiableIterator.unmodifiableIterator(decorated().iterator());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -25,7 +25,7 @@ import java.util.Comparator;
|
||||||
* <p>
|
* <p>
|
||||||
* @see #getTrueFirstComparator()
|
* @see #getTrueFirstComparator()
|
||||||
* @see #getFalseFirstComparator()
|
* @see #getFalseFirstComparator()
|
||||||
* @see #getBooleanComparator(boolean)
|
* @see #booleanComparator(boolean)
|
||||||
*
|
*
|
||||||
* @since Commons Collections 3.0
|
* @since Commons Collections 3.0
|
||||||
* @version $Revision$ $Date$
|
* @version $Revision$ $Date$
|
||||||
|
@ -94,7 +94,7 @@ public final class BooleanComparator implements Comparator<Boolean>, Serializabl
|
||||||
* <code>true</code> <code>Boolean</code>s before <code>false</code>
|
* <code>true</code> <code>Boolean</code>s before <code>false</code>
|
||||||
* @return a singleton BooleanComparator instance
|
* @return a singleton BooleanComparator instance
|
||||||
*/
|
*/
|
||||||
public static BooleanComparator getBooleanComparator(boolean trueFirst) {
|
public static BooleanComparator booleanComparator(boolean trueFirst) {
|
||||||
return trueFirst ? TRUE_FIRST : FALSE_FIRST;
|
return trueFirst ? TRUE_FIRST : FALSE_FIRST;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,7 +60,7 @@ public class ComparableComparator<E extends Comparable<? super E>> implements Co
|
||||||
* @return the singleton ComparableComparator
|
* @return the singleton ComparableComparator
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static <E extends Comparable<? super E>> ComparableComparator<E> getInstance() {
|
public static <E extends Comparable<? super E>> ComparableComparator<E> comparableComparator() {
|
||||||
return (ComparableComparator<E>) INSTANCE;
|
return (ComparableComparator<E>) INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ public class ComparableComparator<E extends Comparable<? super E>> implements Co
|
||||||
/**
|
/**
|
||||||
* Constructor whose use should be avoided.
|
* Constructor whose use should be avoided.
|
||||||
* <p>
|
* <p>
|
||||||
* Please use the {@link #getInstance()} method whenever possible.
|
* Please use the {@link #comparableComparator()} method whenever possible.
|
||||||
*/
|
*/
|
||||||
public ComparableComparator() {
|
public ComparableComparator() {
|
||||||
super();
|
super();
|
||||||
|
|
|
@ -46,7 +46,7 @@ public final class AndPredicate<T> implements Predicate<T>, PredicateDecorator<T
|
||||||
* @return the <code>and</code> predicate
|
* @return the <code>and</code> predicate
|
||||||
* @throws IllegalArgumentException if either predicate is null
|
* @throws IllegalArgumentException if either predicate is null
|
||||||
*/
|
*/
|
||||||
public static <T> Predicate<T> getInstance(Predicate<? super T> predicate1, Predicate<? super T> predicate2) {
|
public static <T> Predicate<T> andPredicate(Predicate<? super T> predicate1, Predicate<? super T> predicate2) {
|
||||||
if (predicate1 == null || predicate2 == null) {
|
if (predicate1 == null || predicate2 == null) {
|
||||||
throw new IllegalArgumentException("Predicate must not be null");
|
throw new IllegalArgumentException("Predicate must not be null");
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,7 @@ public final class AnyPredicate<T> implements Predicate<T>, PredicateDecorator<T
|
||||||
* @throws IllegalArgumentException if any predicate in the array is null
|
* @throws IllegalArgumentException if any predicate in the array is null
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static <T> Predicate<T> getInstance(Predicate<? super T>[] predicates) {
|
public static <T> Predicate<T> anyPredicate(Predicate<? super T>... predicates) {
|
||||||
FunctorUtils.validate(predicates);
|
FunctorUtils.validate(predicates);
|
||||||
if (predicates.length == 0) {
|
if (predicates.length == 0) {
|
||||||
return FalsePredicate.<T>falsePredicate();
|
return FalsePredicate.<T>falsePredicate();
|
||||||
|
@ -78,7 +78,7 @@ public final class AnyPredicate<T> implements Predicate<T>, PredicateDecorator<T
|
||||||
* @throws IllegalArgumentException if any predicate in the array is null
|
* @throws IllegalArgumentException if any predicate in the array is null
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static <T> Predicate<T> getInstance(Collection<? extends Predicate<T>> predicates) {
|
public static <T> Predicate<T> anyPredicate(Collection<? extends Predicate<T>> predicates) {
|
||||||
Predicate<? super T>[] preds = FunctorUtils.validate(predicates);
|
Predicate<? super T>[] preds = FunctorUtils.validate(predicates);
|
||||||
if (preds.length == 0) {
|
if (preds.length == 0) {
|
||||||
return FalsePredicate.<T>falsePredicate();
|
return FalsePredicate.<T>falsePredicate();
|
||||||
|
|
|
@ -45,10 +45,10 @@ public class ChainedClosure<E> implements Closure<E>, Serializable {
|
||||||
* @throws IllegalArgumentException if the closures array is null
|
* @throws IllegalArgumentException if the closures array is null
|
||||||
* @throws IllegalArgumentException if any closure in the array is null
|
* @throws IllegalArgumentException if any closure in the array is null
|
||||||
*/
|
*/
|
||||||
public static <E> Closure<E> getInstance(Closure<? super E>[] closures) {
|
public static <E> Closure<E> chainedClosure(Closure<? super E>... closures) {
|
||||||
FunctorUtils.validate(closures);
|
FunctorUtils.validate(closures);
|
||||||
if (closures.length == 0) {
|
if (closures.length == 0) {
|
||||||
return NOPClosure.<E>getInstance();
|
return NOPClosure.<E>nopClosure();
|
||||||
}
|
}
|
||||||
closures = FunctorUtils.copy(closures);
|
closures = FunctorUtils.copy(closures);
|
||||||
return new ChainedClosure<E>(closures);
|
return new ChainedClosure<E>(closures);
|
||||||
|
@ -65,12 +65,12 @@ public class ChainedClosure<E> implements Closure<E>, Serializable {
|
||||||
* @throws IllegalArgumentException if any closure in the collection is null
|
* @throws IllegalArgumentException if any closure in the collection is null
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static <E> Closure<E> getInstance(Collection<Closure<E>> closures) {
|
public static <E> Closure<E> chainedClosure(Collection<Closure<E>> closures) {
|
||||||
if (closures == null) {
|
if (closures == null) {
|
||||||
throw new IllegalArgumentException("Closure collection must not be null");
|
throw new IllegalArgumentException("Closure collection must not be null");
|
||||||
}
|
}
|
||||||
if (closures.size() == 0) {
|
if (closures.size() == 0) {
|
||||||
return NOPClosure.<E>getInstance();
|
return NOPClosure.<E>nopClosure();
|
||||||
}
|
}
|
||||||
// convert to array like this to guarantee iterator() ordering
|
// convert to array like this to guarantee iterator() ordering
|
||||||
Closure<? super E>[] cmds = new Closure[closures.size()];
|
Closure<? super E>[] cmds = new Closure[closures.size()];
|
||||||
|
@ -82,23 +82,6 @@ public class ChainedClosure<E> implements Closure<E>, Serializable {
|
||||||
return new ChainedClosure<E>(cmds);
|
return new ChainedClosure<E>(cmds);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Factory method that performs validation.
|
|
||||||
*
|
|
||||||
* @param closure1 the first closure, not null
|
|
||||||
* @param closure2 the second closure, not null
|
|
||||||
* @return the <code>chained</code> closure
|
|
||||||
* @throws IllegalArgumentException if either closure is null
|
|
||||||
*/
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public static <E> Closure<E> getInstance(Closure<? super E> closure1, Closure<? super E> closure2) {
|
|
||||||
if (closure1 == null || closure2 == null) {
|
|
||||||
throw new IllegalArgumentException("Closures must not be null");
|
|
||||||
}
|
|
||||||
Closure<E>[] closures = new Closure[] { closure1, closure2 };
|
|
||||||
return new ChainedClosure<E>(closures);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor that performs no validation.
|
* Constructor that performs no validation.
|
||||||
* Use <code>getInstance</code> if you want that.
|
* Use <code>getInstance</code> if you want that.
|
||||||
|
|
|
@ -48,10 +48,10 @@ public class ChainedTransformer<T> implements Transformer<T, T>, Serializable {
|
||||||
* @throws IllegalArgumentException if the transformers array is null
|
* @throws IllegalArgumentException if the transformers array is null
|
||||||
* @throws IllegalArgumentException if any transformer in the array is null
|
* @throws IllegalArgumentException if any transformer in the array is null
|
||||||
*/
|
*/
|
||||||
public static <T> Transformer<T, T> getInstance(Transformer<? super T, ? extends T>[] transformers) {
|
public static <T> Transformer<T, T> chainedTransformer(Transformer<? super T, ? extends T>... transformers) {
|
||||||
FunctorUtils.validate(transformers);
|
FunctorUtils.validate(transformers);
|
||||||
if (transformers.length == 0) {
|
if (transformers.length == 0) {
|
||||||
return NOPTransformer.<T>getInstance();
|
return NOPTransformer.<T>nopTransformer();
|
||||||
}
|
}
|
||||||
transformers = FunctorUtils.copy(transformers);
|
transformers = FunctorUtils.copy(transformers);
|
||||||
return new ChainedTransformer<T>(transformers);
|
return new ChainedTransformer<T>(transformers);
|
||||||
|
@ -68,12 +68,12 @@ public class ChainedTransformer<T> implements Transformer<T, T>, Serializable {
|
||||||
* @throws IllegalArgumentException if any transformer in the collection is null
|
* @throws IllegalArgumentException if any transformer in the collection is null
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static <T> Transformer<T, T> getInstance(Collection<? extends Transformer<T, T>> transformers) {
|
public static <T> Transformer<T, T> chainedTransformer(Collection<? extends Transformer<T, T>> transformers) {
|
||||||
if (transformers == null) {
|
if (transformers == null) {
|
||||||
throw new IllegalArgumentException("Transformer collection must not be null");
|
throw new IllegalArgumentException("Transformer collection must not be null");
|
||||||
}
|
}
|
||||||
if (transformers.size() == 0) {
|
if (transformers.size() == 0) {
|
||||||
return NOPTransformer.<T>getInstance();
|
return NOPTransformer.<T>nopTransformer();
|
||||||
}
|
}
|
||||||
// convert to array like this to guarantee iterator() ordering
|
// convert to array like this to guarantee iterator() ordering
|
||||||
Transformer<T, T>[] cmds = transformers.toArray(new Transformer[transformers.size()]);
|
Transformer<T, T>[] cmds = transformers.toArray(new Transformer[transformers.size()]);
|
||||||
|
@ -81,23 +81,6 @@ public class ChainedTransformer<T> implements Transformer<T, T>, Serializable {
|
||||||
return new ChainedTransformer<T>(cmds);
|
return new ChainedTransformer<T>(cmds);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Factory method that performs validation.
|
|
||||||
*
|
|
||||||
* @param transformer1 the first transformer, not null
|
|
||||||
* @param transformer2 the second transformer, not null
|
|
||||||
* @return the <code>chained</code> transformer
|
|
||||||
* @throws IllegalArgumentException if either transformer is null
|
|
||||||
*/
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public static <T> Transformer<T, T> getInstance(Transformer<? super T, ? extends T> transformer1, Transformer<? super T, ? extends T> transformer2) {
|
|
||||||
if (transformer1 == null || transformer2 == null) {
|
|
||||||
throw new IllegalArgumentException("Transformers must not be null");
|
|
||||||
}
|
|
||||||
Transformer<? super T, ? extends T>[] transformers = new Transformer[] { transformer1, transformer2 };
|
|
||||||
return new ChainedTransformer<T>(transformers);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor that performs no validation.
|
* Constructor that performs no validation.
|
||||||
* Use <code>getInstance</code> if you want that.
|
* Use <code>getInstance</code> if you want that.
|
||||||
|
|
|
@ -45,7 +45,7 @@ public class CloneTransformer<T> implements Transformer<T, T>, Serializable {
|
||||||
* @since Commons Collections 3.1
|
* @since Commons Collections 3.1
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static <T> Transformer<T, T> getInstance() {
|
public static <T> Transformer<T, T> cloneTransformer() {
|
||||||
return (Transformer<T, T>) INSTANCE;
|
return (Transformer<T, T>) INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ public class CloneTransformer<T> implements Transformer<T, T>, Serializable {
|
||||||
if (input == null) {
|
if (input == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return PrototypeFactory.getInstance(input).create();
|
return PrototypeFactory.prototypeFactory(input).create();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Object readResolve() {
|
private Object readResolve() {
|
||||||
|
|
|
@ -45,7 +45,7 @@ public class ClosureTransformer<T> implements Transformer<T, T>, Serializable {
|
||||||
* @return the <code>closure</code> transformer
|
* @return the <code>closure</code> transformer
|
||||||
* @throws IllegalArgumentException if the closure is null
|
* @throws IllegalArgumentException if the closure is null
|
||||||
*/
|
*/
|
||||||
public static <T> Transformer<T, T> getInstance(Closure<? super T> closure) {
|
public static <T> Transformer<T, T> closureTransformer(Closure<? super T> closure) {
|
||||||
if (closure == null) {
|
if (closure == null) {
|
||||||
throw new IllegalArgumentException("Closure must not be null");
|
throw new IllegalArgumentException("Closure must not be null");
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,8 +105,8 @@ public class ComparatorPredicate<T> implements Predicate<T>, Serializable {
|
||||||
* @return the predicate
|
* @return the predicate
|
||||||
* @throws IllegalArgumentException if comparator is null
|
* @throws IllegalArgumentException if comparator is null
|
||||||
*/
|
*/
|
||||||
public static <T> Predicate<T> getInstance(T object, Comparator<T> comparator) {
|
public static <T> Predicate<T> comparatorPredicate(T object, Comparator<T> comparator) {
|
||||||
return getInstance(object, comparator, Criterion.EQUAL);
|
return comparatorPredicate(object, comparator, Criterion.EQUAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -118,7 +118,7 @@ public class ComparatorPredicate<T> implements Predicate<T>, Serializable {
|
||||||
* @return the predicate
|
* @return the predicate
|
||||||
* @throws IllegalArgumentException if comparator is null of criterion is invalid
|
* @throws IllegalArgumentException if comparator is null of criterion is invalid
|
||||||
*/
|
*/
|
||||||
public static <T> Predicate<T> getInstance(T object, Comparator<T> comparator, Criterion criterion) {
|
public static <T> Predicate<T> comparatorPredicate(T object, Comparator<T> comparator, Criterion criterion) {
|
||||||
if (comparator == null) {
|
if (comparator == null) {
|
||||||
throw new IllegalArgumentException("Comparator must not be null.");
|
throw new IllegalArgumentException("Comparator must not be null.");
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ public class ConstantFactory<T> implements Factory<T>, Serializable {
|
||||||
* @return the <code>constant</code> factory.
|
* @return the <code>constant</code> factory.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static <T> Factory<T> getInstance(T constantToReturn) {
|
public static <T> Factory<T> constantFactory(T constantToReturn) {
|
||||||
if (constantToReturn == null) {
|
if (constantToReturn == null) {
|
||||||
return (Factory<T>) NULL_INSTANCE;
|
return (Factory<T>) NULL_INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ public class ConstantTransformer<I, O> implements Transformer<I, O>, Serializabl
|
||||||
* @return Transformer<I, O> that always returns null.
|
* @return Transformer<I, O> that always returns null.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static <I, O> Transformer<I, O> getNullInstance() {
|
public static <I, O> Transformer<I, O> nullTransformer() {
|
||||||
return (Transformer<I, O>) NULL_INSTANCE;
|
return (Transformer<I, O>) NULL_INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,9 +60,9 @@ public class ConstantTransformer<I, O> implements Transformer<I, O>, Serializabl
|
||||||
* @param constantToReturn the constant object to return each time in the factory
|
* @param constantToReturn the constant object to return each time in the factory
|
||||||
* @return the <code>constant</code> factory.
|
* @return the <code>constant</code> factory.
|
||||||
*/
|
*/
|
||||||
public static <I, O> Transformer<I, O> getInstance(O constantToReturn) {
|
public static <I, O> Transformer<I, O> constantTransformer(O constantToReturn) {
|
||||||
if (constantToReturn == null) {
|
if (constantToReturn == null) {
|
||||||
return getNullInstance();
|
return nullTransformer();
|
||||||
}
|
}
|
||||||
return new ConstantTransformer<I, O>(constantToReturn);
|
return new ConstantTransformer<I, O>(constantToReturn);
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,7 +60,7 @@ public class DefaultEquator<T> implements Equator<T> {
|
||||||
* @return {@link DefaultEquator#INSTANCE}
|
* @return {@link DefaultEquator#INSTANCE}
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static <T> DefaultEquator<T> instance() {
|
public static <T> DefaultEquator<T> defaultEquator() {
|
||||||
return (DefaultEquator<T>) DefaultEquator.INSTANCE;
|
return (DefaultEquator<T>) DefaultEquator.INSTANCE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,7 @@ public final class EqualPredicate<T> implements Predicate<T>, Serializable {
|
||||||
|
|
||||||
/** The value to compare to */
|
/** The value to compare to */
|
||||||
private final Object iValue;
|
private final Object iValue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Factory to create the identity predicate.
|
* Factory to create the identity predicate.
|
||||||
*
|
*
|
||||||
|
|
|
@ -44,7 +44,7 @@ public final class ExceptionClosure<E> implements Closure<E>, Serializable {
|
||||||
* @since Commons Collections 3.1
|
* @since Commons Collections 3.1
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static <E> Closure<E> getInstance() {
|
public static <E> Closure<E> exceptionClosure() {
|
||||||
return (Closure<E>) INSTANCE;
|
return (Closure<E>) INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ public final class ExceptionFactory<T> implements Factory<T>, Serializable {
|
||||||
* @since Commons Collections 3.1
|
* @since Commons Collections 3.1
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static <T> Factory<T> getInstance() {
|
public static <T> Factory<T> exceptionFactory() {
|
||||||
return (Factory<T>) INSTANCE;
|
return (Factory<T>) INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ public final class ExceptionPredicate<T> implements Predicate<T>, Serializable {
|
||||||
* @since Commons Collections 3.1
|
* @since Commons Collections 3.1
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static <T> Predicate<T> getInstance() {
|
public static <T> Predicate<T> exceptionPredicate() {
|
||||||
return (Predicate<T>) INSTANCE;
|
return (Predicate<T>) INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ public final class ExceptionTransformer<I, O> implements Transformer<I, O>, Seri
|
||||||
* @since Commons Collections 3.1
|
* @since Commons Collections 3.1
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static <I, O> Transformer<I, O> getInstance() {
|
public static <I, O> Transformer<I, O> exceptionTransformer() {
|
||||||
return (Transformer<I, O>) INSTANCE;
|
return (Transformer<I, O>) INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ public class FactoryTransformer<I, O> implements Transformer<I, O>, Serializable
|
||||||
* @return the <code>factory</code> transformer
|
* @return the <code>factory</code> transformer
|
||||||
* @throws IllegalArgumentException if the factory is null
|
* @throws IllegalArgumentException if the factory is null
|
||||||
*/
|
*/
|
||||||
public static <I, O> Transformer<I, O> getInstance(Factory<? extends O> factory) {
|
public static <I, O> Transformer<I, O> factoryTransformer(Factory<? extends O> factory) {
|
||||||
if (factory == null) {
|
if (factory == null) {
|
||||||
throw new IllegalArgumentException("Factory must not be null");
|
throw new IllegalArgumentException("Factory must not be null");
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ public final class FalsePredicate<T> implements Predicate<T>, Serializable {
|
||||||
* Get a typed instance.
|
* Get a typed instance.
|
||||||
*
|
*
|
||||||
* @return the singleton instance
|
* @return the singleton instance
|
||||||
* @since Commons Collections 5
|
* @since Commons Collections 4.0
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static <T> Predicate<T> falsePredicate() {
|
public static <T> Predicate<T> falsePredicate() {
|
||||||
|
|
|
@ -49,9 +49,9 @@ public class ForClosure<E> implements Closure<E>, Serializable {
|
||||||
* @return the <code>for</code> closure
|
* @return the <code>for</code> closure
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static <E> Closure<E> getInstance(int count, Closure<? super E> closure) {
|
public static <E> Closure<E> forClosure(int count, Closure<? super E> closure) {
|
||||||
if (count <= 0 || closure == null) {
|
if (count <= 0 || closure == null) {
|
||||||
return NOPClosure.<E>getInstance();
|
return NOPClosure.<E>nopClosure();
|
||||||
}
|
}
|
||||||
if (count == 1) {
|
if (count == 1) {
|
||||||
return (Closure<E>) closure;
|
return (Closure<E>) closure;
|
||||||
|
|
|
@ -44,7 +44,7 @@ public final class IdentityPredicate<T> implements Predicate<T>, Serializable {
|
||||||
* @return the predicate
|
* @return the predicate
|
||||||
* @throws IllegalArgumentException if the predicate is null
|
* @throws IllegalArgumentException if the predicate is null
|
||||||
*/
|
*/
|
||||||
public static <T> Predicate<T> getInstance(T object) {
|
public static <T> Predicate<T> identityPredicate(T object) {
|
||||||
if (object == null) {
|
if (object == null) {
|
||||||
return NullPredicate.<T>nullPredicate();
|
return NullPredicate.<T>nullPredicate();
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,8 +55,8 @@ public class IfClosure<E> implements Closure<E>, Serializable {
|
||||||
* @throws IllegalArgumentException if either argument is null
|
* @throws IllegalArgumentException if either argument is null
|
||||||
* @since Commons Collections 3.2
|
* @since Commons Collections 3.2
|
||||||
*/
|
*/
|
||||||
public static <E> Closure<E> getInstance(Predicate<? super E> predicate, Closure<? super E> trueClosure) {
|
public static <E> Closure<E> ifClosure(Predicate<? super E> predicate, Closure<? super E> trueClosure) {
|
||||||
return IfClosure.<E>getInstance(predicate, trueClosure, NOPClosure.<E>getInstance());
|
return IfClosure.<E>ifClosure(predicate, trueClosure, NOPClosure.<E>nopClosure());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -68,7 +68,7 @@ public class IfClosure<E> implements Closure<E>, Serializable {
|
||||||
* @return the <code>if</code> closure
|
* @return the <code>if</code> closure
|
||||||
* @throws IllegalArgumentException if any argument is null
|
* @throws IllegalArgumentException if any argument is null
|
||||||
*/
|
*/
|
||||||
public static <E> Closure<E> getInstance(Predicate<? super E> predicate, Closure<? super E> trueClosure, Closure<? super E> falseClosure) {
|
public static <E> Closure<E> ifClosure(Predicate<? super E> predicate, Closure<? super E> trueClosure, Closure<? super E> falseClosure) {
|
||||||
if (predicate == null) {
|
if (predicate == null) {
|
||||||
throw new IllegalArgumentException("Predicate must not be null");
|
throw new IllegalArgumentException("Predicate must not be null");
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ public final class InstanceofPredicate implements Predicate<Object>, Serializabl
|
||||||
* @return the predicate
|
* @return the predicate
|
||||||
* @throws IllegalArgumentException if the class is null
|
* @throws IllegalArgumentException if the class is null
|
||||||
*/
|
*/
|
||||||
public static Predicate<Object> getInstance(Class<?> type) {
|
public static Predicate<Object> instanceOfPredicate(Class<?> type) {
|
||||||
if (type == null) {
|
if (type == null) {
|
||||||
throw new IllegalArgumentException("The type to check instanceof must not be null");
|
throw new IllegalArgumentException("The type to check instanceof must not be null");
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,7 @@ public class InstantiateFactory<T> implements Factory<T>, Serializable {
|
||||||
* @param args the constructor arguments
|
* @param args the constructor arguments
|
||||||
* @return a new instantiate factory
|
* @return a new instantiate factory
|
||||||
*/
|
*/
|
||||||
public static <T> Factory<T> getInstance(Class<T> classToInstantiate, Class<?>[] paramTypes, Object[] args) {
|
public static <T> Factory<T> instantiateFactory(Class<T> classToInstantiate, Class<?>[] paramTypes, Object[] args) {
|
||||||
if (classToInstantiate == null) {
|
if (classToInstantiate == null) {
|
||||||
throw new IllegalArgumentException("Class to instantiate must not be null");
|
throw new IllegalArgumentException("Class to instantiate must not be null");
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,7 @@ public class InstantiateTransformer<T> implements Transformer<Class<? extends T>
|
||||||
* @param <T>
|
* @param <T>
|
||||||
* @return Transformer<Class<? extends T>, T>
|
* @return Transformer<Class<? extends T>, T>
|
||||||
*/
|
*/
|
||||||
public static <T> Transformer<Class<? extends T>, T> getInstance() {
|
public static <T> Transformer<Class<? extends T>, T> instantiateTransformer() {
|
||||||
return new InstantiateTransformer<T>();
|
return new InstantiateTransformer<T>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ public class InstantiateTransformer<T> implements Transformer<Class<? extends T>
|
||||||
* @param args the constructor arguments
|
* @param args the constructor arguments
|
||||||
* @return an instantiate transformer
|
* @return an instantiate transformer
|
||||||
*/
|
*/
|
||||||
public static <T> Transformer<Class<? extends T>, T> getInstance(Class<?>[] paramTypes, Object[] args) {
|
public static <T> Transformer<Class<? extends T>, T> instantiateTransformer(Class<?>[] paramTypes, Object[] args) {
|
||||||
if (((paramTypes == null) && (args != null))
|
if (((paramTypes == null) && (args != null))
|
||||||
|| ((paramTypes != null) && (args == null))
|
|| ((paramTypes != null) && (args == null))
|
||||||
|| ((paramTypes != null) && (args != null) && (paramTypes.length != args.length))) {
|
|| ((paramTypes != null) && (args != null) && (paramTypes.length != args.length))) {
|
||||||
|
|
|
@ -50,7 +50,7 @@ public class InvokerTransformer<I, O> implements Transformer<I, O>, Serializable
|
||||||
* @return an invoker transformer
|
* @return an invoker transformer
|
||||||
* @since Commons Collections 3.1
|
* @since Commons Collections 3.1
|
||||||
*/
|
*/
|
||||||
public static <I, O> Transformer<I, O> getInstance(String methodName) {
|
public static <I, O> Transformer<I, O> invokerTransformer(String methodName) {
|
||||||
if (methodName == null) {
|
if (methodName == null) {
|
||||||
throw new IllegalArgumentException("The method to invoke must not be null");
|
throw new IllegalArgumentException("The method to invoke must not be null");
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,7 @@ public class InvokerTransformer<I, O> implements Transformer<I, O>, Serializable
|
||||||
* @param args the arguments to pass to the method
|
* @param args the arguments to pass to the method
|
||||||
* @return an invoker transformer
|
* @return an invoker transformer
|
||||||
*/
|
*/
|
||||||
public static <I, O> Transformer<I, O> getInstance(String methodName, Class<?>[] paramTypes, Object[] args) {
|
public static <I, O> Transformer<I, O> invokerTransformer(String methodName, Class<?>[] paramTypes, Object[] args) {
|
||||||
if (methodName == null) {
|
if (methodName == null) {
|
||||||
throw new IllegalArgumentException("The method to invoke must not be null");
|
throw new IllegalArgumentException("The method to invoke must not be null");
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,9 +46,9 @@ public final class MapTransformer<I, O> implements Transformer<I, O>, Serializab
|
||||||
* @param map the map, not cloned
|
* @param map the map, not cloned
|
||||||
* @return the transformer
|
* @return the transformer
|
||||||
*/
|
*/
|
||||||
public static <I, O> Transformer<I, O> getInstance(Map<? super I, ? extends O> map) {
|
public static <I, O> Transformer<I, O> mapTransformer(Map<? super I, ? extends O> map) {
|
||||||
if (map == null) {
|
if (map == null) {
|
||||||
return ConstantTransformer.<I, O>getNullInstance();
|
return ConstantTransformer.<I, O>nullTransformer();
|
||||||
}
|
}
|
||||||
return new MapTransformer<I, O>(map);
|
return new MapTransformer<I, O>(map);
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ public final class NOPClosure<E> implements Closure<E>, Serializable {
|
||||||
* @since Commons Collections 3.1
|
* @since Commons Collections 3.1
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static <E> Closure<E> getInstance() {
|
public static <E> Closure<E> nopClosure() {
|
||||||
return (Closure<E>) INSTANCE;
|
return (Closure<E>) INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ public class NOPTransformer<T> implements Transformer<T, T>, Serializable {
|
||||||
* @since Commons Collections 3.1
|
* @since Commons Collections 3.1
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static <T> Transformer<T, T> getInstance() {
|
public static <T> Transformer<T, T> nopTransformer() {
|
||||||
return (Transformer<T, T>) INSTANCE;
|
return (Transformer<T, T>) INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,7 @@ public final class NonePredicate<T> implements Predicate<T>, PredicateDecorator<
|
||||||
* @throws IllegalArgumentException if the predicates array is null
|
* @throws IllegalArgumentException if the predicates array is null
|
||||||
* @throws IllegalArgumentException if any predicate in the array is null
|
* @throws IllegalArgumentException if any predicate in the array is null
|
||||||
*/
|
*/
|
||||||
public static <T> Predicate<T> getInstance(Predicate<? super T>[] predicates) {
|
public static <T> Predicate<T> nonePredicate(Predicate<? super T>... predicates) {
|
||||||
FunctorUtils.validate(predicates);
|
FunctorUtils.validate(predicates);
|
||||||
if (predicates.length == 0) {
|
if (predicates.length == 0) {
|
||||||
return TruePredicate.<T>truePredicate();
|
return TruePredicate.<T>truePredicate();
|
||||||
|
@ -72,7 +72,7 @@ public final class NonePredicate<T> implements Predicate<T>, PredicateDecorator<
|
||||||
* @throws IllegalArgumentException if the predicates array is null
|
* @throws IllegalArgumentException if the predicates array is null
|
||||||
* @throws IllegalArgumentException if any predicate in the array is null
|
* @throws IllegalArgumentException if any predicate in the array is null
|
||||||
*/
|
*/
|
||||||
public static <T> Predicate<T> getInstance(Collection<? extends Predicate<T>> predicates) {
|
public static <T> Predicate<T> nonePredicate(Collection<? extends Predicate<T>> predicates) {
|
||||||
Predicate<? super T>[] preds = FunctorUtils.validate(predicates);
|
Predicate<? super T>[] preds = FunctorUtils.validate(predicates);
|
||||||
if (preds.length == 0) {
|
if (preds.length == 0) {
|
||||||
return TruePredicate.<T>truePredicate();
|
return TruePredicate.<T>truePredicate();
|
||||||
|
|
|
@ -43,7 +43,7 @@ public final class NotNullPredicate<T> implements Predicate<T>, Serializable {
|
||||||
* @since Commons Collections 3.1
|
* @since Commons Collections 3.1
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static <T> Predicate<T> getInstance() {
|
public static <T> Predicate<T> notNullPredicate() {
|
||||||
return (Predicate<T>) INSTANCE;
|
return (Predicate<T>) INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ public final class NotPredicate<T> implements Predicate<T>, PredicateDecorator<T
|
||||||
* @return the predicate
|
* @return the predicate
|
||||||
* @throws IllegalArgumentException if the predicate is null
|
* @throws IllegalArgumentException if the predicate is null
|
||||||
*/
|
*/
|
||||||
public static <T> Predicate<T> getInstance(Predicate<? super T> predicate) {
|
public static <T> Predicate<T> notPredicate(Predicate<? super T> predicate) {
|
||||||
if (predicate == null) {
|
if (predicate == null) {
|
||||||
throw new IllegalArgumentException("Predicate must not be null");
|
throw new IllegalArgumentException("Predicate must not be null");
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ public final class NullIsExceptionPredicate<T> implements Predicate<T>, Predicat
|
||||||
* @return the predicate
|
* @return the predicate
|
||||||
* @throws IllegalArgumentException if the predicate is null
|
* @throws IllegalArgumentException if the predicate is null
|
||||||
*/
|
*/
|
||||||
public static <T> Predicate<T> getInstance(Predicate<? super T> predicate) {
|
public static <T> Predicate<T> nullIsExceptionPredicate(Predicate<? super T> predicate) {
|
||||||
if (predicate == null) {
|
if (predicate == null) {
|
||||||
throw new IllegalArgumentException("Predicate must not be null");
|
throw new IllegalArgumentException("Predicate must not be null");
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ public final class NullIsFalsePredicate<T> implements Predicate<T>, PredicateDec
|
||||||
* @return the predicate
|
* @return the predicate
|
||||||
* @throws IllegalArgumentException if the predicate is null
|
* @throws IllegalArgumentException if the predicate is null
|
||||||
*/
|
*/
|
||||||
public static <T> Predicate<T> getInstance(Predicate<? super T> predicate) {
|
public static <T> Predicate<T> nullIsFalsePredicate(Predicate<? super T> predicate) {
|
||||||
if (predicate == null) {
|
if (predicate == null) {
|
||||||
throw new IllegalArgumentException("Predicate must not be null");
|
throw new IllegalArgumentException("Predicate must not be null");
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ public final class NullIsTruePredicate<T> implements Predicate<T>, PredicateDeco
|
||||||
* @return the predicate
|
* @return the predicate
|
||||||
* @throws IllegalArgumentException if the predicate is null
|
* @throws IllegalArgumentException if the predicate is null
|
||||||
*/
|
*/
|
||||||
public static <T> Predicate<T> getInstance(Predicate<? super T> predicate) {
|
public static <T> Predicate<T> nullIsTruePredicate(Predicate<? super T> predicate) {
|
||||||
if (predicate == null) {
|
if (predicate == null) {
|
||||||
throw new IllegalArgumentException("Predicate must not be null");
|
throw new IllegalArgumentException("Predicate must not be null");
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,7 @@ public final class OnePredicate<T> implements Predicate<T>, PredicateDecorator<T
|
||||||
* @throws IllegalArgumentException if any predicate in the array is null
|
* @throws IllegalArgumentException if any predicate in the array is null
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static <T> Predicate<T> getInstance(Predicate<? super T>[] predicates) {
|
public static <T> Predicate<T> onePredicate(Predicate<? super T>... predicates) {
|
||||||
FunctorUtils.validate(predicates);
|
FunctorUtils.validate(predicates);
|
||||||
if (predicates.length == 0) {
|
if (predicates.length == 0) {
|
||||||
return FalsePredicate.<T>falsePredicate();
|
return FalsePredicate.<T>falsePredicate();
|
||||||
|
@ -75,7 +75,7 @@ public final class OnePredicate<T> implements Predicate<T>, PredicateDecorator<T
|
||||||
* @throws IllegalArgumentException if the predicates array is null
|
* @throws IllegalArgumentException if the predicates array is null
|
||||||
* @throws IllegalArgumentException if any predicate in the array is null
|
* @throws IllegalArgumentException if any predicate in the array is null
|
||||||
*/
|
*/
|
||||||
public static <T> Predicate<T> getInstance(Collection<? extends Predicate<T>> predicates) {
|
public static <T> Predicate<T> onePredicate(Collection<? extends Predicate<T>> predicates) {
|
||||||
Predicate<? super T>[] preds = FunctorUtils.validate(predicates);
|
Predicate<? super T>[] preds = FunctorUtils.validate(predicates);
|
||||||
return new OnePredicate<T>(preds);
|
return new OnePredicate<T>(preds);
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,7 @@ public final class OrPredicate<T> implements Predicate<T>, PredicateDecorator<T>
|
||||||
* @return the <code>and</code> predicate
|
* @return the <code>and</code> predicate
|
||||||
* @throws IllegalArgumentException if either predicate is null
|
* @throws IllegalArgumentException if either predicate is null
|
||||||
*/
|
*/
|
||||||
public static <T> Predicate<T> getInstance(Predicate<? super T> predicate1, Predicate<? super T> predicate2) {
|
public static <T> Predicate<T> orPredicate(Predicate<? super T> predicate1, Predicate<? super T> predicate2) {
|
||||||
if (predicate1 == null || predicate2 == null) {
|
if (predicate1 == null || predicate2 == null) {
|
||||||
throw new IllegalArgumentException("Predicate must not be null");
|
throw new IllegalArgumentException("Predicate must not be null");
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,7 @@ public class PredicateTransformer<T> implements Transformer<T, Boolean>, Seriali
|
||||||
* @return the <code>predicate</code> transformer
|
* @return the <code>predicate</code> transformer
|
||||||
* @throws IllegalArgumentException if the predicate is null
|
* @throws IllegalArgumentException if the predicate is null
|
||||||
*/
|
*/
|
||||||
public static <T> Transformer<T, Boolean> getInstance(Predicate<? super T> predicate) {
|
public static <T> Transformer<T, Boolean> predicateTransformer(Predicate<? super T> predicate) {
|
||||||
if (predicate == null) {
|
if (predicate == null) {
|
||||||
throw new IllegalArgumentException("Predicate must not be null");
|
throw new IllegalArgumentException("Predicate must not be null");
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,9 +56,9 @@ public class PrototypeFactory {
|
||||||
* @throws IllegalArgumentException if the prototype cannot be cloned
|
* @throws IllegalArgumentException if the prototype cannot be cloned
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static <T> Factory<T> getInstance(T prototype) {
|
public static <T> Factory<T> prototypeFactory(T prototype) {
|
||||||
if (prototype == null) {
|
if (prototype == null) {
|
||||||
return ConstantFactory.<T>getInstance(null);
|
return ConstantFactory.<T>constantFactory(null);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
Method method = prototype.getClass().getMethod("clone", (Class[]) null);
|
Method method = prototype.getClass().getMethod("clone", (Class[]) null);
|
||||||
|
|
|
@ -44,7 +44,7 @@ public final class StringValueTransformer<T> implements Transformer<T, String>,
|
||||||
* @since Commons Collections 3.1
|
* @since Commons Collections 3.1
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static <T> Transformer<T, String> getInstance() {
|
public static <T> Transformer<T, String> stringValueTransformer() {
|
||||||
return (Transformer<T, String>) INSTANCE;
|
return (Transformer<T, String>) INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,14 +54,14 @@ public class SwitchClosure<E> implements Closure<E>, Serializable {
|
||||||
* @throws IllegalArgumentException if any element in the array is null
|
* @throws IllegalArgumentException if any element in the array is null
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static <E> Closure<E> getInstance(Predicate<? super E>[] predicates, Closure<? super E>[] closures, Closure<? super E> defaultClosure) {
|
public static <E> Closure<E> switchClosure(Predicate<? super E>[] predicates, Closure<? super E>[] closures, Closure<? super E> defaultClosure) {
|
||||||
FunctorUtils.validate(predicates);
|
FunctorUtils.validate(predicates);
|
||||||
FunctorUtils.validate(closures);
|
FunctorUtils.validate(closures);
|
||||||
if (predicates.length != closures.length) {
|
if (predicates.length != closures.length) {
|
||||||
throw new IllegalArgumentException("The predicate and closure arrays must be the same size");
|
throw new IllegalArgumentException("The predicate and closure arrays must be the same size");
|
||||||
}
|
}
|
||||||
if (predicates.length == 0) {
|
if (predicates.length == 0) {
|
||||||
return (Closure<E>) (defaultClosure == null ? NOPClosure.<E>getInstance(): defaultClosure);
|
return (Closure<E>) (defaultClosure == null ? NOPClosure.<E>nopClosure(): defaultClosure);
|
||||||
}
|
}
|
||||||
predicates = FunctorUtils.copy(predicates);
|
predicates = FunctorUtils.copy(predicates);
|
||||||
closures = FunctorUtils.copy(closures);
|
closures = FunctorUtils.copy(closures);
|
||||||
|
@ -86,7 +86,7 @@ public class SwitchClosure<E> implements Closure<E>, Serializable {
|
||||||
* @throws ClassCastException if the map elements are of the wrong type
|
* @throws ClassCastException if the map elements are of the wrong type
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static <E> Closure<E> getInstance(Map<Predicate<E>, Closure<E>> predicatesAndClosures) {
|
public static <E> Closure<E> switchClosure(Map<Predicate<E>, Closure<E>> predicatesAndClosures) {
|
||||||
if (predicatesAndClosures == null) {
|
if (predicatesAndClosures == null) {
|
||||||
throw new IllegalArgumentException("The predicate and closure map must not be null");
|
throw new IllegalArgumentException("The predicate and closure map must not be null");
|
||||||
}
|
}
|
||||||
|
@ -94,7 +94,7 @@ public class SwitchClosure<E> implements Closure<E>, Serializable {
|
||||||
Closure<? super E> defaultClosure = predicatesAndClosures.remove(null);
|
Closure<? super E> defaultClosure = predicatesAndClosures.remove(null);
|
||||||
int size = predicatesAndClosures.size();
|
int size = predicatesAndClosures.size();
|
||||||
if (size == 0) {
|
if (size == 0) {
|
||||||
return (Closure<E>) (defaultClosure == null ? NOPClosure.<E>getInstance() : defaultClosure);
|
return (Closure<E>) (defaultClosure == null ? NOPClosure.<E>nopClosure() : defaultClosure);
|
||||||
}
|
}
|
||||||
Closure<E>[] closures = new Closure[size];
|
Closure<E>[] closures = new Closure[size];
|
||||||
Predicate<E>[] preds = new Predicate[size];
|
Predicate<E>[] preds = new Predicate[size];
|
||||||
|
@ -120,7 +120,7 @@ public class SwitchClosure<E> implements Closure<E>, Serializable {
|
||||||
super();
|
super();
|
||||||
iPredicates = predicates;
|
iPredicates = predicates;
|
||||||
iClosures = closures;
|
iClosures = closures;
|
||||||
iDefault = (Closure<? super E>) (defaultClosure == null ? NOPClosure.<E>getInstance() : defaultClosure);
|
iDefault = (Closure<? super E>) (defaultClosure == null ? NOPClosure.<E>nopClosure() : defaultClosure);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -54,7 +54,7 @@ public class SwitchTransformer<I, O> implements Transformer<I, O>, Serializable
|
||||||
* @throws IllegalArgumentException if any element in the array is null
|
* @throws IllegalArgumentException if any element in the array is null
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static <I, O> Transformer<I, O> getInstance(Predicate<? super I>[] predicates,
|
public static <I, O> Transformer<I, O> switchTransformer(Predicate<? super I>[] predicates,
|
||||||
Transformer<? super I, ? extends O>[] transformers,
|
Transformer<? super I, ? extends O>[] transformers,
|
||||||
Transformer<? super I, ? extends O> defaultTransformer) {
|
Transformer<? super I, ? extends O> defaultTransformer) {
|
||||||
FunctorUtils.validate(predicates);
|
FunctorUtils.validate(predicates);
|
||||||
|
@ -63,7 +63,7 @@ public class SwitchTransformer<I, O> implements Transformer<I, O>, Serializable
|
||||||
throw new IllegalArgumentException("The predicate and transformer arrays must be the same size");
|
throw new IllegalArgumentException("The predicate and transformer arrays must be the same size");
|
||||||
}
|
}
|
||||||
if (predicates.length == 0) {
|
if (predicates.length == 0) {
|
||||||
return (Transformer<I, O>) (defaultTransformer == null ? ConstantTransformer.<I, O>getNullInstance() : defaultTransformer);
|
return (Transformer<I, O>) (defaultTransformer == null ? ConstantTransformer.<I, O>nullTransformer() : defaultTransformer);
|
||||||
}
|
}
|
||||||
predicates = FunctorUtils.copy(predicates);
|
predicates = FunctorUtils.copy(predicates);
|
||||||
transformers = FunctorUtils.copy(transformers);
|
transformers = FunctorUtils.copy(transformers);
|
||||||
|
@ -88,19 +88,19 @@ public class SwitchTransformer<I, O> implements Transformer<I, O>, Serializable
|
||||||
* @throws ClassCastException if the map elements are of the wrong type
|
* @throws ClassCastException if the map elements are of the wrong type
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static <I, O> Transformer<I, O> getInstance(
|
public static <I, O> Transformer<I, O> switchTransformer(
|
||||||
Map<? extends Predicate<? super I>, ? extends Transformer<? super I, ? extends O>> predicatesAndTransformers) {
|
Map<? extends Predicate<? super I>, ? extends Transformer<? super I, ? extends O>> predicatesAndTransformers) {
|
||||||
if (predicatesAndTransformers == null) {
|
if (predicatesAndTransformers == null) {
|
||||||
throw new IllegalArgumentException("The predicate and transformer map must not be null");
|
throw new IllegalArgumentException("The predicate and transformer map must not be null");
|
||||||
}
|
}
|
||||||
if (predicatesAndTransformers.size() == 0) {
|
if (predicatesAndTransformers.size() == 0) {
|
||||||
return ConstantTransformer.<I, O>getNullInstance();
|
return ConstantTransformer.<I, O>nullTransformer();
|
||||||
}
|
}
|
||||||
// convert to array like this to guarantee iterator() ordering
|
// convert to array like this to guarantee iterator() ordering
|
||||||
Transformer<? super I, ? extends O> defaultTransformer = predicatesAndTransformers.remove(null);
|
Transformer<? super I, ? extends O> defaultTransformer = predicatesAndTransformers.remove(null);
|
||||||
int size = predicatesAndTransformers.size();
|
int size = predicatesAndTransformers.size();
|
||||||
if (size == 0) {
|
if (size == 0) {
|
||||||
return (Transformer<I, O>) (defaultTransformer == null ? ConstantTransformer.<I, O>getNullInstance() : defaultTransformer);
|
return (Transformer<I, O>) (defaultTransformer == null ? ConstantTransformer.<I, O>nullTransformer() : defaultTransformer);
|
||||||
}
|
}
|
||||||
Transformer<? super I, ? extends O>[] transformers = new Transformer[size];
|
Transformer<? super I, ? extends O>[] transformers = new Transformer[size];
|
||||||
Predicate<? super I>[] preds = new Predicate[size];
|
Predicate<? super I>[] preds = new Predicate[size];
|
||||||
|
@ -128,7 +128,7 @@ public class SwitchTransformer<I, O> implements Transformer<I, O>, Serializable
|
||||||
super();
|
super();
|
||||||
iPredicates = predicates;
|
iPredicates = predicates;
|
||||||
iTransformers = transformers;
|
iTransformers = transformers;
|
||||||
iDefault = (Transformer<? super I, ? extends O>) (defaultTransformer == null ? ConstantTransformer.<I, O>getNullInstance() : defaultTransformer);
|
iDefault = (Transformer<? super I, ? extends O>) (defaultTransformer == null ? ConstantTransformer.<I, O>nullTransformer() : defaultTransformer);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -49,7 +49,7 @@ public final class TransformedPredicate<T> implements Predicate<T>, PredicateDec
|
||||||
* @return the predicate
|
* @return the predicate
|
||||||
* @throws IllegalArgumentException if the transformer or the predicate is null
|
* @throws IllegalArgumentException if the transformer or the predicate is null
|
||||||
*/
|
*/
|
||||||
public static <T> Predicate<T> getInstance(Transformer<? super T, ? extends T> transformer, Predicate<? super T> predicate) {
|
public static <T> Predicate<T> transformedPredicate(Transformer<? super T, ? extends T> transformer, Predicate<? super T> predicate) {
|
||||||
if (transformer == null) {
|
if (transformer == null) {
|
||||||
throw new IllegalArgumentException("The transformer to call must not be null");
|
throw new IllegalArgumentException("The transformer to call must not be null");
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,9 +46,9 @@ public class TransformerClosure<E> implements Closure<E>, Serializable {
|
||||||
* @param transformer the transformer to call, null means nop
|
* @param transformer the transformer to call, null means nop
|
||||||
* @return the <code>transformer</code> closure
|
* @return the <code>transformer</code> closure
|
||||||
*/
|
*/
|
||||||
public static <E> Closure<E> getInstance(Transformer<? super E, ?> transformer) {
|
public static <E> Closure<E> transformerClosure(Transformer<? super E, ?> transformer) {
|
||||||
if (transformer == null) {
|
if (transformer == null) {
|
||||||
return NOPClosure.<E>getInstance();
|
return NOPClosure.<E>nopClosure();
|
||||||
}
|
}
|
||||||
return new TransformerClosure<E>(transformer);
|
return new TransformerClosure<E>(transformer);
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,7 @@ public final class TransformerPredicate<T> implements Predicate<T>, Serializable
|
||||||
* @return the predicate
|
* @return the predicate
|
||||||
* @throws IllegalArgumentException if the transformer is null
|
* @throws IllegalArgumentException if the transformer is null
|
||||||
*/
|
*/
|
||||||
public static <T> Predicate<T> getInstance(Transformer<? super T, Boolean> transformer) {
|
public static <T> Predicate<T> transformerPredicate(Transformer<? super T, Boolean> transformer) {
|
||||||
if (transformer == null) {
|
if (transformer == null) {
|
||||||
throw new IllegalArgumentException("The transformer to call must not be null");
|
throw new IllegalArgumentException("The transformer to call must not be null");
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,7 @@ public final class UniquePredicate<T> implements Predicate<T>, Serializable {
|
||||||
* @return the predicate
|
* @return the predicate
|
||||||
* @throws IllegalArgumentException if the predicate is null
|
* @throws IllegalArgumentException if the predicate is null
|
||||||
*/
|
*/
|
||||||
public static <E> Predicate<E> getInstance() {
|
public static <E> Predicate<E> uniquePredicate() {
|
||||||
return new UniquePredicate<E>();
|
return new UniquePredicate<E>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,7 @@ public class WhileClosure<E> implements Closure<E>, Serializable {
|
||||||
* @return the <code>while</code> closure
|
* @return the <code>while</code> closure
|
||||||
* @throws IllegalArgumentException if the predicate or closure is null
|
* @throws IllegalArgumentException if the predicate or closure is null
|
||||||
*/
|
*/
|
||||||
public static <E> Closure<E> getInstance(Predicate<? super E> predicate, Closure<? super E> closure, boolean doLoop) {
|
public static <E> Closure<E> whileClosure(Predicate<? super E> predicate, Closure<? super E> closure, boolean doLoop) {
|
||||||
if (predicate == null) {
|
if (predicate == null) {
|
||||||
throw new IllegalArgumentException("Predicate must not be null");
|
throw new IllegalArgumentException("Predicate must not be null");
|
||||||
}
|
}
|
||||||
|
|
|
@ -201,7 +201,7 @@ public class CollatingIterator<E> implements Iterator<E> {
|
||||||
* @return the unmodifiable list of iterators added
|
* @return the unmodifiable list of iterators added
|
||||||
*/
|
*/
|
||||||
public List<Iterator<? extends E>> getIterators() {
|
public List<Iterator<? extends E>> getIterators() {
|
||||||
return UnmodifiableList.decorate(iterators);
|
return UnmodifiableList.unmodifiableList(iterators);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -52,7 +52,7 @@ public class EmptyIterator<E> extends AbstractEmptyIterator<E> implements Resett
|
||||||
* @return ResettableIterator<E>
|
* @return ResettableIterator<E>
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static <E> ResettableIterator<E> getResettableInstance() {
|
public static <E> ResettableIterator<E> resettableEmptyIterator() {
|
||||||
return (ResettableIterator<E>) RESETTABLE_INSTANCE;
|
return (ResettableIterator<E>) RESETTABLE_INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ public class EmptyIterator<E> extends AbstractEmptyIterator<E> implements Resett
|
||||||
* @return Iterator<E>
|
* @return Iterator<E>
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static <E> Iterator<E> getInstance() {
|
public static <E> Iterator<E> emptyIterator() {
|
||||||
return (Iterator<E>) INSTANCE;
|
return (Iterator<E>) INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,7 @@ public class EmptyListIterator<E> extends AbstractEmptyIterator<E> implements
|
||||||
* @return {@link ResettableListIterator}<E>
|
* @return {@link ResettableListIterator}<E>
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static <E> ResettableListIterator<E> getResettableInstance() {
|
public static <E> ResettableListIterator<E> resettableEmptyListIterator() {
|
||||||
return (ResettableListIterator<E>) RESETTABLE_INSTANCE;
|
return (ResettableListIterator<E>) RESETTABLE_INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ public class EmptyListIterator<E> extends AbstractEmptyIterator<E> implements
|
||||||
* @return {@link ListIterator}<E>
|
* @return {@link ListIterator}<E>
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static <E> ListIterator<E> getInstance() {
|
public static <E> ListIterator<E> emptyListIterator() {
|
||||||
return (ListIterator<E>) INSTANCE;
|
return (ListIterator<E>) INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ public class EmptyMapIterator<K, V> extends AbstractEmptyMapIterator<K, V> imple
|
||||||
* @return {@link MapIterator}<K, V>
|
* @return {@link MapIterator}<K, V>
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static <K, V> MapIterator<K, V> getInstance() {
|
public static <K, V> MapIterator<K, V> emptyMapIterator() {
|
||||||
return (MapIterator<K, V>) INSTANCE;
|
return (MapIterator<K, V>) INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ public class EmptyOrderedIterator<E> extends AbstractEmptyIterator<E> implements
|
||||||
* @return OrderedIterator<E>
|
* @return OrderedIterator<E>
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static <E> OrderedIterator<E> getInstance() {
|
public static <E> OrderedIterator<E> emptyOrderedIterator() {
|
||||||
return (OrderedIterator<E>) INSTANCE;
|
return (OrderedIterator<E>) INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ public class EmptyOrderedMapIterator<K, V> extends AbstractEmptyMapIterator<K, V
|
||||||
* @return {@link OrderedMapIterator}<K, V>
|
* @return {@link OrderedMapIterator}<K, V>
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static <K, V> OrderedMapIterator<K, V> getInstance() {
|
public static <K, V> OrderedMapIterator<K, V> emptyOrderedMapIterator() {
|
||||||
return (OrderedMapIterator<K, V>) INSTANCE;
|
return (OrderedMapIterator<K, V>) INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -127,7 +127,7 @@ public class IteratorChain<E> implements Iterator<E> {
|
||||||
* @param iteratorChain the array of iterators, not null
|
* @param iteratorChain the array of iterators, not null
|
||||||
* @throws NullPointerException if iterators array is or contains null
|
* @throws NullPointerException if iterators array is or contains null
|
||||||
*/
|
*/
|
||||||
public IteratorChain(Iterator<? extends E>[] iteratorChain) {
|
public IteratorChain(Iterator<? extends E>... iteratorChain) {
|
||||||
super();
|
super();
|
||||||
for (int i = 0; i < iteratorChain.length; i++) {
|
for (int i = 0; i < iteratorChain.length; i++) {
|
||||||
addIterator(iteratorChain[i]);
|
addIterator(iteratorChain[i]);
|
||||||
|
@ -193,7 +193,7 @@ public class IteratorChain<E> implements Iterator<E> {
|
||||||
* @return the unmodifiable list of iterators added
|
* @return the unmodifiable list of iterators added
|
||||||
*/
|
*/
|
||||||
public List<Iterator<? extends E>> getIterators() {
|
public List<Iterator<? extends E>> getIterators() {
|
||||||
return UnmodifiableList.decorate(iteratorChain);
|
return UnmodifiableList.unmodifiableList(iteratorChain);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -243,7 +243,7 @@ public class IteratorChain<E> implements Iterator<E> {
|
||||||
protected void updateCurrentIterator() {
|
protected void updateCurrentIterator() {
|
||||||
if (currentIterator == null) {
|
if (currentIterator == null) {
|
||||||
if (iteratorChain.isEmpty()) {
|
if (iteratorChain.isEmpty()) {
|
||||||
currentIterator = EmptyIterator.<E> getInstance();
|
currentIterator = EmptyIterator.<E> emptyIterator();
|
||||||
} else {
|
} else {
|
||||||
currentIterator = iteratorChain.get(0);
|
currentIterator = iteratorChain.get(0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,7 +69,7 @@ public class ObjectArrayIterator<E>
|
||||||
* @param array the array to iterate over
|
* @param array the array to iterate over
|
||||||
* @throws NullPointerException if <code>array</code> is <code>null</code>
|
* @throws NullPointerException if <code>array</code> is <code>null</code>
|
||||||
*/
|
*/
|
||||||
public ObjectArrayIterator(E[] array) {
|
public ObjectArrayIterator(E... array) {
|
||||||
this(array, 0, array.length);
|
this(array, 0, array.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -69,7 +69,7 @@ public class ObjectArrayListIterator<E> extends ObjectArrayIterator<E>
|
||||||
* @param array the array to iterate over
|
* @param array the array to iterate over
|
||||||
* @throws NullPointerException if <code>array</code> is <code>null</code>
|
* @throws NullPointerException if <code>array</code> is <code>null</code>
|
||||||
*/
|
*/
|
||||||
public ObjectArrayListIterator(E[] array) {
|
public ObjectArrayListIterator(E... array) {
|
||||||
super(array);
|
super(array);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ public class UniqueFilterIterator<E> extends FilterIterator<E> {
|
||||||
* @param iterator the iterator to use
|
* @param iterator the iterator to use
|
||||||
*/
|
*/
|
||||||
public UniqueFilterIterator(Iterator<E> iterator) {
|
public UniqueFilterIterator(Iterator<E> iterator) {
|
||||||
super(iterator, UniquePredicate.getInstance());
|
super(iterator, UniquePredicate.uniquePredicate());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ public final class UnmodifiableIterator<E> implements Iterator<E>, Unmodifiable
|
||||||
* @param iterator the iterator to decorate
|
* @param iterator the iterator to decorate
|
||||||
* @throws IllegalArgumentException if the iterator is null
|
* @throws IllegalArgumentException if the iterator is null
|
||||||
*/
|
*/
|
||||||
public static <E> Iterator<E> decorate(Iterator<E> iterator) {
|
public static <E> Iterator<E> unmodifiableIterator(Iterator<E> iterator) {
|
||||||
if (iterator == null) {
|
if (iterator == null) {
|
||||||
throw new IllegalArgumentException("Iterator must not be null");
|
throw new IllegalArgumentException("Iterator must not be null");
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,7 @@ public final class UnmodifiableListIterator<E> implements ListIterator<E>, Unmod
|
||||||
* @param iterator the iterator to decorate
|
* @param iterator the iterator to decorate
|
||||||
* @throws IllegalArgumentException if the iterator is null
|
* @throws IllegalArgumentException if the iterator is null
|
||||||
*/
|
*/
|
||||||
public static <E> ListIterator<E> decorate(ListIterator<E> iterator) {
|
public static <E> ListIterator<E> umodifiableListIterator(ListIterator<E> iterator) {
|
||||||
if (iterator == null) {
|
if (iterator == null) {
|
||||||
throw new IllegalArgumentException("ListIterator must not be null");
|
throw new IllegalArgumentException("ListIterator must not be null");
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@ public final class UnmodifiableMapIterator<K, V> implements MapIterator<K, V>, U
|
||||||
* @param iterator the iterator to decorate
|
* @param iterator the iterator to decorate
|
||||||
* @throws IllegalArgumentException if the iterator is null
|
* @throws IllegalArgumentException if the iterator is null
|
||||||
*/
|
*/
|
||||||
public static <K, V> MapIterator<K, V> decorate(MapIterator<K, V> iterator) {
|
public static <K, V> MapIterator<K, V> unmodifiableMapIterator(MapIterator<K, V> iterator) {
|
||||||
if (iterator == null) {
|
if (iterator == null) {
|
||||||
throw new IllegalArgumentException("MapIterator must not be null");
|
throw new IllegalArgumentException("MapIterator must not be null");
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,7 @@ public final class UnmodifiableOrderedMapIterator<K, V> implements OrderedMapIte
|
||||||
* @param iterator the iterator to decorate
|
* @param iterator the iterator to decorate
|
||||||
* @throws IllegalArgumentException if the iterator is null
|
* @throws IllegalArgumentException if the iterator is null
|
||||||
*/
|
*/
|
||||||
public static <K, V> OrderedMapIterator<K, V> decorate(OrderedMapIterator<K, V> iterator) {
|
public static <K, V> OrderedMapIterator<K, V> unmodifiableOrderedMapIterator(OrderedMapIterator<K, V> iterator) {
|
||||||
if (iterator == null) {
|
if (iterator == null) {
|
||||||
throw new IllegalArgumentException("OrderedMapIterator must not be null");
|
throw new IllegalArgumentException("OrderedMapIterator must not be null");
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,7 @@ public class FixedSizeList<E>
|
||||||
* @param list the list to decorate, must not be null
|
* @param list the list to decorate, must not be null
|
||||||
* @throws IllegalArgumentException if list is null
|
* @throws IllegalArgumentException if list is null
|
||||||
*/
|
*/
|
||||||
public static <E> List<E> decorate(List<E> list) {
|
public static <E> List<E> fixedSizeList(List<E> list) {
|
||||||
return new FixedSizeList<E>(list);
|
return new FixedSizeList<E>(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,7 +105,7 @@ public class FixedSizeList<E>
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Iterator<E> iterator() {
|
public Iterator<E> iterator() {
|
||||||
return UnmodifiableIterator.decorate(decorated().iterator());
|
return UnmodifiableIterator.unmodifiableIterator(decorated().iterator());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue