title: GSON. workaround for enum and int
body: <p>I get a json-answer from server. And i'm parsing it with GSON-library.</p>
  
  <p>A key within json has  an integer value. Is it somehow possible without to change the server answer (it is the external server interface, we have no influence on it) to cast the integer value to an enumeration?</p>
  
  <p>Thank you.</p>
  
  <p><strong>UPD:</strong></p>
  
  <p>The json-Response. NOTE: we can't change it</p>
  
  <pre><code>"testObject":{
  "id":123,
  "type":42
  }
  </code></pre>
  
  <p>The enumeration:</p>
  
  <pre><code>public enum ObjectTypeEnum
  {
      UNKNOWN_TYPE(0),
      SIMPLE_TYPE(11),
      COMPLEX_TYPE(42);
  
      private int value;
  
      private ObjectTypeEnum(int value)
      {
          this.value = value;         
      }
  
      public static ObjectTypeEnum findByAbbr(int value)
      {
          for (ObjectTypeEnum currEnum : ObjectTypeEnum.values())
          {
              if (currEnum.value == value)
              {
                  return currEnum;
              }
          }
  
          return null;
      }
  
      public int getValue()
      {
          return value;
      }
  }
  </code></pre>
  
  <p>And the object class</p>
  
  <pre><code>public class TestObject
  {
      publuc int id;
      public ObjectTypeEnum type; 
  }
  </code></pre>