Package cool.solr.search.solr.util
Class ConvenientNamedList
- java.lang.Object
-
- cool.solr.search.solr.util.ConvenientNamedList
-
public class ConvenientNamedList extends Object
Provides more convenient read-only access to the elements of aNamedList. ThegetNestedmethods of this class return a nested named list, wrapped in another instance of this class. If the nested list does not exist or the element at the given name or index isnull, the returnedConvenientNamedListis empty. All other getter methods returnnullif the underlying named list does not contain a value for a given name, or if the value for the given name isnull. The underlying named list may itself benull, in this case, the methods will also returnnull.
-
-
Constructor Summary
Constructors Constructor Description ConvenientNamedList(org.apache.solr.common.util.NamedList namedList)Creates a new read-only wrapper for the given named list.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> Collection<T>getCollection(String name)Returns the collection of the given name.<T> List<T>getList(String name)Returns the list of the given name.org.apache.solr.common.util.NamedList<?>getNamedList()Returns the underlyingNamedList.ConvenientNamedListgetNested(int index)Returns the nestedNamedListat the given index, or returns an emptyConvenientNamedListif the given index is invalid in the underlying list.ConvenientNamedListgetNested(String name)Returns the nestedNamedListof the given name.ConvenientNamedListgetNested(String... names)Returns the nestedNamedListat the given path.<T> Set<T>getSet(String name)Returns the set of the given name.StringgetString(String name)Returns the string of the given name.intsize()Returns the size of the underlying named list.StringtoString()
-
-
-
Method Detail
-
size
public int size()
Returns the size of the underlying named list.
-
getNested
public ConvenientNamedList getNested(String name)
Returns the nestedNamedListof the given name.
-
getNested
public ConvenientNamedList getNested(String... names)
Returns the nestedNamedListat the given path.
-
getNested
public ConvenientNamedList getNested(int index)
Returns the nestedNamedListat the given index, or returns an emptyConvenientNamedListif the given index is invalid in the underlying list.
-
getSet
public <T> Set<T> getSet(String name)
Returns the set of the given name.- Type Parameters:
T- the type of the elements in the set. This is not checked by this method. If any elements in the set are not of the expected type, accessing the elements of the set will result in aClassCastException.
-
getList
public <T> List<T> getList(String name)
Returns the list of the given name.- Type Parameters:
T- the type of the elements in the list. This is not checked by this method. If any elements in the list are not of the expected type, accessing the elements of the list will result in aClassCastException.
-
getCollection
public <T> Collection<T> getCollection(String name)
Returns the collection of the given name.- Type Parameters:
T- the type of the elements in the set. This is not checked by this method. If any elements in the set are not of the expected type, accessing the elements of the set will result in aClassCastException.
-
getNamedList
public org.apache.solr.common.util.NamedList<?> getNamedList()
Returns the underlyingNamedList.
-
-