-
- All Implemented Interfaces:
-
java.lang.annotation.Annotation
@Retention(value = RUNTIME)@Target(value = ElementType.METHOD) public @interface ReactPropGroup
Use this annotation to annotate group of properties of native views that should be exposed to JS. This annotation should only be used for setter methods of subclasses of . It's a batched version of ReactProp annotation (please see documentation of ReactProp for more details about how this annotation can be used).
This annotation is meant to be used for a group of similar properties. That's why it support only a set of properties of the same type. A good example is supporting "border", where we have 7 variations of that property ("borderLeft", "borderHorizontal", etc.) and very similar code for handling each of those.
Each annotated method should return
{@code void}
and take exactly three arguments: first being a view instance to be updated, second should be of type int and will represent index in the group of the property being updated. Last, third argument represent the value that should be set.Currently only
{@code int}
,{@code float}
,{@code double}
and String value types are supported.In case when property has been removed from the corresponding react component annotated setter will be called and default value will be provided as a value parameter. Default value can be customize using defaultInt or defaultFloat in the case when property is of one of primitive types. In case when String is the property type
{@code null}
value will be provided as a default.
-
-
Field Summary
Fields Modifier and Type Field Description public final static String
USE_DEFAULT_TYPE
-
Method Summary
Modifier and Type Method Description abstract Array<String>
names()
Array of names of properties exposed to JS that will be updated using setter method annotatedwith the given instance of {@code ReactPropGroup}
annotationabstract String
customType()
Type of property that will be send to JS. abstract float
defaultFloat()
Default value for property of type {@code float}
.abstract double
defaultDouble()
Default value for property of type {@code double}
.abstract int
defaultInt()
Default value for property of type {@code int}
.-
-
Method Detail
-
names
abstract Array<String> names()
Array of names of properties exposed to JS that will be updated using setter method annotatedwith the given instance of
{@code ReactPropGroup}
annotation
-
customType
@Nullable() abstract String customType()
Type of property that will be send to JS. In most of the cases
{@code customType}
should not beset in which case default type will be send to JS based on the type of value argument from thesetter method (e.g. for{@code int}
,{@code float}
default is "number"). Custom type may beused when additional processing of the value needs to be done in JS before sending it over thebridge. A good example of that would be backgroundColor property, which is expressed as a{@code String}
in JS, but we use{@code processColor}
JS module to convert it to{@code int}
before sending over the bridge.
-
defaultFloat
abstract float defaultFloat()
Default value for property of type
{@code float}
. This value will be provided to propertysetter method annotated with ReactPropGroup if property with a given name gets removedfrom the component description in JS
-
defaultDouble
abstract double defaultDouble()
Default value for property of type
{@code double}
. This value will be provided to propertysetter method annotated with ReactPropGroup if property with a given name gets removedfrom the component description in JS
-
defaultInt
abstract int defaultInt()
Default value for property of type
{@code int}
. This value will be provided to property settermethod annotated with ReactPropGroup if property with a given name gets removed fromthe component description in JS
-
-
-
-