I wanted to create a generic interface with a method I could use to convert objects ...
Let me explain.
In GWT, using GWT-Platform, the presenters have an inner interface that extends View. This interface is implemented by the class that builds the screen (the presenters have the button actions, etc.).
So, assuming I have a presenter for user account, for example. It "represents" my User bean.
I wish I could create a class implementing an interface, I could call a method passing the instance of the implementation of view, and he returned the bean populated ... I do not know if I could be clear enough ..
OK. So far so good. I created an interface like this:
public interface ViewBeanConverter<T, U extends View>
{
public T convert(U u);
}
It works for simple views, but the problem is that sometimes I need to pass parameters that are not in the interface view, but only in the presenter class, things that does not make sense being in view.
For example, suppose the bean to build user, I need a list of belongings (the first thing that came to mind right now). And then, on another screen, a bean car for example, need an owner and a parts list for the concert... How I can handle that?
I can not explain it right, sorry about that, but the real problem is I need different amounts of different types of parameters ... and was wondering if there is a elegant way to do this.
thanks in advance.
for different amounts of different types of parameters, use var args
public interface ViewBeanConverter<T, V extends View>
{
public T convert(V v,Object... objects);
}
or simply a Map
public T convert(V v, Map<Object, Object> objects);