@Override public RetrieveFeatureProperty setDittoHeaders(final DittoHeaders dittoHeaders) { return of(thingId, featureId, propertyPointer, dittoHeaders); }
private RetrieveFeaturePropertyLiveCommandImpl(final RetrieveFeatureProperty command) { super(command); featureId = command.getFeatureId(); propertyPointer = command.getPropertyPointer(); }
/** * Returns a Command for retrieving a Feature's Property on a Thing. * * @param thingId the {@code Thing}'s ID whose {@code Feature}'s Property to retrieve. * @param featureId the {@code Feature}'s ID whose Property to retrieve. * @param propertyJsonPointer the JSON pointer of the Property key to retrieve. * @param dittoHeaders the headers of the command. * @return a Command for retrieving the Property at the specified Pointer. * @throws NullPointerException if any argument but {@code thingId} is {@code null}. * @throws org.eclipse.ditto.model.things.ThingIdInvalidException if the parsed thing ID did not comply to {@link * org.eclipse.ditto.model.things.Thing#ID_REGEX}. */ public static RetrieveFeatureProperty of(final String thingId, final String featureId, final JsonPointer propertyJsonPointer, final DittoHeaders dittoHeaders) { return new RetrieveFeatureProperty(thingId, featureId, propertyJsonPointer, dittoHeaders); }
private Result getRetrieveFeaturePropertyResult(final JsonObject featureProperties, final Context context, final RetrieveFeatureProperty command, @Nullable final Thing thing) { final String featureId = command.getFeatureId(); final JsonPointer propertyPointer = command.getPropertyPointer(); final DittoHeaders dittoHeaders = command.getDittoHeaders(); return featureProperties.getValue(propertyPointer) .map(featureProperty -> RetrieveFeaturePropertyResponse.of(context.getThingId(), featureId, propertyPointer, featureProperty, dittoHeaders)) .map(response -> ResultFactory.newQueryResult(command, thing, response, this)) .orElseGet(() -> ResultFactory.newErrorResult( ExceptionFactory.featurePropertyNotFound(context.getThingId(), featureId, propertyPointer, dittoHeaders))); }
@Override protected Result doApply(final Context context, @Nullable final Thing thing, final long nextRevision, final RetrieveFeatureProperty command) { final String featureId = command.getFeatureId(); return extractFeature(command, thing) .map(feature -> getRetrieveFeaturePropertyResult(feature, context, command, thing)) .orElseGet(() -> ResultFactory.newErrorResult(ExceptionFactory.featureNotFound(context.getThingId(), featureId, command.getDittoHeaders()))); }
@Override public Optional<JsonValue> determineETagEntity(final RetrieveFeatureProperty command, @Nullable final Thing thing) { return extractFeature(command, thing) .flatMap(Feature::getProperties) .flatMap(featureProperties -> featureProperties.getValue(command.getPropertyPointer())); } }
private Optional<Feature> extractFeature(final RetrieveFeatureProperty command, final @Nullable Thing thing) { return getThingOrThrow(thing).getFeatures() .flatMap(features -> features.getFeature(command.getFeatureId())); }
@SuppressWarnings("squid:MethodCyclomaticComplexity") @Override public boolean equals(@Nullable final Object obj) { if (this == obj) { return true; } if (obj == null || getClass() != obj.getClass()) { return false; } final RetrieveFeatureProperty that = (RetrieveFeatureProperty) obj; return that.canEqual(this) && Objects.equals(thingId, that.thingId) && Objects.equals(featureId, that.featureId) && Objects.equals(propertyPointer, that.propertyPointer) && super.equals(that); }
private Result getRetrieveFeaturePropertyResult(final Feature feature, final Context context, final RetrieveFeatureProperty command, @Nullable final Thing thing) { return feature.getProperties() .map(featureProperties -> getRetrieveFeaturePropertyResult(featureProperties, context, command, thing)) .orElseGet(() -> ResultFactory.newErrorResult( ExceptionFactory.featurePropertiesNotFound(context.getThingId(), feature.getId(), command.getDittoHeaders()))); }
/** * Creates a new {@code RetrieveFeatureProperty} from a JSON string. * * @param jsonString the JSON string of which the command is to be created. * @param dittoHeaders the headers of the command. * @return the command. * @throws NullPointerException if any argument is {@code null}. * @throws IllegalArgumentException if {@code jsonString} is empty. * @throws org.eclipse.ditto.json.JsonParseException if the passed in {@code jsonString} was not in the expected * format. * @throws org.eclipse.ditto.model.things.ThingIdInvalidException if the parsed thing ID did not comply to {@link * org.eclipse.ditto.model.things.Thing#ID_REGEX}. */ public static RetrieveFeatureProperty fromJson(final String jsonString, final DittoHeaders dittoHeaders) { return fromJson(JsonFactory.newObject(jsonString), dittoHeaders); }
private Result getRetrieveFeaturePropertyResult(final JsonObject featureProperties, final Context context, final RetrieveFeatureProperty command, @Nullable final Thing thing) { final String featureId = command.getFeatureId(); final JsonPointer propertyPointer = command.getPropertyPointer(); final DittoHeaders dittoHeaders = command.getDittoHeaders(); return featureProperties.getValue(propertyPointer) .map(featureProperty -> RetrieveFeaturePropertyResponse.of(context.getThingId(), featureId, propertyPointer, featureProperty, dittoHeaders)) .map(response -> ResultFactory.newQueryResult(command, thing, response, this)) .orElseGet(() -> ResultFactory.newErrorResult( ExceptionFactory.featurePropertyNotFound(context.getThingId(), featureId, propertyPointer, dittoHeaders))); }
@Override protected Result doApply(final Context context, @Nullable final Thing thing, final long nextRevision, final RetrieveFeatureProperty command) { final String featureId = command.getFeatureId(); return extractFeature(command, thing) .map(feature -> getRetrieveFeaturePropertyResult(feature, context, command, thing)) .orElseGet(() -> ResultFactory.newErrorResult(ExceptionFactory.featureNotFound(context.getThingId(), featureId, command.getDittoHeaders()))); }
@Override public Optional<JsonValue> determineETagEntity(final RetrieveFeatureProperty command, @Nullable final Thing thing) { return extractFeature(command, thing) .flatMap(Feature::getProperties) .flatMap(featureProperties -> featureProperties.getValue(command.getPropertyPointer())); } }
private Optional<Feature> extractFeature(final RetrieveFeatureProperty command, final @Nullable Thing thing) { return getThingOrThrow(thing).getFeatures() .flatMap(features -> features.getFeature(command.getFeatureId())); }
@SuppressWarnings("squid:MethodCyclomaticComplexity") @Override public boolean equals(@Nullable final Object obj) { if (this == obj) { return true; } if (obj == null || getClass() != obj.getClass()) { return false; } final RetrieveFeatureProperty that = (RetrieveFeatureProperty) obj; return that.canEqual(this) && Objects.equals(thingId, that.thingId) && Objects.equals(featureId, that.featureId) && Objects.equals(propertyPointer, that.propertyPointer) && super.equals(that); }
private Result getRetrieveFeaturePropertyResult(final Feature feature, final Context context, final RetrieveFeatureProperty command, @Nullable final Thing thing) { return feature.getProperties() .map(featureProperties -> getRetrieveFeaturePropertyResult(featureProperties, context, command, thing)) .orElseGet(() -> ResultFactory.newErrorResult( ExceptionFactory.featurePropertiesNotFound(context.getThingId(), feature.getId(), command.getDittoHeaders()))); }
/** * Creates a new {@code RetrieveFeatureProperty} from a JSON string. * * @param jsonString the JSON string of which the command is to be created. * @param dittoHeaders the headers of the command. * @return the command. * @throws NullPointerException if any argument is {@code null}. * @throws IllegalArgumentException if {@code jsonString} is empty. * @throws org.eclipse.ditto.json.JsonParseException if the passed in {@code jsonString} was not in the expected * format. * @throws org.eclipse.ditto.model.things.ThingIdInvalidException if the parsed thing ID did not comply to {@link * org.eclipse.ditto.model.things.Thing#ID_REGEX}. */ public static RetrieveFeatureProperty fromJson(final String jsonString, final DittoHeaders dittoHeaders) { return fromJson(JsonFactory.newObject(jsonString), dittoHeaders); }
@Override public RetrieveFeatureProperty setDittoHeaders(final DittoHeaders dittoHeaders) { return of(thingId, featureId, propertyPointer, dittoHeaders); }
private RetrieveFeaturePropertyLiveCommandImpl(final RetrieveFeatureProperty command) { super(command); featureId = command.getFeatureId(); propertyPointer = command.getPropertyPointer(); }
/** * Returns a Command for retrieving a Feature's Property on a Thing. * * @param thingId the {@code Thing}'s ID whose {@code Feature}'s Property to retrieve. * @param featureId the {@code Feature}'s ID whose Property to retrieve. * @param propertyJsonPointer the JSON pointer of the Property key to retrieve. * @param dittoHeaders the headers of the command. * @return a Command for retrieving the Property at the specified Pointer. * @throws NullPointerException if any argument but {@code thingId} is {@code null}. * @throws org.eclipse.ditto.model.things.ThingIdInvalidException if the parsed thing ID did not comply to {@link * org.eclipse.ditto.model.things.Thing#ID_REGEX}. */ public static RetrieveFeatureProperty of(final String thingId, final String featureId, final JsonPointer propertyJsonPointer, final DittoHeaders dittoHeaders) { return new RetrieveFeatureProperty(thingId, featureId, propertyJsonPointer, dittoHeaders); }