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

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

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

JsonObject.set介绍

[英]Sets the specified field to a copy of this object. A previous field with the same key is replaced.
[中]将指定字段设置为此对象的副本。替换具有相同键的上一个字段。

代码示例

代码示例来源:origin: org.eclipse.ditto/ditto-model-things

@Override
public <T> FeatureProperties set(final JsonFieldDefinition<T> fieldDefinition, @Nullable final T value) {
  return determineResult(() -> wrapped.set(fieldDefinition, value));
}

代码示例来源:origin: org.eclipse.ditto/ditto-json

private static JsonObject setFieldInHierarchy(final JsonObject target, final JsonPointer pointer,
    final JsonField jsonField) {
  if (1 >= pointer.getLevelCount()) {
    return target.set(jsonField);
  }
  final JsonKey rootKey = pointer.getRoot().orElse(ROOT_KEY);
  final JsonObject newTarget = target.getValue(rootKey)
      .filter(JsonValue::isObject)
      .filter(jsonValue -> !jsonValue.isNull())
      .map(JsonValue::asObject)
      .orElseGet(ImmutableJsonObject::empty);
  // let the recursion begin ]:-)
  return target.setValue(rootKey, setFieldInHierarchy(newTarget, pointer.nextLevel(), jsonField));
}

代码示例来源:origin: org.eclipse.ditto/ditto-model-things

@Override
public FeatureProperties set(final JsonField field) {
  return determineResult(() -> wrapped.set(field));
}

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

private static JsonObject setFieldInHierarchy(final JsonObject target, final JsonPointer pointer,
    final JsonField jsonField) {
  if (1 >= pointer.getLevelCount()) {
    return target.set(jsonField);
  }
  final JsonKey rootKey = pointer.getRoot().orElse(ROOT_KEY);
  final JsonObject newTarget = target.getValue(rootKey)
      .filter(JsonValue::isObject)
      .filter(jsonValue -> !jsonValue.isNull())
      .map(JsonValue::asObject)
      .orElseGet(ImmutableJsonObject::empty);
  // let the recursion begin ]:-)
  return target.setValue(rootKey, setFieldInHierarchy(newTarget, pointer.nextLevel(), jsonField));
}

代码示例来源:origin: org.eclipse.ditto/ditto-model-things

@Override
public <T> Attributes set(final JsonFieldDefinition<T> fieldDefinition, @Nullable final T value) {
  return determineResult(() -> wrapped.set(fieldDefinition, value));
}

代码示例来源:origin: org.eclipse.ditto/ditto-model-things

@Override
public Attributes set(final JsonField field) {
  return determineResult(() -> wrapped.set(field));
}

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

@Override
public FeatureProperties set(final JsonField field) {
  return determineResult(() -> wrapped.set(field));
}

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

@Override
public Attributes set(final JsonField field) {
  return determineResult(() -> wrapped.set(field));
}

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

@Override
public <T> FeatureProperties set(final JsonFieldDefinition<T> fieldDefinition, @Nullable final T value) {
  return determineResult(() -> wrapped.set(fieldDefinition, value));
}

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

@Override
public <T> Attributes set(final JsonFieldDefinition<T> fieldDefinition, @Nullable final T value) {
  return determineResult(() -> wrapped.set(fieldDefinition, value));
}

代码示例来源:origin: org.eclipse.ditto/ditto-signals-commands-things

@Override
public Optional<JsonValue> getEntity(final JsonSchemaVersion schemaVersion) {
  final JsonObject thingJson = thing.toJson(schemaVersion, FieldType.regularOrSpecial());
  final JsonObject withInlinePolicyThingJson =
      getInitialPolicy().map(ip -> thingJson.set(JSON_INLINE_POLICY, ip)).orElse(thingJson);
  final JsonObject fullThingJson = getPolicyIdOrPlaceholder().map(
      containedPolicyIdOrPlaceholder -> withInlinePolicyThingJson.set(JSON_COPY_POLICY_FROM,
          containedPolicyIdOrPlaceholder)).orElse(withInlinePolicyThingJson);
  return Optional.of(fullThingJson);
}

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

@Override
public Optional<JsonValue> getEntity(final JsonSchemaVersion schemaVersion) {
  final JsonObject thingJson = thing.toJson(schemaVersion, FieldType.regularOrSpecial());
  final JsonObject withInlinePolicyThingJson =
      getInitialPolicy().map(ip -> thingJson.set(JSON_INLINE_POLICY, ip)).orElse(thingJson);
  final JsonObject fullThingJson = getPolicyIdOrPlaceholder().map(
      containedPolicyIdOrPlaceholder -> withInlinePolicyThingJson.set(JSON_COPY_POLICY_FROM,
          containedPolicyIdOrPlaceholder)).orElse(withInlinePolicyThingJson);
  return Optional.of(fullThingJson);
}

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

@Override
public Optional<JsonValue> getEntity(final JsonSchemaVersion schemaVersion) {
  final JsonObject thingJson = thing.toJson(schemaVersion, FieldType.regularOrSpecial());
  final JsonObject withInlinePolicyThingJson =
      getInitialPolicy().map(ip -> thingJson.set(JSON_INLINE_POLICY, ip)).orElse(thingJson);
  final JsonObject fullThingJson = getPolicyIdOrPlaceholder().map(
      containedPolicyIdOrPlaceholder -> withInlinePolicyThingJson.set(JSON_POLICY_ID_OR_PLACEHOLDER,
          containedPolicyIdOrPlaceholder)).orElse(withInlinePolicyThingJson);
  return Optional.of(fullThingJson);
}

代码示例来源:origin: org.eclipse.ditto/ditto-signals-commands-things

@Override
public Optional<JsonValue> getEntity(final JsonSchemaVersion schemaVersion) {
  final JsonObject thingJson = thing.toJson(schemaVersion, FieldType.regularOrSpecial());
  final JsonObject withInlinePolicyThingJson =
      getInitialPolicy().map(ip -> thingJson.set(JSON_INLINE_POLICY, ip)).orElse(thingJson);
  final JsonObject fullThingJson = getPolicyIdOrPlaceholder().map(
      containedPolicyIdOrPlaceholder -> withInlinePolicyThingJson.set(JSON_POLICY_ID_OR_PLACEHOLDER,
          containedPolicyIdOrPlaceholder)).orElse(withInlinePolicyThingJson);
  return Optional.of(fullThingJson);
}

代码示例来源:origin: org.eclipse.ditto/ditto-model-things

@Override
public <T> Attributes set(final JsonFieldDefinition<T> fieldDefinition, @Nullable final T value) {
  return ImmutableAttributes.of(JsonFactory.newObject().set(fieldDefinition, value));
}

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

@Override
public <T> Attributes set(final JsonFieldDefinition<T> fieldDefinition, @Nullable final T value) {
  return ImmutableAttributes.of(JsonFactory.newObject().set(fieldDefinition, value));
}

代码示例来源:origin: org.eclipse.ditto/ditto-model-things

@Override
public Attributes set(final JsonField field) {
  return ImmutableAttributes.of(JsonFactory.newObject().set(field));
}

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

@Override
public Attributes set(final JsonField field) {
  return ImmutableAttributes.of(JsonFactory.newObject().set(field));
}

代码示例来源:origin: org.eclipse.ditto/ditto-services-connectivity-messaging

static Optional<JsonArray> migrateTargets(@Nonnull final JsonObject connectionJsonObject,
      final JsonArray authContext) {
    return connectionJsonObject.getValue(Connection.JsonFields.TARGETS)
        .map(targetsArray -> IntStream.range(0, targetsArray.getSize())
            .mapToObj(index -> targetsArray.get(index)
                .filter(JsonValue::isObject)
                .map(JsonValue::asObject)
                .map(object -> {
                  if (object.contains(Target.JsonFields.AUTHORIZATION_CONTEXT.getPointer())) {
                    // keep the authContext if it was already set in the target
                    return object;
                  } else {
                    return object.set(Target.JsonFields.AUTHORIZATION_CONTEXT, authContext);
                  }
                })
                .orElse(null)
            ).collect(JsonCollectors.valuesToArray())
        );
  }
}

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

static Optional<JsonArray> migrateTargets(@Nonnull final JsonObject connectionJsonObject,
      final JsonArray authContext) {
    return connectionJsonObject.getValue(Connection.JsonFields.TARGETS)
        .map(targetsArray -> IntStream.range(0, targetsArray.getSize())
            .mapToObj(index -> targetsArray.get(index)
                .filter(JsonValue::isObject)
                .map(JsonValue::asObject)
                .map(object -> {
                  if (object.contains(Target.JsonFields.AUTHORIZATION_CONTEXT.getPointer())) {
                    // keep the authContext if it was already set in the target
                    return object;
                  } else {
                    return object.set(Target.JsonFields.AUTHORIZATION_CONTEXT, authContext);
                  }
                })
                .orElse(null)
            ).collect(JsonCollectors.valuesToArray())
        );
  }
}

相关文章