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

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

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

JsonObject.forEach介绍

暂无

代码示例

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

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 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 Collection<ResourcePermissions> createEntriesForFeatureProperty(final CharSequence featureId,
    final JsonPointer propertyPointer, final JsonValue propertyValue, final Enforcer policyEnforcer) {
  final Collection<ResourcePermissions> result = new HashSet<>(3);
  if (propertyValue.isObject() && !propertyValue.isNull()) {
    final JsonObject propertyValueJsonObject = propertyValue.asObject();
    // Recursion!
    propertyValueJsonObject.forEach(subField -> result.addAll(
        createEntriesForFeatureProperty(featureId, propertyPointer.addLeaf(subField.getKey()),
            subField.getValue(), policyEnforcer)));
  } else {
    result.add(FeaturePropertyResourcePermissions.getInstance(featureId, propertyPointer, propertyValue,
        policyEnforcer));
  }
  return result;
}

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

private static Collection<ResourcePermissions> createEntriesForFeatureProperty(final CharSequence featureId,
    final JsonPointer propertyPointer, final JsonValue propertyValue, final Enforcer policyEnforcer) {
  final Collection<ResourcePermissions> result = new HashSet<>(3);
  if (propertyValue.isObject() && !propertyValue.isNull()) {
    final JsonObject propertyValueJsonObject = propertyValue.asObject();
    // Recursion!
    propertyValueJsonObject.forEach(subField -> result.addAll(
        createEntriesForFeatureProperty(featureId, propertyPointer.addLeaf(subField.getKey()),
            subField.getValue(), policyEnforcer)));
  } else {
    result.add(FeaturePropertyResourcePermissions.getInstance(featureId, propertyPointer, propertyValue,
        policyEnforcer));
  }
  return result;
}

代码示例来源:origin: bsinno/iot-things-examples

/**
 * Collect list of individual property changes
 */
private static void collectChanges(List target, String thingId, String featureId, JsonPointer path,
    JsonValue value) {
  if (value.isObject()) {
    // on Object recursively collect all individual properties with concatenated property path
    JsonObject obj = value.asObject();
    obj.forEach(c -> {
      collectChanges(target, thingId, featureId, path.addLeaf(c.getKey()), c.getValue());
    });
  } else {
    target.add(new History(thingId, featureId, path, value, LocalDateTime.now()));
  }
}

代码示例来源: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 List<PointerAndValue> collectFlatPointers(final JsonPointer createdPointer, final JsonField field,
    final List<PointerAndValue> flattenedFields) {
  final JsonValue fieldValue = field.getValue();
  if (fieldValue.isObject()) {
    final JsonObject jsonObject = fieldValue.asObject();
    if (!jsonObject.isEmpty()) {
      jsonObject.forEach(jsonField -> collectFlatPointers(createdPointer.addLeaf(jsonField.getKey()),
          jsonField, flattenedFields));
    } else {
      flattenedFields.add(new PointerAndValue(createdPointer, fieldValue));
    }
  } else {
    flattenedFields.add(new PointerAndValue(createdPointer, fieldValue));
  }
  return flattenedFields;
}

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

.orElse("?");
                  final JsonObjectBuilder subBuilder = JsonObject.newBuilder();
                  subStatusObj.forEach(subBuilder::set);
                  if (roleStatusBuilder.build().contains(key)) {
                    key = key + "_" + UUID.randomUUID().toString().hashCode();
.thenApply(roleStatuses -> {
  final JsonObjectBuilder rolesStatusBuilder = JsonFactory.newObjectBuilder();
  roleStatuses.forEach(subStatusObj -> subStatusObj.forEach(rolesStatusBuilder::set));

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

private static JsonObject mergeJsonObjects(final JsonObject object1, final JsonObject object2) {
  final JsonObjectBuilder builder = JsonFactory.newObjectBuilder();
  if(object1.isNull() && object2.isNull()) {
    return JsonFactory.nullObject();
  }
  // add fields of jsonObject1
  object1.forEach(jsonField -> {
    final JsonKey key = jsonField.getKey();
    final JsonValue value1 = jsonField.getValue();
    final Optional<JsonValue> maybeValue2 = object2.getValue(key);
    if (maybeValue2.isPresent()) {
      builder.set(key, mergeJsonValues(value1, maybeValue2.get()));
    } else {
      builder.set(jsonField);
    }
  });
  // add fields of jsonObject2 not present in jsonObject0
  object2.forEach(jsonField -> {
    if (!object1.contains(jsonField.getKey())) {
      builder.set(jsonField);
    }
  });
  return builder.build();
}

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

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

代码示例来源:origin: bsinno/iot-things-examples

JsonObject o = v.asObject();
  Map<String, Object> m = new HashMap<>();
  o.forEach(e -> m.put(e.getKeyName(), getJavaValue(e.getValue())));
  return m;
} else {

相关文章