@Override
  public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
    for (Class<?> t = type.getRawType();
        (t != Object.class) && (t.getSuperclass() != null);
        t = t.getSuperclass()) {
      for (Method m : t.getDeclaredMethods()) {
        if (m.isAnnotationPresent(PostConstruct.class)) {
          m.setAccessible(true);
          TypeAdapter<T> delegate = gson.getDelegateAdapter(this, type);
          return new PostConstructAdapter<>(delegate, m);
        }
      }
    }
    return null;
  }
@Test
  public void testList() {
    MultipleSandwiches sandwiches =
        new MultipleSandwiches(
            Arrays.asList(new Sandwich("white", "cheddar"), new Sandwich("whole wheat", "swiss")));

    Gson gson =
        new GsonBuilder().registerTypeAdapterFactory(new PostConstructAdapterFactory()).create();

    // Throws NullPointerException without the fix in https://github.com/google/gson/pull/1103
    String json = gson.toJson(sandwiches);
    assertThat(json)
        .isEqualTo(
            "{\"sandwiches\":[{\"bread\":\"white\",\"cheese\":\"cheddar\"},"
                + "{\"bread\":\"whole wheat\",\"cheese\":\"swiss\"}]}");

    MultipleSandwiches sandwichesFromJson = gson.fromJson(json, MultipleSandwiches.class);
    assertThat(sandwichesFromJson).isEqualTo(sandwiches);
  }