public class ReactStylesDiffMap
extends java.lang.Object
ReadableMap
which should be used for styles property map. It extends
some of the accessor methods of ReadableMap
by adding a default value property
such that caller is enforced to provide a default value for a style property.
Instances of this class are used to update View
or CSSNode
style properties.
Since properties are generated by React framework based on what has been updated each value
in this map should either be interpreted as a new value set for a style property or as a "reset
this property to default" command in case when value is null (this is a way React communicates
change in which the style key that was previously present in a map has been removed).
NOTE: Accessor method with default value will throw an exception when the key is not present in
the map. Style applicator logic should verify whether the key exists in the map using
hasKey(java.lang.String)
before fetching the value. The motivation behind this is that in case when the
updated style diff map doesn't contain a certain style key it means that the corresponding view
property shouldn't be updated (whereas in all other cases it should be updated to the new value
or the property should be reset).Constructor and Description |
---|
ReactStylesDiffMap(ReadableMap props) |
Modifier and Type | Method and Description |
---|---|
ReadableArray |
getArray(java.lang.String key) |
boolean |
getBoolean(java.lang.String name,
boolean restoreNullToDefaultValue) |
double |
getDouble(java.lang.String name,
double restoreNullToDefaultValue) |
float |
getFloat(java.lang.String name,
float restoreNullToDefaultValue) |
int |
getInt(java.lang.String name,
int restoreNullToDefaultValue) |
ReadableMap |
getMap(java.lang.String key) |
java.lang.String |
getString(java.lang.String name) |
boolean |
hasKey(java.lang.String name) |
boolean |
isNull(java.lang.String name) |
java.lang.String |
toString() |
public ReactStylesDiffMap(ReadableMap props)
public boolean hasKey(java.lang.String name)
public boolean isNull(java.lang.String name)
public boolean getBoolean(java.lang.String name, boolean restoreNullToDefaultValue)
public double getDouble(java.lang.String name, double restoreNullToDefaultValue)
public float getFloat(java.lang.String name, float restoreNullToDefaultValue)
public int getInt(java.lang.String name, int restoreNullToDefaultValue)
@Nullable public java.lang.String getString(java.lang.String name)
@Nullable public ReadableArray getArray(java.lang.String key)
@Nullable public ReadableMap getMap(java.lang.String key)
public java.lang.String toString()
toString
in class java.lang.Object