com.fasterxml.jackson.databind.JsonNode.isShort()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(6.3k)|赞(0)|评价(0)|浏览(121)

本文整理了Java中com.fasterxml.jackson.databind.JsonNode.isShort()方法的一些代码示例,展示了JsonNode.isShort()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JsonNode.isShort()方法的具体详情如下:
包路径:com.fasterxml.jackson.databind.JsonNode
类名称:JsonNode
方法名:isShort

JsonNode.isShort介绍

[英]Method that can be used to check whether contained value is a number represented as Java short. Note, however, that even if this method returns false, it is possible that conversion would be possible from other numeric types -- to check if this is possible, use #canConvertToInt() instead.
[中]方法,该方法可用于检查所包含的值是否为表示为Javashort的数字。但是,请注意,即使此方法返回false,也有可能从其他数值类型进行转换——要检查这是否可行,请使用#canConvertToInt()代替。

代码示例

代码示例来源:origin: kite-sdk/kite

} else if (datum.isLong()) {
 list.add(datum.asLong());
} else if (datum.isShort()) {
 list.add(datum.shortValue());
} else if (datum.isDouble()) {

代码示例来源:origin: org.kitesdk/kite-morphlines-json

} else if (datum.isLong()) {
 list.add(datum.asLong());
} else if (datum.isShort()) {
 list.add(datum.shortValue());
} else if (datum.isDouble()) {

代码示例来源:origin: com.cloudera.cdk/cdk-morphlines-json

} else if (datum.isLong()) {
 list.add(datum.asLong());
} else if (datum.isShort()) {
 list.add(datum.shortValue());
} else if (datum.isDouble()) {

代码示例来源:origin: com.blackducksoftware.magpie/magpie-test

/**
 * Unwraps a JSON node as an object.
 */
@Nullable
static Object unwrap(@Nullable JsonNode node) {
  if (node == null) {
    return null;
  } else if (node.isArray()) {
    return StreamSupport.stream(node.spliterator(), false)
        .map(JsonUtil::unwrap).collect(Collectors.toList());
  } else if (node.isBoolean()) {
    return node.booleanValue();
  } else if (node.isDouble()) {
    return node.doubleValue();
  } else if (node.isFloat()) {
    return node.floatValue();
  } else if (node.isShort()) {
    return node.shortValue();
  } else if (node.isInt()) {
    return node.intValue();
  } else if (node.isLong()) {
    return node.longValue();
  } else if (node.isTextual()) {
    return node.asText();
  } else if (node.isNull()) {
    return null;
  } else {
    return node;
  }
}

代码示例来源:origin: apache/olingo-odata4

private EdmPrimitiveTypeKind guessPrimitiveTypeKind(final JsonNode node) {
 return node.isShort() ? EdmPrimitiveTypeKind.Int16 :
  node.isInt() ? EdmPrimitiveTypeKind.Int32 :
   node.isLong() ? EdmPrimitiveTypeKind.Int64 :
    node.isBoolean() ? EdmPrimitiveTypeKind.Boolean :
     node.isFloat() ? EdmPrimitiveTypeKind.Single :
      node.isDouble() ? EdmPrimitiveTypeKind.Double :
       node.isBigDecimal() ? EdmPrimitiveTypeKind.Decimal :
        EdmPrimitiveTypeKind.String;
}

代码示例来源:origin: org.apache.olingo/odata-client-core

private EdmPrimitiveTypeKind guessPrimitiveTypeKind(final JsonNode node) {
 return node.isShort() ? EdmPrimitiveTypeKind.Int16 :
  node.isInt() ? EdmPrimitiveTypeKind.Int32 :
   node.isLong() ? EdmPrimitiveTypeKind.Int64 :
    node.isBoolean() ? EdmPrimitiveTypeKind.Boolean :
     node.isFloat() ? EdmPrimitiveTypeKind.Single :
      node.isDouble() ? EdmPrimitiveTypeKind.Double :
       node.isBigDecimal() ? EdmPrimitiveTypeKind.Decimal :
        EdmPrimitiveTypeKind.String;
}

代码示例来源:origin: kite-sdk/kite

} else if (datum.isLong()) {
 record.put(fieldName, datum.asLong());
} else if (datum.isShort()) {
 record.put(fieldName, datum.shortValue());
} else if (datum.isDouble()) {

代码示例来源:origin: com.cloudera.cdk/cdk-morphlines-json

} else if (datum.isLong()) {
 record.put(fieldName, datum.asLong());
} else if (datum.isShort()) {
 record.put(fieldName, datum.shortValue());
} else if (datum.isDouble()) {

代码示例来源:origin: org.kitesdk/kite-morphlines-json

} else if (datum.isLong()) {
 record.put(fieldName, datum.asLong());
} else if (datum.isShort()) {
 record.put(fieldName, datum.shortValue());
} else if (datum.isDouble()) {

代码示例来源:origin: kite-sdk/kite

if (datum == null || datum.isNull()) {
 primitiveSchema = closestPrimitive(primitives, Schema.Type.NULL);
} else if (datum.isShort() || datum.isInt()) {
 primitiveSchema = closestPrimitive(primitives,
   Schema.Type.INT, Schema.Type.LONG,

代码示例来源:origin: com.reprezen.jsonoverlay/jsonoverlay

@Override
protected 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;
  }
}

代码示例来源:origin: com.hotels/jasvorno

private static UnionResolution identifyPrimitiveMatch(JsonNode datum, Set<Schema.Type> primitives) {
 // Try to identify specific primitive types
 Schema primitiveSchema = null;
 if (datum == null || datum.isNull()) {
  primitiveSchema = closestPrimitive(primitives, Schema.Type.NULL);
 } else if (datum.isShort() || datum.isInt()) {
  primitiveSchema = closestPrimitive(primitives, Schema.Type.INT, Schema.Type.LONG, Schema.Type.FLOAT,
    Schema.Type.DOUBLE);
 } else if (datum.isLong()) {
  primitiveSchema = closestPrimitive(primitives, Schema.Type.LONG, Schema.Type.DOUBLE);
 } else if (datum.isFloat()) {
  primitiveSchema = closestPrimitive(primitives, Schema.Type.FLOAT, Schema.Type.DOUBLE);
 } else if (datum.isDouble()) {
  primitiveSchema = closestPrimitive(primitives, Schema.Type.DOUBLE);
 } else if (datum.isBoolean()) {
  primitiveSchema = closestPrimitive(primitives, Schema.Type.BOOLEAN);
 }
 if (primitiveSchema == null
   && ((datum.isDouble() && datum.doubleValue() >= -Float.MAX_VALUE && datum.doubleValue() <= Float.MAX_VALUE)
     || (datum.isLong()
       && datum.longValue() >= (long) -Float.MAX_VALUE
       && datum.longValue() <= (long) Float.MAX_VALUE))) {
  primitiveSchema = closestPrimitive(primitives, Schema.Type.FLOAT, Schema.Type.DOUBLE);
 }
 if (primitiveSchema != null) {
  return new UnionResolution(primitiveSchema, MatchType.FULL);
 }
 return null;
}

代码示例来源:origin: io.atlasmap/atlas-json-core

private Object handleNumberNode(JsonNode valueNode, JsonField jsonField) {
  if (valueNode.isInt()) {
    jsonField.setFieldType(FieldType.INTEGER);
    return valueNode.intValue();
  } else if (valueNode.isDouble()) {
    jsonField.setFieldType(FieldType.DOUBLE);
    return valueNode.doubleValue();
  } else if (valueNode.isBigDecimal()) {
    jsonField.setFieldType(FieldType.DECIMAL);
    return valueNode.decimalValue();
  } else if (valueNode.isFloat()) {
    jsonField.setFieldType(FieldType.DOUBLE);
    return valueNode.floatValue();
  } else if (valueNode.isLong()) {
    jsonField.setFieldType(FieldType.LONG);
    return valueNode.longValue();
  } else if (valueNode.isShort()) {
    jsonField.setFieldType(FieldType.SHORT);
    return valueNode.shortValue();
  } else if (valueNode.isBigInteger()) {
    jsonField.setFieldType(FieldType.BIG_INTEGER);
    return valueNode.bigIntegerValue();
  } else {
    jsonField.setFieldType(FieldType.NUMBER);
    return valueNode.numberValue();
  }
}

相关文章