com.fasterxml.jackson.databind.node.ObjectNode.hasNonNull()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(10.2k)|赞(0)|评价(0)|浏览(347)

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

ObjectNode.hasNonNull介绍

暂无

代码示例

代码示例来源:origin: batfish/batfish

public boolean hasNonNull(String column) {
  return _data.hasNonNull(column);
 }
}

代码示例来源:origin: com.microsoft.azure/azure-cosmosdb-commons

/**
 * Gets an integer value.
 * 
 * @param propertyName the property to get.
 * @return the boolean value
 */
public Integer getInt(String propertyName) {
  if (this.has(propertyName) && this.propertyBag.hasNonNull(propertyName)) {
    return Integer.valueOf(this.propertyBag.get(propertyName).asInt());
  } else {
    return null;
  }
}

代码示例来源:origin: Yubico/java-webauthn-server

@Override
public AttestationType getAttestationType(AttestationObject attestation) {
  if (attestation.getAttestationStatement().hasNonNull("x5c")) {
    return AttestationType.BASIC;
  } else if (attestation.getAttestationStatement().hasNonNull("ecdaaKeyId")) {
    return AttestationType.ECDAA;
  } else {
    return AttestationType.SELF_ATTESTATION;
  }
}

代码示例来源:origin: com.microsoft.azure/azure-cosmosdb-commons

/**
 * Gets a boolean value.
 * 
 * @param propertyName the property to get.
 * @return the boolean value.
 */
public Boolean getBoolean(String propertyName) {
  if (this.has(propertyName) && this.propertyBag.hasNonNull(propertyName)) {
    return this.propertyBag.get(propertyName).asBoolean();
  } else {
    return null;
  }
}

代码示例来源:origin: com.microsoft.azure/azure-cosmosdb-commons

/**
 * Gets a long value.
 * 
 * @param propertyName the property to get.
 * @return the long value
 */
public Long getLong(String propertyName) {
  if (this.has(propertyName) && this.propertyBag.hasNonNull(propertyName)) {
    return Long.valueOf(this.propertyBag.get(propertyName).asLong());
  } else {
    return null;
  }
}

代码示例来源:origin: com.microsoft.azure/azure-cosmosdb-commons

/**
 * Gets a JSONObject.
 * 
 * @param propertyName the property to get.
 * @return the JSONObject.
 */
public ObjectNode getObject(String propertyName) {
  if (this.propertyBag.has(propertyName) && this.propertyBag.hasNonNull(propertyName)) {
    ObjectNode jsonObj = (ObjectNode) this.propertyBag.get(propertyName);
    return jsonObj;
  }
  return null;
}

代码示例来源:origin: com.microsoft.azure/azure-cosmosdb-commons

/**
 * Gets a string value.
 * 
 * @param propertyName the property to get.
 * @return the string value.
 */
public String getString(String propertyName) {
  if (this.has(propertyName) && this.propertyBag.hasNonNull(propertyName)) {
    return this.propertyBag.get(propertyName).asText();
  } else {
    return null;
  }
}

代码示例来源:origin: com.microsoft.azure/azure-cosmosdb-commons

/**
 * Gets a double value.
 * 
 * @param propertyName the property to get.
 * @return the double value.
 */
public Double getDouble(String propertyName) {
  if (this.has(propertyName) && this.propertyBag.hasNonNull(propertyName)) {
    return new Double(this.propertyBag.get(propertyName).asDouble());
  } else {
    return null;
  }
}

代码示例来源:origin: io.wcm.caravan/io.wcm.caravan.pipeline.extensions.hal

@Override
public boolean apply(HalPath halPath, HalResource hal) {
 return hal.getModel().hasNonNull(fieldName);
}

代码示例来源:origin: com.github.cafdataprocessing/corepolicy-common

public static Class<?> getRealRequestClassType( Class<?> requestClassType, ObjectNode objectNode ){

    if ( requestClassType == Condition.class ) {
      // we know this class has a discriminator field called "type"
      // if its present, use its given concrete class instead.

      // Now we know its a valid filter - get the value for the criterion.
      if (objectNode.hasNonNull(ApiStrings.Conditions.Arguments.TYPE)) {
        JsonNode node = objectNode.get(ApiStrings.Conditions.Arguments.TYPE);

        return ConditionType.getConditionClass(node.textValue());
      }
    }

    // default is just to use the source request class.
    return requestClassType;
  }
}

代码示例来源:origin: alien4cloud/alien4cloud-cloudify-events-model

@Override
  public AlienEvent deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException {
    ObjectMapper mapper = (ObjectMapper) jp.getCodec();
    ObjectNode root = mapper.readTree(jp);
    Class<? extends AlienEvent> eventClass = null;
    String type = EventType.INSTANCE_STATE;
    if (root.hasNonNull(TYPE_FIELD)) {
      type = root.findValue(TYPE_FIELD).asText();
    }
    eventClass = registry.get(type);
    if (eventClass == null) {
      return null;
    }
    return mapper.readValue(jp, eventClass);
  }
}

代码示例来源:origin: com.microsoft.azure/azure-cosmosdb-commons

/**
 * Gets a JSONObject collection.
 * 
 * @param propertyName the property to get.
 * @return the JSONObject collection.
 */
public Collection<ObjectNode> getCollection(String propertyName) {
  Collection<ObjectNode> result = null;
  if (this.propertyBag.has(propertyName) && this.propertyBag.hasNonNull(propertyName)) {
    result = new ArrayList<ObjectNode>();
    for (JsonNode n : this.propertyBag.findValues(propertyName)) {
      result.add((ObjectNode) n);
    }
  }
  return result;    
}

代码示例来源:origin: com.microsoft.azure/azure-cosmosdb-commons

/**
 * Gets a property value as Object.
 * 
 * @param propertyName the property to get.
 * @return the value of the property.
 */
public Object get(String propertyName) {
  if (this.has(propertyName) && this.propertyBag.hasNonNull(propertyName)) {
    return getValue(this.propertyBag.get(propertyName));
  } else {
    return null;
  }
}

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

final URI contextURL = tree.hasNonNull(Constants.JSON_CONTEXT) ?
  URI.create(tree.get(Constants.JSON_CONTEXT).textValue()) : null;
if (contextURL != null) {
if (tree.hasNonNull(Constants.JSON_COUNT)) {
 delta.setCount(tree.get(Constants.JSON_COUNT).asInt());
if (tree.hasNonNull(Constants.JSON_NEXT_LINK)) {
 delta.setNext(URI.create(tree.get(Constants.JSON_NEXT_LINK).textValue()));
if (tree.hasNonNull(Constants.JSON_DELTA_LINK)) {
 delta.setDeltaLink(URI.create(tree.get(Constants.JSON_DELTA_LINK).textValue()));
if (tree.hasNonNull(Constants.VALUE)) {
 JsonEntityDeserializer entityDeserializer = new JsonEntityDeserializer(serverMode);
 for (JsonNode jsonNode : tree.get(Constants.VALUE)) {
  final ObjectNode item = (ObjectNode) jsonNode;
  final ContextURL itemContextURL = item.hasNonNull(Constants.JSON_CONTEXT) ?
    ContextURLParser.parse(URI.create(item.get(Constants.JSON_CONTEXT).textValue())) : null;
  item.remove(Constants.JSON_CONTEXT);

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

final URI contextURL = tree.hasNonNull(Constants.JSON_CONTEXT) ?
  URI.create(tree.get(Constants.JSON_CONTEXT).textValue()) : null;
if (contextURL != null) {
if (tree.hasNonNull(Constants.JSON_COUNT)) {
 delta.setCount(tree.get(Constants.JSON_COUNT).asInt());
if (tree.hasNonNull(Constants.JSON_NEXT_LINK)) {
 delta.setNext(URI.create(tree.get(Constants.JSON_NEXT_LINK).textValue()));
if (tree.hasNonNull(Constants.JSON_DELTA_LINK)) {
 delta.setDeltaLink(URI.create(tree.get(Constants.JSON_DELTA_LINK).textValue()));
if (tree.hasNonNull(Constants.VALUE)) {
 JsonEntityDeserializer entityDeserializer = new JsonEntityDeserializer(serverMode);
 for (JsonNode jsonNode : tree.get(Constants.VALUE)) {
  final ObjectNode item = (ObjectNode) jsonNode;
  final ContextURL itemContextURL = item.hasNonNull(Constants.JSON_CONTEXT) ?
    ContextURLParser.parse(URI.create(item.get(Constants.JSON_CONTEXT).textValue())) : null;
  item.remove(Constants.JSON_CONTEXT);

代码示例来源:origin: keenlabs/KeenClient-Java

private static void validatePersistentAnalysisRequiredFields(ObjectNode requestNode) {
  // Should have 'refresh_rate' and 'query' top-level keys, at least.
  assertTrue("Missing required top-level fields.", 2 <= requestNode.size());
  assertTrue(requestNode.hasNonNull(KeenQueryConstants.REFRESH_RATE));
  RefreshRate.validateRefreshRate(requestNode.get(KeenQueryConstants.REFRESH_RATE).asInt());
  assertTrue(requestNode.hasNonNull(KeenQueryConstants.QUERY));
  // The "query" should have the typical stuff (tested elsewhere) but also the "analysis_type"
  JsonNode queryNode = requestNode.get(KeenQueryConstants.QUERY);
  assertTrue(queryNode.hasNonNull(KeenQueryConstants.ANALYSIS_TYPE));
}

代码示例来源:origin: keenlabs/KeenClient-Java

@Test
public void testSavedQuery_Update_Simple() throws IOException {
  setMockResponsesForUpdate();
  Map<String, Object> updates = new HashMap<String, Object>();
  int refreshRate = 6 * 3600; // 6 hrs
  updates.put(KeenQueryConstants.REFRESH_RATE, refreshRate);
  Map<String, Object> updateResponse = savedQueryApi.updateQuery(TEST_RESOURCE_NAME, updates);
  ObjectNode requestNode = verifyPut(updateResponse, null, 1);
  assertTrue(requestNode.hasNonNull(KeenQueryConstants.REFRESH_RATE));
  assertEquals(refreshRate, requestNode.get(KeenQueryConstants.REFRESH_RATE).asInt());
}

代码示例来源:origin: keenlabs/KeenClient-Java

@Test
public void testSavedQuery_UpdateHelpers_QueryName() throws IOException {
  setMockResponsesForUpdate();
  String newQueryName = "new_name";
  Map<String, Object> updateResponse = savedQueryApi.setQueryName(TEST_RESOURCE_NAME,
                                  newQueryName);
  ObjectNode requestNode = verifyPut(updateResponse, null, 1);
  assertTrue(requestNode.hasNonNull(KeenQueryConstants.QUERY_NAME));
  assertEquals(newQueryName, requestNode.get(KeenQueryConstants.QUERY_NAME).asText());
}

代码示例来源:origin: keenlabs/KeenClient-Java

@Test
public void testSavedQuery_UpdateHelpers_RefreshRate() throws IOException {
  setMockResponsesForUpdate();
  int refreshRate = RefreshRate.fromHours(8);
  Map<String, Object> updateResponse = savedQueryApi.setRefreshRate(TEST_RESOURCE_NAME,
                                   refreshRate);
  ObjectNode requestNode = verifyPut(updateResponse, null, 1);
  assertTrue(requestNode.hasNonNull(KeenQueryConstants.REFRESH_RATE));
  assertEquals(refreshRate, requestNode.get(KeenQueryConstants.REFRESH_RATE).asInt());
}

代码示例来源:origin: keenlabs/KeenClient-Java

private ObjectNode verifyPut(Map<String, Object> putResponse, String displayName, int numExtraFields)
    throws IOException {
  assertNotNull(putResponse);
  assertTrue(!putResponse.isEmpty());
  // Even when we change the "query_name" the canned responses return the original name. But
  // we're not testing that the back end actually changes things, but rather that we parse
  // correctly.
  assertEquals(TEST_RESOURCE_NAME, putResponse.get(KeenQueryConstants.QUERY_NAME));
  ObjectNode requestNode = getPersistentAnalysisRequestNode();
  // Normally "refresh_rate" and "query" are in the request, but if "display_name" or updates
  // like "query_name" are in the PUT, there'll be more top-level nodes.
  assertEquals((null != displayName ? 3 : 2) + numExtraFields, requestNode.size());
  if (null != displayName) {
    // Verify we added a "metadata" node.
    assertTrue(requestNode.hasNonNull(KeenQueryConstants.METADATA));
    JsonNode metadataNode = requestNode.get(KeenQueryConstants.METADATA);
    assertTrue(metadataNode.hasNonNull(KeenQueryConstants.DISPLAY_NAME));
    assertEquals(displayName, metadataNode.get(KeenQueryConstants.DISPLAY_NAME).asText());
  }
  return requestNode;
}

相关文章

微信公众号

最新文章

更多