本文整理了Java中com.fasterxml.jackson.databind.node.NullNode.getInstance()
方法的一些代码示例,展示了NullNode.getInstance()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。NullNode.getInstance()
方法的具体详情如下:
包路径:com.fasterxml.jackson.databind.node.NullNode
类名称:NullNode
方法名:getInstance
暂无
代码示例来源:origin: redisson/redisson
/**
* Factory method for getting an instance of JSON null node (which
* represents literal null value)
*/
@Override
public NullNode nullNode() { return NullNode.getInstance(); }
代码示例来源:origin: redisson/redisson
@Override
public JsonNode getNullValue(DeserializationContext ctxt) {
return NullNode.getInstance();
}
代码示例来源:origin: aws/aws-sdk-java
@JsonProperty(PropertyNames.PARAMETERS)
public Builder parameters(JsonNode parameters) {
this.parameters = parameters == null ? NullNode.getInstance() : parameters;
return this;
}
代码示例来源:origin: aws/aws-sdk-java
/**
* If an explicit null is set we preserve that in a {@link NullNode} so that we
* can serialize an explicit JSON null instead of ommitting that field from the JSON object.
*
* @return NullNode if path is null, otherwise a TextNode containing the value.
*/
private JsonNode resolvePath(String pathString) {
if (pathString == null) {
return NullNode.getInstance();
}
return TextNode.valueOf(pathString);
}
代码示例来源:origin: embulk/embulk
@Deprecated
public ToString(com.google.common.base.Optional<JsonNode> option) throws JsonMappingException {
JsonNode node = option.or(NullNode.getInstance());
if (node.isTextual()) {
this.string = node.textValue();
} else if (node.isValueNode()) {
this.string = node.toString();
} else {
throw new JsonMappingException(String.format("Arrays and objects are invalid: '%s'", node));
}
}
代码示例来源:origin: embulk/embulk
@JsonCreator
public ToString(final Optional<JsonNode> option) throws JsonMappingException {
final JsonNode node = option.orElse(NullNode.getInstance());
if (node.isTextual()) {
this.string = node.textValue();
} else if (node.isValueNode()) {
this.string = node.toString();
} else {
throw new JsonMappingException(String.format("Arrays and objects are invalid: '%s'", node));
}
}
代码示例来源:origin: docker-java/docker-java
@Override
public ExposedPort deserialize(JsonParser jsonParser, DeserializationContext deserializationContext)
throws IOException, JsonProcessingException {
ObjectCodec oc = jsonParser.getCodec();
JsonNode node = oc.readTree(jsonParser);
if (!node.equals(NullNode.getInstance())) {
Entry<String, JsonNode> field = node.fields().next();
return ExposedPort.parse(field.getKey());
} else {
return null;
}
}
}
代码示例来源:origin: docker-java/docker-java
@Override
public ExposedPorts deserialize(JsonParser jsonParser, DeserializationContext deserializationContext)
throws IOException, JsonProcessingException {
List<ExposedPort> exposedPorts = new ArrayList<ExposedPort>();
ObjectCodec oc = jsonParser.getCodec();
JsonNode node = oc.readTree(jsonParser);
for (Iterator<Map.Entry<String, JsonNode>> it = node.fields(); it.hasNext();) {
Map.Entry<String, JsonNode> field = it.next();
if (!field.getValue().equals(NullNode.getInstance())) {
exposedPorts.add(ExposedPort.parse(field.getKey()));
}
}
return new ExposedPorts(exposedPorts.toArray(new ExposedPort[0]));
}
}
代码示例来源:origin: aws/aws-sdk-java
/**
* Retrieves the value of the field node
*
* @param fieldNode JmesPath field type
* @param input Input json node whose value is
* retrieved
* @return Value of the input json node
*/
@Override
public JsonNode visit(JmesPathField fieldNode, JsonNode input) {
if (input.isObject()) {
//TODO : CamelCase will need to change at some point
return input.get(CamelCaseUtils.toCamelCase(fieldNode.getValue()));
}
return NullNode.getInstance();
}
代码示例来源:origin: docker-java/docker-java
@Override
public Links deserialize(final JsonParser jsonParser, final DeserializationContext deserializationContext)
throws IOException, JsonProcessingException {
final List<Link> binds = new ArrayList<Link>();
final ObjectCodec oc = jsonParser.getCodec();
final JsonNode node = oc.readTree(jsonParser);
for (final Iterator<JsonNode> it = node.elements(); it.hasNext();) {
final JsonNode element = it.next();
if (!element.equals(NullNode.getInstance())) {
binds.add(Link.parse(element.asText()));
}
}
return new Links(binds.toArray(new Link[0]));
}
}
代码示例来源:origin: docker-java/docker-java
@Override
public Volumes deserialize(JsonParser jsonParser, DeserializationContext deserializationContext)
throws IOException, JsonProcessingException {
List<Volume> volumes = new ArrayList<Volume>();
ObjectCodec oc = jsonParser.getCodec();
JsonNode node = oc.readTree(jsonParser);
for (Iterator<Map.Entry<String, JsonNode>> it = node.fields(); it.hasNext();) {
Map.Entry<String, JsonNode> field = it.next();
if (!field.getValue().equals(NullNode.getInstance())) {
String path = field.getKey();
Volume volume = new Volume(path);
volumes.add(volume);
}
}
return new Volumes(volumes.toArray(new Volume[0]));
}
}
代码示例来源:origin: docker-java/docker-java
@Override
public VolumeRW deserialize(JsonParser jsonParser, DeserializationContext deserializationContext)
throws IOException, JsonProcessingException {
ObjectCodec oc = jsonParser.getCodec();
JsonNode node = oc.readTree(jsonParser);
if (!node.equals(NullNode.getInstance())) {
Entry<String, JsonNode> field = node.fields().next();
String volume = field.getKey();
AccessMode accessMode = AccessMode.fromBoolean(field.getValue().asBoolean());
return new VolumeRW(new Volume(volume), accessMode);
} else {
return null;
}
}
}
代码示例来源:origin: auth0/java-jwt
@Test
public void shouldGetNullStringWhenParsingNullNode() throws Exception {
Map<String, JsonNode> tree = new HashMap<>();
NullNode node = NullNode.getInstance();
tree.put("key", node);
String text = deserializer.getString(tree, "key");
assertThat(text, is(nullValue()));
}
代码示例来源:origin: auth0/java-jwt
@Test
public void shouldGetNullDateWhenParsingNullNode() throws Exception {
Map<String, JsonNode> tree = new HashMap<>();
NullNode node = NullNode.getInstance();
tree.put("key", node);
Date date = deserializer.getDateFromSeconds(tree, "key");
assertThat(date, is(nullValue()));
}
代码示例来源:origin: auth0/java-jwt
@Test
public void shouldGetNullStringWhenParsingNullNode() throws Exception {
Map<String, JsonNode> tree = new HashMap<>();
NullNode node = NullNode.getInstance();
tree.put("key", node);
String text = deserializer.getString(tree, "key");
assertThat(text, is(nullValue()));
}
代码示例来源:origin: auth0/java-jwt
@Test
public void shouldGetNullArrayWhenParsingNullNode() throws Exception {
Map<String, JsonNode> tree = new HashMap<>();
NullNode node = NullNode.getInstance();
tree.put("key", node);
List<String> values = deserializer.getStringOrArray(tree, "key");
assertThat(values, is(nullValue()));
}
代码示例来源:origin: auth0/java-jwt
@Test
public void shouldHaveTree() throws Exception {
HashMap<String, JsonNode> map = new HashMap<>();
JsonNode node = NullNode.getInstance();
map.put("key", node);
BasicHeader header = new BasicHeader(null, null, null, null, map, objectReader);
assertThat(header.getTree(), is(notNullValue()));
assertThat(header.getTree(), is(IsMapContaining.hasEntry("key", node)));
}
代码示例来源:origin: Graylog2/graylog2-server
public static Entity createRoot(ContentPack contentPack) {
return EntityV1.builder()
.type(ModelTypes.ROOT)
.id(ModelId.of("virtual-root-" + contentPack.id() + "-" + contentPack.revision()))
.data(NullNode.getInstance())
.constraints(ImmutableSet.of())
.build();
}
代码示例来源:origin: auth0/java-jwt
@Test
public void shouldReturnBaseClaimWhenParsingNullNode() throws Exception {
JsonNode value = NullNode.getInstance();
Claim claim = claimFromNode(value);
assertThat(claim, is(notNullValue()));
assertThat(claim, is(instanceOf(NullClaim.class)));
assertThat(claim.isNull(), is(true));
}
代码示例来源:origin: apache/avro
@Test
public void testToJsonNode() {
assertEquals(null, toJsonNode(null));
assertEquals(NullNode.getInstance(), toJsonNode(JsonProperties.NULL_VALUE));
assertEquals(BooleanNode.TRUE, toJsonNode(true));
assertEquals(IntNode.valueOf(1), toJsonNode(1));
assertEquals(LongNode.valueOf(2), toJsonNode(2L));
assertEquals(FloatNode.valueOf(1.0f), toJsonNode(1.0f));
assertEquals(DoubleNode.valueOf(2.0), toJsonNode(2.0));
assertEquals(TextNode.valueOf("\u0001\u0002"), toJsonNode(new byte[] { 1, 2 }));
assertEquals(TextNode.valueOf("a"), toJsonNode("a"));
assertEquals(TextNode.valueOf("UP"), toJsonNode(Direction.UP));
ArrayNode an = JsonNodeFactory.instance.arrayNode();
an.add(1);
assertEquals(an, toJsonNode(Collections.singletonList(1)));
ObjectNode on = JsonNodeFactory.instance.objectNode();
on.put("a", 1);
assertEquals(on, toJsonNode(Collections.singletonMap("a", 1)));
}
内容来源于网络,如有侵权,请联系作者删除!