public final class PropertySet extends Object
This class represents a map of key to value. Multiple values may be associated with each key.
This class is generally created by reading an INI or properties file.
See IniFile and PropertiesFile.
| Modifier and Type | Method and Description |
|---|---|
ImmutableMap<String,String> |
asMap()
Returns the property set as a map.
|
ImmutableListMultimap<String,String> |
asMultimap()
Returns the property set as a multimap.
|
PropertySet |
combinedWith(PropertySet other)
Combines this property set with another.
|
boolean |
contains(String key)
Checks if this property set contains the specified key.
|
static PropertySet |
empty()
Obtains an empty property set.
|
boolean |
equals(Object obj)
Checks if this property set equals another.
|
Optional<String> |
findValue(String key)
Finds a single value in this property set.
|
int |
hashCode()
Returns a suitable hash code for the property set.
|
boolean |
isEmpty()
Checks if this property set is empty.
|
ImmutableSet<String> |
keys()
Returns the set of keys of this property set.
|
static PropertySet |
of(Map<String,String> keyValues)
Obtains an instance from a map.
|
static PropertySet |
of(Multimap<String,String> keyValues)
Obtains an instance from a map allowing for multiple values for each key.
|
PropertySet |
overrideWith(PropertySet other)
Overrides this property set with another.
|
String |
toString()
Returns a string describing the property set.
|
String |
value(String key)
Gets a single value from this property set.
|
ImmutableList<String> |
valueList(String key)
Gets the list of values associated with the specified key.
|
public static PropertySet empty()
The result contains no properties.
public static PropertySet of(Map<String,String> keyValues)
The returned instance will have one value for each key.
keyValues - the key-values to create the instance withpublic static PropertySet of(Multimap<String,String> keyValues)
The returned instance may have more than one value for each key.
keyValues - the key-values to create the instance withpublic ImmutableSet<String> keys()
The iteration order of the map matches that of the input data.
public ImmutableListMultimap<String,String> asMultimap()
The iteration order of the map matches that of the input data.
public ImmutableMap<String,String> asMap()
The iteration order of the map matches that of the input data.
If a key has multiple values, the values will be returned as a comma separated list.
public boolean isEmpty()
public boolean contains(String key)
key - the key namepublic String value(String key)
This returns the value associated with the specified key.
If a key has multiple values, the values will be returned as a comma separated list.
key - the key nameIllegalArgumentException - if the key does not existpublic Optional<String> findValue(String key)
This returns the value associated with the specified key, empty if not present.
If a key has multiple values, the values will be returned as a comma separated list.
key - the key nameIllegalArgumentException - if more than one value is associatedpublic ImmutableList<String> valueList(String key)
A key-values instance may contain multiple values for each key. This method returns that list of values. The iteration order of the map matches that of the input data. The returned list may be empty.
key - the key namepublic PropertySet combinedWith(PropertySet other)
This property set takes precedence. Where a key exists in both sets the values in the other property set will be discarded. Any order of any additional keys will be retained, with those keys located after the base set of keys.
other - the other property setpublic PropertySet overrideWith(PropertySet other)
The specified property set takes precedence. The order of any existing keys will be retained, with the value replaced. Any order of any additional keys will be retained, with those keys located after the base set of keys.
other - the other property setpublic boolean equals(Object obj)
The comparison checks the content.
public int hashCode()
Copyright 2009-Present by OpenGamma Inc. and individual contributors
Apache v2 licensed
Additional documentation can be found at strata.opengamma.io.