@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 test() throws Exception {
    Gson gson =
        new GsonBuilder().registerTypeAdapterFactory(new PostConstructAdapterFactory()).create();
    Sandwich unused =
        gson.fromJson("{\"bread\": \"white\", \"cheese\": \"cheddar\"}", Sandwich.class);

    var e =
        assertThrows(
            IllegalArgumentException.class,
            () ->
                gson.fromJson(
                    "{\"bread\": \"cheesey bread\", \"cheese\": \"swiss\"}", Sandwich.class));
    assertThat(e).hasMessageThat().isEqualTo("too cheesey");
  }