com.github.fge.uritemplate.vars.values
Class MapValue

java.lang.Object
  extended by com.github.fge.uritemplate.vars.values.VariableValue
      extended by com.github.fge.uritemplate.vars.values.MapValue

@Immutable
public final class MapValue
extends VariableValue

Map variable value

Note that some methods allow to pass values of arbitrary type. It is the caller's responsibility to ensure that these values have a correct .toString() implementation.

Also note that null keys or values are not accepted.

While there is one public constructor, it is deprecated. Use copyOf(Map) instead, or for more control, use a MapValue.Builder (see newBuilder()).


Nested Class Summary
static class MapValue.Builder
          Builder class for a MapValue
 
Field Summary
 
Fields inherited from class com.github.fge.uritemplate.vars.values.VariableValue
BUNDLE
 
Method Summary
static
<T> VariableValue
copyOf(Map<String,T> map)
          Convenience method to build a variable value from an existing Map
 Map<String,String> getMapValue()
          Get a map for this value
 boolean isEmpty()
          Tell whether this value is empty
static MapValue.Builder newBuilder()
          Create a new builder for this class
 
Methods inherited from class com.github.fge.uritemplate.vars.values.VariableValue
getListValue, getScalarValue, getType
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

newBuilder

public static MapValue.Builder newBuilder()
Create a new builder for this class

Returns:
a MapValue.Builder

copyOf

public static <T> VariableValue copyOf(Map<String,T> map)
Convenience method to build a variable value from an existing Map

Type Parameters:
T - the type of values in this map
Parameters:
map - the map
Returns:
a new map value as a VariableValue
Throws:
NullPointerException - map is null, or one of its keys or values is null

getMapValue

public Map<String,String> getMapValue()
Description copied from class: VariableValue
Get a map for this value

Only valid for map values

Overrides:
getMapValue in class VariableValue
Returns:
the map

isEmpty

public boolean isEmpty()
Description copied from class: VariableValue
Tell whether this value is empty

For strings, this tells whether the string itself is empty. For lists and maps, this tells whether the list or map have no elements/entries.

Specified by:
isEmpty in class VariableValue
Returns:
true if the value is empty