public final class NamedLists extends Object
NamedList. All methods of this class are null-safe: if the named list is
null, the methods will simply return null.
The convenience methods that take a number of path elements as an argument all work by first navigating to the given
nested NamedList and then returning the requested element of that list. Note that if any of the lists in the
given path contains a null value for the path element, or no value of that name, the methods return
null.
All methods of this class throw a NamedListEntryClassCastException if an element does not have the expected
type.
| Modifier and Type | Method and Description |
|---|---|
static <T> T |
get(org.apache.solr.common.util.NamedList<?> namedList,
Class<T> elementClass,
int index)
Gets the element at the specified index from the given list.
|
static <T> T |
get(org.apache.solr.common.util.NamedList<?> namedList,
Class<T> elementClass,
String... names)
Gets a nested element from the given list.
|
static <T> T |
get(org.apache.solr.common.util.NamedList<?> namedList,
Class<T> elementClass,
String name)
Gets the element of the specified name from the given list.
|
static <T> Collection<T> |
getCollection(org.apache.solr.common.util.NamedList<?> namedList,
String... names)
Gets a collection from the given list.
|
static <T> Collection<T> |
getCollection(org.apache.solr.common.util.NamedList<?> namedList,
String name)
Gets the
Collection of the specified name from the given list. |
static <T> List<T> |
getList(org.apache.solr.common.util.NamedList<?> namedList,
String... names)
Gets a list from the given list.
|
static <T> List<T> |
getList(org.apache.solr.common.util.NamedList<?> namedList,
String name)
Gets the
List of the specified name from the given list. |
static <T> Set<T> |
getSet(org.apache.solr.common.util.NamedList<?> namedList,
String... names)
Gets a set from the given list.
|
static <T> Set<T> |
getSet(org.apache.solr.common.util.NamedList<?> namedList,
String name)
Gets the
Set of the specified name from the given list. |
static String |
getString(org.apache.solr.common.util.NamedList<?> namedList,
String... names)
Gets a string value from the given list.
|
static String |
getString(org.apache.solr.common.util.NamedList<?> namedList,
String name)
Gets the string value of the specified name from the given list.
|
static Set<String> |
keys(org.apache.solr.common.util.NamedList<?> namedList)
Returns the set of keys in the given named list.
|
static org.apache.solr.common.util.NamedList<?> |
navigate(org.apache.solr.common.util.NamedList<?> namedList,
int index)
Gets the nested
NamedList stored at the given index. |
static org.apache.solr.common.util.NamedList<?> |
navigate(org.apache.solr.common.util.NamedList<?> namedList,
String... names)
Gets the nested
NamedList stored under the given path. |
static org.apache.solr.common.util.NamedList<?> |
navigate(org.apache.solr.common.util.NamedList<?> namedList,
String name)
Gets the nested
NamedList stored under the given name. |
public static org.apache.solr.common.util.NamedList<?> navigate(org.apache.solr.common.util.NamedList<?> namedList,
String name)
NamedList stored under the given name.namedList - the list.name - the name of the element in the list.NamedList, or null if no element with the given name exists in the list or the
value is null.public static org.apache.solr.common.util.NamedList<?> navigate(org.apache.solr.common.util.NamedList<?> namedList,
String... names)
NamedList stored under the given path. See the class documentation for notes on
convenience methods that take a path as their argument.public static org.apache.solr.common.util.NamedList<?> navigate(org.apache.solr.common.util.NamedList<?> namedList,
int index)
NamedList stored at the given index. Note that unlike NamedList.getVal(int), this
method will return null if the given index is invalid instead of throwing an
IndexOutOfBoundsException.namedList - the list.index - the index of the element.NamedList, or null if the element at the given index is null or if the
given index is not a valid index.public static Set<String> keys(org.apache.solr.common.util.NamedList<?> namedList)
namedList - the list.null if namedList was null.public static <T> Set<T> getSet(org.apache.solr.common.util.NamedList<?> namedList, String name)
Set of the specified name from the given list.T - the type of the elements in the returned set. Note that this type is not checked by
this method, so a ClassCastException may occur when trying to actually access the elements of
the set if they're not of the expected class.namedList - the list.name - the name of the element in the list.null if the list does not contain an element with the given name or the value is
null.public static <T> Set<T> getSet(org.apache.solr.common.util.NamedList<?> namedList, String... names)
getSet(NamedList, String)public static <T> List<T> getList(org.apache.solr.common.util.NamedList<?> namedList, String name)
List of the specified name from the given list.T - the type of the elements in the returned list. Note that this type is not checked by
this method, so a ClassCastException may occur when trying to actually access the elements of
the list if they're not of the expected class.namedList - the list.name - the name of the element in the list.null if the list does not contain an element with the given name or the value is
null.public static <T> List<T> getList(org.apache.solr.common.util.NamedList<?> namedList, String... names)
getList(NamedList, String)public static <T> Collection<T> getCollection(org.apache.solr.common.util.NamedList<?> namedList, String name)
Collection of the specified name from the given list.T - the type of the elements in the returned collection. Note that this type is not checked
by this method, so a ClassCastException may occur when trying to actually access the elements of
the collection if they're not of the expected class.namedList - the list.name - the name of the element in the list.null if the list does not contain an element with the given name or the value
is null.public static <T> Collection<T> getCollection(org.apache.solr.common.util.NamedList<?> namedList, String... names)
getCollection(NamedList, String)public static String getString(org.apache.solr.common.util.NamedList<?> namedList, String name)
namedList - the list.name - the name of the element in the list.null if the list does not contain an element with the given name or the value is
null.public static String getString(org.apache.solr.common.util.NamedList<?> namedList, String... names)
getString(NamedList, String)public static <T> T get(org.apache.solr.common.util.NamedList<?> namedList,
Class<T> elementClass,
String name)
namedList - the list.elementClass - the class of the element expected in the list under the given name.name - the name of the list entry to return.null if no element with the given
name exists in the list or the value if null.NamedListEntryClassCastException - if the value stored in the list is not an instance of class elementClass.public static <T> T get(org.apache.solr.common.util.NamedList<?> namedList,
Class<T> elementClass,
String... names)
get(NamedList, Class, String)public static <T> T get(org.apache.solr.common.util.NamedList<?> namedList,
Class<T> elementClass,
int index)
namedList - the list.elementClass - the class of the element expected in the list at the specified index.index - the index of the element.NamedListEntryClassCastException - if the value stored in the list is not an instance of elementClass.IndexOutOfBoundsException - if the given index is not a valid index into the given list.Copyright © 2020. All rights reserved.