code: public static String unboxArgument (Type type, String name)
      {
          if (Boolean.TYPE.equals(type)) {
              return "((Boolean)" + name + ").booleanValue()";
          } else if (Byte.TYPE.equals(type)) {
              return "((Byte)" + name + ").byteValue()";
          } else if (Character.TYPE.equals(type)) {
              return "((Character)" + name + ").charValue()";
          } else if (Short.TYPE.equals(type)) {
              return "((Short)" + name + ").shortValue()";
          } else if (Integer.TYPE.equals(type)) {
              return "((Integer)" + name + ").intValue()";
          } else if (Long.TYPE.equals(type)) {
              return "((Long)" + name + ").longValue()";
          } else if (Float.TYPE.equals(type)) {
              return "((Float)" + name + ").floatValue()";
          } else if (Double.TYPE.equals(type)) {
              return "((Double)" + name + ").doubleValue()";
          } else if (Object.class.equals(type)) {
              return name; // no need to cast object
          } else if (type instanceof Class<?>) {
              return "(" + simpleName(type) + ")" + name;
          } else {
              return "this.<" + simpleName(type) + ">cast(" + name + ")";
          }
      }
docs: "Unboxes" the supplied argument, ie. turning an <code>Integer</code> object into an
  <code>int</code>.