public final class OCLCollections extends Object
| Constructor and Description |
|---|
OCLCollections() |
| Modifier and Type | Method and Description |
|---|---|
static Object |
any(Collection collection,
org.apache.commons.collections.Predicate predicate)
Returns a random element from the collection for which the argument expression evaluates true.
|
static boolean |
append(org.apache.commons.collections.Bag collection,
Object item)
Appends the item to the bag.
|
static boolean |
append(List list,
Object item)
Appends the item to the list.
|
static org.apache.commons.collections.Bag |
asBag(Collection collection)
Returns the argument as a bag.
|
static Set |
asOrderedSet(Collection collection)
Returns the argument as an ordered set.
|
static List |
asSequence(Collection collection)
Returns the argument as a list.
|
static Set |
asSet(Collection collection)
Returns the argument as a set.
|
static Object |
at(List list,
int index)
Returns the element at the specified index in the argument list.
|
static Collection |
collect(Collection collection,
org.apache.commons.collections.Transformer transformer)
Returns the collection of Objects that results from executing the transformer on each individual element in the
source collection.
|
static Collection |
collectNested(Collection collection)
TODO: implement
|
static int |
count(Collection collection,
Object item)
Counts the number of occurrences of the argument item in the source collection.
|
static boolean |
excludes(Collection collection,
Object item)
Return true if the object is not an element of the collection, false otherwise.
|
static boolean |
excludesAll(Collection collection,
Collection items)
Returns true if all elements of the parameter collection are not present in the current collection, false
otherwise.
|
static boolean |
excluding(Collection collection,
Object item)
Removes all occurrences of the item in the source collection.
|
static boolean |
exists(Collection collection,
org.apache.commons.collections.Predicate predicate)
Returns true if a predicate is true for at least one element of a collection.
|
static boolean |
exists(Object collection,
org.apache.commons.collections.Predicate predicate)
Returns true if a predicate is true for at least one element of a collection.
|
static Object |
first(Object object)
Returns the first element in the collection.
|
static Collection |
flatten(Collection collection)
Recursively flattens this collection, this method returns a Collection containing no nested Collection
instances.
|
static boolean |
forAll(Collection collection,
org.apache.commons.collections.Predicate predicate)
Executes every
predicate for the given collectoin, if one evaluates to false this
operation returns false, otherwise true is returned. |
static boolean |
forAll(Object collection,
org.apache.commons.collections.Predicate predicate)
Executes every
predicate for the given collection, if one evaluates to false this
operation returns false, otherwise true is returned. |
static boolean |
includes(Collection collection,
Object item)
Returns true if the object is an element of the collection, false otherwise.
|
static boolean |
includesAll(Collection collection,
Collection items)
Returns true if all elements of the parameter collection are present in the current collection, false otherwise.
|
static boolean |
including(Collection collection,
Object item)
Adds the item to the list
|
static int |
indexOf(List collection,
Object item)
Returns the index in this list of the first occurrence of the specified element, or -1 if this list does not
contain this element.
|
static void |
insertAt(List collection,
int index,
Object item)
Insert the item at the specified index into the collection.
|
static Collection |
intersection(Collection first,
Collection second)
Returns the collection of elements common in both argument collections.
|
static boolean |
isEmpty(Collection collection)
Returns true if the collection contains no elements, false otherwise.
|
static boolean |
isEmpty(Object object)
Returns true if the argument is
null, false otherwise. |
static boolean |
isEmpty(String string)
Returns true if the argument is either
null or only contains whitespace characters, false
otherwise. |
static boolean |
isUnique(Collection collection,
org.apache.commons.collections.Transformer transformer)
Returns
true if the result of executing the transformer has a unique value for each
element in the source collection. |
static boolean |
isUnique(Object collection,
org.apache.commons.collections.Transformer transformer)
Returns
true if the result of executing the transformer has a unique value for each
element in the source collection. |
static Collection |
iterate(Collection collection)
TODO: implement
|
static Object |
last(Object object)
Returns the last element in the collection.
|
static boolean |
notEmpty(Collection collection)
Returns true if the collection contains one or more elements, false otherwise.
|
static boolean |
notEmpty(Object object)
Returns true if the argument is not
null, false otherwise. |
static boolean |
notEmpty(String string)
Returns true if the argument is neither
null nor only contains whitespace characters, false
otherwise. |
static boolean |
one(Collection collection,
org.apache.commons.collections.Predicate predicate)
Returns
true when the argument expression evaluates true for one and only one element in the
collection. |
static boolean |
one(Object collection,
org.apache.commons.collections.Predicate predicate)
Returns
true if |
static Object |
prepend(List list,
Object item)
Insert the item into the first position of the list.
|
static Collection |
reject(Collection collection,
org.apache.commons.collections.Predicate predicate)
Returns a subcollection of the source collection containing all elements for which the expression evaluates
false. |
static Collection |
select(Collection collection,
org.apache.commons.collections.Predicate predicate)
Returns a subcollection of the source collection containing all elements for which the expression evaluates
true. |
static Collection |
select(Object collection,
org.apache.commons.collections.Predicate predicate)
Returns a subcollection of the source collection containing all elements for which the expression evaluates
true. |
static int |
size(Collection collection)
Returns the number of elements in the collection.
|
static int |
size(Object object)
Checks the instance of the
object and makes sure its a Collection, if the object is a collection the
size is checked and returned, if its NOT a collection, 0 is returned. |
static Collection |
sortedBy(Collection collection)
TODO: implement
|
static Set |
subOrderedSet(Set collection)
TODO: implement
|
static List |
subSequence(List collection)
TODO: implement
|
static double |
sum(Collection collection)
Returns the sum of all the element in the collection.
|
static double |
sum(Object collection)
Returns the sum of all the elements in the collection.
|
static Collection |
symmetricDifference(Collection first,
Collection second)
Returns those element that are contained in only one of both collections.
|
static Collection |
union(Collection first,
Collection second)
Returns the union of both collections into a single collection.
|
public OCLCollections()
public static int count(Collection collection, Object item)
collection - item - public static boolean excludes(Collection collection, Object item)
collection - item - public static boolean excludesAll(Collection collection, Collection items)
collection - items - public static boolean includes(Collection collection, Object item)
collection - item - public static boolean includesAll(Collection collection, Collection items)
collection - items - public static boolean isEmpty(Collection collection)
collection - public static boolean isEmpty(Object object)
null, false otherwise.object - public static boolean isEmpty(String string)
null or only contains whitespace characters, false
otherwise.string - public static boolean notEmpty(Collection collection)
collection - public static boolean notEmpty(Object object)
null, false otherwise.object - public static boolean notEmpty(String string)
null nor only contains whitespace characters, false
otherwise.string - public static int size(Object object)
object and makes sure its a Collection, if the object is a collection the
size is checked and returned, if its NOT a collection, 0 is returned.object - the object to check.public static int size(Collection collection)
collection - public static double sum(Object collection)
collection - a collection containing only classes extending Numberpublic static double sum(Collection collection)
collection - a collection containing only classes extending Numberpublic static boolean append(List list, Object item)
list - item - public static Object prepend(List list, Object item)
list - item - public static boolean append(org.apache.commons.collections.Bag collection, Object item)
collection - item - public static org.apache.commons.collections.Bag asBag(Collection collection)
collection - public static Set asOrderedSet(Collection collection)
collection - public static List asSequence(Collection collection)
collection - public static Set asSet(Collection collection)
collection - public static Object at(List list, int index)
list - index - public static boolean excluding(Collection collection, Object item)
collection - item - public static boolean including(Collection collection, Object item)
collection - item - public static Collection flatten(Collection collection)
collection - public static int indexOf(List collection, Object item)
collection - item - public static void insertAt(List collection, int index, Object item)
collection - index - item - public static Collection intersection(Collection first, Collection second)
first - second - public static Collection union(Collection first, Collection second)
first - second - public static Object last(Object object)
object - the collection or single instance which will be converted to a collection.public static Object first(Object object)
object - the collection or single instance which will be converted to a collection.public static Collection symmetricDifference(Collection first, Collection second)
first - second - public static Set subOrderedSet(Set collection)
collection - public static List subSequence(List collection)
collection - public static Object any(Collection collection, org.apache.commons.collections.Predicate predicate)
collection - predicate - public static Collection collect(Collection collection, org.apache.commons.collections.Transformer transformer)
collection - transformer - public static Collection collectNested(Collection collection)
collection - public static boolean exists(Collection collection, org.apache.commons.collections.Predicate predicate)
collection - predicate - public static boolean exists(Object collection, org.apache.commons.collections.Predicate predicate)
collection - predicate - public static boolean forAll(Collection collection, org.apache.commons.collections.Predicate predicate)
predicate for the given collectoin, if one evaluates to false this
operation returns false, otherwise true is returned. If the input collection or
closure is null false is returned.collection - predicate - public static boolean forAll(Object collection, org.apache.commons.collections.Predicate predicate)
predicate for the given collection, if one evaluates to false this
operation returns false, otherwise true is returned. If the input collection or
closure is null false is returned.collection - predicate - public static boolean isUnique(Collection collection, org.apache.commons.collections.Transformer transformer)
true if the result of executing the transformer has a unique value for each
element in the source collection.collection - transformer - public static boolean isUnique(Object collection, org.apache.commons.collections.Transformer transformer)
true if the result of executing the transformer has a unique value for each
element in the source collection.collection - transformer - public static Collection iterate(Collection collection)
collection - public static boolean one(Collection collection, org.apache.commons.collections.Predicate predicate)
true when the argument expression evaluates true for one and only one element in the
collection. Returns false otherwise.collection - predicate - public static boolean one(Object collection, org.apache.commons.collections.Predicate predicate)
true if collection is actually a Collection instance and if the
predicate expression evaluates true for one and only one element in the collection. Returns
false otherwise. collection - predicate - public static Collection reject(Collection collection, org.apache.commons.collections.Predicate predicate)
false.collection - predicate - public static Collection select(Collection collection, org.apache.commons.collections.Predicate predicate)
true.collection - predicate - public static Collection select(Object collection, org.apache.commons.collections.Predicate predicate)
true.collection - predicate - public static Collection sortedBy(Collection collection)
collection - Copyright © 2003–2014 AndroMDA.org. All rights reserved.