org.eclipse.ditto.json.JsonField.getKey()方法的使用及代码示例

x33g5p2x  于2022-01-22 转载在 其他  
字(9.4k)|赞(0)|评价(0)|浏览(96)

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

JsonField.getKey介绍

[英]Returns this JSON field's key.
[中]返回此JSON字段的键。

代码示例

代码示例来源:origin: org.eclipse.ditto/ditto-services-thingsearch-persistence

private static List<Document> createInternalAttributes(final Iterable<JsonField> attributes) {
  final List<Document> internalFlatList = new ArrayList<>();
  for (final JsonField attribute : attributes) {
    final JsonValue value = attribute.getValue();
    final JsonKey key = attribute.getKey();
    internalFlatList.addAll(toFlatAttributesList(PersistenceConstants.SLASH + key, value, new ArrayList<>()));
  }
  return internalFlatList;
}

代码示例来源:origin: eclipse/ditto

private static List<Document> createInternalAttributes(final Iterable<JsonField> attributes) {
  final List<Document> internalFlatList = new ArrayList<>();
  for (final JsonField attribute : attributes) {
    final JsonValue value = attribute.getValue();
    final JsonKey key = attribute.getKey();
    internalFlatList.addAll(toFlatAttributesList(PersistenceConstants.SLASH + key, value, new ArrayList<>()));
  }
  return internalFlatList;
}

代码示例来源:origin: eclipse/ditto

@Nullable
private JsonValue getViewForJsonFieldOrNull(final JsonField jsonField,
    final PolicyTrie defaultPolicyTrie,
    final Set<String> subjectIds,
    final Permissions permissions) {
  final PolicyTrie relevantTrie = children.getOrDefault(jsonField.getKey(), defaultPolicyTrie);
  return relevantTrie.getViewForJsonValueOrNull(jsonField.getValue(), subjectIds, permissions);
}

代码示例来源:origin: org.eclipse.ditto/ditto-services-thingsearch-persistence

private static void handleObject(final String path,
    final Iterable<JsonField> jsonObject,
    final String featureId,
    final List<Document> flatAttributes) {
  jsonObject.forEach(jsonField -> {
    final String newPath = path + PersistenceConstants.SLASH + jsonField.getKey();
    final JsonValue innerValue = jsonField.getValue();
    toFlatFeaturesList(newPath, featureId, innerValue, flatAttributes);
  });
}

代码示例来源:origin: eclipse/ditto

private static void handleObject(final String path,
    final Iterable<JsonField> jsonObject,
    final String featureId,
    final List<Document> flatAttributes) {
  jsonObject.forEach(jsonField -> {
    final String newPath = path + PersistenceConstants.SLASH + jsonField.getKey();
    final JsonValue innerValue = jsonField.getValue();
    toFlatFeaturesList(newPath, featureId, innerValue, flatAttributes);
  });
}

代码示例来源:origin: org.eclipse.ditto/ditto-services-thingsearch-persistence

private static Collection<ResourcePermissions> createEntriesForAttributes(final Attributes attributes,
    final Enforcer policyEnforcer) {
  final Collection<ResourcePermissions> result = new HashSet<>();
  attributes.forEach(attribute -> result.addAll(
      createEntriesForAttribute(JsonFactory.newPointer(attribute.getKey()), attribute.getValue(),
          policyEnforcer)));
  return result;
}

代码示例来源:origin: eclipse/ditto

private static Collection<ResourcePermissions> createEntriesForAttributes(final Attributes attributes,
    final Enforcer policyEnforcer) {
  final Collection<ResourcePermissions> result = new HashSet<>();
  attributes.forEach(attribute -> result.addAll(
      createEntriesForAttribute(JsonFactory.newPointer(attribute.getKey()), attribute.getValue(),
          policyEnforcer)));
  return result;
}

代码示例来源:origin: eclipse/ditto

private Set<JsonField> calculateThresholdViolations(final String featureId,
    final FeatureProperties featureProperties) {
  return featureProperties.stream()
      .filter(field -> violatesThreshold(
          field.getKey().asPointer(),
          field.getValue(),
          featurePropertyOverhead(featureId),
          MAX_INDEX_CONTENT_LENGTH))
      .collect(Collectors.toSet());
}

代码示例来源:origin: eclipse/ditto

private static Optional<JsonField> getField(final Iterable<JsonField> jsonFields, final JsonKey key) {
  return StreamSupport.stream(jsonFields.spliterator(), false)
      .filter(jsonField -> Objects.equals(jsonField.getKey(), key))
      .findAny();
}

代码示例来源:origin: org.eclipse.ditto/ditto-services-thingsearch-persistence

private Set<JsonField> calculateThresholdViolations(final Attributes attributes) {
  return attributes
      .stream()
      .filter(field -> violatesThreshold(field.getKey().asPointer(),
          field.getValue(),
          attributeOverhead(),
          MAX_INDEX_CONTENT_LENGTH))
      .collect(Collectors.toSet());
}

代码示例来源:origin: org.eclipse.ditto/ditto-services-thingsearch-persistence

private Attributes fixViolations(final Set<JsonField> exceededAttributes,
    final Attributes attributes) {
  final AttributesBuilder builder = attributes.toBuilder();
  exceededAttributes.forEach(field -> builder.set(
      field.getKey().toString(),
      fixViolation(field.getKey().asPointer(),
          field.getValue(),
          attributeOverhead(),
          MAX_INDEX_CONTENT_LENGTH)));
  return builder.build();
}

代码示例来源:origin: org.eclipse.ditto/ditto-services-thingsearch-persistence

private Set<JsonField> calculateThresholdViolations(final String featureId,
    final FeatureProperties featureProperties) {
  return featureProperties.stream()
      .filter(field -> violatesThreshold(
          field.getKey().asPointer(),
          field.getValue(),
          featurePropertyOverhead(featureId),
          MAX_INDEX_CONTENT_LENGTH))
      .collect(Collectors.toSet());
}

代码示例来源:origin: eclipse/ditto

private Set<JsonField> calculateThresholdViolations(final Attributes attributes) {
  return attributes
      .stream()
      .filter(field -> violatesThreshold(field.getKey().asPointer(),
          field.getValue(),
          attributeOverhead(),
          MAX_INDEX_CONTENT_LENGTH))
      .collect(Collectors.toSet());
}

代码示例来源:origin: eclipse/ditto

private Attributes fixViolations(final Set<JsonField> exceededAttributes,
    final Attributes attributes) {
  final AttributesBuilder builder = attributes.toBuilder();
  exceededAttributes.forEach(field -> builder.set(
      field.getKey().toString(),
      fixViolation(field.getKey().asPointer(),
          field.getValue(),
          attributeOverhead(),
          MAX_INDEX_CONTENT_LENGTH)));
  return builder.build();
}

代码示例来源:origin: org.eclipse.ditto/ditto-services-thingsearch-persistence

private static Collection<ResourcePermissions> createEntriesForFeature(final Feature feature,
    final Enforcer policyEnforcer) {
  final Collection<ResourcePermissions> result = new HashSet<>();
  result.add(FeatureResourcePermissions.getInstance(feature, policyEnforcer));
  final FeatureProperties featureProperties = feature.getProperties().orElseGet(
      ThingsModelFactory::emptyFeatureProperties);
  featureProperties.forEach(featureProperty -> result.addAll(
      createEntriesForFeatureProperty(feature.getId(), JsonFactory.newPointer(featureProperty.getKey()),
          featureProperty.getValue(), policyEnforcer)));
  return result;
}

代码示例来源:origin: eclipse/ditto

private static Collection<ResourcePermissions> createEntriesForFeature(final Feature feature,
    final Enforcer policyEnforcer) {
  final Collection<ResourcePermissions> result = new HashSet<>();
  result.add(FeatureResourcePermissions.getInstance(feature, policyEnforcer));
  final FeatureProperties featureProperties = feature.getProperties().orElseGet(
      ThingsModelFactory::emptyFeatureProperties);
  featureProperties.forEach(featureProperty -> result.addAll(
      createEntriesForFeatureProperty(feature.getId(), JsonFactory.newPointer(featureProperty.getKey()),
          featureProperty.getValue(), policyEnforcer)));
  return result;
}

代码示例来源:origin: eclipse/ditto

private static Collection<ResourcePermissions> createEntriesForAttribute(final JsonPointer attributePointer,
    final JsonValue attributeValue, final Enforcer policyEnforcer) {
  final Collection<ResourcePermissions> result = new HashSet<>(3);
  if (attributeValue.isObject() && !attributeValue.isNull()) {
    final JsonObject jsonObject = attributeValue.asObject();
    // Recursion!
    jsonObject.forEach(
        subField -> result.addAll(createEntriesForAttribute(attributePointer.addLeaf(subField.getKey()),
            subField.getValue(), policyEnforcer)));
  } else {
    result.add(AttributeResourcePermissions.getInstance(attributePointer, attributeValue, policyEnforcer));
  }
  return result;
}

代码示例来源:origin: eclipse/ditto

private static void compareFieldDefinitions(final JsonField expectedField, final JsonField actualField) {
  final Optional<JsonFieldDefinition> expectedFieldDefinition = expectedField.getDefinition();
  final Optional<JsonFieldDefinition> actualFieldDefinition = actualField.getDefinition();
  if (expectedFieldDefinition.isPresent()) {
    Assertions.assertThat(actualFieldDefinition)
        .overridingErrorMessage("Expected JsonField <%s> to have definition <%s> but it had " +
            "none", expectedField.getKey(), expectedFieldDefinition.get())
        .isPresent();
    Assertions.assertThat(expectedFieldDefinition)
        .as("Definitions of JsonField <%s> are equal", expectedField.getKey())
        .contains(actualFieldDefinition.get());
  }
}

代码示例来源:origin: org.eclipse.ditto/ditto-services-utils-persistence

/**
 * Maps the specified JsonObject to a {@link com.mongodb.BasicDBObject} which can be stored in MongoDB.
 *
 * @param jsonObject the object to be mapped.
 * @return {@code jsonObject} as BasicDBObject.
 * @throws NullPointerException if {@code jsonObject} is {@code null}.
 */
private BasicDBObject mapJsonObjectToBasicDBObject(final JsonObject jsonObject) {
  checkNotNull(jsonObject, "JSON object to be mapped");
  final BasicDBObject result = new BasicDBObject(jsonObject.getSize());
  jsonObject.forEach(jsonField -> result.put(reviseKeyName(jsonField.getKey()),
      mapJsonValueToJavaObject(jsonField.getValue())));
  return result;
}

代码示例来源:origin: eclipse/ditto

private static void compareFieldValues(final JsonField expectedField, final JsonField actualField,
    final boolean compareFieldDefinitions) {
  compareValuesWithFieldKey(expectedField.getKey(), expectedField.getValue(),
      actualField.getValue(), compareFieldDefinitions);
}

相关文章