discomarathon / google-gson

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

Support @NotSince annotation for removing fields in future versions #48

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I don't think this is currently possible, but it'd be nice for some protocols.

Original issue reported on code.google.com by ch...@gmail.com on 26 Sep 2008 at 7:28

GoogleCodeExporter commented 9 years ago
How is that better than simply marking the method @deprecated? 
Can you list some specific use-cases where @NotSince will be better than 
@deprecated? 

Original comment by inder123 on 26 Sep 2008 at 7:39

GoogleCodeExporter commented 9 years ago
Maybe I'm misunderstanding Gson's functionality. Assume the following example:

public class Person {
  private int age;
  @Since(1.1) private int birthYear;
}

new GsonBuilder().setVersion(1.0).create().toJson(new Person()) => "{age: 0}"
new GsonBuilder().setVersion(1.1).create().toJson(new Person()) => "{age: 0,
birthYear: 0}"

I would like to replace the field, as in (renaming @NotSince to @Until):

public class Person {
  @Until(1.1) private int age;
  @Since(1.1) private int birthYear;
}

So that:

new GsonBuilder().setVersion(1.0).create().toJson(new Person()) => "{age: 0}"
new GsonBuilder().setVersion(1.1).create().toJson(new Person()) => "{birthYear: 
0}"

Original comment by ch...@gmail.com on 27 Sep 2008 at 12:22

GoogleCodeExporter commented 9 years ago
Inderjeet and I have discussed that we needed some way to "version" field 
deletions
from classes, but have not put much thought into it.  The above proposal seems 
like a
pretty good solution.

I prefer "Until" as it fits well with the "Since" annotation.

Original comment by joel.leitch@gmail.com on 27 Sep 2008 at 6:38

GoogleCodeExporter commented 9 years ago

Original comment by joel.leitch@gmail.com on 13 Oct 2008 at 7:13

GoogleCodeExporter commented 9 years ago
Enhancement submitted in r322.

Original comment by joel.leitch@gmail.com on 1 Dec 2008 at 12:10