class ModifyFeaturesStrategy extends AbstractThingCommandStrategy<ModifyFeatures> {

    @Override
    protected Result<ThingEvent> doApply(final Context<ThingId> context,
            @Nullable final Thing thing,
            final long nextRevision,
            final ModifyFeatures command,
            @Nullable final Metadata metadata) {

        final Thing nonNullThing = getEntityOrThrow(thing);

        final JsonObject thingWithoutFeaturesJsonObject = nonNullThing.removeFeatures().toJson();
        final JsonObject featuresJsonObject = command.getFeatures().toJson();

        ThingCommandSizeValidator.getInstance().ensureValidSize(
                () -> {
                    final long lengthWithOutFeatures = thingWithoutFeaturesJsonObject.getUpperBoundForStringSize();
                    final long featuresLength = featuresJsonObject.getUpperBoundForStringSize() + "features".length() + 5L;
                    return lengthWithOutFeatures + featuresLength;
                },
                () -> {
                    final long lengthWithOutFeatures = thingWithoutFeaturesJsonObject.toString().length();
                    final long featuresLength = featuresJsonObject.toString().length() + "features".length() + 5L;
                    return lengthWithOutFeatures + featuresLength;
                },
                command::getDittoHeaders);

        return nonNullThing.getFeatures()
                .map(features -> getModifyResult(context, nextRevision, command, thing, metadata))
                .orElseGet(() -> getCreateResult(context, nextRevision, command, thing, metadata));
    }

      ModifyFeaturesStrategy();

}