private BigInteger getNumericValue(final Object data) {
    if (data == null) {
      throw new IllegalArgumentException("Cannot convert <null> to numeric");
    }
    if (data instanceof BigInteger) {
      return (BigInteger) data;
    }
    if (data instanceof BigDecimal) {
      return BigInteger.valueOf(((BigDecimal) data).longValue());
    } else if (data instanceof Integer || data instanceof Long) {
      return BigInteger.valueOf(Long.valueOf(data + ""));
    } else if (data instanceof Float || data instanceof Double) {
      return BigInteger.valueOf(Double.doubleToLongBits((Double) data));
    } else {
      final String value;
      if (data instanceof byte[]) {
        value = new String((byte[]) data).trim();
      } else {
        value = data.toString().trim();
      }
      if (NumberMatcher.matcher(value).matches()) {
        return new BigInteger(value);
      }
    }
    throw new IllegalArgumentException("Could not convert " + data.getClass().getSimpleName() + " to numeric");
  }