Class StructuredDictionary
java.lang.Object
net.visma.autopay.http.structured.StructuredDictionary
- All Implemented Interfaces:
StructuredField,StructuredMap
Class representing Structured Dictionaries
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionbooleanCompares the specified object with this Structured Dictionary for equality.<T extends StructuredItem>
Optional<List<T>>Returns the value ofStructuredInnerListat requested key.inthashCode()Returns hash code for this Structured Dictionary.<T extends StructuredItem>
Map<String,T> itemMap()ReturnsMapof Structured Items stored in this Dictionary or Parameters.<T extends StructuredItem>
Map<String,List<T>> listMap()Returns this map with Inner List values converted toListofStructuredItemobjects.static StructuredDictionaryCreates Structured Dictionary of provided keys and values.static StructuredDictionaryCreates Structured Dictionary of given Map value.static StructuredDictionaryParses given string for Structured Dictionary, according to the specificationstatic StructuredDictionaryparse(Collection<String> httpHeaders) Parses given HTTP header values for Structured Dictionary, according to the specificationSerializes this Structured Dictionary to a String, according to the specification.toString()Returns the string representation of this Structured Dictionary, which is the same as serialized representation.Methods inherited from interface net.visma.autopay.http.structured.StructuredMap
bigDecimalMap, boolMap, bytesMap, doubleMap, entrySet, entrySet, getBigDecimal, getBool, getBytes, getDouble, getInt, getItem, getItem, getLong, getString, intMap, isEmpty, itemMap, keySet, longMap, stringMap, values, values
-
Method Details
-
of
Creates Structured Dictionary of given Map value.Order of Map entries is preserved. For supported value types and conversion rules see
StructuredList.of(Collection).- Parameters:
objectMap- Map to be converted to Structured Dictionary- Returns:
- Created Structured Dictionary
- Throws:
IllegalArgumentException- Invalid keys or values
-
of
Creates Structured Dictionary of provided keys and values.Keys and values should be provided in alternate indices of the vararg param. Order of Map entries is preserved.
Keys are created using from "even" vararg items, using
Object.toString(). Values are created from "odd" vararg items, using conversion described atStructuredList.of(Collection).- Parameters:
keysAndValues- Alternating keys and values: key1, value1, key2, value2, ...- Returns:
- Created Structured Dictionary
- Throws:
IllegalArgumentException- Invalid keys or values
-
itemMap
Description copied from interface:StructuredMapReturnsMapof Structured Items stored in this Dictionary or Parameters. Keys or returned map correspond to Dictionary or Parameters keys. Values areStructuredItemmembers of Dictionary or Parameters.- Specified by:
itemMapin interfaceStructuredMap- Type Parameters:
T- Specific Item class if needed. No type check is performed, only simple casting.- Returns:
- Underlying map of
StructuredItemobjects
-
listMap
Returns this map with Inner List values converted toListofStructuredItemobjects. This map must containStructuredInnerListvalues only.- Type Parameters:
T- Specific class of List members, if needed and the inner lists are homogenous- Returns:
- Map with values converted to List of StructuredItem
- Throws:
ClassCastException- Thrown if this map contains non-StructuredInnerListvalues
-
getList
Returns the value ofStructuredInnerListat requested key. Valid forStructuredInnerListItems only.- Type Parameters:
T- Specific class of Inner List members, if needed and the list is homogenous- Parameters:
key- Dictionary key- Returns:
- List of StructuredItem values stored at requested key
-
serialize
Serializes this Structured Dictionary to a String, according to the specification.- Specified by:
serializein interfaceStructuredField- Returns:
- Serialized representation of this Structured Dictionary
- See Also:
-
parse
Parses given string for Structured Dictionary, according to the specification- Parameters:
httpHeader- String to parse, e.g. HTTP header- Returns:
- Parsed Structured Dictionary
- Throws:
StructuredException- Thrown in case of malformatted string or wrong item type- See Also:
-
parse
Parses given HTTP header values for Structured Dictionary, according to the specification- Parameters:
httpHeaders- HTTP header values, for common header name, provided in order of occurrence in HTTP message- Returns:
- Parsed Structured Dictionary
- Throws:
StructuredException- Thrown in case of malformatted string or wrong item type- See Also:
-
equals
Compares the specified object with this Structured Dictionary for equality. Returns true if the given object is of the same class as this Dictionary, has the same value and properties. -
hashCode
public int hashCode()Returns hash code for this Structured Dictionary. The hash code is a combination of hash codes of Dictionary entries. -
toString
Returns the string representation of this Structured Dictionary, which is the same as serialized representation.
-