Package io.microsphere.collection
Class CollectionUtils
- java.lang.Object
-
- io.microsphere.util.BaseUtils
-
- io.microsphere.collection.CollectionUtils
-
-
Constructor Summary
Constructors Constructor Description CollectionUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> int
addAll(java.util.Collection<T> collection, T... values)
Add the multiple values intothe specified collection
static boolean
equals(java.util.Collection<?> one, java.util.Collection<?> another)
Compares the specified collection with another, the main implementation referencesAbstractSet
static <T> T
first(java.lang.Iterable<T> values)
Take the first element from the specifiedIterable
static <T> T
first(java.util.Collection<T> values)
Take the first element from the specified collectionstatic <T> T
first(java.util.Iterator<T> values)
Take the first element from the specifiedstatic boolean
isEmpty(java.util.Collection<?> collection)
static boolean
isNotEmpty(java.util.Collection<?> collection)
static <E> java.util.Enumeration<E>
singletonEnumeration(E element)
static <E> java.lang.Iterable<E>
singletonIterable(E element)
static <E> java.util.Iterator<E>
singletonIterator(E element)
static int
size(java.lang.Iterable<?> iterable)
Get the size of the specifiedIterable
static int
size(java.util.Collection<?> collection)
Get the size of the specifiedCollection
static <E> java.lang.Iterable<E>
toIterable(java.util.Collection<E> collection)
static <E> java.lang.Iterable<E>
toIterable(java.util.Enumeration<E> enumeration)
static <E> java.lang.Iterable<E>
toIterable(java.util.Iterator<E> iterator)
static <E> java.util.Iterator<E>
toIterator(java.util.Enumeration<E> enumeration)
static <E> java.util.Iterator<E>
unmodifiableIterator(java.util.Iterator<E> iterator)
-
-
-
Method Detail
-
isEmpty
public static boolean isEmpty(java.util.Collection<?> collection)
-
isNotEmpty
public static boolean isNotEmpty(java.util.Collection<?> collection)
-
toIterable
public static <E> java.lang.Iterable<E> toIterable(java.util.Collection<E> collection)
-
toIterable
public static <E> java.lang.Iterable<E> toIterable(java.util.Iterator<E> iterator)
-
toIterator
public static <E> java.util.Iterator<E> toIterator(java.util.Enumeration<E> enumeration)
-
toIterable
public static <E> java.lang.Iterable<E> toIterable(java.util.Enumeration<E> enumeration)
-
singletonIterable
public static <E> java.lang.Iterable<E> singletonIterable(E element)
-
singletonIterator
public static <E> java.util.Iterator<E> singletonIterator(E element)
-
singletonEnumeration
public static <E> java.util.Enumeration<E> singletonEnumeration(E element)
-
unmodifiableIterator
public static <E> java.util.Iterator<E> unmodifiableIterator(java.util.Iterator<E> iterator)
-
size
public static int size(java.util.Collection<?> collection)
Get the size of the specifiedCollection
- Parameters:
collection
- the specifiedCollection
- Returns:
- must be positive number
-
size
public static int size(java.lang.Iterable<?> iterable)
Get the size of the specifiedIterable
- Parameters:
iterable
- the specifiedIterable
- Returns:
- must be positive number
-
equals
public static boolean equals(java.util.Collection<?> one, java.util.Collection<?> another)
Compares the specified collection with another, the main implementation referencesAbstractSet
- Parameters:
one
-Collection
another
-Collection
- Returns:
- if equals, return
true
, orfalse
-
addAll
public static <T> int addAll(java.util.Collection<T> collection, T... values)
Add the multiple values intothe specified collection
- Type Parameters:
T
- the type of values- Parameters:
collection
-the specified collection
values
- the multiple values- Returns:
- the effected count after added
-
first
public static <T> T first(java.util.Collection<T> values)
Take the first element from the specified collection- Type Parameters:
T
- the type of element of collection- Parameters:
values
- the collection object- Returns:
- if found, return the first one, or
null
-
first
public static <T> T first(java.lang.Iterable<T> values)
Take the first element from the specifiedIterable
- Type Parameters:
T
- the type of element ofIterable
- Parameters:
values
- theIterable
object- Returns:
- if found, return the first one, or
null
-
first
public static <T> T first(java.util.Iterator<T> values)
Take the first element from the specified- Type Parameters:
T
- the type of element of- Parameters:
values
- theIterator
object- Returns:
- if found, return the first one, or
null
-
-