try {
      if (literalKind == EdmLiteralKind.URI) {
        if (value.endsWith("L") || value.endsWith("l")) {
          valueLong = Long.parseLong(value.substring(0, value.length() - 1));
        } else {
          throw new EdmSimpleTypeException(EdmSimpleTypeException.LITERAL_ILLEGAL_CONTENT.addContent(value));
        }
      } else {
        valueLong = Long.parseLong(value);
      }
    } catch (final NumberFormatException e) {
      throw new EdmSimpleTypeException(EdmSimpleTypeException.LITERAL_ILLEGAL_CONTENT.addContent(value), e);
    }
    if (returnType.isAssignableFrom(Long.class)) {
      return returnType.cast(valueLong);
    } else if (returnType.isAssignableFrom(Byte.class)) {
      if (valueLong >= Byte.MIN_VALUE && valueLong <= Byte.MAX_VALUE) {
        return returnType.cast(valueLong.byteValue());
      } else {
        throw new EdmSimpleTypeException(EdmSimpleTypeException.LITERAL_UNCONVERTIBLE_TO_VALUE_TYPE.addContent(value,
            returnType));
      }
    } else if (returnType.isAssignableFrom(Short.class)) {
      if (valueLong >= Short.MIN_VALUE && valueLong <= Short.MAX_VALUE) {
        return returnType.cast(valueLong.shortValue());
      } else {
        throw new EdmSimpleTypeException(EdmSimpleTypeException.LITERAL_UNCONVERTIBLE_TO_VALUE_TYPE.addContent(value,
            returnType));
      }
    } else if (returnType.isAssignableFrom(Integer.class)) {
      if (valueLong >= Integer.MIN_VALUE && valueLong <= Integer.MAX_VALUE) {
        return returnType.cast(valueLong.intValue());
      } else {
        throw new EdmSimpleTypeException(EdmSimpleTypeException.LITERAL_UNCONVERTIBLE_TO_VALUE_TYPE.addContent(value,
            returnType));
      }
    } else if (returnType.isAssignableFrom(BigInteger.class)) {
      return returnType.cast(BigInteger.valueOf(valueLong));
    } else {
      throw new EdmSimpleTypeException(EdmSimpleTypeException.VALUE_TYPE_NOT_SUPPORTED.addContent(returnType));
    }
  }