Package com.github.m0nk3y2k4.thetvdb.api
Interface QueryParameters
-
- All Superinterfaces:
Iterable<QueryParameters.Parameter>
- All Known Implementing Classes:
QueryParametersImpl
public interface QueryParameters extends Iterable<QueryParameters.Parameter>
Interface representing a set of query parameters. These parameters can be used for some of the API calls in order to narrow the results being returned by the remote service. Instances of this interface might be created by using theTheTVDBApiFactory
class.
Individual parameters hold by this object can be accessed as Iterator or Stream.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
QueryParameters.Parameter
Interface representing a single, individual key/value parameter
-
Method Summary
All Methods Instance Methods Abstract 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.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.-
Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
-
-
-
-
Method Detail
-
addParameter
QueryParameters addParameter(@Nonnull String key, @Nonnull String value)
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
.- 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
Optional<String> getParameterValue(@Nonnull String key)
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.- 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
boolean containsParameter(@Nonnull 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.- 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
int size()
Returns the count of single parameter elements held by this container- Returns:
- Number of single query parameters contained in this parameter set
-
stream
Stream<QueryParameters.Parameter> stream()
Returns a Stream of individual query parameters held by this class.- Returns:
- Stream of all query parameters that have been added to this object
-
-