code: public static Integer castInt(Object o) {
          if (o == null) {
              return null;
          }
          if (o instanceof Number) {
              return ((Number) o).intValue();
          }
          try {
              return Integer.valueOf(o.toString());
          } catch (NumberFormatException e) {
              return null;
          }
      }
docs: Casts a value to an integer. May return null.
  
  @param o The object to attempt to cast
  @return The object as an int