public class Metadata extends Object implements Iterable<Map.Entry<String,String>>
Null keys are invalid as arguments. Null values are invalid as arguments. Duplicate key-value pairs are not stored. Adding a key-value pair that is already present has no effect.
This class is mutable and not thread-safe.
Constructor and Description |
---|
Metadata()
Create empty instance.
|
Metadata(Iterable<Map.Entry<String,String>> m)
Duplicate.
|
Modifier and Type | Method and Description |
---|---|
void |
add(String k,
String v)
Increases values mapped to k with v.
|
boolean |
equals(Object o)
True if exactly the same key-values are represented.
|
Set<String> |
getAllValues(String key)
Gives unmodifiable reference to inserted values for key, empty if none.
|
Set<String> |
getKeys()
Get modifiable set of all keys with at least one value.
|
String |
getOneValue(String key)
One of the inserted values, or null if none.
|
int |
hashCode() |
boolean |
isEmpty() |
Iterator<Map.Entry<String,String>> |
iterator()
Provides every key and value in immutable entries sorted
alphabetically, first by key, and secondly by value.
|
void |
set(Iterable<Map.Entry<String,String>> it)
Replaces entries inside of this metadata with provided ones.
|
void |
set(String k,
Set<String> v)
Make copy of v be the values associated with key.
|
void |
set(String k,
String v)
Make value be only value associated with key.
|
String |
toString()
Contains every key and value pair; useful for debugging.
|
Metadata |
unmodifiableView()
Get a reference to an unmodifiable view of this object.
|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
forEach, spliterator
public void set(String k, String v)
k
- keyv
- valuepublic void set(String k, Set<String> v)
k
- keyv
- set of values of which none are nullpublic void add(String k, String v)
k
- keyv
- value that is also to be mapped from kpublic void set(Iterable<Map.Entry<String,String>> it)
it
- all key-value pairs that this instance should representpublic Set<String> getAllValues(String key)
key
- to be looked uppublic String getOneValue(String key)
key
- to be looked uppublic Set<String> getKeys()
public Iterator<Map.Entry<String,String>> iterator()
Behaviour is undefined if backing Metadata instance is modified during iteration.
remove() is unsupported on returned iterator.
public boolean equals(Object o)
public boolean isEmpty()
true
when instance has 0 entriespublic String toString()
public Metadata unmodifiableView()