本文整理汇总了Java中javax.json.JsonNumber.longValueExact方法的典型用法代码示例。如果您正苦于以下问题:Java JsonNumber.longValueExact方法的具体用法?Java JsonNumber.longValueExact怎么用?Java JsonNumber.longValueExact使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.json.JsonNumber
的用法示例。
在下文中一共展示了JsonNumber.longValueExact方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: verifyInjectedCustomInteger
import javax.json.JsonNumber; //导入方法依赖的package包/类
@GET
@Path("/verifyInjectedCustomInteger")
@Produces(MediaType.APPLICATION_JSON)
public JsonObject verifyInjectedCustomInteger(@QueryParam("value") Long value) {
boolean pass = false;
String msg;
// iat
Object test = customInteger.get();
System.out.printf("+++ verifyInjectedCustomInteger, JsonNumber.class.CL: %s\n",
JsonNumber.class.getClassLoader());
System.out.printf("+++ customInteger.CL: %s\n",
test.getClass().getClassLoader());
Class[] ifaces = test.getClass().getInterfaces();
for(Class iface : ifaces) {
System.out.printf("%s: %s\n", iface, iface.getClassLoader());
}
JsonNumber customValue = JsonNumber.class.cast(test);
if(customValue == null || customValue.isIntegral() == false) {
msg = "customInteger value is null or not integral, FAIL";
}
else if(customValue.longValueExact() == value) {
msg = "customInteger PASS";
pass = true;
}
else {
msg = String.format("customInteger: %d != %d", customValue, value);
}
JsonObject result = Json.createObjectBuilder()
.add("pass", pass)
.add("msg", msg)
.build();
return result;
}
示例2: verifyInjectedCustomInteger
import javax.json.JsonNumber; //导入方法依赖的package包/类
@GET
@Path("/verifyInjectedCustomInteger")
@Produces(MediaType.APPLICATION_JSON)
public JsonObject verifyInjectedCustomInteger(@QueryParam("value") Long value) {
boolean pass = false;
String msg;
// iat
Object test = customInteger.getValue();
System.out.printf("+++ verifyInjectedCustomInteger, JsonNumber.class.CL: %s\n",
JsonNumber.class.getClassLoader());
System.out.printf("+++ customInteger.CL: %s\n",
test.getClass().getClassLoader());
Class[] ifaces = test.getClass().getInterfaces();
for(Class iface : ifaces) {
System.out.printf("%s: %s\n", iface, iface.getClassLoader());
}
JsonNumber customValue = JsonNumber.class.cast(test);
if(customValue == null || customValue.isIntegral() == false) {
msg = "customInteger value is null or not integral, FAIL";
}
else if(customValue.longValueExact() == value) {
msg = "customInteger PASS";
pass = true;
}
else {
msg = String.format("customInteger: %d != %d", customValue, value);
}
JsonObject result = Json.createObjectBuilder()
.add("pass", pass)
.add("msg", msg)
.build();
return result;
}
示例3: failure
import javax.json.JsonNumber; //导入方法依赖的package包/类
@Test(expected = ArithmeticException.class)
public void failure() {
JsonNumber n = new WritableJsonDecimalNumber(new BigDecimal("123456789123456789.123"));
n.longValueExact();
}