Class ObjectUtils
- java.lang.Object
-
- org.eclipse.nebula.widgets.nattable.util.ObjectUtils
-
public final class ObjectUtils extends Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> Collection<T>
asCollection(Iterator<T> iterator)
Transfers the given iterator to an unmodifiable collection.static int[]
asIntArray(Collection<Integer> collection)
static <T> List<T>
asList(Collection<T> collection)
static <T> Collection<T>
asOrderedCollection(Iterator<T> iterator, Comparator<T> comparator)
Transfers the given iterator into an unmodifiable ordered collection based on the given comparator.static <T> T
getFirstElement(List<T> list)
static <T> T
getLastElement(List<T> list)
static Date
getRandomDate()
static int
getRandomNumber()
static int
getRandomNumber(int max)
static boolean
isEmpty(String string)
static <T> boolean
isEmpty(Collection<T> collection)
static boolean
isNotEmpty(String string)
static <T> boolean
isNotEmpty(Collection<T> collection)
static boolean
isNotNull(Object object)
static boolean
isNull(Object object)
static <T> String
toString(Collection<T> collection)
static <T> String
toString(T[] array)
-
-
-
Method Detail
-
asCollection
public static <T> Collection<T> asCollection(Iterator<T> iterator)
Transfers the given iterator to an unmodifiable collection.- Type Parameters:
T
- The type of the objects contained in the iterator.- Parameters:
iterator
- The iterator to transfer.- Returns:
- Contents of the iterator as an unmodifiable Collection.
-
asList
public static <T> List<T> asList(Collection<T> collection)
-
asIntArray
public static int[] asIntArray(Collection<Integer> collection)
-
asOrderedCollection
public static <T> Collection<T> asOrderedCollection(Iterator<T> iterator, Comparator<T> comparator)
Transfers the given iterator into an unmodifiable ordered collection based on the given comparator.- Type Parameters:
T
- The type of the objects contained in the iterator.- Parameters:
iterator
- The iterator to transfer.comparator
- The comparator to order the collection.- Returns:
- Contents of the iterator as an unmodifiable ordered Collection.
-
toString
public static <T> String toString(Collection<T> collection)
-
toString
public static <T> String toString(T[] array)
-
isEmpty
public static <T> boolean isEmpty(Collection<T> collection)
- Type Parameters:
T
- The type of objects in the collection.- Parameters:
collection
- The collection to check.- Returns:
true
if the given collection isnull
or empty.
-
isEmpty
public static boolean isEmpty(String string)
- Parameters:
string
- The string to check.- Returns:
true
if the given string isnull
or empty.
-
isNotEmpty
public static boolean isNotEmpty(String string)
- Parameters:
string
- The string to check.- Returns:
true
if the given string is notnull
and not empty.
-
isNotEmpty
public static <T> boolean isNotEmpty(Collection<T> collection)
- Type Parameters:
T
- The type of objects in the collection.- Parameters:
collection
- The collection to check.- Returns:
true
if the given collection is notnull
and not empty.
-
isNull
public static boolean isNull(Object object)
- Parameters:
object
- The object to check.- Returns:
true
if the given object reference isnull
.
-
isNotNull
public static boolean isNotNull(Object object)
- Parameters:
object
- The object to check.- Returns:
true
if the given object reference is notnull
.
-
getRandomDate
public static Date getRandomDate()
- Returns:
- a random Date
-
getRandomNumber
public static int getRandomNumber()
- Returns:
- 4 digit random Integer number
-
getRandomNumber
public static int getRandomNumber(int max)
- Parameters:
max
- the upper bound (exclusive)- Returns:
- random Integer number between 0 and parameter max
-
getLastElement
public static <T> T getLastElement(List<T> list)
-
getFirstElement
public static <T> T getFirstElement(List<T> list)
-
-