kshchepanovskyi / protostuff-googlecode-exported

Automatically exported from code.google.com/p/protostuff

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Visual disturbance of @Deprecated annotation

GoogleCodeExporter opened this issue · comments

Hi.

I'm using my bean classes in other parts besides network and I have extra 
fields to not send over network. According to the standards, I have to use 
@Deprecated but it really disturbs me to see that each field I use is crossed. 
Can you define any other normal annotation for this, please? 

Regards.

Original issue reported on code.google.com by mty...@gmail.com on 18 Feb 2014 at 1:55

You can annotate all the fields that need to be serialized with @Tag explicitly 
instead.
In the long run, this will benefit you more than you know.
As a bonus, you can also control the field names on the wire (via @Tag.alias) 
for the text formats.

Original comment by david.yu...@gmail.com on 18 Feb 2014 at 3:01

The problem is I don't want to serialize some fields but I have to use them in 
the serializable class for other purposes. Besides, as respect to default 
@Deprecated annotation, shouldn't another annotation be used to not lead 
confusions?

Original comment by mty...@gmail.com on 18 Feb 2014 at 3:16

@Deprecated was chosen at that time, because the philosophy was to remove the 
field, not filter it.  @Tag annotation was not around at that time.  In that 
context, marking it as deprecated made sense.

I do see your point about the visual disturbance since you're only trying to 
filter fields (not remove it).

"The problem is I don't want to serialize some fields but I have to use them in 
the serializable class for other purposes".  Not sure I understand.  The @Tag 
annotation is the reverse of @Deprecated.  E.g If you want to exclude a field, 
do not annotate it.

Original comment by david.yu...@gmail.com on 18 Feb 2014 at 3:45

When you tag one field you have to annotate the others, the docs say. So there 
is no option to ignore fields in a nice way?

Original comment by mty...@gmail.com on 18 Feb 2014 at 4:14

We sure can introduce a new annotation (@Exclude probably) with the same 
functionality as @Deprecated.
What version are you using? 1.0.x or 1.1.x?

Original comment by david.yu...@gmail.com on 19 Feb 2014 at 2:55

I am using 1.0.8 right now. That'd be great.

Original comment by mty...@gmail.com on 19 Feb 2014 at 8:35

Any improvement on this?

Original comment by mty...@gmail.com on 25 Mar 2014 at 12:29

The "transient" keyword currently works btw (forgot to mention it earlier)

Original comment by david.yu...@gmail.com on 6 May 2014 at 2:15

What do you mean as keyword? Shouldn't it be an annotation to use in a Java 
class?

Original comment by mty...@gmail.com on 6 May 2014 at 6:53

So instead of "@Deprecated int exclude;", it would be:
transient int exclude;

The transient keyword is used to indicate that a field should not be serialized.

Original comment by david.yu...@gmail.com on 6 May 2014 at 8:15

It works! Thanks.

Original comment by mty...@gmail.com on 6 May 2014 at 4:07

@Exclude has been added for 1.1.x
It works the same way as transient where you filter out fields that aren't 
supposed to be serialized (excluded).
https://github.com/protostuff/protostuff/commit/4b0a1ea2d227a993ff303609f85ad202
f3f0383a

Original comment by david.yu...@gmail.com on 28 Sep 2014 at 7:45

  • Changed state: Accepted