title: java.lang.ClassCastException: java.lang.Short cannot be cast to java.lang.Integer
body: <p>In my project I have an Enum like this :</p>
  
  <pre><code>public enum MyEnum {
  
  FIRST(1),
  
  SECOND(2);
  
  private int value;
  
  private MyEnum(int value) {
      this.value = value;
  }
  
  public int getValue() {
      return value;
  }
  
  public static MyEnum fromValue(int value) {
      for (MyEnum e : MyEnum.values()) {
          if (e.getValue() == value) {
              return e;
          }
      }
      return null;
  }
  </code></pre>
  
  <p>And I have this code :</p>
  
  <pre><code>Map&lt;String, Object&gt; myMap = new HashMap&lt;&gt;();
  // Fill my Map with data from database
  myMap = namedParameterJdbcTemplate.queryForList(qry, paramsMap);
  
  ***if (Arrays.asList(MyEnum.values())
                  .contains(MyEnum.fromValue((int) 
                  myMap.get("myKey")) )))*** {
      // Do something
      }
  </code></pre>
  
  <p>I get the Exception </p>
  
  <pre><code> java.lang.ClassCastException: java.lang.Short cannot be cast to java.lang.Integer** on this line : **if (Arrays.asList(MyEnum.values())
              .contains(MyEnum.fromValue((int)myMap.get("myKey")) )))
  </code></pre>
  
  <p><strong><em>myMap</em></strong> is filled with data from database, knowing that it is an SQL Server Database and that the <strong><em>myKey</em></strong> returned from database is of type <strong><em>tinyint</em></strong> in the database.</p>
  
  <p>Can you please tell me what I am doing wrong ?
  Thanks.</p>
  
  <p>Regards.</p>