Merge pull request #761 from google/jw/nuke-synthetics
Remove synthetic accessors from being generated.
This commit is contained in:
commit
1f803bd37d
|
@ -120,7 +120,7 @@ public enum FieldNamingPolicy implements FieldNamingStrategy {
|
||||||
* Converts the field name that uses camel-case define word separation into
|
* Converts the field name that uses camel-case define word separation into
|
||||||
* separate words that are separated by the provided {@code separatorString}.
|
* separate words that are separated by the provided {@code separatorString}.
|
||||||
*/
|
*/
|
||||||
private static String separateCamelCase(String name, String separator) {
|
static String separateCamelCase(String name, String separator) {
|
||||||
StringBuilder translation = new StringBuilder();
|
StringBuilder translation = new StringBuilder();
|
||||||
for (int i = 0; i < name.length(); i++) {
|
for (int i = 0; i < name.length(); i++) {
|
||||||
char character = name.charAt(i);
|
char character = name.charAt(i);
|
||||||
|
@ -135,7 +135,7 @@ public enum FieldNamingPolicy implements FieldNamingStrategy {
|
||||||
/**
|
/**
|
||||||
* Ensures the JSON field names begins with an upper case letter.
|
* Ensures the JSON field names begins with an upper case letter.
|
||||||
*/
|
*/
|
||||||
private static String upperCaseFirstLetter(String name) {
|
static String upperCaseFirstLetter(String name) {
|
||||||
StringBuilder fieldNameBuilder = new StringBuilder();
|
StringBuilder fieldNameBuilder = new StringBuilder();
|
||||||
int index = 0;
|
int index = 0;
|
||||||
char firstCharacter = name.charAt(index);
|
char firstCharacter = name.charAt(index);
|
||||||
|
|
|
@ -303,7 +303,7 @@ public final class Gson {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkValidFloatingPoint(double value) {
|
static void checkValidFloatingPoint(double value) {
|
||||||
if (Double.isNaN(value) || Double.isInfinite(value)) {
|
if (Double.isNaN(value) || Double.isInfinite(value)) {
|
||||||
throw new IllegalArgumentException(value
|
throw new IllegalArgumentException(value
|
||||||
+ " is not a valid double value as per JSON specification. To override this"
|
+ " is not a valid double value as per JSON specification. To override this"
|
||||||
|
@ -459,7 +459,7 @@ public final class Gson {
|
||||||
* }</pre>
|
* }</pre>
|
||||||
* Note that this call will skip all factories registered before {@code skipPast}. In case of
|
* Note that this call will skip all factories registered before {@code skipPast}. In case of
|
||||||
* multiple TypeAdapterFactories registered it is up to the caller of this function to insure
|
* multiple TypeAdapterFactories registered it is up to the caller of this function to insure
|
||||||
* that the order of registration does not prevent this method from reaching a factory they
|
* that the order of registration does not prevent this method from reaching a factory they
|
||||||
* would expect to reply from this call.
|
* would expect to reply from this call.
|
||||||
* Note that since you can not override type adapter factories for String and Java primitive
|
* Note that since you can not override type adapter factories for String and Java primitive
|
||||||
* types, our stats factory will not count the number of String or primitives that will be
|
* types, our stats factory will not count the number of String or primitives that will be
|
||||||
|
|
|
@ -38,7 +38,7 @@ final class TreeTypeAdapter<T> extends TypeAdapter<T> {
|
||||||
/** The delegate is lazily created because it may not be needed, and creating it may fail. */
|
/** The delegate is lazily created because it may not be needed, and creating it may fail. */
|
||||||
private TypeAdapter<T> delegate;
|
private TypeAdapter<T> delegate;
|
||||||
|
|
||||||
private TreeTypeAdapter(JsonSerializer<T> serializer, JsonDeserializer<T> deserializer,
|
TreeTypeAdapter(JsonSerializer<T> serializer, JsonDeserializer<T> deserializer,
|
||||||
Gson gson, TypeToken<T> typeToken, TypeAdapterFactory skipPast) {
|
Gson gson, TypeToken<T> typeToken, TypeAdapterFactory skipPast) {
|
||||||
this.serializer = serializer;
|
this.serializer = serializer;
|
||||||
this.deserializer = deserializer;
|
this.deserializer = deserializer;
|
||||||
|
@ -112,7 +112,7 @@ final class TreeTypeAdapter<T> extends TypeAdapter<T> {
|
||||||
private final JsonSerializer<?> serializer;
|
private final JsonSerializer<?> serializer;
|
||||||
private final JsonDeserializer<?> deserializer;
|
private final JsonDeserializer<?> deserializer;
|
||||||
|
|
||||||
private SingleTypeFactory(Object typeAdapter, TypeToken<?> exactType, boolean matchRawType,
|
SingleTypeFactory(Object typeAdapter, TypeToken<?> exactType, boolean matchRawType,
|
||||||
Class<?> hierarchyType) {
|
Class<?> hierarchyType) {
|
||||||
serializer = typeAdapter instanceof JsonSerializer
|
serializer = typeAdapter instanceof JsonSerializer
|
||||||
? (JsonSerializer<?>) typeAdapter
|
? (JsonSerializer<?>) typeAdapter
|
||||||
|
|
|
@ -16,9 +16,6 @@
|
||||||
|
|
||||||
package com.google.gson.internal;
|
package com.google.gson.internal;
|
||||||
|
|
||||||
import static com.google.gson.internal.$Gson$Preconditions.checkArgument;
|
|
||||||
import static com.google.gson.internal.$Gson$Preconditions.checkNotNull;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.lang.reflect.Array;
|
import java.lang.reflect.Array;
|
||||||
import java.lang.reflect.GenericArrayType;
|
import java.lang.reflect.GenericArrayType;
|
||||||
|
@ -34,6 +31,9 @@ import java.util.Map;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
|
import static com.google.gson.internal.$Gson$Preconditions.checkArgument;
|
||||||
|
import static com.google.gson.internal.$Gson$Preconditions.checkNotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Static methods for working with types.
|
* Static methods for working with types.
|
||||||
*
|
*
|
||||||
|
@ -212,7 +212,7 @@ public final class $Gson$Types {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int hashCodeOrZero(Object o) {
|
static int hashCodeOrZero(Object o) {
|
||||||
return o != null ? o.hashCode() : 0;
|
return o != null ? o.hashCode() : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -430,7 +430,7 @@ public final class $Gson$Types {
|
||||||
: null;
|
: null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void checkNotPrimitive(Type type) {
|
static void checkNotPrimitive(Type type) {
|
||||||
checkArgument(!(type instanceof Class<?>) || !((Class<?>) type).isPrimitive());
|
checkArgument(!(type instanceof Class<?>) || !((Class<?>) type).isPrimitive());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -762,6 +762,9 @@ public final class LinkedHashTreeMap<K, V> extends AbstractMap<K, V> implements
|
||||||
Node<K, V> lastReturned = null;
|
Node<K, V> lastReturned = null;
|
||||||
int expectedModCount = modCount;
|
int expectedModCount = modCount;
|
||||||
|
|
||||||
|
LinkedTreeMapIterator() {
|
||||||
|
}
|
||||||
|
|
||||||
public final boolean hasNext() {
|
public final boolean hasNext() {
|
||||||
return next != header;
|
return next != header;
|
||||||
}
|
}
|
||||||
|
|
|
@ -528,6 +528,9 @@ public final class LinkedTreeMap<K, V> extends AbstractMap<K, V> implements Seri
|
||||||
Node<K, V> lastReturned = null;
|
Node<K, V> lastReturned = null;
|
||||||
int expectedModCount = modCount;
|
int expectedModCount = modCount;
|
||||||
|
|
||||||
|
LinkedTreeMapIterator() {
|
||||||
|
}
|
||||||
|
|
||||||
public final boolean hasNext() {
|
public final boolean hasNext() {
|
||||||
return next != header;
|
return next != header;
|
||||||
}
|
}
|
||||||
|
@ -624,4 +627,4 @@ public final class LinkedTreeMap<K, V> extends AbstractMap<K, V> implements Seri
|
||||||
private Object writeReplace() throws ObjectStreamException {
|
private Object writeReplace() throws ObjectStreamException {
|
||||||
return new LinkedHashMap<K, V>(this);
|
return new LinkedHashMap<K, V>(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,7 +85,7 @@ public final class Streams {
|
||||||
private final Appendable appendable;
|
private final Appendable appendable;
|
||||||
private final CurrentWrite currentWrite = new CurrentWrite();
|
private final CurrentWrite currentWrite = new CurrentWrite();
|
||||||
|
|
||||||
private AppendableWriter(Appendable appendable) {
|
AppendableWriter(Appendable appendable) {
|
||||||
this.appendable = appendable;
|
this.appendable = appendable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -104,7 +104,7 @@ import java.util.Map;
|
||||||
*/
|
*/
|
||||||
public final class MapTypeAdapterFactory implements TypeAdapterFactory {
|
public final class MapTypeAdapterFactory implements TypeAdapterFactory {
|
||||||
private final ConstructorConstructor constructorConstructor;
|
private final ConstructorConstructor constructorConstructor;
|
||||||
private final boolean complexMapKeySerialization;
|
final boolean complexMapKeySerialization;
|
||||||
|
|
||||||
public MapTypeAdapterFactory(ConstructorConstructor constructorConstructor,
|
public MapTypeAdapterFactory(ConstructorConstructor constructorConstructor,
|
||||||
boolean complexMapKeySerialization) {
|
boolean complexMapKeySerialization) {
|
||||||
|
|
|
@ -47,7 +47,7 @@ public final class ObjectTypeAdapter extends TypeAdapter<Object> {
|
||||||
|
|
||||||
private final Gson gson;
|
private final Gson gson;
|
||||||
|
|
||||||
private ObjectTypeAdapter(Gson gson) {
|
ObjectTypeAdapter(Gson gson) {
|
||||||
this.gson = gson;
|
this.gson = gson;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,16 +16,6 @@
|
||||||
|
|
||||||
package com.google.gson.internal.bind;
|
package com.google.gson.internal.bind;
|
||||||
|
|
||||||
import static com.google.gson.internal.bind.JsonAdapterAnnotationTypeAdapterFactory.getTypeAdapter;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.lang.reflect.Type;
|
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import com.google.gson.FieldNamingStrategy;
|
import com.google.gson.FieldNamingStrategy;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.JsonSyntaxException;
|
import com.google.gson.JsonSyntaxException;
|
||||||
|
@ -42,6 +32,15 @@ import com.google.gson.reflect.TypeToken;
|
||||||
import com.google.gson.stream.JsonReader;
|
import com.google.gson.stream.JsonReader;
|
||||||
import com.google.gson.stream.JsonToken;
|
import com.google.gson.stream.JsonToken;
|
||||||
import com.google.gson.stream.JsonWriter;
|
import com.google.gson.stream.JsonWriter;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.lang.reflect.Type;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static com.google.gson.internal.bind.JsonAdapterAnnotationTypeAdapterFactory.getTypeAdapter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Type adapter that reflects over the fields and methods of a class.
|
* Type adapter that reflects over the fields and methods of a class.
|
||||||
|
@ -127,7 +126,7 @@ public final class ReflectiveTypeAdapterFactory implements TypeAdapterFactory {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private TypeAdapter<?> getFieldAdapter(Gson gson, Field field, TypeToken<?> fieldType) {
|
TypeAdapter<?> getFieldAdapter(Gson gson, Field field, TypeToken<?> fieldType) {
|
||||||
JsonAdapter annotation = field.getAnnotation(JsonAdapter.class);
|
JsonAdapter annotation = field.getAnnotation(JsonAdapter.class);
|
||||||
if (annotation != null) {
|
if (annotation != null) {
|
||||||
TypeAdapter<?> adapter = getTypeAdapter(constructorConstructor, gson, fieldType, annotation);
|
TypeAdapter<?> adapter = getTypeAdapter(constructorConstructor, gson, fieldType, annotation);
|
||||||
|
@ -193,7 +192,7 @@ public final class ReflectiveTypeAdapterFactory implements TypeAdapterFactory {
|
||||||
private final ObjectConstructor<T> constructor;
|
private final ObjectConstructor<T> constructor;
|
||||||
private final Map<String, BoundField> boundFields;
|
private final Map<String, BoundField> boundFields;
|
||||||
|
|
||||||
private Adapter(ObjectConstructor<T> constructor, Map<String, BoundField> boundFields) {
|
Adapter(ObjectConstructor<T> constructor, Map<String, BoundField> boundFields) {
|
||||||
this.constructor = constructor;
|
this.constructor = constructor;
|
||||||
this.boundFields = boundFields;
|
this.boundFields = boundFields;
|
||||||
}
|
}
|
||||||
|
|
|
@ -242,7 +242,7 @@ public class JsonReader implements Closeable {
|
||||||
private int lineNumber = 0;
|
private int lineNumber = 0;
|
||||||
private int lineStart = 0;
|
private int lineStart = 0;
|
||||||
|
|
||||||
private int peeked = PEEKED_NONE;
|
int peeked = PEEKED_NONE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A peeked value that was composed entirely of digits with an optional
|
* A peeked value that was composed entirely of digits with an optional
|
||||||
|
@ -462,7 +462,7 @@ public class JsonReader implements Closeable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int doPeek() throws IOException {
|
int doPeek() throws IOException {
|
||||||
int peekStack = stack[stackSize - 1];
|
int peekStack = stack[stackSize - 1];
|
||||||
if (peekStack == JsonScope.EMPTY_ARRAY) {
|
if (peekStack == JsonScope.EMPTY_ARRAY) {
|
||||||
stack[stackSize - 1] = JsonScope.NONEMPTY_ARRAY;
|
stack[stackSize - 1] = JsonScope.NONEMPTY_ARRAY;
|
||||||
|
@ -1314,11 +1314,11 @@ public class JsonReader implements Closeable {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getLineNumber() {
|
int getLineNumber() {
|
||||||
return lineNumber + 1;
|
return lineNumber + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getColumnNumber() {
|
int getColumnNumber() {
|
||||||
return pos - lineStart + 1;
|
return pos - lineStart + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user