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

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

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

JsonObject.isNull介绍

暂无

代码示例

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

@Override
public boolean isNull() {
  return wrapped.isNull();
}

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

@Override
public boolean isNull() {
  return wrapped.isNull();
}

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

@Override
public boolean isNull() {
  return wrapped.isNull();
}

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

@Override
public boolean isNull() {
  return wrapped.isNull();
}

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

/**
 * Creates a response to a {@link RetrieveFeatureProperties} command.
 *
 * @param thingId the Thing ID of the retrieved feature properties.
 * @param featureId the identifier of the Feature whose Properties were retrieved.
 * @param jsonObject the retrieved FeatureProperties JSON.
 * @param dittoHeaders the headers of the preceding command.
 * @return the response.
 * @throws NullPointerException if any argument is {@code null}.
 */
public static RetrieveFeaturePropertiesResponse of(final String thingId, final String featureId,
    @Nullable final JsonObject jsonObject, final DittoHeaders dittoHeaders) {
  final FeatureProperties featureProperties;
  if (jsonObject == null || jsonObject.isNull()) {
    featureProperties = ThingsModelFactory.nullFeatureProperties();
  } else {
    featureProperties = ThingsModelFactory.newFeatureProperties(jsonObject);
  }
  return of(thingId, featureId, featureProperties, dittoHeaders);
}

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

/**
 * Creates a response to a {@link RetrieveFeatureProperties} command.
 *
 * @param thingId the Thing ID of the retrieved feature properties.
 * @param featureId the identifier of the Feature whose Properties were retrieved.
 * @param jsonObject the retrieved FeatureProperties JSON.
 * @param dittoHeaders the headers of the preceding command.
 * @return the response.
 * @throws NullPointerException if any argument is {@code null}.
 */
public static RetrieveFeaturePropertiesResponse of(final String thingId, final String featureId,
    @Nullable final JsonObject jsonObject, final DittoHeaders dittoHeaders) {
  final FeatureProperties featureProperties;
  if (jsonObject == null || jsonObject.isNull()) {
    featureProperties = ThingsModelFactory.nullFeatureProperties();
  } else {
    featureProperties = ThingsModelFactory.newFeatureProperties(jsonObject);
  }
  return of(thingId, featureId, featureProperties, dittoHeaders);
}

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

/**
 * Returns a new immutable {@link FeatureProperties} which is initialised with the values of the given JSON object.
 *
 * @param jsonObject provides the initial values of the result.
 * @return the new immutable initialised {@code FeatureProperties}.
 * @throws NullPointerException if {@code jsonObject} is {@code null}.
 */
public static FeatureProperties newFeatureProperties(final JsonObject jsonObject) {
  checkNotNull(jsonObject, "JSON object for initialization");
  if (!jsonObject.isNull()) {
    return ImmutableFeatureProperties.of(jsonObject);
  } else {
    return nullFeatureProperties();
  }
}

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

/**
 * Returns a new immutable {@link Attributes} which is initialised with the values of the given JSON object.
 *
 * @param jsonObject provides the initial values of the result.
 * @return the new immutable initialised {@code Attributes}.
 * @throws NullPointerException if {@code jsonObject} is {@code null}.
 */
public static Attributes newAttributes(final JsonObject jsonObject) {
  checkNotNull(jsonObject, "JSON object for initialization");
  if (!jsonObject.isNull()) {
    return ImmutableAttributes.of(jsonObject);
  } else {
    return nullAttributes();
  }
}

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

/**
 * Returns a new immutable {@link Attributes} which is initialised with the values of the given JSON object.
 *
 * @param jsonObject provides the initial values of the result.
 * @return the new immutable initialised {@code Attributes}.
 * @throws NullPointerException if {@code jsonObject} is {@code null}.
 */
public static Attributes newAttributes(final JsonObject jsonObject) {
  checkNotNull(jsonObject, "JSON object for initialization");
  if (!jsonObject.isNull()) {
    return ImmutableAttributes.of(jsonObject);
  } else {
    return nullAttributes();
  }
}

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

/**
 * Returns a new immutable {@link FeatureProperties} which is initialised with the values of the given JSON object.
 *
 * @param jsonObject provides the initial values of the result.
 * @return the new immutable initialised {@code FeatureProperties}.
 * @throws NullPointerException if {@code jsonObject} is {@code null}.
 */
public static FeatureProperties newFeatureProperties(final JsonObject jsonObject) {
  checkNotNull(jsonObject, "JSON object for initialization");
  if (!jsonObject.isNull()) {
    return ImmutableFeatureProperties.of(jsonObject);
  } else {
    return nullFeatureProperties();
  }
}

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

/**
 * Creates a new builder for a Feature object based on the given JSON object.
 *
 * @param jsonObject the JSON object of which a new Feature instance is to be created.
 * @return an object handle which allows further configuration of the Feature to be built.
 * @throws NullPointerException if {@code jsonObject} is {@code null}.
 */
public static FromJsonBuildable newFeatureFromJson(final JsonObject jsonObject) {
  ConditionChecker.checkNotNull(jsonObject, "Feature JSON object");
  final ImmutableFeatureFromScratchBuilder result = new ImmutableFeatureFromScratchBuilder();
  if (jsonObject.isNull()) {
    result.isFeatureValueJsonNull = true;
  } else {
    result.definition(jsonObject.getValue(Feature.JsonFields.DEFINITION)
        .map(ThingsModelFactory::newFeatureDefinition)
        .orElse(null));
    result.properties(jsonObject.getValue(Feature.JsonFields.PROPERTIES)
        .map(ThingsModelFactory::newFeatureProperties)
        .orElse(null));
  }
  return result;
}

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

@Override
public FromScratch setFeatures(final JsonObject featuresJsonObject) {
  checkNotNull(featuresJsonObject, "JSON object representation of Features to be set");
  if (featuresJsonObject.isNull()) {
    return setNullFeatures();
  }
  return setFeatures(ThingsModelFactory.newFeatures(featuresJsonObject));
}

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

@Override
public FromScratch setFeatures(final JsonObject featuresJsonObject) {
  checkNotNull(featuresJsonObject, "JSON object representation of Features to be set");
  if (featuresJsonObject.isNull()) {
    return setNullFeatures();
  }
  return setFeatures(ThingsModelFactory.newFeatures(featuresJsonObject));
}

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

/**
 * @param jsonFields the json fields to create a new JsonObject from.
 * @return a null object if {@code jsonFields} is a null json object. Else this returns a new object containing the
 * given {code jsonFields}.
 */
public static JsonObject newObject(final Iterable<JsonField> jsonFields) {
  if (jsonFields instanceof JsonObject && ((JsonObject) jsonFields).isNull()) {
    return JsonFactory.nullObject();
  } else {
    return JsonFactory.newObjectBuilder()
        .setAll(jsonFields)
        .build();
  }
}

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

@SuppressWarnings("unchecked")
JsonObject buildJsonView(final Iterable<JsonField> jsonFields, final Set<String> subjectIds,
    final Permissions permissions) {
  final PolicyTrie defaultPolicyTrie = new PolicyTrie(grantRevokeIndex, Collections.emptyMap());
  if (jsonFields instanceof JsonObject && ((JsonObject) jsonFields).isNull()) {
    return (JsonObject) jsonFields;
  }
  final JsonObjectBuilder outputObjectBuilder = JsonFactory.newObjectBuilder();
  for (final JsonField field : jsonFields) {
    final JsonValue jsonView = getViewForJsonFieldOrNull(field, defaultPolicyTrie, subjectIds, permissions);
    if (null != jsonView) {
      final Optional<JsonFieldDefinition> definitionOptional = field.getDefinition();
      if (definitionOptional.isPresent()) {
        outputObjectBuilder.set(definitionOptional.get(), jsonView);
      } else {
        outputObjectBuilder.set(field.getKey(), jsonView);
      }
    }
  }
  return outputObjectBuilder.build();
}

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

@Override
public FromScratch setAttributes(final JsonObject attributesJsonObject) {
  checkNotNull(attributesJsonObject, "JSON object representation of Attributes to be set");
  if (attributesJsonObject.isNull()) {
    return setNullAttributes();
  } else if (attributesJsonObject.isEmpty()) {
    return setEmptyAttributes();
  }
  return setAttributes(ThingsModelFactory.newAttributes(attributesJsonObject));
}

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

@Override
public FromScratch setAttributes(final JsonObject attributesJsonObject) {
  checkNotNull(attributesJsonObject, "JSON object representation of Attributes to be set");
  if (attributesJsonObject.isNull()) {
    return setNullAttributes();
  } else if (attributesJsonObject.isEmpty()) {
    return setEmptyAttributes();
  }
  return setAttributes(ThingsModelFactory.newAttributes(attributesJsonObject));
}

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

/**
 * Creates a response to a {@link ModifyAttributes} command from a JSON object.
 *
 * @param jsonObject the JSON object of which the response is to be created.
 * @param dittoHeaders the headers of the preceding command.
 * @return the response.
 * @throws NullPointerException if {@code jsonObject} is {@code null}.
 * @throws org.eclipse.ditto.json.JsonParseException if the passed in {@code jsonObject} was not in the expected
 * format.
 */
public static ModifyAttributesResponse fromJson(final JsonObject jsonObject, final DittoHeaders dittoHeaders) {
  return new CommandResponseJsonDeserializer<ModifyAttributesResponse>(TYPE, jsonObject).deserialize(
      statusCode -> {
        final String thingId =
            jsonObject.getValueOrThrow(ThingModifyCommandResponse.JsonFields.JSON_THING_ID);
        final JsonObject attributesJsonObject = jsonObject.getValueOrThrow(JSON_ATTRIBUTES);
        final Attributes extractedAttributes = (!attributesJsonObject.isNull())
            ? ThingsModelFactory.newAttributes(attributesJsonObject)
            : ThingsModelFactory.nullAttributes();
        return new ModifyAttributesResponse(thingId, statusCode, extractedAttributes, dittoHeaders);
      });
}

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

/**
 * Creates a new {@code FeaturesCreated} from a JSON object.
 *
 * @param jsonObject the JSON object from which a new FeaturesCreated instance is to be created.
 * @param dittoHeaders the headers of the command which was the cause of this event.
 * @return the {@code FeaturesCreated} which was created from the given JSON object.
 * @throws NullPointerException if any argument is {@code null}.
 * @throws org.eclipse.ditto.json.JsonParseException if the passed in {@code jsonObject} was not in the expected
 * 'FeaturesCreated' format.
 */
public static FeaturesCreated fromJson(final JsonObject jsonObject, final DittoHeaders dittoHeaders) {
  return new EventJsonDeserializer<FeaturesCreated>(TYPE, jsonObject).deserialize((revision, timestamp) -> {
    final String extractedThingId = jsonObject.getValueOrThrow(JsonFields.THING_ID);
    final JsonObject featuresJsonObject = jsonObject.getValueOrThrow(JSON_FEATURES);
    final Features extractedFeatures = (null != featuresJsonObject && !featuresJsonObject.isNull())
        ? ThingsModelFactory.newFeatures(featuresJsonObject)
        : ThingsModelFactory.nullFeatures();
    return of(extractedThingId, extractedFeatures, revision, timestamp, dittoHeaders);
  });
}

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

/**
 * Creates a new {@code FeatureCreated} from a JSON object.
 *
 * @param jsonObject the JSON object from which a new FeatureCreated instance is to be created.
 * @param dittoHeaders the headers of the command which was the cause of this event.
 * @return the {@code FeatureCreated} which was created from the given JSON object.
 * @throws NullPointerException if {@code jsonObject} is {@code null}.
 * @throws org.eclipse.ditto.json.JsonParseException if the passed in {@code jsonObject} was not in the expected
 * 'FeatureCreated' format.
 */
public static FeatureCreated fromJson(final JsonObject jsonObject, final DittoHeaders dittoHeaders) {
  return new EventJsonDeserializer<FeatureCreated>(TYPE, jsonObject).deserialize((revision, timestamp) -> {
    final String extractedThingId = jsonObject.getValueOrThrow(JsonFields.THING_ID);
    final String extractedFeatureId = jsonObject.getValueOrThrow(JsonFields.FEATURE_ID);
    final JsonObject featureJsonObject = jsonObject.getValueOrThrow(JSON_FEATURE);
    final Feature extractedFeature = !featureJsonObject.isNull()
        ? ThingsModelFactory.newFeatureBuilder(featureJsonObject).useId(extractedFeatureId).build()
        : ThingsModelFactory.nullFeature(extractedFeatureId);
    return of(extractedThingId, extractedFeature, revision, timestamp, dittoHeaders);
  });
}

相关文章