本文整理匯總了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();
}