public class GenericJson extends GenericData implements Cloneable
Subclasses can declare fields for known data keys using the Key annotation. Each field
can be of any visibility (private, package private, protected, or public) and must not be static.
null unknown data key names are not allowed, but null data values are allowed.
Implementation is not thread-safe. For a thread-safe choice instead use an implementation of
ConcurrentMap.
GenericData.FlagsAbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>| Constructor and Description |
|---|
GenericJson() |
| Modifier and Type | Method and Description |
|---|---|
GenericJson |
clone()
Makes a "deep" clone of the generic data, in which the clone is completely independent of the
original.
|
JsonFactory |
getFactory()
Returns the JSON factory or
null for none. |
GenericJson |
set(String fieldName,
Object value)
Sets the given field value (may be
null) for the given field name. |
void |
setFactory(JsonFactory factory)
Sets the JSON factory or
null for none. |
String |
toPrettyString()
Returns a pretty-printed serialized JSON string representation or
toString() if getFactory() is null. |
String |
toString() |
entrySet, equals, get, getClassInfo, getUnknownKeys, hashCode, put, putAll, remove, setUnknownKeysclear, containsKey, containsValue, isEmpty, keySet, size, valuesfinalize, getClass, notify, notifyAll, wait, wait, waitcompute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAllpublic final JsonFactory getFactory()
null for none.public final void setFactory(JsonFactory factory)
null for none.public String toString()
toString in class GenericDatapublic String toPrettyString() throws IOException
toString() if getFactory() is null.IOExceptionpublic GenericJson clone()
GenericDataclone in class GenericDatapublic GenericJson set(String fieldName, Object value)
GenericDatanull) for the given field name. Any existing value
for the field will be overwritten. It may be more slightly more efficient than GenericData.put(String, Object) because it avoids accessing the field's original value.
Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.
set in class GenericDataCopyright © 2011–2025 Google. All rights reserved.