com.github.fge.jsonschema.core.util
Class Dictionary<T>

java.lang.Object
  extended by com.github.fge.jsonschema.core.util.Dictionary<T>
Type Parameters:
T - the type of values for this dictionary
All Implemented Interfaces:
Frozen<DictionaryBuilder<T>>

@Immutable
public final class Dictionary<T>
extends Object
implements Frozen<DictionaryBuilder<T>>

A dictionary

This class is a wrapper over a Map, where keys are always Strings. The type of values is arbitrary.

This class is immutable. If you want to build a dictionary, you have two options:

For instance:

     // New builder
     final DictionaryBuilder<Foo> builder = Dictionary.newBuilder();
     // From an existing dictionary
     final DictionaryBuilder<Foo> builder = dict.thaw();
 

See Also:
DictionaryBuilder

Method Summary
 Map<String,T> entries()
          Return the entries from this dictionary as a map
static
<T> DictionaryBuilder<T>
newBuilder()
          Return a new, empty builder for a dictionary of this type
 DictionaryBuilder<T> thaw()
          Return a builder with a copy of all entries from this dictionary
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

newBuilder

public static <T> DictionaryBuilder<T> newBuilder()
Return a new, empty builder for a dictionary of this type

Type Parameters:
T - the type of values
Returns:
a new, empty builder

entries

public Map<String,T> entries()
Return the entries from this dictionary as a map

The returned map is immutable.

Returns:
an immutable map of entries
See Also:
ImmutableMap

thaw

public DictionaryBuilder<T> thaw()
Return a builder with a copy of all entries from this dictionary

Specified by:
thaw in interface Frozen<DictionaryBuilder<T>>
Returns:
a DictionaryBuilder