Package com.fauna.query
Class QueryTags
- java.lang.Object
-
- java.util.AbstractMap<K,V>
-
- java.util.HashMap<java.lang.String,java.lang.String>
-
- com.fauna.query.QueryTags
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
,java.util.Map<java.lang.String,java.lang.String>
public class QueryTags extends java.util.HashMap<java.lang.String,java.lang.String>
A utility class representing a collection of query tags as a map of key-value pairs. This class extendsHashMap
and provides methods to build, encode, and parse query tags.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description QueryTags()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
encode()
Encodes theQueryTags
instance as a single string.static QueryTags
of(java.lang.String... tags)
Creates a newQueryTags
instance from an array of tag strings.static QueryTags
parse(com.fasterxml.jackson.core.JsonParser parser)
Parses a JSON parser to construct aQueryTags
instance.-
Methods inherited from class java.util.HashMap
clear, clone, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, forEach, get, getOrDefault, isEmpty, keySet, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, values
-
-
-
-
Method Detail
-
of
public static QueryTags of(java.lang.String... tags)
Creates a newQueryTags
instance from an array of tag strings. Each tag string must be in the form "key=value".- Parameters:
tags
- an array of strings representing tags in the format "k=v", wherek
is the tag key andv
is the tag value.- Returns:
- a new
QueryTags
instance containing the parsed tags. - Throws:
ClientResponseException
- if a tag string is not in the expected "k=v" format.
-
encode
public java.lang.String encode()
Encodes theQueryTags
instance as a single string. The tags are sorted by their keys and concatenated in the format "key=value,key=value,...".- Returns:
- a
String
representing the encoded query tags.
-
parse
public static QueryTags parse(com.fasterxml.jackson.core.JsonParser parser) throws java.io.IOException
Parses a JSON parser to construct aQueryTags
instance. This method expects the JSON to contain either a null value or a string representation of tags in "key=value,key=value,..." format.- Parameters:
parser
- aJsonParser
positioned at the JSON data to parse.- Returns:
- a
QueryTags
instance representing the parsed tags, ornull
if the JSON value is null. - Throws:
java.io.IOException
- if an error occurs during parsing.ClientResponseException
- if the JSON token is not a string or null.
-
-