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 extendsHashMapand 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.Stringencode()Encodes theQueryTagsinstance as a single string.static QueryTagsof(java.lang.String... tags)Creates a newQueryTagsinstance from an array of tag strings.static QueryTagsparse(com.fasterxml.jackson.core.JsonParser parser)Parses a JSON parser to construct aQueryTagsinstance.-
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 newQueryTagsinstance 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", wherekis the tag key andvis the tag value.- Returns:
- a new
QueryTagsinstance 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 theQueryTagsinstance as a single string. The tags are sorted by their keys and concatenated in the format "key=value,key=value,...".- Returns:
- a
Stringrepresenting 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 aQueryTagsinstance. 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- aJsonParserpositioned at the JSON data to parse.- Returns:
- a
QueryTagsinstance representing the parsed tags, ornullif 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.
-
-