mirror of
https://github.com/fankes/moshi.git
synced 2025-10-19 16:09:21 +08:00
Enable Checkstyle 7.7.
This commit is contained in:
@@ -31,7 +31,7 @@ final class AdapterMethodsFactory implements JsonAdapter.Factory {
|
||||
private final List<AdapterMethod> toAdapters;
|
||||
private final List<AdapterMethod> fromAdapters;
|
||||
|
||||
public AdapterMethodsFactory(List<AdapterMethod> toAdapters, List<AdapterMethod> fromAdapters) {
|
||||
AdapterMethodsFactory(List<AdapterMethod> toAdapters, List<AdapterMethod> fromAdapters) {
|
||||
this.toAdapters = toAdapters;
|
||||
this.fromAdapters = fromAdapters;
|
||||
}
|
||||
@@ -271,7 +271,7 @@ final class AdapterMethodsFactory implements JsonAdapter.Factory {
|
||||
return null;
|
||||
}
|
||||
|
||||
static abstract class AdapterMethod {
|
||||
abstract static class AdapterMethod {
|
||||
final Type type;
|
||||
final Set<? extends Annotation> annotations;
|
||||
final Object adapter;
|
||||
@@ -280,7 +280,7 @@ final class AdapterMethodsFactory implements JsonAdapter.Factory {
|
||||
final JsonAdapter<?>[] jsonAdapters;
|
||||
final boolean nullable;
|
||||
|
||||
public AdapterMethod(Type type, Set<? extends Annotation> annotations, Object adapter,
|
||||
AdapterMethod(Type type, Set<? extends Annotation> annotations, Object adapter,
|
||||
Method method, int parameterCount, int adaptersOffset, boolean nullable) {
|
||||
this.type = Types.canonicalize(type);
|
||||
this.annotations = annotations;
|
||||
|
@@ -194,7 +194,7 @@ final class ClassJsonAdapter<T> extends JsonAdapter<T> {
|
||||
final Field field;
|
||||
final JsonAdapter<T> adapter;
|
||||
|
||||
public FieldBinding(String name, Field field, JsonAdapter<T> adapter) {
|
||||
FieldBinding(String name, Field field, JsonAdapter<T> adapter) {
|
||||
this.name = name;
|
||||
this.field = field;
|
||||
this.adapter = adapter;
|
||||
|
@@ -58,7 +58,7 @@ public abstract class JsonAdapter<T> {
|
||||
/**
|
||||
* Encodes {@code value} as a Java value object comprised of maps, lists, strings, numbers,
|
||||
* booleans, and nulls.
|
||||
*
|
||||
*
|
||||
* <p>Values encoded using {@code value(double)} or {@code value(long)} are modeled with the
|
||||
* corresponding boxed type. Values encoded using {@code value(Number)} are modeled as a
|
||||
* {@link Long} for boxed integer types ({@link Byte}, {@link Short}, {@link Integer}, and {@link
|
||||
|
@@ -182,7 +182,7 @@ public abstract class JsonReader implements Closeable {
|
||||
final String[] pathNames = new String[32];
|
||||
final int[] pathIndices = new int[32];
|
||||
|
||||
/** True to accept non-spec compliant JSON */
|
||||
/** True to accept non-spec compliant JSON. */
|
||||
boolean lenient;
|
||||
|
||||
/** True to throw a {@link JsonDataException} on any attempt to call {@link #skipValue()}. */
|
||||
|
@@ -17,6 +17,8 @@ package com.squareup.moshi;
|
||||
|
||||
/** Lexical scoping elements within a JSON reader or writer. */
|
||||
final class JsonScope {
|
||||
private JsonScope() {
|
||||
}
|
||||
|
||||
/** An array with no elements requires no separators or newlines before it is closed. */
|
||||
static final int EMPTY_ARRAY = 1;
|
||||
|
@@ -50,7 +50,7 @@ final class JsonValueReader extends JsonReader {
|
||||
|
||||
private final Object[] stack = new Object[32];
|
||||
|
||||
public JsonValueReader(Object root) {
|
||||
JsonValueReader(Object root) {
|
||||
scopes[stackSize] = JsonScope.NONEMPTY_DOCUMENT;
|
||||
stack[stackSize++] = root;
|
||||
}
|
||||
|
@@ -55,7 +55,7 @@ final class LinkedHashTreeMap<K, V> extends AbstractMap<K, V> implements Seriali
|
||||
* Create a natural order, empty tree map whose keys must be mutually
|
||||
* comparable and non-null.
|
||||
*/
|
||||
public LinkedHashTreeMap() {
|
||||
LinkedHashTreeMap() {
|
||||
this(null);
|
||||
}
|
||||
|
||||
@@ -66,8 +66,10 @@ final class LinkedHashTreeMap<K, V> extends AbstractMap<K, V> implements Seriali
|
||||
* @param comparator the comparator to order elements with, or {@code null} to
|
||||
* use the natural ordering.
|
||||
*/
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" }) // unsafe! if comparator is null, this assumes K is comparable
|
||||
public LinkedHashTreeMap(Comparator<? super K> comparator) {
|
||||
@SuppressWarnings({
|
||||
"unchecked", "rawtypes" // Unsafe! if comparator is null, this assumes K is comparable.
|
||||
})
|
||||
LinkedHashTreeMap(Comparator<? super K> comparator) {
|
||||
this.comparator = comparator != null
|
||||
? comparator
|
||||
: (Comparator) NATURAL_ORDER;
|
||||
@@ -473,14 +475,14 @@ final class LinkedHashTreeMap<K, V> extends AbstractMap<K, V> implements Seriali
|
||||
V value;
|
||||
int height;
|
||||
|
||||
/** Create the header entry */
|
||||
/** Create the header entry. */
|
||||
Node() {
|
||||
key = null;
|
||||
hash = -1;
|
||||
next = prev = this;
|
||||
}
|
||||
|
||||
/** Create a regular entry */
|
||||
/** Create a regular entry. */
|
||||
Node(Node<K, V> parent, K key, int hash, Node<K, V> next, Node<K, V> prev) {
|
||||
this.parent = parent;
|
||||
this.key = key;
|
||||
@@ -665,7 +667,7 @@ final class LinkedHashTreeMap<K, V> extends AbstractMap<K, V> implements Seriali
|
||||
* comparisons. Using this class to create a tree of size <i>S</i> is
|
||||
* {@code O(S)}.
|
||||
*/
|
||||
final static class AvlBuilder<K, V> {
|
||||
static final class AvlBuilder<K, V> {
|
||||
/** This stack is a singly linked list, linked by the 'parent' field. */
|
||||
private Node<K, V> stack;
|
||||
private int leavesToSkip;
|
||||
|
@@ -41,7 +41,7 @@ final class MapJsonAdapter<K, V> extends JsonAdapter<Map<K, V>> {
|
||||
private final JsonAdapter<K> keyAdapter;
|
||||
private final JsonAdapter<V> valueAdapter;
|
||||
|
||||
public MapJsonAdapter(Moshi moshi, Type keyType, Type valueType) {
|
||||
MapJsonAdapter(Moshi moshi, Type keyType, Type valueType) {
|
||||
this.keyAdapter = moshi.adapter(keyType);
|
||||
this.valueAdapter = moshi.adapter(valueType);
|
||||
}
|
||||
|
@@ -24,6 +24,9 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
final class StandardJsonAdapters {
|
||||
private StandardJsonAdapters() {
|
||||
}
|
||||
|
||||
public static final JsonAdapter.Factory FACTORY = new JsonAdapter.Factory() {
|
||||
@Override public JsonAdapter<?> create(
|
||||
Type type, Set<? extends Annotation> annotations, Moshi moshi) {
|
||||
@@ -216,7 +219,7 @@ final class StandardJsonAdapters {
|
||||
private final T[] constants;
|
||||
private final JsonReader.Options options;
|
||||
|
||||
public EnumJsonAdapter(Class<T> enumType) {
|
||||
EnumJsonAdapter(Class<T> enumType) {
|
||||
this.enumType = enumType;
|
||||
try {
|
||||
constants = enumType.getEnumConstants();
|
||||
@@ -264,7 +267,7 @@ final class StandardJsonAdapters {
|
||||
static final class ObjectJsonAdapter extends JsonAdapter<Object> {
|
||||
private final Moshi moshi;
|
||||
|
||||
public ObjectJsonAdapter(Moshi moshi) {
|
||||
ObjectJsonAdapter(Moshi moshi) {
|
||||
this.moshi = moshi;
|
||||
}
|
||||
|
||||
|
@@ -149,7 +149,7 @@ public final class Types {
|
||||
return (Class<?>) rawType;
|
||||
|
||||
} else if (type instanceof GenericArrayType) {
|
||||
Type componentType = ((GenericArrayType)type).getGenericComponentType();
|
||||
Type componentType = ((GenericArrayType) type).getGenericComponentType();
|
||||
return Array.newInstance(getRawType(componentType), 0).getClass();
|
||||
|
||||
} else if (type instanceof TypeVariable) {
|
||||
@@ -560,7 +560,7 @@ public final class Types {
|
||||
private static final class GenericArrayTypeImpl implements GenericArrayType {
|
||||
private final Type componentType;
|
||||
|
||||
public GenericArrayTypeImpl(Type componentType) {
|
||||
GenericArrayTypeImpl(Type componentType) {
|
||||
this.componentType = canonicalize(componentType);
|
||||
}
|
||||
|
||||
@@ -591,7 +591,7 @@ public final class Types {
|
||||
private final Type upperBound;
|
||||
private final Type lowerBound;
|
||||
|
||||
public WildcardTypeImpl(Type[] upperBounds, Type[] lowerBounds) {
|
||||
WildcardTypeImpl(Type[] upperBounds, Type[] lowerBounds) {
|
||||
if (lowerBounds.length > 1) throw new IllegalArgumentException();
|
||||
if (upperBounds.length != 1) throw new IllegalArgumentException();
|
||||
|
||||
|
@@ -25,6 +25,9 @@ import java.util.Set;
|
||||
final class Util {
|
||||
public static final Set<Annotation> NO_ANNOTATIONS = Collections.emptySet();
|
||||
|
||||
private Util() {
|
||||
}
|
||||
|
||||
public static boolean typesMatch(Type pattern, Type candidate) {
|
||||
// TODO: permit raw types (like Set.class) to match non-raw candidates (like Set<Long>).
|
||||
return pattern.equals(candidate);
|
||||
|
Reference in New Issue
Block a user