title: How to pass custom enum in @Query via Retrofit?
body: <p>I have a simple enum:</p>
  
  <pre class="lang-java prettyprint-override"><code>public enum Season {
      @SerializedName("0")
      AUTUMN,
      @SerializedName("1")
      SPRING;
  }
  </code></pre>
  
  <p>Starting some version, GSON became able to parse such enums. To make sure, I did this:</p>
  
  <pre class="lang-java prettyprint-override"><code>final String s = gson.toJson(Season.AUTUMN);
  </code></pre>
  
  <p>It works as I expected. Output is <code>"0"</code>. So, I tried use it in my Retrofit services:</p>
  
  <pre class="lang-java prettyprint-override"><code>@GET("index.php?page[api]=test")
  Observable&lt;List&lt;Month&gt;&gt; getMonths(@Query("season_lookup") Season season);
  /*...some files later...*/
  service.getMonths(Season.AUTUMN);
  </code></pre>
  
  <p>And also added logging to be really certain about its result:</p>
  
  <pre class="lang-java prettyprint-override"><code>HttpLoggingInterceptor httpLoggingInterceptor = new HttpLoggingInterceptor();
  httpLoggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
  
  OkHttpClient httpClient = new OkHttpClient.Builder()
          .addInterceptor(httpLoggingInterceptor)
          .build();
  </code></pre>
  
  <p>But it failed. <code>@Query</code> totally ignored <code>@SerializedName</code> and used <code>.toString()</code> instead, so the log shown me <code>.../index.php?page[api]=test&amp;season_lookup=AUTUMN</code>.</p>
  
  <p>I traced Retrofit sources and found file <code>RequestFactoryParser</code> with lines :</p>
  
  <pre class="lang-java prettyprint-override"><code>Converter&lt;?, String&gt; converter = 
      retrofit.stringConverter(parameterType, parameterAnnotations);
  action = new RequestAction.Query&lt;&gt;(name, converter, encoded);
  </code></pre>
  
  <p>It seems, like it doesn't care at all about enums. Before these lines, it tested <code>rawParameterType.isArray()</code> to be an array or <code>Iterable.class.isAssignableFrom()</code> and nothing more.</p>
  
  <p>Retrofit instance creation is:</p>
  
  <pre class="lang-java prettyprint-override"><code>retrofit = new Retrofit.Builder()
                  .baseUrl(ApiConstants.API_ENDPOINT)
                  .client(httpClient)
                  .addConverterFactory(GsonConverterFactory.create(gson))
                  .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
                  .build();
  </code></pre>
  
  <p><code>gson</code> is <code>GsonBuilder().create()</code>. I peeked at sources, there is predefined <code>ENUM_TypeAdapters.ENUM_FACTORY</code> in it for enums, so I leave it as it is.</p>
  
  <hr>
  
  <p><strong>The question is what can I do, to prevent using</strong> <code>toString()</code> <strong>on my enums and use</strong> <code>@SerializedName</code><strong>? I use</strong> <code>toString()</code> <strong>for other purposes.</strong></p>