title: Why is JsonAdapter annotation ignored when serializing built-in type?
body: <h3>The Problem</h3>
  
  <p>Imagine the following field:</p>
  
  <pre><code>@JsonAdapter(CustomTypeAdapter.class)
  private int field;
  </code></pre>
  
  <p>When <em>deserializing</em>, the <code>CustomTypeAdapter</code>'s <code>read</code> method is called as usual, but when <em>serializing</em>, the <code>write</code> method is completely ignored and the built-in type is written out as it would ordinarily be. (The same thing happens if I use <code>Integer</code> instead of <code>int</code>.)</p>
  
  <h3>The Question</h3>
  
  <p>I cannot find anything in <a href="http://google-gson.googlecode.com/svn/trunk/gson/docs/javadocs/com/google/gson/annotations/JsonAdapter.html" rel="nofollow">the documentation</a> which says that this is the expected behavior. Is it? Or is this a bug?</p>
  
  <h3>A Workaround</h3>
  
  <p>The only workaround I've been able to find is to create a custom "holder" type and then expose that, e.g.,</p>
  
  <pre><code>@JsonAdapter(CustomTypeAdapter.class)
  class CustomType { /* blah blah */ }
  
  private CustomType field;
  
  public int getField() {
      return field.getValue();
  }
  
  public void setField(int field) {
      this.field = new CustomType(field);
  }
  </code></pre>
  
  <p>This works but is a bit more cumbersome.</p>