Search code examples
javaannotationsgsonjavadoc

Javadoc field comments with gson annotations


I am commenting some code I wrote. But ive hit a wall.

When commenting a field, it must be right before the field declaration, but I use GSON for serialization, with the @SerializedName annotation.

Now is the question, do I need to make the Javadoc comment before or after the annotation tag?

The code looks like this:

package Generic;

import com.google.gson.annotations.SerializedName;

public class Address {

    @SerializedName(value = "name")
    public String name;
    @SerializedName(value = "line1")
    public String line1;
    @SerializedName(value = "postCode")
    public String postCode;
    @SerializedName(value = "city")
    public String city;
    @SerializedName(value = "country")
    public String country;
    }

Thanks in advance!


Solution

  • It doesn't matter, but I prefer the before version:

    /*
     * JAVADOC!!!
     */
    @SerializedName(value = "name")