Add Javadoc since tags for previously added elements (#2211)

This commit is contained in:
Marcono1234 2022-10-02 00:58:26 +02:00 committed by GitHub
parent 47668fad57
commit 28609089fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 34 additions and 10 deletions

View File

@ -86,6 +86,8 @@ public enum FieldNamingPolicy implements FieldNamingStrategy {
* <li>aStringField ---&gt; A_STRING_FIELD</li> * <li>aStringField ---&gt; A_STRING_FIELD</li>
* <li>aURL ---&gt; A_U_R_L</li> * <li>aURL ---&gt; A_U_R_L</li>
* </ul> * </ul>
*
* @since 2.9.0
*/ */
UPPER_CASE_WITH_UNDERSCORES() { UPPER_CASE_WITH_UNDERSCORES() {
@Override public String translateName(Field f) { @Override public String translateName(Field f) {
@ -125,7 +127,8 @@ public enum FieldNamingPolicy implements FieldNamingStrategy {
* Using dashes in JavaScript is not recommended since dash is also used for a minus sign in * Using dashes in JavaScript is not recommended since dash is also used for a minus sign in
* expressions. This requires that a field named with dashes is always accessed as a quoted * expressions. This requires that a field named with dashes is always accessed as a quoted
* property like {@code myobject['my-field']}. Accessing it as an object field * property like {@code myobject['my-field']}. Accessing it as an object field
* {@code myobject.my-field} will result in an unintended javascript expression. * {@code myobject.my-field} will result in an unintended JavaScript expression.
*
* @since 1.4 * @since 1.4
*/ */
LOWER_CASE_WITH_DASHES() { LOWER_CASE_WITH_DASHES() {
@ -148,8 +151,9 @@ public enum FieldNamingPolicy implements FieldNamingStrategy {
* Using dots in JavaScript is not recommended since dot is also used for a member sign in * Using dots in JavaScript is not recommended since dot is also used for a member sign in
* expressions. This requires that a field named with dots is always accessed as a quoted * expressions. This requires that a field named with dots is always accessed as a quoted
* property like {@code myobject['my.field']}. Accessing it as an object field * property like {@code myobject['my.field']}. Accessing it as an object field
* {@code myobject.my.field} will result in an unintended javascript expression. * {@code myobject.my.field} will result in an unintended JavaScript expression.
* @since 2.8 *
* @since 2.8.4
*/ */
LOWER_CASE_WITH_DOTS() { LOWER_CASE_WITH_DOTS() {
@Override public String translateName(Field f) { @Override public String translateName(Field f) {

View File

@ -343,6 +343,7 @@ public final class Gson {
* instance. * instance.
* *
* @return a GsonBuilder instance. * @return a GsonBuilder instance.
* @since 2.8.3
*/ */
public GsonBuilder newBuilder() { public GsonBuilder newBuilder() {
return new GsonBuilder(this); return new GsonBuilder(this);

View File

@ -364,6 +364,7 @@ public final class GsonBuilder {
* @param objectToNumberStrategy the actual object-to-number strategy * @param objectToNumberStrategy the actual object-to-number strategy
* @return a reference to this {@code GsonBuilder} object to fulfill the "Builder" pattern * @return a reference to this {@code GsonBuilder} object to fulfill the "Builder" pattern
* @see ToNumberPolicy#DOUBLE The default object-to-number strategy * @see ToNumberPolicy#DOUBLE The default object-to-number strategy
* @since 2.8.9
*/ */
public GsonBuilder setObjectToNumberStrategy(ToNumberStrategy objectToNumberStrategy) { public GsonBuilder setObjectToNumberStrategy(ToNumberStrategy objectToNumberStrategy) {
this.objectToNumberStrategy = Objects.requireNonNull(objectToNumberStrategy); this.objectToNumberStrategy = Objects.requireNonNull(objectToNumberStrategy);
@ -376,6 +377,7 @@ public final class GsonBuilder {
* @param numberToNumberStrategy the actual number-to-number strategy * @param numberToNumberStrategy the actual number-to-number strategy
* @return a reference to this {@code GsonBuilder} object to fulfill the "Builder" pattern * @return a reference to this {@code GsonBuilder} object to fulfill the "Builder" pattern
* @see ToNumberPolicy#LAZILY_PARSED_NUMBER The default number-to-number strategy * @see ToNumberPolicy#LAZILY_PARSED_NUMBER The default number-to-number strategy
* @since 2.8.9
*/ */
public GsonBuilder setNumberToNumberStrategy(ToNumberStrategy numberToNumberStrategy) { public GsonBuilder setNumberToNumberStrategy(ToNumberStrategy numberToNumberStrategy) {
this.numberToNumberStrategy = Objects.requireNonNull(numberToNumberStrategy); this.numberToNumberStrategy = Objects.requireNonNull(numberToNumberStrategy);
@ -682,6 +684,7 @@ public final class GsonBuilder {
* disabling usage of {@code Unsafe}. * disabling usage of {@code Unsafe}.
* *
* @return a reference to this {@code GsonBuilder} object to fulfill the "Builder" pattern * @return a reference to this {@code GsonBuilder} object to fulfill the "Builder" pattern
* @since 2.9.0
*/ */
public GsonBuilder disableJdkUnsafe() { public GsonBuilder disableJdkUnsafe() {
this.useJdkUnsafe = false; this.useJdkUnsafe = false;
@ -702,6 +705,7 @@ public final class GsonBuilder {
* *
* @param filter filter to add * @param filter filter to add
* @return a reference to this {@code GsonBuilder} object to fulfill the "Builder" pattern * @return a reference to this {@code GsonBuilder} object to fulfill the "Builder" pattern
* @since 2.9.1
*/ */
public GsonBuilder addReflectionAccessFilter(ReflectionAccessFilter filter) { public GsonBuilder addReflectionAccessFilter(ReflectionAccessFilter filter) {
Objects.requireNonNull(filter); Objects.requireNonNull(filter);

View File

@ -48,6 +48,7 @@ public final class JsonArray extends JsonElement implements Iterable<JsonElement
* @param capacity initial capacity. * @param capacity initial capacity.
* @throws IllegalArgumentException if the {@code capacity} is * @throws IllegalArgumentException if the {@code capacity} is
* negative * negative
* @since 2.8.1
*/ */
@SuppressWarnings("deprecation") // superclass constructor @SuppressWarnings("deprecation") // superclass constructor
public JsonArray(int capacity) { public JsonArray(int capacity) {
@ -75,6 +76,7 @@ public final class JsonArray extends JsonElement implements Iterable<JsonElement
* Adds the specified boolean to self. * Adds the specified boolean to self.
* *
* @param bool the boolean that needs to be added to the array. * @param bool the boolean that needs to be added to the array.
* @since 2.4
*/ */
public void add(Boolean bool) { public void add(Boolean bool) {
elements.add(bool == null ? JsonNull.INSTANCE : new JsonPrimitive(bool)); elements.add(bool == null ? JsonNull.INSTANCE : new JsonPrimitive(bool));
@ -84,6 +86,7 @@ public final class JsonArray extends JsonElement implements Iterable<JsonElement
* Adds the specified character to self. * Adds the specified character to self.
* *
* @param character the character that needs to be added to the array. * @param character the character that needs to be added to the array.
* @since 2.4
*/ */
public void add(Character character) { public void add(Character character) {
elements.add(character == null ? JsonNull.INSTANCE : new JsonPrimitive(character)); elements.add(character == null ? JsonNull.INSTANCE : new JsonPrimitive(character));
@ -93,6 +96,7 @@ public final class JsonArray extends JsonElement implements Iterable<JsonElement
* Adds the specified number to self. * Adds the specified number to self.
* *
* @param number the number that needs to be added to the array. * @param number the number that needs to be added to the array.
* @since 2.4
*/ */
public void add(Number number) { public void add(Number number) {
elements.add(number == null ? JsonNull.INSTANCE : new JsonPrimitive(number)); elements.add(number == null ? JsonNull.INSTANCE : new JsonPrimitive(number));
@ -102,6 +106,7 @@ public final class JsonArray extends JsonElement implements Iterable<JsonElement
* Adds the specified string to self. * Adds the specified string to self.
* *
* @param string the string that needs to be added to the array. * @param string the string that needs to be added to the array.
* @since 2.4
*/ */
public void add(String string) { public void add(String string) {
elements.add(string == null ? JsonNull.INSTANCE : new JsonPrimitive(string)); elements.add(string == null ? JsonNull.INSTANCE : new JsonPrimitive(string));
@ -190,6 +195,7 @@ public final class JsonArray extends JsonElement implements Iterable<JsonElement
* Returns true if the array is empty. * Returns true if the array is empty.
* *
* @return true if the array is empty. * @return true if the array is empty.
* @since 2.8.7
*/ */
public boolean isEmpty() { public boolean isEmpty() {
return elements.isEmpty(); return elements.isEmpty();

View File

@ -146,6 +146,7 @@ public final class JsonObject extends JsonElement {
* Returns the number of key/value pairs in the object. * Returns the number of key/value pairs in the object.
* *
* @return the number of key/value pairs in the object. * @return the number of key/value pairs in the object.
* @since 2.7
*/ */
public int size() { public int size() {
return members.size(); return members.size();

View File

@ -45,6 +45,7 @@ public final class JsonParser {
* @param json JSON text * @param json JSON text
* @return a parse tree of {@link JsonElement}s corresponding to the specified JSON * @return a parse tree of {@link JsonElement}s corresponding to the specified JSON
* @throws JsonParseException if the specified text is not valid JSON * @throws JsonParseException if the specified text is not valid JSON
* @since 2.8.6
*/ */
public static JsonElement parseString(String json) throws JsonSyntaxException { public static JsonElement parseString(String json) throws JsonSyntaxException {
return parseReader(new StringReader(json)); return parseReader(new StringReader(json));
@ -61,6 +62,7 @@ public final class JsonParser {
* @return a parse tree of {@link JsonElement}s corresponding to the specified JSON * @return a parse tree of {@link JsonElement}s corresponding to the specified JSON
* @throws JsonParseException if there is an IOException or if the specified * @throws JsonParseException if there is an IOException or if the specified
* text is not valid JSON * text is not valid JSON
* @since 2.8.6
*/ */
public static JsonElement parseReader(Reader reader) throws JsonIOException, JsonSyntaxException { public static JsonElement parseReader(Reader reader) throws JsonIOException, JsonSyntaxException {
try { try {
@ -90,6 +92,7 @@ public final class JsonParser {
* *
* @throws JsonParseException if there is an IOException or if the specified * @throws JsonParseException if there is an IOException or if the specified
* text is not valid JSON * text is not valid JSON
* @since 2.8.6
*/ */
public static JsonElement parseReader(JsonReader reader) public static JsonElement parseReader(JsonReader reader)
throws JsonIOException, JsonSyntaxException { throws JsonIOException, JsonSyntaxException {

View File

@ -1,8 +1,7 @@
package com.google.gson; package com.google.gson;
import java.lang.reflect.AccessibleObject;
import com.google.gson.internal.ReflectionAccessFilterHelper; import com.google.gson.internal.ReflectionAccessFilterHelper;
import java.lang.reflect.AccessibleObject;
/** /**
* Filter for determining whether reflection based serialization and * Filter for determining whether reflection based serialization and
@ -28,10 +27,13 @@ import com.google.gson.internal.ReflectionAccessFilterHelper;
* fields and classes. * fields and classes.
* *
* @see GsonBuilder#addReflectionAccessFilter(ReflectionAccessFilter) * @see GsonBuilder#addReflectionAccessFilter(ReflectionAccessFilter)
* @since 2.9.1
*/ */
public interface ReflectionAccessFilter { public interface ReflectionAccessFilter {
/** /**
* Result of a filter check. * Result of a filter check.
*
* @since 2.9.1
*/ */
enum FilterResult { enum FilterResult {
/** /**

View File

@ -16,12 +16,11 @@
package com.google.gson; package com.google.gson;
import java.io.IOException;
import java.math.BigDecimal;
import com.google.gson.internal.LazilyParsedNumber; import com.google.gson.internal.LazilyParsedNumber;
import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonReader;
import com.google.gson.stream.MalformedJsonException; import com.google.gson.stream.MalformedJsonException;
import java.io.IOException;
import java.math.BigDecimal;
/** /**
* An enumeration that defines two standard number reading strategies and a couple of * An enumeration that defines two standard number reading strategies and a couple of
@ -29,6 +28,7 @@ import com.google.gson.stream.MalformedJsonException;
* {@link Object} and {@link Number}. * {@link Object} and {@link Number}.
* *
* @see ToNumberStrategy * @see ToNumberStrategy
* @since 2.8.9
*/ */
public enum ToNumberPolicy implements ToNumberStrategy { public enum ToNumberPolicy implements ToNumberStrategy {

View File

@ -16,9 +16,8 @@
package com.google.gson; package com.google.gson;
import java.io.IOException;
import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonReader;
import java.io.IOException;
/** /**
* A strategy that is used to control how numbers should be deserialized for {@link Object} and {@link Number} * A strategy that is used to control how numbers should be deserialized for {@link Object} and {@link Number}
@ -56,6 +55,7 @@ import com.google.gson.stream.JsonReader;
* @see ToNumberPolicy * @see ToNumberPolicy
* @see GsonBuilder#setObjectToNumberStrategy(ToNumberStrategy) * @see GsonBuilder#setObjectToNumberStrategy(ToNumberStrategy)
* @see GsonBuilder#setNumberToNumberStrategy(ToNumberStrategy) * @see GsonBuilder#setNumberToNumberStrategy(ToNumberStrategy)
* @since 2.8.9
*/ */
public interface ToNumberStrategy { public interface ToNumberStrategy {

View File

@ -429,6 +429,7 @@ public class JsonWriter implements Closeable, Flushable {
* @return this writer. * @return this writer.
* @throws UnsupportedOperationException if this writer does not support * @throws UnsupportedOperationException if this writer does not support
* writing raw JSON values. * writing raw JSON values.
* @since 2.4
*/ */
public JsonWriter jsonValue(String value) throws IOException { public JsonWriter jsonValue(String value) throws IOException {
if (value == null) { if (value == null) {
@ -475,6 +476,7 @@ public class JsonWriter implements Closeable, Flushable {
* Encodes {@code value}. * Encodes {@code value}.
* *
* @return this writer. * @return this writer.
* @since 2.7
*/ */
public JsonWriter value(Boolean value) throws IOException { public JsonWriter value(Boolean value) throws IOException {
if (value == null) { if (value == null) {
@ -495,6 +497,7 @@ public class JsonWriter implements Closeable, Flushable {
* @return this writer. * @return this writer.
* @throws IllegalArgumentException if the value is NaN or Infinity and this writer is not {@link * @throws IllegalArgumentException if the value is NaN or Infinity and this writer is not {@link
* #setLenient(boolean) lenient}. * #setLenient(boolean) lenient}.
* @since 2.9.1
*/ */
public JsonWriter value(float value) throws IOException { public JsonWriter value(float value) throws IOException {
writeDeferredName(); writeDeferredName();