discomarathon / google-gson

Automatically exported from code.google.com/p/google-gson
0 stars 0 forks source link

Why not getter and setter? #185

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
Gson does not use the getter and setter when serialize and deserialize 
Java objects, that is very strange. 
e.g. I want to do something in the setter: 
private int number;
public void setNumber(int number) {
    this.number = number > 0 ? number : 0;
}
But Gson skip over it. 

What is the expected output? What do you see instead?
When setNumber(- 1);
this.number == 0;
But not this.number == - 1;

What version of the product are you using? On what operating system?
1.4

Please provide any additional information below.

Original issue reported on code.google.com by jessige...@gmail.com on 14 Jan 2010 at 3:12

GoogleCodeExporter commented 9 years ago
Yes, I agree, this is confusing. Breaking java bean model means that we can't 
use
inheritance, overriding getters in successors. 

Original comment by Anton.Troshin@gmail.com on 12 Feb 2010 at 7:15

GoogleCodeExporter commented 9 years ago
that's also bad because one can't access private fields in unsigned applets

Original comment by nordlig....@gmail.com on 13 Mar 2010 at 3:13

GoogleCodeExporter commented 9 years ago
Why do you want to touch privete fields??

Original comment by minglq.9 on 16 Mar 2010 at 3:33

GoogleCodeExporter commented 9 years ago

Original comment by limpbizkit on 6 Oct 2010 at 6:09