/** * The name of the method will be taken as the first key, then the path provided with the * annotation. */ @Wrapped(path = {"1"}) abstract Meta meta();
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null || getClass() != obj.getClass()) return false; Wrapped wrapped = (Wrapped) obj; return Arrays.equals(path, wrapped.path()) && failOnNotFound == wrapped.failOnNotFound(); }
private static class Data3 { @Custom @Wrapped(path = "1") String str; }
@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()); } };
private static class Data2 { @Wrapped(path = { "1", "2" }) Data1 data; }
private static class Data4 { @Wrapped(path = "1") Throws th; }
/** Helps to test the unwrap adapter. */ @GET("/") @Wrapped(path = {"one", "two"}) Call<String> unwrap();
@GET("/") @Wrapped(path = {"one", "two"}) Call<Nested> unwrapNested();
@Multipart @Headers("Authorization: Client-ID f6b6c9586f097ac") @POST("image") @Wrapped(path = {"data", "link"}) Single<String> postImage(@Part MultipartBody.Part file);
/** Helps to test the first element json adapter. */ @GET("/") @Wrapped(path = {"one", "two"}) @FirstElement Call<String> unwrapFirstElement();
@POST("/") Call<ResponseBody> wrappedPost(@Body @Wrapped(path = {"1", "2"}) String value);
@Wrapped(path = "1") @Retention(RetentionPolicy.RUNTIME) @Target({ ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER })