com.atlassian.bamboo.util
Class BambooCollectionUtils

java.lang.Object
  extended by com.atlassian.bamboo.util.BambooCollectionUtils

public class BambooCollectionUtils
extends java.lang.Object


Constructor Summary
BambooCollectionUtils()
           
 
Method Summary
static
<E> boolean
addIgnoreNull(java.util.Collection<? super E> collection, E element)
          Add element to the collection if it is not null.
static java.util.List<java.lang.String> convertToList(java.lang.String s)
           
static
<E> E
get(java.util.List<? extends E> list, int index)
          Get Nth element from list or null if list hasn't got so many elements
static
<E> java.util.List<E>
newArrayList(java.lang.Iterable<? extends E> elements, java.util.Comparator<? super E> comparator)
          Deprecated. since 3.0 use Ordering.sortedCopy
static
<E> java.util.List<E>
newLinkedList(java.lang.Iterable<? extends E> elements, java.util.Comparator<? super E> comparator)
          Deprecated. since 3.0 use Ordering.sortedCopy
static
<T> java.util.List<T>
removeDuplicates(java.util.List<T> input)
           
static
<T extends java.lang.Comparable<? super T>>
java.util.List<T>
removeDuplicatesAndSort(java.util.List<T> input)
           
static
<T> java.util.List<T>
removeDuplicatesAndSort(java.util.List<T> input, java.util.Comparator<? super T> c)
           
static
<K,V extends java.lang.Comparable<? super V>>
java.util.List<java.util.Map.Entry<K,V>>
sortByValue(java.util.Map<K,V> map)
          Given a map returns the list of entries in the map sorted by Entry.getValue() in descending order.
static java.util.Set<java.lang.String> stringArrayToHashSet(java.lang.String[] values)
           
static java.util.List<java.lang.String> stringArrayToList(java.lang.String[] s)
           
static java.util.List<java.lang.String> stringToCollection(java.lang.String s)
          Converts a string with a given pattern into a Collection of strings.
static
<T> java.util.List<T>
subtract(java.util.Collection<T> a, java.util.Collection<T> b)
          Generic version of ListUtils.subtract
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BambooCollectionUtils

public BambooCollectionUtils()
Method Detail

stringToCollection

@NotNull
public static java.util.List<java.lang.String> stringToCollection(java.lang.String s)
Converts a string with a given pattern into a Collection of strings.

Parameters:
s - string to be analyzed
Returns:
list of strings

stringArrayToList

@NotNull
public static java.util.List<java.lang.String> stringArrayToList(@Nullable
                                                                         java.lang.String[] s)

stringArrayToHashSet

@NotNull
public static java.util.Set<java.lang.String> stringArrayToHashSet(@Nullable
                                                                           java.lang.String[] values)

removeDuplicates

@Nullable
public static <T> java.util.List<T> removeDuplicates(@Nullable
                                                              java.util.List<T> input)

removeDuplicatesAndSort

@Nullable
public static <T extends java.lang.Comparable<? super T>> java.util.List<T> removeDuplicatesAndSort(java.util.List<T> input)

removeDuplicatesAndSort

@Nullable
public static <T> java.util.List<T> removeDuplicatesAndSort(java.util.List<T> input,
                                                                     @NotNull
                                                                     java.util.Comparator<? super T> c)

convertToList

@Nullable
public static java.util.List<java.lang.String> convertToList(@Nullable
                                                                      java.lang.String s)

subtract

@NotNull
public static <T> java.util.List<T> subtract(@NotNull
                                                     java.util.Collection<T> a,
                                                     @NotNull
                                                     java.util.Collection<T> b)
Generic version of ListUtils.subtract

Type Parameters:
T - any type
Parameters:
a - collection A
b - collection B
Returns:
List of (A - B)

newArrayList

@Deprecated
public static <E> java.util.List<E> newArrayList(@NotNull
                                                            java.lang.Iterable<? extends E> elements,
                                                            @NotNull
                                                            java.util.Comparator<? super E> comparator)
Deprecated. since 3.0 use Ordering.sortedCopy

Creates a sorted mutable ArrayList consisting of input elements

Parameters:
elements - Elements to be copied
comparator - Comparator used for sorting
Returns:
Sorted mutable list consisting of input elements

newLinkedList

@Deprecated
public static <E> java.util.List<E> newLinkedList(@NotNull
                                                             java.lang.Iterable<? extends E> elements,
                                                             @NotNull
                                                             java.util.Comparator<? super E> comparator)
Deprecated. since 3.0 use Ordering.sortedCopy

Creates a sorted mutable LinkedList consisting of input elements

Parameters:
elements - Elements to be copied
comparator - Comparator used for sorting
Returns:
Sorted mutable list consisting of input elements

sortByValue

public static <K,V extends java.lang.Comparable<? super V>> java.util.List<java.util.Map.Entry<K,V>> sortByValue(java.util.Map<K,V> map)
Given a map returns the list of entries in the map sorted by Entry.getValue() in descending order.

Parameters:
map -
Returns:
sorted list of map's entries

addIgnoreNull

public static <E> boolean addIgnoreNull(@NotNull
                                        java.util.Collection<? super E> collection,
                                        E element)
Add element to the collection if it is not null. Generified version of Apache's CollectionUtils.addIgnoreNull.

Type Parameters:
E - Element type
Parameters:
collection - Collection where element will be added to
element - Element to be added to the collection
Returns:
true if the collection changed

get

@Nullable
public static <E> E get(@NotNull
                                 java.util.List<? extends E> list,
                                 int index)
Get Nth element from list or null if list hasn't got so many elements

Type Parameters:
E - Type of the elements in the list
Parameters:
list - List to get element from
index - Index of element to get
Returns:
Element of given index or null


Copyright © 2011 Atlassian. All Rights Reserved.