Package com.google.api.client.util
Class GenericData
- java.lang.Object
-
- java.util.AbstractMap<java.lang.String,java.lang.Object>
-
- com.google.api.client.util.GenericData
-
- All Implemented Interfaces:
java.lang.Cloneable,java.util.Map<java.lang.String,java.lang.Object>
- Direct Known Subclasses:
GenericJson,GenericUrl,GenericXml,HttpHeaders,JsonRpcRequest
public class GenericData extends java.util.AbstractMap<java.lang.String,java.lang.Object> implements java.lang.CloneableGeneric data that stores all unknown data key name/value pairs.Subclasses can declare fields for known data keys using the
Keyannotation. Each field can be of any visibility (private, package private, protected, or public) and must not be static.nullunknown data key names are not allowed, butnulldata values are allowed.Iteration order of the data keys is based on the sorted (ascending) key names of the declared fields, followed by the iteration order of all of the unknown data key name/value pairs.
Implementation is not thread-safe. For a thread-safe choice instead use an implementation of
ConcurrentMap.- Since:
- 1.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) classGenericData.EntryIteratorIterator over the object data key/value map entries which iterates first over the fields and then over the unknown keys.(package private) classGenericData.EntrySetSet of object data key/value map entries.static classGenericData.FlagsFlags that impact behavior of generic data.
-
Field Summary
Fields Modifier and Type Field Description (package private) ClassInfoclassInfoClass information.(package private) java.util.Map<java.lang.String,java.lang.Object>unknownFieldsMap of unknown fields.
-
Constructor Summary
Constructors Constructor Description GenericData()Constructs with case-insensitive keys.GenericData(java.util.EnumSet<GenericData.Flags> flags)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description GenericDataclone()Makes a "deep" clone of the generic data, in which the clone is completely independent of the original.java.util.Set<java.util.Map.Entry<java.lang.String,java.lang.Object>>entrySet()java.lang.Objectget(java.lang.Object name)ClassInfogetClassInfo()Returns the class information.java.util.Map<java.lang.String,java.lang.Object>getUnknownKeys()Returns the map of unknown data key name to value.java.lang.Objectput(java.lang.String fieldName, java.lang.Object value)voidputAll(java.util.Map<? extends java.lang.String,?> map)java.lang.Objectremove(java.lang.Object name)GenericDataset(java.lang.String fieldName, java.lang.Object value)Sets the given field value (may benull) for the given field name.voidsetUnknownKeys(java.util.Map<java.lang.String,java.lang.Object> unknownFields)Sets the map of unknown data key name to value.-
Methods inherited from class java.util.AbstractMap
clear, containsKey, containsValue, equals, hashCode, isEmpty, keySet, size, toString, values
-
-
-
-
Field Detail
-
unknownFields
java.util.Map<java.lang.String,java.lang.Object> unknownFields
Map of unknown fields.
-
classInfo
final ClassInfo classInfo
Class information.
-
-
Constructor Detail
-
GenericData
public GenericData()
Constructs with case-insensitive keys.
-
GenericData
public GenericData(java.util.EnumSet<GenericData.Flags> flags)
- Parameters:
flags- flags that impact behavior of generic data- Since:
- 1.10
-
-
Method Detail
-
get
public final java.lang.Object get(java.lang.Object name)
- Specified by:
getin interfacejava.util.Map<java.lang.String,java.lang.Object>- Overrides:
getin classjava.util.AbstractMap<java.lang.String,java.lang.Object>
-
put
public final java.lang.Object put(java.lang.String fieldName, java.lang.Object value)- Specified by:
putin interfacejava.util.Map<java.lang.String,java.lang.Object>- Overrides:
putin classjava.util.AbstractMap<java.lang.String,java.lang.Object>
-
set
public GenericData set(java.lang.String fieldName, java.lang.Object value)
Sets the given field value (may benull) for the given field name. Any existing value for the field will be overwritten. It may be more slightly more efficient thanput(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.
-
putAll
public final void putAll(java.util.Map<? extends java.lang.String,?> map)
- Specified by:
putAllin interfacejava.util.Map<java.lang.String,java.lang.Object>- Overrides:
putAllin classjava.util.AbstractMap<java.lang.String,java.lang.Object>
-
remove
public final java.lang.Object remove(java.lang.Object name)
- Specified by:
removein interfacejava.util.Map<java.lang.String,java.lang.Object>- Overrides:
removein classjava.util.AbstractMap<java.lang.String,java.lang.Object>
-
entrySet
public java.util.Set<java.util.Map.Entry<java.lang.String,java.lang.Object>> entrySet()
- Specified by:
entrySetin interfacejava.util.Map<java.lang.String,java.lang.Object>- Specified by:
entrySetin classjava.util.AbstractMap<java.lang.String,java.lang.Object>
-
clone
public GenericData clone()
Makes a "deep" clone of the generic data, in which the clone is completely independent of the original.- Overrides:
clonein classjava.util.AbstractMap<java.lang.String,java.lang.Object>
-
getUnknownKeys
public final java.util.Map<java.lang.String,java.lang.Object> getUnknownKeys()
Returns the map of unknown data key name to value.- Since:
- 1.5
-
setUnknownKeys
public final void setUnknownKeys(java.util.Map<java.lang.String,java.lang.Object> unknownFields)
Sets the map of unknown data key name to value.- Since:
- 1.5
-
getClassInfo
public final ClassInfo getClassInfo()
Returns the class information.- Since:
- 1.10
-
-