When working with Variants you can use the default constructor which is taking your object, but that will not work if you use Maps/Collections because the actual type(s) used inside of those objects are not known on runtime (due to Java type erasure).
In this case you can use this builder providing the Class type you want to have inside of your Variant (e.g. Map.class) and the generic class types used inside of the Map.
Example:
VariantBuilder.of(Map.class).withGenericTypes(String.class, Integer.class).create(myMap);
| Modifier and Type | Field and Description |
|---|---|
| private final Class | |
| private final List |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public < Type inside of the Variant X> Variant | Returns: Variantdata to store in Variant _data)Create the Variant instance using the provided data object. |
| public static VariantBuilder | |
| public VariantBuilder |
| baseClass | back to summary |
|---|---|
| private final Class<?> baseClass | |
| genericTypes | back to summary |
|---|---|
| private final List<Class<?>> genericTypes | |
| VariantBuilder | back to summary |
|---|---|
| private VariantBuilder(Class<?> _baseClass) | |
| create | back to summary |
|---|---|
| public <X> Variant Create the Variant instance using the provided data object.
| |
| of | back to summary |
|---|---|
| public static VariantBuilder of(Class<?> _clz) Create a new instance using the given class as starting point. If you want to create Variant containing a Map or List, this would be Map/List.class.
| |
| withGenericTypes | back to summary |
|---|---|
| public VariantBuilder withGenericTypes(Class<?>... _clz) Add one or more generic types. Use this if you want to create a Variant containing a Map, Collection. You have to provide the data types used inside of your Map/Collection to this method. E.g. you have Map>Integer,String< than you have to provide Integer.class and String.class to this method.
| |