Package com.smartgwt.client.bean

# Interface BeanValueType.MetaFactory

Enclosing class:
  BeanValueType<ValueType>

public static interface BeanValueType.MetaFactory
Interface used to trigger the generation and registration of reflection metadata for argument types.

In order to use `BeanValueType` to convert values to a type, you need to create the correct kind of `BeanValueType` for each type, which sometimes involves code generation. This is all automatic for types required by `BeanFactory`. However, if want to use `BeanValueType` outside of `BeanFactory`, then you can use `BeanValueType.MetaFactory` for specific types.

Usage is most easily explained with an example. First, you define an interface. (Note that it can be an inner interface.)

>      public interface MyMetaFactory extends BeanValueType.MetaFactory {
>          BeanValueType<Integer[]> getIntegerArrayValueType();
>          BeanValueType<Canvas> findMeTheCanvasValueType();
>      }

... and then you trigger the generation process:

>      GWT.create(MyMetaFactory.class);

Each function in the interface you define will result in the creation of the `BeanValueType` for one type ... so, in this case, we would end up with `BeanValueTypes` for Integer arrays and Canvas. The rules are as follows:

1. The interface must extend `BeanValueType.MetaFactory`
2. The return type for each function must be `BeanValueType`, with a generic type that is the type you want to be able to convert to.
3. The function must take no arguments.
4. The name of the function doesn't matter.

If you want, you can keep a reference to the results of the `GWT.create()`, and call the functions:

>      MyMetaFactory metaFactory = GWT.create(MyMetaFactory.class);
>      BeanValueType<Integer[]> integerArrayType = myMetaFactory.getIntegerArrayValueType();
>      Integer[] intArray = integerArrayType.convertFrom(new String[] {"7", "8"});

However, you don't have to do that ... you can ignore the results of `GWT.create()` and just use the `BeanValueType` static API:

>      GWT.create(MyMetaFactory.class);
>      Integer[] intArray = BeanValueType.convertFrom(Integer[].class, new String[] {"7", "8"});

Note that the call to `GWT.create()` must occur at run-time before the types are used. However, you can modularize by creating some types first and others later, as long as each `BeanValueType` is created before being used.

If you just need to convert to basic types -- int, long, float, double, boolean, Integer, Long, Float, Double, Boolean and String, then you can call `BeanValueType.registerBasicValueTypes()` instead of using `GWT.create()`.