public class

JsonMap

extends Object
implements JsonSerializable Iterable<T>
java.lang.Object
   ↳ com.urbanairship.json.JsonMap

Class Overview

An immutable mapping of String keys to JsonValues.

Summary

Nested Classes
class JsonMap.Builder Builder class for JsonMap Objects. 
Fields
public static final JsonMap EMPTY_MAP
Public Constructors
JsonMap(Map<StringJsonValue> map)
Creates a JsonMap from a Map.
Public Methods
boolean containsKey(String key)
Returns whether this map contains the specified key.
boolean containsValue(JsonValue value)
Returns whether this map contains the specified value.
Set<Entry<StringJsonValue>> entrySet()
Returns a set containing all of the mappings in this map.
boolean equals(Object object)
JsonValue get(String key)
Returns the value of the mapping with the specified key.
Map<StringJsonValue> getMap()
Gets the JsonMap as a Map.
int hashCode()
boolean isEmpty()
Returns whether this map is empty.
Iterator<Entry<StringJsonValue>> iterator()
Set<String> keySet()
Returns a set of the keys contained in this map.
static JsonMap.Builder newBuilder()
Factory method to create a new JSON map builder.
JsonValue opt(String key)
Returns the optional value in the map with the specified key.
int size()
Returns the number of elements in this map.
JsonValue toJsonValue()
Returns the objects represented as a JsonValue.
String toString()
Returns the JsonMap as a JSON encoded String.
Collection<JsonValue> values()
Returns a collection of the values contained in this map.
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.urbanairship.json.JsonSerializable
From interface java.lang.Iterable

Fields

public static final JsonMap EMPTY_MAP

Public Constructors

public JsonMap (Map<StringJsonValue> map)

Creates a JsonMap from a Map.

Parameters
map A map of strings to JsonValues.

Public Methods

public boolean containsKey (String key)

Returns whether this map contains the specified key.

Parameters
key the key to search for.
Returns
  • true if this map contains the specified key, false otherwise.

public boolean containsValue (JsonValue value)

Returns whether this map contains the specified value.

Parameters
value the value to search for.
Returns
  • true if this map contains the specified value, false otherwise.

public Set<Entry<StringJsonValue>> entrySet ()

Returns a set containing all of the mappings in this map. Each mapping is an instance of Map.Entry. As the set is backed by this map, changes in one will be reflected in the other.

Returns
  • a set of the mappings.

public boolean equals (Object object)

public JsonValue get (String key)

Returns the value of the mapping with the specified key.

Parameters
key the key.
Returns
  • the value of the mapping with the specified key, or null if no mapping for the specified key is found.

public Map<StringJsonValue> getMap ()

Gets the JsonMap as a Map.

Returns
  • The JsonMap as a Map.

public int hashCode ()

public boolean isEmpty ()

Returns whether this map is empty.

Returns
  • true if this map has no elements, false otherwise.

public Iterator<Entry<StringJsonValue>> iterator ()

public Set<String> keySet ()

Returns a set of the keys contained in this map. The set is backed by this map so changes to one are reflected by the other. The set does not support adding.

Returns
  • a set of the keys.

public static JsonMap.Builder newBuilder ()

Factory method to create a new JSON map builder.

Returns
  • A JSON map builder.

public JsonValue opt (String key)

Returns the optional value in the map with the specified key. If the value is not in the map NULL will be returned instead null.

Parameters
key the key.
Returns
  • the value of the mapping with the specified key, or NULL if no mapping for the specified key is found.

public int size ()

Returns the number of elements in this map.

Returns
  • the number of elements in this map.

public JsonValue toJsonValue ()

Returns the objects represented as a JsonValue.

Returns
  • The object as a JsonValue.

public String toString ()

Returns the JsonMap as a JSON encoded String.

Returns
  • The value as a JSON encoded String.

public Collection<JsonValue> values ()

Returns a collection of the values contained in this map.

Returns
  • a collection of the values contained in this map.