Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you exclude object property in GWT from serialization?

Is there a way to exclude primitive and Object properties within Serializable Object from GWT Serialization?

public class Provider implements Serializable{  
    public Provider() {  
    }  

    //Id like to exclude this property:   
        private String password;  
    //  

    private String address1;  
    private String address2;  
    private String companyName;  
    private String phone;  
}
like image 278
MatBanik Avatar asked Nov 28 '10 04:11

MatBanik


People also ask

How do I exclude a field from serialization?

If there are fields in Java objects that do not wish to be serialized, we can use the @JsonIgnore annotation in the Jackson library. The @JsonIgnore can be used at the field level, for ignoring fields during the serialization and deserialization.

Which of the following keyword we can exclude some object properties from serialization process?

You could use the transient keyword to omit a field from being serialized. For example: int k; transient int j; Variable j will not be serialized as we have mentioned the transient keyword.


1 Answers

I was hoping for something like special annotation

I think what you are looking for is @GwtTransient

@GwtTransient, an annotation that tells GWT RPC to treat a field as if it were marked with the Java transient keyword, even though it's not.

This annotation means the same thing as the transient keyword, but it is ignored by all serialization systems other than GWT's. Usually the transient keyword should be used in preference to this annotation. However, for types used with multiple serialization systems, it can be useful.

Reference: @GwtTransient

like image 101
bakkal Avatar answered Sep 26 '22 00:09

bakkal