Class DynamicModel<T>
- java.lang.Object
-
- com.ibm.cloud.sdk.core.service.model.DynamicModel<T>
-
- All Implemented Interfaces:
ObjectModel
public abstract class DynamicModel<T> extends java.lang.Object implements ObjectModel
Abstract model class for a model which supports dynamic (arbitrary) properties of type T.
-
-
Constructor Summary
Constructors Constructor Description DynamicModel(com.google.gson.reflect.TypeToken<T> t)
This ctor accepts a TypeToken instance that represents the type of values stored in the map.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object o)
T
get(java.lang.String key)
Returns the value of the specified property.com.google.gson.reflect.TypeToken<T>
getAdditionalPropertyTypeToken()
Returns the TypeToken which describes the type of additional properties stored in the map.java.util.Map<java.lang.String,T>
getProperties()
Returns a map containing the arbitrary properties set on this object.java.util.Set<java.lang.String>
getPropertyNames()
Returns the names of arbitrary properties set on this object.int
hashCode()
T
put(java.lang.String key, T value)
Sets an arbitrary property.void
removeProperties()
Removes all of the arbitrary properties set on this object.T
removeProperty(java.lang.String key)
Removes the specified property from this object's map of arbitrary properties.void
setProperties(java.util.Map<java.lang.String,T> properties)
Sets the map containing the arbitrary properties set on this object.java.lang.String
toString()
-
-
-
Constructor Detail
-
DynamicModel
public DynamicModel(com.google.gson.reflect.TypeToken<T> t)
This ctor accepts a TypeToken instance that represents the type of values stored in the map.- Parameters:
t
- the TypeToken which represents the type of map values
-
-
Method Detail
-
getAdditionalPropertyTypeToken
public com.google.gson.reflect.TypeToken<T> getAdditionalPropertyTypeToken()
Returns the TypeToken which describes the type of additional properties stored in the map.- Returns:
- The TypeToken which describes the map value type
-
put
public T put(java.lang.String key, T value)
Sets an arbitrary property.- Parameters:
key
- the name of the property to setvalue
- the value of the property to be set- Returns:
- the previous value of the property, or null if the property was not previously set
-
get
public T get(java.lang.String key)
Returns the value of the specified property.- Parameters:
key
- the name of the property to get- Returns:
- the value of the property, or null if the property is not set
-
setProperties
public void setProperties(java.util.Map<java.lang.String,T> properties)
Sets the map containing the arbitrary properties set on this object.- Parameters:
properties
- a map containing arbitrary properties to set on this object
-
getProperties
public java.util.Map<java.lang.String,T> getProperties()
Returns a map containing the arbitrary properties set on this object.- Returns:
- a copy of the map containing arbitrary properties set on this object
-
getPropertyNames
public java.util.Set<java.lang.String> getPropertyNames()
Returns the names of arbitrary properties set on this object.- Returns:
- a set containing the names of arbitrary properties set on this object
-
removeProperty
public T removeProperty(java.lang.String key)
Removes the specified property from this object's map of arbitrary properties.- Parameters:
key
- the name of the property to be removed- Returns:
- the previous value of the property, or null if the property was not previously set
-
removeProperties
public void removeProperties()
Removes all of the arbitrary properties set on this object.
-
equals
public boolean equals(java.lang.Object o)
- Specified by:
equals
in interfaceObjectModel
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Specified by:
hashCode
in interfaceObjectModel
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Specified by:
toString
in interfaceObjectModel
- Overrides:
toString
in classjava.lang.Object
-
-