Class QueryParametersImpl
- java.lang.Object
-
- com.github.m0nk3y2k4.thetvdb.internal.api.impl.QueryParametersImpl
-
- All Implemented Interfaces:
QueryParameters
,Iterable<QueryParameters.Parameter>
public class QueryParametersImpl extends Object implements QueryParameters
Internal implementation of theQueryParameters
interface
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.github.m0nk3y2k4.thetvdb.api.QueryParameters
QueryParameters.Parameter
-
-
Constructor Summary
Constructors Constructor Description QueryParametersImpl()
Creates a new empty set of query parametersQueryParametersImpl(Map<String,String> parameters)
Creates an object of this class with a pre-defined set of individual query parameters based on the given key/value pairs.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description QueryParameters
addParameter(String key, String value)
Adds a new parameter to this object.boolean
containsParameter(String key)
Returnstrue
if an individual parameter with the given key exists in this very object orfalse
if no such parameter has been added yet.Optional<String>
getParameterValue(String key)
Returns an Optional representing the parameter value for the given key.Iterator<QueryParameters.Parameter>
iterator()
int
size()
Returns the count of single parameter elements held by this containerStream<QueryParameters.Parameter>
stream()
Returns a Stream of individual query parameters held by this class.String
toString()
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Constructor Detail
-
QueryParametersImpl
public QueryParametersImpl()
Creates a new empty set of query parameters
-
QueryParametersImpl
public QueryParametersImpl(@Nonnull Map<String,String> parameters)
Creates an object of this class with a pre-defined set of individual query parameters based on the given key/value pairs. For each entry in this map an appropriate query parameter will be added to this instance.- Parameters:
parameters
- Map containing key/value pairs of query parameters to be initially added to this instance. Might be empty but notnull
.
-
-
Method Detail
-
addParameter
public QueryParameters addParameter(@Nonnull String key, @Nonnull String value)
Description copied from interface:QueryParameters
Adds a new parameter to this object. An individual query parameter consists of a key/value pair. Adding the same parameter key twice will not result in two different parameters. Instead the parameter value from the first addition will be replaced by the new given value. For a predefined list of query parameters seeQuery
.- Specified by:
addParameter
in interfaceQueryParameters
- Parameters:
key
- The new parameters key. The classQuery
provides a basic set of parameter constants for the various API routes, which can be used at this point.value
- The new parameters value. Should not benull
or empty. These values will be encoded before being added to the URI.- Returns:
- Reference to this very instance. Can be used to add multiple parameters in a fluent notation.
-
getParameterValue
public Optional<String> getParameterValue(@Nonnull String key)
Description copied from interface:QueryParameters
Returns an Optional representing the parameter value for the given key. The Optional might be empty if this object currently holds no individual query parameter with this key.- Specified by:
getParameterValue
in interfaceQueryParameters
- Parameters:
key
- The parameter key for which the current value should be returned- Returns:
- Optional containing the current value for the given key or
Optional.empty()
if no parameter with this key exists - See Also:
containsParameter(key)
-
containsParameter
public boolean containsParameter(@Nonnull String key)
Description copied from interface:QueryParameters
Returnstrue
if an individual parameter with the given key exists in this very object orfalse
if no such parameter has been added yet.- Specified by:
containsParameter
in interfaceQueryParameters
- Parameters:
key
- The parameter key to check for- Returns:
True
if a parameter with the given key has already been added to this object orfalse
if not
-
size
public int size()
Description copied from interface:QueryParameters
Returns the count of single parameter elements held by this container- Specified by:
size
in interfaceQueryParameters
- Returns:
- Number of single query parameters contained in this parameter set
-
stream
public Stream<QueryParameters.Parameter> stream()
Description copied from interface:QueryParameters
Returns a Stream of individual query parameters held by this class.- Specified by:
stream
in interfaceQueryParameters
- Returns:
- Stream of all query parameters that have been added to this object
-
iterator
@Nonnull public Iterator<QueryParameters.Parameter> iterator()
- Specified by:
iterator
in interfaceIterable<QueryParameters.Parameter>
-
-