@@ -0,0 +1,2179 @@
+/*%0A * Copyright (C) 2015 Square, Inc.%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *    http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0Apackage com.squareup.moshi.recipes;%0A%0A%0Aimport com.squareup.moshi.FromJson;%0Aimport com.squareup.moshi.Json;%0Aimport com.squareup.moshi.JsonAdapter;%0Aimport com.squareup.moshi.Moshi;%0Aimport com.squareup.moshi.JsonReader;%0A%0Aimport javax.annotation.Nullable;%0Aimport java.io.IOException;%0A%0Apublic final class CustomAdapterWithDelegate %7B%0A  public void run() throws Exception %7B%0A    // We want to match any Stage that starts with 'in-progress' as Stage.IN_PROGRESS%0A    // and leave the rest of the enum values as to match as normal.%0A    Moshi moshi = new Moshi.Builder().add(new StageAdapter()).build();%0A    JsonAdapter%3CStage%3E jsonAdapter = moshi.adapter(Stage.class);%0A%0A    System.out.println(jsonAdapter.fromJson(%22%5C%22not-started%5C%22%22));%0A    System.out.println(jsonAdapter.fromJson(%22%5C%22in-progress%5C%22%22));%0A    System.out.println(jsonAdapter.fromJson(%22%5C%22in-progress-step1%5C%22%22));%0A  %7D%0A%0A  public static void main(String%5B%5D args) throws Exception %7B%0A    new CustomAdapterWithDelegate().run();%0A  %7D%0A%0A  private enum Stage %7B%0A    @Json(name = %22not-started%22) NOT_STARTED,%0A    @Json(name = %22in-progress%22) IN_PROGRESS,%0A    @Json(name = %22rejected%22) REJECTED,%0A    @Json(name = %22completed%22) COMPLETED%0A  %7D%0A%0A  private static final class StageAdapter %7B%0A    @FromJson%0A    @Nullable%0A    Stage fromJson(JsonReader jsonReader, JsonAdapter%3CStage%3E delegate) throws IOException %7B%0A      String value = jsonReader.nextString();%0A%0A      Stage stage;%0A      if (value.startsWith(%22in-progress%22)) %7B%0A        stage = Stage.IN_PROGRESS;%0A      %7D else %7B%0A        stage = delegate.fromJsonValue(value);%0A      %7D%0A      return stage;%0A    %7D%0A  %7D%0A%7D%0A

Add an example custom adapter which delegates