public class KSCollectionUtils extends Object
Constructor and Description |
---|
KSCollectionUtils() |
Modifier and Type | Method and Description |
---|---|
static <T> boolean |
areCollectionContentsEqual(Collection<T> source,
Collection<T> target)
A Null-safe test of the contents of each list that returns true if they are identical using bag semantics.
|
static <T> T |
getOptionalZeroElement(List<T> list)
Cardinality of zero or one.
|
static <T> T |
getOptionalZeroElement(List<T> list,
boolean throwOnNullList)
Cardinality of zero or one.
|
static <T> T |
getRequiredZeroElement(List<T> list)
Cardinality of one
This is a generic method so you will not need to worry about casting when using this method
Using get(0) in a non-test class will result in a critical sonar issue being reported which will result in a JIRA issue.
|
static <T> T |
getRequiredZeroElement(List<T> list,
boolean throwOnNullList,
boolean throwOnEmptyList)
Cardinality of one
This is a generic method so you will not need to worry about casting when using this method
Using get(0) in a non-test class will result in a critical sonar issue being reported which will result in a JIRA issue.
|
public KSCollectionUtils()
public static <T> T getRequiredZeroElement(List<T> list) throws OperationFailedException
T
- Type of element to returnlist
- Typed list passed into method. Cannot be null.OperationFailedException
public static <T> T getRequiredZeroElement(List<T> list, boolean throwOnNullList, boolean throwOnEmptyList) throws OperationFailedException
T
- Type of element to returnlist
- Typed list passed into method. Cannot be null.throwOnNullList
- true if an OperationFailedException should be thrown if the list is null. If false it will allow null to be returned in the list is null case.throwOnEmptyList
- true if an OperationFailedException should be thrown if the list is empty. If false it will allow null to be returned in the list is empty case.OperationFailedException
public static <T> T getOptionalZeroElement(List<T> list) throws OperationFailedException
T
- Type of element to returnlist
- Typed list passed into method. Cannot be null.OperationFailedException
public static <T> T getOptionalZeroElement(List<T> list, boolean throwOnNullList) throws OperationFailedException
T
- Type of element to returnlist
- Typed list passed into method.throwOnNullList
- true if an OperationFailedException should be thrown if the list is null. If false it will allow null to be returned in the list is null case.throwOnEmptyList
- true if an OperationFailedException should be thrown if the list is empty. If false it will allow null to be returned in the list is empty case.OperationFailedException
public static <T> boolean areCollectionContentsEqual(Collection<T> source, Collection<T> target)
source
- the first collection in the comparisontarget
- the second collection in the comparisonCopyright © 2004-2014 The Kuali Foundation. All Rights Reserved.