title: Java generic method to get value of type by using switch on type
body: <p>I want to have something like this below (example how I would do this in C#), to get typed value from SQLiteDB:</p>
  
  <pre><code>private T GetValueFromDB&lt;T&gt;(String colName) {
      object returnValue = null;
  
      switch (typeof(T)) {
          case Boolean:
              returnValue = dbData.getInt(colName) == 1;
              break;
  
          case Int32:
              returnValue = dbData.getInt(colName);
              break;
  
          case Int64:
              returnValue = dbData.getLong(colName);
              break;
  
          case String:
              returnValue = dbData.getString(colName);
              break;
      }
      return (T)returnValue;
  }
  </code></pre>
  
  <p>Is there a possibility (with switch case or if else) to implement it in Java?</p>