当前位置: 首页>>代码示例>>Java>>正文


Java NullNode类代码示例

本文整理汇总了Java中com.fasterxml.jackson.databind.node.NullNode的典型用法代码示例。如果您正苦于以下问题:Java NullNode类的具体用法?Java NullNode怎么用?Java NullNode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


NullNode类属于com.fasterxml.jackson.databind.node包,在下文中一共展示了NullNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: execute

import com.fasterxml.jackson.databind.node.NullNode; //导入依赖的package包/类
JsonNode execute(String filename, String source, List<String> command) {
    if (!m_found) {
        return NullNode.getInstance();
    }

    String content = "";
    try {
        content = runCommand(filename, source, command);
        JsonNode jsonNode = m_objectMapper.readTree(content);
        JsonNode valueNode = extractResponse(jsonNode);
        return valueNode == null ? NullNode.getInstance() : valueNode;
    } catch (Exception ex) {
        throw new RuntimeException("An error occurred when executing a command for the file " + filename + "\n"
                + "The command is: " + Joiner.join(" ", command) + "\n"
                + "The output from merlin is: " + content, ex);
    }
}
 
开发者ID:reasonml-editor,项目名称:reasonml-idea-plugin,代码行数:18,代码来源:MerlinProcess3.java

示例2: activate

import com.fasterxml.jackson.databind.node.NullNode; //导入依赖的package包/类
@Activate
public void activate() {
    Serializer serializer = Serializer.using(KryoNamespaces.API,
                    ObjectNode.class, ArrayNode.class,
                    JsonNodeFactory.class, LinkedHashMap.class,
                    TextNode.class, BooleanNode.class,
                    LongNode.class, DoubleNode.class, ShortNode.class,
                    IntNode.class, NullNode.class);

    prefsConsistentMap = storageService.<String, ObjectNode>consistentMapBuilder()
            .withName(ONOS_USER_PREFERENCES)
            .withSerializer(serializer)
            .withRelaxedReadConsistency()
            .build();
    prefsConsistentMap.addListener(prefsListener);
    prefs = prefsConsistentMap.asJavaMap();
    register(core);
    log.info("Started");
}
 
开发者ID:shlee89,项目名称:athena,代码行数:20,代码来源:UiExtensionManager.java

示例3: activate

import com.fasterxml.jackson.databind.node.NullNode; //导入依赖的package包/类
@Activate
public void activate() {
    KryoNamespace.Builder kryoBuilder = new KryoNamespace.Builder()
            .register(KryoNamespaces.API)
            .register(ConfigKey.class, ObjectNode.class, ArrayNode.class,
                      JsonNodeFactory.class, LinkedHashMap.class,
                      TextNode.class, BooleanNode.class,
                      LongNode.class, DoubleNode.class, ShortNode.class, IntNode.class,
                      NullNode.class);

    configs = storageService.<ConfigKey, JsonNode>consistentMapBuilder()
            .withSerializer(Serializer.using(kryoBuilder.build()))
            .withName("onos-network-configs")
            .withRelaxedReadConsistency()
            .build();
    configs.addListener(listener);
    log.info("Started");
}
 
开发者ID:shlee89,项目名称:athena,代码行数:19,代码来源:DistributedNetworkConfigStore.java

示例4: kidForKeyId

import com.fasterxml.jackson.databind.node.NullNode; //导入依赖的package包/类
@Nonnull
public static JsonNode kidForKeyId(
  @Nonnull final JsonNode node,
  @Nonnull final String keyId){

    for(JsonNode keyNode : node){
        if(keyNode
          .get("kid")
          .asText()
          .equals(keyId)){

            return keyNode;
        }
    }
    return NullNode.getInstance();
}
 
开发者ID:Xitikit,项目名称:xitikit-blue,代码行数:17,代码来源:VerificationUtil.java

示例5: startExistingJob

import com.fasterxml.jackson.databind.node.NullNode; //导入依赖的package包/类
/**
 * Start existing job and return id of new jobrun
 */
public JobRunId startExistingJob(JobId id) {
    ApiResponse response = this.sendPOST(startJobTemplate, ImmutableMap.of("jobId", id.toString()), NullNode.getInstance());
    Optional<HttpResponse> optHttpResponse = response.getOptHttpResponse();

    if (!optHttpResponse.isPresent()) {
        throw new WebmateApiClientException("Could not start Job with id "+id+". Got no response");
    }

    try {
        String jobRunId = EntityUtils.toString(optHttpResponse.get().getEntity()).replaceAll("\"", "");
        return new JobRunId(UUID.fromString(jobRunId));
    } catch (IOException e) {
        throw new WebmateApiClientException("Could not start Job with id "+id+". Got no JobRunId");
    }
}
 
开发者ID:webmate-io,项目名称:webmate-sdk-java,代码行数:19,代码来源:JobEngine.java

示例6: from

import com.fasterxml.jackson.databind.node.NullNode; //导入依赖的package包/类
/**
 * Create a new config from the specified file.
 * 
 * @param file
 *            the file containing config values. Assumed to be in *.json format.
 * @return the loaded confing
 * @throws IOException
 *             if an IO error occurred
 * @throws JsonProcessingException
 *             if an error occurred while processing the json text
 */
public static HVConfig from( File file )
	throws IOException
{
	HVConfig config = new HVConfig();

	ObjectMapper mapper = new ObjectMapper();
	mapper.configure( JsonParser.Feature.ALLOW_COMMENTS, true );
	mapper.configure( JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true );

	JsonNode rootNode = mapper.readTree( file );

	try {
		for ( Field field : HVConfig.class.getDeclaredFields() ) {
			JsonNode node = rootNode.get( field.getName() );
			if ( node != null && node instanceof NullNode == false && isValidField( field ) ) {
				config.setField( field, node );
			}
		}
	}
	catch ( IllegalArgumentException | IllegalAccessException e ) {
		log.error( "Error while processing config fields: ", e );
	}

	return config;
}
 
开发者ID:kartoFlane,项目名称:hiervis,代码行数:37,代码来源:HVConfig.java

示例7: testServiceNetworkDecodeNullAndEmptyProviders

import com.fasterxml.jackson.databind.node.NullNode; //导入依赖的package包/类
/**
 * Checks if decoding service network with null and empty providers allowed.
 */
@Test
public void testServiceNetworkDecodeNullAndEmptyProviders() {
    JsonNode jsonInvalidProvider = context.mapper().createObjectNode()
            .put(ID, ID_1.id())
            .put(NAME, NAME_1)
            .put(TYPE, PRIVATE.name())
            .put(SEGMENT_ID, SEGMENT_ID_1.id())
            .put(SUBNET, SUBNET_1.toString())
            .put(SERVICE_IP, SERVICE_IP_1.toString())
            .set(PROVIDERS, NullNode.getInstance());
    codec.decode((ObjectNode) jsonInvalidProvider, context);

    jsonInvalidProvider = context.mapper().createObjectNode()
            .put(ID, ID_1.id())
            .put(NAME, NAME_1)
            .put(TYPE, PRIVATE.name())
            .put(SEGMENT_ID, SEGMENT_ID_1.id())
            .put(SUBNET, SUBNET_1.toString())
            .put(SERVICE_IP, SERVICE_IP_1.toString())
            .set(PROVIDERS, context.mapper().createArrayNode());
    codec.decode((ObjectNode) jsonInvalidProvider, context);
}
 
开发者ID:opencord,项目名称:vtn,代码行数:26,代码来源:ServiceNetworkCodecTest.java

示例8: testServiceNetworkNullProviderId

import com.fasterxml.jackson.databind.node.NullNode; //导入依赖的package包/类
/**
 * Checks if decoding service network with invalid provider fails.
 */
@Test(expected = IllegalArgumentException.class)
public void testServiceNetworkNullProviderId() {
    final ArrayNode jsonProviders = context.mapper().createArrayNode();
    final JsonNode jsonProvider = context.mapper().createObjectNode()
            .put(DEP_TYPE, true)
            .set(ID, NullNode.getInstance());
    jsonProviders.add(jsonProvider);
    final JsonNode jsonInvalidProvider = context.mapper().createObjectNode()
            .put(ID, ID_1.id())
            .put(NAME, NAME_1)
            .put(TYPE, PRIVATE.name())
            .put(SEGMENT_ID, SEGMENT_ID_1.id())
            .put(SUBNET, SUBNET_1.toString())
            .put(SERVICE_IP, SERVICE_IP_1.toString())
            .set(PROVIDERS, jsonProvider);
    codec.decode((ObjectNode) jsonInvalidProvider, context);
}
 
开发者ID:opencord,项目名称:vtn,代码行数:21,代码来源:ServiceNetworkCodecTest.java

示例9: testServiceNetworkNullProviderType

import com.fasterxml.jackson.databind.node.NullNode; //导入依赖的package包/类
/**
 * Checks if decoding service network with invalid provider fails.
 */
@Test(expected = IllegalArgumentException.class)
public void testServiceNetworkNullProviderType() {
    final ArrayNode jsonProviders = context.mapper().createArrayNode();
    final JsonNode jsonProvider = context.mapper().createObjectNode()
            .put(ID, PROVIDER_ID_1.id())
            .set(DEP_TYPE, NullNode.getInstance());
    jsonProviders.add(jsonProvider);
    final JsonNode jsonInvalidProvider = context.mapper().createObjectNode()
            .put(ID, ID_1.id())
            .put(NAME, NAME_1)
            .put(TYPE, PRIVATE.name())
            .put(SEGMENT_ID, SEGMENT_ID_1.id())
            .put(SUBNET, SUBNET_1.toString())
            .put(SERVICE_IP, SERVICE_IP_1.toString())
            .set(PROVIDERS, jsonProvider);
    codec.decode((ObjectNode) jsonInvalidProvider, context);
}
 
开发者ID:opencord,项目名称:vtn,代码行数:21,代码来源:ServiceNetworkCodecTest.java

示例10: testServicePortDecodeNullAndEmptyAddressPairs

import com.fasterxml.jackson.databind.node.NullNode; //导入依赖的package包/类
/**
 * Checks if null and empty array node is allowed for floating address pairs.
 */
@Test
public void testServicePortDecodeNullAndEmptyAddressPairs() {
    JsonNode jsonInvalidAddrPair = context.mapper().createObjectNode()
            .put(ID, PORT_ID_1.id())
            .put(NETWORK_ID, NETWORK_ID_1.id())
            .put(NAME, PORT_NAME_1)
            .put(IP_ADDRESS, IP_ADDRESS_1.toString())
            .put(MAC_ADDRESS, MAC_ADDRESS_1.toString())
            .put(VLAN_ID, VLAN_ID_1.toShort())
            .set(FLOATING_ADDRESS_PAIRS, NullNode.getInstance());
    codec.decode((ObjectNode) jsonInvalidAddrPair, context);

    jsonInvalidAddrPair = context.mapper().createObjectNode()
            .put(ID, PORT_ID_1.id())
            .put(NETWORK_ID, NETWORK_ID_1.id())
            .put(NAME, PORT_NAME_1)
            .put(IP_ADDRESS, IP_ADDRESS_1.toString())
            .put(MAC_ADDRESS, MAC_ADDRESS_1.toString())
            .put(VLAN_ID, VLAN_ID_1.toShort())
            .set(FLOATING_ADDRESS_PAIRS, context.mapper().createArrayNode());
    codec.decode((ObjectNode) jsonInvalidAddrPair, context);
}
 
开发者ID:opencord,项目名称:vtn,代码行数:26,代码来源:ServicePortCodecTest.java

示例11: testServicePortDecodeNullFloatingAddrPairIp

import com.fasterxml.jackson.databind.node.NullNode; //导入依赖的package包/类
/**
 * Checks if null IP address for floating address pair fails.
 */
@Test(expected = IllegalArgumentException.class)
public void testServicePortDecodeNullFloatingAddrPairIp() {
    final ArrayNode jsonAddrPairs = context.mapper().createArrayNode();
    final JsonNode jsonAddrPair = context.mapper().createObjectNode()
            .put(MAC_ADDRESS, ADDRESS_PAIR_1.mac().toString())
            .set(IP_ADDRESS, NullNode.getInstance());
    jsonAddrPairs.add(jsonAddrPair);
    final JsonNode jsonInvalidAddrPair = context.mapper().createObjectNode()
            .put(ID, PORT_ID_1.id())
            .put(NETWORK_ID, NETWORK_ID_1.id())
            .put(NAME, PORT_NAME_1)
            .put(IP_ADDRESS, IP_ADDRESS_1.toString())
            .put(MAC_ADDRESS, MAC_ADDRESS_1.toString())
            .put(VLAN_ID, VLAN_ID_1.toShort())
            .set(FLOATING_ADDRESS_PAIRS, jsonAddrPairs);
    codec.decode((ObjectNode) jsonInvalidAddrPair, context);
}
 
开发者ID:opencord,项目名称:vtn,代码行数:21,代码来源:ServicePortCodecTest.java

示例12: testServicePortDecodeNullFloatingAddrPairMac

import com.fasterxml.jackson.databind.node.NullNode; //导入依赖的package包/类
/**
 * Checks if null MAC address for floating address pair fails.
 */
@Test(expected = IllegalArgumentException.class)
public void testServicePortDecodeNullFloatingAddrPairMac() {
    final ArrayNode jsonAddrPairs = context.mapper().createArrayNode();
    final JsonNode jsonAddrPair = context.mapper().createObjectNode()
            .put(IP_ADDRESS, ADDRESS_PAIR_1.ip().toString())
            .set(MAC_ADDRESS, NullNode.getInstance());
    jsonAddrPairs.add(jsonAddrPair);
    final JsonNode jsonInvalidAddrPair = context.mapper().createObjectNode()
            .put(ID, PORT_ID_1.id())
            .put(NETWORK_ID, NETWORK_ID_1.id())
            .put(NAME, PORT_NAME_1)
            .put(IP_ADDRESS, IP_ADDRESS_1.toString())
            .put(MAC_ADDRESS, MAC_ADDRESS_1.toString())
            .put(VLAN_ID, VLAN_ID_1.toShort())
            .set(FLOATING_ADDRESS_PAIRS, jsonAddrPairs);
    codec.decode((ObjectNode) jsonInvalidAddrPair, context);
}
 
开发者ID:opencord,项目名称:vtn,代码行数:21,代码来源:ServicePortCodecTest.java

示例13: deserialize

import com.fasterxml.jackson.databind.node.NullNode; //导入依赖的package包/类
@Override
public ExposedPorts deserialize(JsonParser jsonParser, DeserializationContext deserializationContext)
        throws IOException {

    List<ExposedPort> exposedPorts = new ArrayList<>();
    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]));
}
 
开发者ID:codeabovelab,项目名称:haven-platform,代码行数:17,代码来源:ExposedPorts.java

示例14: deserialize

import com.fasterxml.jackson.databind.node.NullNode; //导入依赖的package包/类
@Override
public Ports deserialize(JsonParser jsonParser, DeserializationContext deserializationContext)
        throws IOException {

    Ports out = new Ports();
    ObjectCodec oc = jsonParser.getCodec();
    JsonNode node = oc.readTree(jsonParser);
    for (Iterator<Map.Entry<String, JsonNode>> it = node.fields(); it.hasNext(); ) {

        Map.Entry<String, JsonNode> portNode = it.next();
        JsonNode bindingsArray = portNode.getValue();
        if (bindingsArray.equals(NullNode.getInstance())) {
            out.bind(ExposedPort.parse(portNode.getKey()), null);
        } else {
            for (int i = 0; i < bindingsArray.size(); i++) {
                JsonNode bindingNode = bindingsArray.get(i);
                if (!bindingNode.equals(NullNode.getInstance())) {
                    String hostIp = bindingNode.get("HostIp").textValue();
                    String hostPort = bindingNode.get("HostPort").textValue();
                    out.bind(ExposedPort.parse(portNode.getKey()), new Binding(hostIp, hostPort));
                }
            }
        }
    }
    return out;
}
 
开发者ID:codeabovelab,项目名称:haven-platform,代码行数:27,代码来源:Ports.java

示例15: deserialize

import com.fasterxml.jackson.databind.node.NullNode; //导入依赖的package包/类
@Test
public void deserialize() throws Exception {
    StratumMessage m1 = readValue("{\"id\":123, \"method\":\"a.b\", \"params\":[1, \"x\", null]}");
    assertEquals(123L, (long)m1.id);
    assertEquals("a.b", m1.method);
    assertEquals(Lists.newArrayList(new IntNode(1), new TextNode("x"), NullNode.getInstance()), m1.params);
    StratumMessage m2 = readValue("{\"id\":123, \"result\":{\"x\": 123}}");
    assertTrue(m2.isResult());
    assertEquals(123L, (long)m2.id);
    assertEquals(mapper.createObjectNode().put("x", 123), m2.result);

    StratumMessage m3 = readValue("{\"id\":123, \"result\":[\"x\"]}");
    assertEquals(123L, (long)m3.id);
    //noinspection AssertEqualsBetweenInconvertibleTypes
    assertEquals(mapper.createArrayNode().add("x"), m3.result);
}
 
开发者ID:devrandom,项目名称:java-stratum,代码行数:17,代码来源:StratumMessageTest.java


注:本文中的com.fasterxml.jackson.databind.node.NullNode类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。