1. Domino Jackson
  2. Generics

Generics

Domino-jackson can process generics types as long as the type information are available for the processor for example :

			public abstract class BaseGenericType<T, V> {

    private T field1;
    private V field2;

    public T getField1() {
        return field1;
    }

    public void setField1(T field1) {
        this.field1 = field1;
    }

    public V getField2() {
        return field2;
    }

    public void setField2(V field2) {
        this.field2 = field2;
    }
}
		

Then when a child class extends from that type, it can provide the specific generics types for domino-jackson

			@JSONMapper
public class SampleGenericType extends BaseGenericType<String, Integer> {

    private String field3;

    public String getField3() {
        return field3;
    }

    public void setField3(String field3) {
        this.field3 = field3;
    }
}
		

This allows domino-jackson to generate a correct mapper for this pojo and will use the correct String and Integer types for field1 and field2 from the base class.

notice that annotating the Base class with JSONMapper wont work, as the type information is not available for the processor.

defining the mapper using an interface like this should work

			@JSONMapper
interface GenericMapper extend ObjectMapper<BaseGenericType<T, V>>{}
		

We are a group of passionate people who love what we do

Donate & Support Us