Package org.lazywizard.lazylib
Class CollectionUtils
Object
CollectionUtils
Contains methods for working with Collections.
- Since:
- 1.0
- Author:
- LazyWizard
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceUsed withfilter(Collection, CollectionUtils.CollectionFilter)to filter out unwanted entries in aCollection.static classstatic class -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> List<T>combinedList(Collection<T>... toCombine) Returns a combinedListfrom severalCollections.static <T> Set<T>combinedSet(Collection<T>... toCombine) Returns a combinedSetfrom severalCollections.static <T> List<T>filter(Collection<T> toFilter, List<CollectionUtils.CollectionFilter<T>> filters) Filters aCollectionand returns aListcontaining only the entries that the filters accepted.static <T> List<T>filter(Collection<T> toFilter, CollectionUtils.CollectionFilter<T> filter) Filters aCollectionand returns aListcontaining only the entries that the filter accepted.static <T> Stringstatic <T> Stringstatic Stringimplode(Collection toImplode) Creates a comma-separatedStringfrom aCollection's entries.static Stringimplode(Collection toImplode, String separator) Combines and separates aCollectionofStrings.
-
Method Details
-
implode
Combines and separates aCollectionofStrings. Useful for comma-separated lists.- Parameters:
toImplode- ACollectionwhose contents should be combined into oneString.separator- The separator character to splittoImplodewith.- Returns:
- A single
Stringconsisting oftoImplode's values separated withseparator. - Since:
- 1.0
-
implode
Creates a comma-separatedStringfrom aCollection's entries.- Parameters:
toImplode- ACollectionto be combined (using each entry'stoStringmethod).- Returns:
- A single
Stringconsisting oftoImplode's values separated with commas. - Since:
- 1.0
- See Also:
-
implode
-
implode
-
combinedList
Returns a combinedListfrom severalCollections.- Parameters:
toCombine- TheCollectionof elements to combine.- Returns:
- A new
ArrayListcontaining the combined contents oftoCombine. - Since:
- 2.1
-
combinedSet
Returns a combinedSetfrom severalCollections.- Parameters:
toCombine- TheCollectionof elements to combine.- Returns:
- A new
HashSetcontaining the combined contents oftoCombine. The capacity will be the total size of all sourceCollections. - Since:
- 2.1
-
filter
public static <T> List<T> filter(Collection<T> toFilter, CollectionUtils.CollectionFilter<T> filter) Filters aCollectionand returns aListcontaining only the entries that the filter accepted.- Parameters:
toFilter- TheCollectionto filter.filter- ACollectionUtils.CollectionFilterthat will be used to filtertoFilter.- Returns:
- A
Listcontaining only the entries oftoFilterthat passedfilter'saccept()method. - Since:
- 1.7
-
filter
public static <T> List<T> filter(Collection<T> toFilter, List<CollectionUtils.CollectionFilter<T>> filters) Filters aCollectionand returns aListcontaining only the entries that the filters accepted.- Parameters:
toFilter- TheCollectionto filter.filters- AListofCollectionUtils.CollectionFilters that will be used to filtertoFilter.- Returns:
- A
Listcontaining only the entries oftoFilterthat passedfilters'accept()methods. - Since:
- 1.7
- See Also:
-