Let’s say I have:
public class Components<T> extends TupleList<Class<T>, String> {
private static final long serialVersionUID = 1L;
public void add(Class<T> classe, String name) {
this.add(new Tuple<Class<T>, String>(classe, name));
}
}
I’d like to be able to do the following:
Components<IFilter> engines=new Components<IFilter>(){{
add(FilterEngineIdentity.class, "Identity");
}};
where FilterEngineIdentity implements IFilter. How would I achieve this without binding my class Components to more specific class definitions?
Edit: It works! See my test added on the bottom.
Would the following work?
Whole class:
The test (compiles without problems on my machine, Java 1.7 but I didn’t use the <> so it should work fine with other versions):