title: Gson: can we get the serialized field name in a type adapter?
body: <p>I've seen that the default TypeAdapter for Enum doesn't fit my need:</p>
  
  <pre><code>private static final class EnumTypeAdapter&lt;T extends Enum&lt;T&gt;&gt; extends TypeAdapter&lt;T&gt; {
      private final Map&lt;String, T&gt; nameToConstant = new HashMap&lt;String, T&gt;();
      private final Map&lt;T, String&gt; constantToName = new HashMap&lt;T, String&gt;();
  
      public EnumTypeAdapter(Class&lt;T&gt; classOfT) {
        try {
          for (T constant : classOfT.getEnumConstants()) {
            String name = constant.name();
            SerializedName annotation = classOfT.getField(name).getAnnotation(SerializedName.class);
            if (annotation != null) {
              name = annotation.value();
            }
            nameToConstant.put(name, constant);
            constantToName.put(constant, name);
          }
        } catch (NoSuchFieldException e) {
          throw new AssertionError();
        }
      }
      public T read(JsonReader in) throws IOException {
        if (in.peek() == JsonToken.NULL) {
          in.nextNull();
          return null;
        }
        return nameToConstant.get(in.nextString());
      }
  
      public void write(JsonWriter out, T value) throws IOException {
        out.value(value == null ? null : constantToName.get(value));
      }
    }
  </code></pre>
  
  <p>If the Enum has value ONE and TWO, when we try to parse THREE, then this value is unknown and Gson will map null instead of raising a parsing exception. I need something more fail-fast.</p>
  
  <p>But I also need something which permits me to know the name of the field which is currently read and creates a parsing failure.</p>
  
  <p>Is it possible with Gson?</p>