Skip to content

Commit

Permalink
Remove synthetic accessors from being generated.
Browse files Browse the repository at this point in the history
  • Loading branch information
JakeWharton committed Dec 27, 2015
1 parent e48c780 commit 7a1c94f
Show file tree
Hide file tree
Showing 11 changed files with 36 additions and 31 deletions.
4 changes: 2 additions & 2 deletions gson/src/main/java/com/google/gson/FieldNamingPolicy.java
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public enum FieldNamingPolicy implements FieldNamingStrategy {
* Converts the field name that uses camel-case define word separation into
* 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();
for (int i = 0; i < name.length(); i++) {
char character = name.charAt(i);
Expand All @@ -135,7 +135,7 @@ private static String separateCamelCase(String name, String separator) {
/**
* 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();
int index = 0;
char firstCharacter = name.charAt(index);
Expand Down
4 changes: 2 additions & 2 deletions gson/src/main/java/com/google/gson/Gson.java
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ private TypeAdapter<Number> floatAdapter(boolean serializeSpecialFloatingPointVa
};
}

private void checkValidFloatingPoint(double value) {
static void checkValidFloatingPoint(double value) {
if (Double.isNaN(value) || Double.isInfinite(value)) {
throw new IllegalArgumentException(value
+ " is not a valid double value as per JSON specification. To override this"
Expand Down Expand Up @@ -459,7 +459,7 @@ public <T> TypeAdapter<T> getAdapter(TypeToken<T> type) {
* }</pre>
* 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
* 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.
* 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
Expand Down
4 changes: 2 additions & 2 deletions gson/src/main/java/com/google/gson/TreeTypeAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
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) {
this.serializer = serializer;
this.deserializer = deserializer;
Expand Down Expand Up @@ -112,7 +112,7 @@ private static class SingleTypeFactory implements TypeAdapterFactory {
private final JsonSerializer<?> serializer;
private final JsonDeserializer<?> deserializer;

private SingleTypeFactory(Object typeAdapter, TypeToken<?> exactType, boolean matchRawType,
SingleTypeFactory(Object typeAdapter, TypeToken<?> exactType, boolean matchRawType,
Class<?> hierarchyType) {
serializer = typeAdapter instanceof JsonSerializer
? (JsonSerializer<?>) typeAdapter
Expand Down
10 changes: 5 additions & 5 deletions gson/src/main/java/com/google/gson/internal/$Gson$Types.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@

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.lang.reflect.Array;
import java.lang.reflect.GenericArrayType;
Expand All @@ -34,6 +31,9 @@
import java.util.NoSuchElementException;
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.
*
Expand Down Expand Up @@ -212,7 +212,7 @@ public static boolean equals(Type a, Type b) {
}
}

private static int hashCodeOrZero(Object o) {
static int hashCodeOrZero(Object o) {
return o != null ? o.hashCode() : 0;
}

Expand Down Expand Up @@ -430,7 +430,7 @@ private static Class<?> declaringClassOf(TypeVariable<?> typeVariable) {
: null;
}

private static void checkNotPrimitive(Type type) {
static void checkNotPrimitive(Type type) {
checkArgument(!(type instanceof Class<?>) || !((Class<?>) type).isPrimitive());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -762,6 +762,9 @@ private abstract class LinkedTreeMapIterator<T> implements Iterator<T> {
Node<K, V> lastReturned = null;
int expectedModCount = modCount;

LinkedTreeMapIterator() {
}

public final boolean hasNext() {
return next != header;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,9 @@ private abstract class LinkedTreeMapIterator<T> implements Iterator<T> {
Node<K, V> lastReturned = null;
int expectedModCount = modCount;

LinkedTreeMapIterator() {
}

public final boolean hasNext() {
return next != header;
}
Expand Down Expand Up @@ -624,4 +627,4 @@ public K next() {
private Object writeReplace() throws ObjectStreamException {
return new LinkedHashMap<K, V>(this);
}
}
}
2 changes: 1 addition & 1 deletion gson/src/main/java/com/google/gson/internal/Streams.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ private static final class AppendableWriter extends Writer {
private final Appendable appendable;
private final CurrentWrite currentWrite = new CurrentWrite();

private AppendableWriter(Appendable appendable) {
AppendableWriter(Appendable appendable) {
this.appendable = appendable;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
*/
public final class MapTypeAdapterFactory implements TypeAdapterFactory {
private final ConstructorConstructor constructorConstructor;
private final boolean complexMapKeySerialization;
final boolean complexMapKeySerialization;

public MapTypeAdapterFactory(ConstructorConstructor constructorConstructor,
boolean complexMapKeySerialization) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public final class ObjectTypeAdapter extends TypeAdapter<Object> {

private final Gson gson;

private ObjectTypeAdapter(Gson gson) {
ObjectTypeAdapter(Gson gson) {
this.gson = gson;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,6 @@

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.Gson;
import com.google.gson.JsonSyntaxException;
Expand All @@ -42,6 +32,15 @@
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonToken;
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.
Expand Down Expand Up @@ -127,7 +126,7 @@ private ReflectiveTypeAdapterFactory.BoundField createBoundField(
};
}

private TypeAdapter<?> getFieldAdapter(Gson gson, Field field, TypeToken<?> fieldType) {
TypeAdapter<?> getFieldAdapter(Gson gson, Field field, TypeToken<?> fieldType) {
JsonAdapter annotation = field.getAnnotation(JsonAdapter.class);
if (annotation != null) {
TypeAdapter<?> adapter = getTypeAdapter(constructorConstructor, gson, fieldType, annotation);
Expand Down Expand Up @@ -193,7 +192,7 @@ public static final class Adapter<T> extends TypeAdapter<T> {
private final ObjectConstructor<T> constructor;
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.boundFields = boundFields;
}
Expand Down
8 changes: 4 additions & 4 deletions gson/src/main/java/com/google/gson/stream/JsonReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ public class JsonReader implements Closeable {
private int lineNumber = 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
Expand Down Expand Up @@ -462,7 +462,7 @@ public JsonToken peek() throws IOException {
}
}

private int doPeek() throws IOException {
int doPeek() throws IOException {
int peekStack = stack[stackSize - 1];
if (peekStack == JsonScope.EMPTY_ARRAY) {
stack[stackSize - 1] = JsonScope.NONEMPTY_ARRAY;
Expand Down Expand Up @@ -1314,11 +1314,11 @@ private boolean fillBuffer(int minimum) throws IOException {
return false;
}

private int getLineNumber() {
int getLineNumber() {
return lineNumber + 1;
}

private int getColumnNumber() {
int getColumnNumber() {
return pos - lineStart + 1;
}

Expand Down

0 comments on commit 7a1c94f

Please sign in to comment.