Maybe another better solution:

class Filter:

public abstract class Filtro<T> {

    public abstract T getValore();

    public abstract void setValore(T valore);
}

an then 1 class for each filter that you want (String, date,ecc ecc)
as this:

FilterString:
public class  FiltroString extends Filtro implements Serializable{
    private String valore;

    public Object getValore() {
       return valore;
    }

    public void setValore(Object valore) {
        this.valore = (String) valore;
    }

}

Any suggestion?

Thanks

On 24 Gen, 18:39, bond <[email protected]> wrote:
> Hi,
> I've a big problem with generics in GWT. I'm making a generic utility
> to set a filter in a collection of data. I'd like to have a class
> Filter with an attribute value that is the type that the user set:
>
> public class  Filter <T> implements Serializable{
>
> private T value;
>
> }
>
> The problem is that GWT compiler raise an error beacuse the type T is
> not Serializable. Another solution doesn't work:
>
> public class  Filter <T extends Serializable> implements Serializable{
>
> private T value;
>
> }
>
> beacusa the type T can either implements or extends serializable.
>
> So the only solution that I've think is to create a wrapper class
> (that implements interface MyType) for each type that the attribute
> value can be obtain (String,Date,Integer) and so the class Filter
> became:
>
> public class  Filter <T extends MyType & Serializable> implements
> Serializable{
>
> private T value;
>
> }
>
> But I dont' like this solution.
>
> Can someone post some ideas??
>
> Thanks
>
> Regards
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to