本文整理匯總了Java中com.fasterxml.jackson.databind.JsonNode.intValue方法的典型用法代碼示例。如果您正苦於以下問題:Java JsonNode.intValue方法的具體用法?Java JsonNode.intValue怎麽用?Java JsonNode.intValue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.fasterxml.jackson.databind.JsonNode
的用法示例。
在下文中一共展示了JsonNode.intValue方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getShortId
import com.fasterxml.jackson.databind.JsonNode; //導入方法依賴的package包/類
/**
* Get schema ID - an arbitrary shortcut to identify this schema
*
* @return
*/
public Integer getShortId() {
if (SchemaNameUtils.isIdSchema(getName()) && isPresent(SHORT_ID)) {
throw new IllegalStateException("@ShortId found on Id schema " + getName());
}
if (!SchemaNameUtils.isIdSchema(getName()) && !isPresent(SHORT_ID)) {
throw new IllegalStateException("@ShortId NOT found on schema " + getName());
}
JsonNode node = getAnnotations().get(SHORT_ID);
Preconditions.checkArgument(node.isIntegralNumber(), "Expecting text node for @" + SHORT_ID + " annotation");
Integer val = node.intValue();
Preconditions.checkNotNull(val);
return val;
}
示例2: validateRevisionNumber
import com.fasterxml.jackson.databind.JsonNode; //導入方法依賴的package包/類
private static void validateRevisionNumber(DeserializationContext ctx, JsonNode node,
String type, boolean zeroAllowed) throws JsonMappingException {
if (node == null) {
ctx.reportInputMismatch(Revision.class, "missing %s revision number", type);
// Should never reach here.
throw new Error();
}
if (!node.canConvertToInt() || !zeroAllowed && node.intValue() == 0) {
ctx.reportInputMismatch(Revision.class,
"A %s revision number must be %s integer.",
type, zeroAllowed ? "an" : "a non-zero");
// Should never reach here.
throw new Error();
}
}
示例3: fromJson
import com.fasterxml.jackson.databind.JsonNode; //導入方法依賴的package包/類
@Override
public Number fromJson(JsonNode json) {
if (json.isBigDecimal()) {
return json.decimalValue();
} else if (json.isBigInteger()) {
return json.bigIntegerValue();
}
// no methods for Byte, even though numberNode(Byte) is provided.
// experimentations shows that bytes show up as ints. Oh well..
else if (json.isDouble()) {
return json.doubleValue();
} else if (json.isFloat()) {
return json.floatValue();
} else if (json.isInt()) {
return json.intValue();
} else if (json.isLong()) {
return json.longValue();
} else if (json.isShort()) {
return json.shortValue();
} else {
return null;
}
}
示例4: getParentShortId
import com.fasterxml.jackson.databind.JsonNode; //導入方法依賴的package包/類
public Integer getParentShortId() {
if (SchemaNameUtils.isIdSchema(getName()) && !isPresent(PARENT_SHORT_ID)) {
throw new IllegalStateException("PARENT_SHORT_ID not found on Id schema " + getName());
}
JsonNode node = getAnnotations().get(PARENT_SHORT_ID);
Preconditions.checkArgument(node.isIntegralNumber(), "Expecting text node for " + PARENT_SHORT_ID);
Integer val = node.intValue();
Preconditions.checkNotNull(val);
return val;
}
示例5: deserialize
import com.fasterxml.jackson.databind.JsonNode; //導入方法依賴的package包/類
@Override
public Revision deserialize(JsonParser p, DeserializationContext ctx) throws IOException {
final JsonNode node = p.readValueAsTree();
if (node.isNumber()) {
validateRevisionNumber(ctx, node, "major", false);
return new Revision(node.intValue());
}
if (node.isTextual()) {
try {
return new Revision(node.textValue());
} catch (IllegalArgumentException e) {
ctx.reportInputMismatch(Revision.class, e.getMessage());
// Should never reach here.
throw new Error();
}
}
if (!node.isObject()) {
ctx.reportInputMismatch(Revision.class,
"A revision must be a non-zero integer or " +
"an object that contains \"major\" and \"minor\" properties.");
// Should never reach here.
throw new Error();
}
final JsonNode majorNode = node.get("major");
final JsonNode minorNode = node.get("minor");
final int major;
validateRevisionNumber(ctx, majorNode, "major", false);
major = majorNode.intValue();
if (minorNode != null) {
validateRevisionNumber(ctx, minorNode, "minor", true);
if (minorNode.intValue() != 0) {
ctx.reportInputMismatch(Revision.class,
"A revision must not have a non-zero \"minor\" property.");
}
}
return new Revision(major);
}
示例6: fromJson
import com.fasterxml.jackson.databind.JsonNode; //導入方法依賴的package包/類
@Override
public Integer fromJson(JsonNode json) {
return json.isInt() ? json.intValue() : null;
}
示例7: convert
import com.fasterxml.jackson.databind.JsonNode; //導入方法依賴的package包/類
@Override
public Object convert(Schema schema, JsonNode value) {
return (byte) value.intValue();
}