@Override public JsonAdapter<?> create(Type type, Set<? extends Annotation> annotations, Moshi moshi) { Pair<ElementAt, Set<Annotation>> nextAnnotations = nextAnnotations(annotations, ElementAt.class); if (nextAnnotations == null || !nextAnnotations.second.isEmpty()) return null; return new ElementAtJsonAdapter<>(type, moshi, nextAnnotations.first.index()); } };
@Override public JsonAdapter<?> create(Type type, Set<? extends Annotation> annotations, Moshi moshi) { Pair<FallbackOnNull, Set<Annotation>> nextAnnotations = nextAnnotations(annotations, FallbackOnNull.class); if (nextAnnotations == null) return null; Class<?> rawType = Types.getRawType(type); if (!FallbackOnNullJsonAdapter.PRIMITIVE_CLASSES.contains(rawType)) return null; String fallbackType = fallbackType(rawType); Object fallback = retrieveFallback(nextAnnotations.first, fallbackType); return new FallbackOnNullJsonAdapter<>(moshi.adapter(type, nextAnnotations.second), fallback, fallbackType); }
@Override public JsonAdapter<?> create(Type type, Set<? extends Annotation> annotations, Moshi moshi) { Pair<Wrapped, Set<Annotation>> nextAnnotations = nextAnnotations(annotations, Wrapped.class); if (nextAnnotations == null) return null; JsonAdapter<Object> adapter = moshi.adapter(type, nextAnnotations.second); Wrapped wrapped = nextAnnotations.first; return new WrappedJsonAdapter<>(adapter, wrapped.path(), wrapped.failOnNotFound()); } };