Remove creation of synthetic accessor methods.
This commit is contained in:
parent
7d0e2f537b
commit
6b945e5df7
6 changed files with 16 additions and 16 deletions
|
@ -115,7 +115,7 @@ final class ClassJsonAdapter<T> extends JsonAdapter<T> {
|
|||
private final ClassFactory<T> classFactory;
|
||||
private final Map<String, FieldBinding<?>> jsonFields;
|
||||
|
||||
private ClassJsonAdapter(ClassFactory<T> classFactory, Map<String, FieldBinding<?>> jsonFields) {
|
||||
ClassJsonAdapter(ClassFactory<T> classFactory, Map<String, FieldBinding<?>> jsonFields) {
|
||||
this.classFactory = classFactory;
|
||||
this.jsonFields = jsonFields;
|
||||
}
|
||||
|
@ -179,13 +179,13 @@ final class ClassJsonAdapter<T> extends JsonAdapter<T> {
|
|||
this.adapter = adapter;
|
||||
}
|
||||
|
||||
private void read(JsonReader reader, Object value) throws IOException, IllegalAccessException {
|
||||
void read(JsonReader reader, Object value) throws IOException, IllegalAccessException {
|
||||
T fieldValue = adapter.fromJson(reader);
|
||||
field.set(value, fieldValue);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked") // We require that field's values are of type T.
|
||||
private void write(JsonWriter writer, Object value) throws IllegalAccessException, IOException {
|
||||
void write(JsonWriter writer, Object value) throws IllegalAccessException, IOException {
|
||||
T fieldValue = (T) field.get(value);
|
||||
adapter.toJson(writer, fieldValue);
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ abstract class CollectionJsonAdapter<C extends Collection<T>, T> extends JsonAda
|
|||
this.elementAdapter = elementAdapter;
|
||||
}
|
||||
|
||||
private static <T> JsonAdapter<Collection<T>> newArrayListAdapter(Type type, Moshi moshi) {
|
||||
static <T> JsonAdapter<Collection<T>> newArrayListAdapter(Type type, Moshi moshi) {
|
||||
Type elementType = Types.collectionElementType(type, Collection.class);
|
||||
JsonAdapter<T> elementAdapter = moshi.adapter(elementType);
|
||||
return new CollectionJsonAdapter<Collection<T>, T>(elementAdapter) {
|
||||
|
@ -56,7 +56,7 @@ abstract class CollectionJsonAdapter<C extends Collection<T>, T> extends JsonAda
|
|||
};
|
||||
}
|
||||
|
||||
private static <T> JsonAdapter<Set<T>> newLinkedHashSetAdapter(Type type, Moshi moshi) {
|
||||
static <T> JsonAdapter<Set<T>> newLinkedHashSetAdapter(Type type, Moshi moshi) {
|
||||
Type elementType = Types.collectionElementType(type, Collection.class);
|
||||
JsonAdapter<T> elementAdapter = moshi.adapter(elementType);
|
||||
return new CollectionJsonAdapter<Set<T>, T>(elementAdapter) {
|
||||
|
|
|
@ -755,7 +755,7 @@ final class LinkedHashTreeMap<K, V> extends AbstractMap<K, V> implements Seriali
|
|||
}
|
||||
}
|
||||
|
||||
private abstract class LinkedTreeMapIterator<T> implements Iterator<T> {
|
||||
abstract class LinkedTreeMapIterator<T> implements Iterator<T> {
|
||||
Node<K, V> next = header.next;
|
||||
Node<K, V> lastReturned = null;
|
||||
int expectedModCount = modCount;
|
||||
|
|
|
@ -45,7 +45,7 @@ public final class Moshi {
|
|||
private final ThreadLocal<List<DeferredAdapter<?>>> reentrantCalls = new ThreadLocal<>();
|
||||
private final Map<Object, JsonAdapter<?>> adapterCache = new LinkedHashMap<>();
|
||||
|
||||
private Moshi(Builder builder) {
|
||||
Moshi(Builder builder) {
|
||||
List<JsonAdapter.Factory> factories = new ArrayList<>(builder.factories.size() + BUILT_IN_FACTORIES.size());
|
||||
factories.addAll(builder.factories);
|
||||
factories.addAll(BUILT_IN_FACTORIES);
|
||||
|
@ -186,7 +186,7 @@ public final class Moshi {
|
|||
return add(AdapterMethodsFactory.get(adapter));
|
||||
}
|
||||
|
||||
private Builder addAll(List<JsonAdapter.Factory> factories) {
|
||||
Builder addAll(List<JsonAdapter.Factory> factories) {
|
||||
this.factories.addAll(factories);
|
||||
return this;
|
||||
}
|
||||
|
@ -205,14 +205,14 @@ public final class Moshi {
|
|||
* class that has a {@code List<Employee>} field for an organization's management hierarchy.
|
||||
*/
|
||||
private static class DeferredAdapter<T> extends JsonAdapter<T> {
|
||||
private Object cacheKey;
|
||||
Object cacheKey;
|
||||
private JsonAdapter<T> delegate;
|
||||
|
||||
public DeferredAdapter(Object cacheKey) {
|
||||
DeferredAdapter(Object cacheKey) {
|
||||
this.cacheKey = cacheKey;
|
||||
}
|
||||
|
||||
public void ready(JsonAdapter<T> delegate) {
|
||||
void ready(JsonAdapter<T> delegate) {
|
||||
this.delegate = delegate;
|
||||
this.cacheKey = null;
|
||||
}
|
||||
|
|
|
@ -60,7 +60,7 @@ final class StandardJsonAdapters {
|
|||
|
||||
private static final String ERROR_FORMAT = "Expected %s but was %s at path %s";
|
||||
|
||||
private static int rangeCheckNextInt(JsonReader reader, String typeMessage, int min, int max)
|
||||
static int rangeCheckNextInt(JsonReader reader, String typeMessage, int min, int max)
|
||||
throws IOException {
|
||||
int value = reader.nextInt();
|
||||
if (value < min || value > max) {
|
||||
|
|
|
@ -177,7 +177,7 @@ public final class Types {
|
|||
}
|
||||
}
|
||||
|
||||
private static int hashCodeOrZero(Object o) {
|
||||
static int hashCodeOrZero(Object o) {
|
||||
return o != null ? o.hashCode() : 0;
|
||||
}
|
||||
|
||||
|
@ -390,7 +390,7 @@ public final class Types {
|
|||
return genericDeclaration instanceof Class ? (Class<?>) genericDeclaration : null;
|
||||
}
|
||||
|
||||
private static void checkNotPrimitive(Type type) {
|
||||
static void checkNotPrimitive(Type type) {
|
||||
if ((type instanceof Class<?>) && ((Class<?>) type).isPrimitive()) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
@ -399,9 +399,9 @@ public final class Types {
|
|||
private static final class ParameterizedTypeImpl implements ParameterizedType {
|
||||
private final Type ownerType;
|
||||
private final Type rawType;
|
||||
private final Type[] typeArguments;
|
||||
final Type[] typeArguments;
|
||||
|
||||
public ParameterizedTypeImpl(Type ownerType, Type rawType, Type... typeArguments) {
|
||||
ParameterizedTypeImpl(Type ownerType, Type rawType, Type... typeArguments) {
|
||||
// require an owner type if the raw type needs it
|
||||
if (rawType instanceof Class<?>) {
|
||||
Class<?> rawTypeAsClass = (Class<?>) rawType;
|
||||
|
|
Loading…
Reference in a new issue