code: private EnumValueDescriptor findValueByNameAndExtension(EnumDescriptor desc,
        JsonElement jsonElement) {
      if (enumSerialization == EnumSerialization.NAME) {
        // With enum name
        for (EnumValueDescriptor enumDesc : desc.getValues()) {
          String enumValue = getCustSerializedEnumValue(enumDesc.getOptions(), enumDesc.getName());
          if (enumValue.equals(jsonElement.getAsString())) {
            return enumDesc;
          }
        }
        throw new IllegalArgumentException(
            String.format("Unrecognized enum name: %s", jsonElement.getAsString()));
      } else {
        // With enum value
        EnumValueDescriptor fieldValue = desc.findValueByNumber(jsonElement.getAsInt());
        if (fieldValue == null) {
          throw new IllegalArgumentException(
              String.format("Unrecognized enum value: %s", jsonElement.getAsInt()));
        }
        return fieldValue;
      }
    }
docs: Finds an enum value in the given {@link EnumDescriptor} that matches the given JSON element,
  either by name if the current adapter is using {@link EnumSerialization#NAME}, otherwise by
  number. If matching by name, it uses the extension value if it is defined, otherwise it uses
  its default value.
  
  @throws IllegalArgumentException if a matching name/number was not found