public abstract class NamedValues extends Object
Provides utility methods related to working with named values.
Modifier and Type | Method and Description |
---|---|
static <T extends NamedValueWithSource> |
filterBySource(String source,
Collection<T> namedValues)
Filters the NamedValue elements that are associated with the specified source.
|
static Map<String,Object> |
flatten(Map<String,Object> map,
char separator) |
static Map<String,Object> |
flatten(Map<String,Object> map,
String prefix,
char separator) |
static <T extends NamedValue> |
getDuplicateNames(Collection<T> namedValues)
Returns all names that occur more than once.
|
static <T extends NamedValue> |
mergeNamedValues(Collection<T> namedValuesBase,
Collection<T> namedValuesWithPrecedence)
Merges two collections of NamedValue elements.
|
static <T extends NamedValue> |
mergeNamedValues(List<Collection<T>> namedValuesCollections)
Merges collections of NamedValue elements.
|
static Map<String,Object> |
toMap(Collection<? extends NamedValue> namedValues)
Transforms the given
NamedValue s into a Map of String keys and Object values. |
static Map<String,Object> |
toMap(Collection<? extends NamedValue> namedValues,
char nameSeparator)
Transforms the given
NamedValue s into a nested Map of String keys and values of the given type or Map. |
static <T> Map<String,T> |
toMap(Collection<? extends NamedValue> namedValues,
Class<T> expectedValueType)
Transforms the given
NamedValue s into a Map of String keys and values of the given type. |
public static Map<String,Object> toMap(Collection<? extends NamedValue> namedValues)
Transforms the given NamedValue
s into a Map of String keys and Object values.
namedValues
- the named values to transform into a mappublic static <T> Map<String,T> toMap(Collection<? extends NamedValue> namedValues, Class<T> expectedValueType)
Transforms the given NamedValue
s into a Map of String keys and values of the given type.
T
- the type of the valuenamedValues
- the named values to transform into a mapexpectedValueType
- the expected type of the valuespublic static Map<String,Object> toMap(Collection<? extends NamedValue> namedValues, char nameSeparator)
Transforms the given NamedValue
s into a nested Map of String keys and values of the given type or Map. The nesting of maps happens based on the occurrence of the
given separator within the names.
namedValues
- the named values to transform into a mapnameSeparator
- the name separatorpublic static Map<String,Object> flatten(Map<String,Object> map, String prefix, char separator)
public static <T extends NamedValue> com.google.common.collect.ImmutableSortedSet<String> getDuplicateNames(Collection<T> namedValues)
Returns all names that occur more than once.
T
- the type of the named valuenamedValues
- the named values to investigatepublic static <T extends NamedValue> com.google.common.collect.ImmutableCollection<T> mergeNamedValues(Collection<T> namedValuesBase, Collection<T> namedValuesWithPrecedence)
Merges two collections of NamedValue elements. In case of name clashes, elements in the second collection win over elements in the first collection.
T
- the type of the named valuenamedValuesBase
- collection of the base named valuesnamedValuesWithPrecedence
- collection of the named values with precedencepublic static <T extends NamedValue> com.google.common.collect.ImmutableCollection<T> mergeNamedValues(List<Collection<T>> namedValuesCollections)
Merges collections of NamedValue elements. In case of name clashes, elements in higher collections win over elements in lower collections, where a higher collection means a collection with a larger index compared to another collection.
T
- the type of the named valuenamedValuesCollections
- the collections of named values to mergepublic static <T extends NamedValueWithSource> com.google.common.collect.ImmutableCollection<T> filterBySource(String source, Collection<T> namedValues)
Filters the NamedValue elements that are associated with the specified source.
T
- the type of the named value with sourcesource
- the sourcenamedValues
- the named values to filterCopyright © 2010 - 2019 edorasware ag. All Rights Reserved.