diff --git a/services/connectivity/messaging/src/main/java/org/eclipse/ditto/services/connectivity/messaging/persistence/ConnectionPersistenceActor.java b/services/connectivity/messaging/src/main/java/org/eclipse/ditto/services/connectivity/messaging/persistence/ConnectionPersistenceActor.java index afc86845df..e1d3dc8ddf 100644 --- a/services/connectivity/messaging/src/main/java/org/eclipse/ditto/services/connectivity/messaging/persistence/ConnectionPersistenceActor.java +++ b/services/connectivity/messaging/src/main/java/org/eclipse/ditto/services/connectivity/messaging/persistence/ConnectionPersistenceActor.java @@ -116,8 +116,8 @@ * remote server is delegated to a child actor that uses a specific client (AMQP 1.0 or 0.9.1). */ public final class ConnectionPersistenceActor - extends AbstractShardedPersistenceActor { + extends AbstractShardedPersistenceActor, Connection, ConnectionId, ConnectionState, + ConnectivityEvent> { /** * Prefix to prepend to the connection ID to construct the persistence ID. @@ -254,7 +254,7 @@ public String snapshotPluginId() { } @Override - protected Class getEventClass() { + protected Class getEventClass() { return ConnectivityEvent.class; } @@ -274,7 +274,7 @@ protected ConnectionDeletedStrategies getDeletedStrategy() { } @Override - protected EventStrategy getEventStrategy() { + protected EventStrategy, Connection> getEventStrategy() { return ConnectionEventStrategies.getInstance(); } @@ -295,12 +295,12 @@ protected boolean entityExistsAsDeleted() { } @Override - protected DittoRuntimeExceptionBuilder newNotAccessibleExceptionBuilder() { + protected DittoRuntimeExceptionBuilder newNotAccessibleExceptionBuilder() { return ConnectionNotAccessibleException.newBuilder(entityId); } @Override - protected void publishEvent(final ConnectivityEvent event) { + protected void publishEvent(final ConnectivityEvent event) { // Do nothing because nobody subscribes for connectivity events. } @@ -341,8 +341,8 @@ protected void recoveryCompleted(final RecoveryCompleted event) { } @Override - public void onMutation(final Command command, final ConnectivityEvent event, final WithDittoHeaders response, - final boolean becomeCreated, final boolean becomeDeleted) { + public void onMutation(final Command command, final ConnectivityEvent event, + final WithDittoHeaders response, final boolean becomeCreated, final boolean becomeDeleted) { if (command instanceof StagedCommand) { interpretStagedCommand(((StagedCommand) command).withSenderUnlessDefined(getSender())); } else { @@ -381,9 +381,7 @@ private void interpretStagedCommand(final StagedCommand command) { interpretStagedCommand(command.next()); break; case PERSIST_AND_APPLY_EVENT: - persistAndApplyEvent(command.getEvent(), (event, connection) -> { - interpretStagedCommand(command.next()); - }); + persistAndApplyEvent(command.getEvent(), (event, connection) -> interpretStagedCommand(command.next())); break; case SEND_RESPONSE: command.getSender().tell(command.getResponse(), getSelf()); diff --git a/services/connectivity/messaging/src/main/java/org/eclipse/ditto/services/connectivity/messaging/persistence/stages/StagedCommand.java b/services/connectivity/messaging/src/main/java/org/eclipse/ditto/services/connectivity/messaging/persistence/stages/StagedCommand.java index cd15ca94d5..3d53e37cbf 100644 --- a/services/connectivity/messaging/src/main/java/org/eclipse/ditto/services/connectivity/messaging/persistence/stages/StagedCommand.java +++ b/services/connectivity/messaging/src/main/java/org/eclipse/ditto/services/connectivity/messaging/persistence/stages/StagedCommand.java @@ -42,18 +42,18 @@ */ public final class StagedCommand implements ConnectivityCommand, Iterator { - private static final ConnectivityEvent DUMMY_EVENT = + private static final ConnectivityEvent DUMMY_EVENT = ConnectionClosed.of(ConnectionId.dummy(), DittoHeaders.empty()); - private final ConnectivityCommand command; - private final ConnectivityEvent event; - private final WithDittoHeaders response; + private final ConnectivityCommand command; + private final ConnectivityEvent event; + private final WithDittoHeaders response; private final ActorRef sender; private final Collection actions; - private StagedCommand(final ConnectivityCommand command, - final ConnectivityEvent event, - final WithDittoHeaders response, + private StagedCommand(final ConnectivityCommand command, + final ConnectivityEvent event, + final WithDittoHeaders response, final ActorRef sender, final Collection actions) { this.command = command; @@ -72,36 +72,36 @@ private StagedCommand(final ConnectivityCommand command, * @param actions remaining actions. * @return the staged command. */ - public static StagedCommand of(final ConnectivityCommand command, final ConnectivityEvent event, - final WithDittoHeaders response, final List actions) { + public static StagedCommand of(final ConnectivityCommand command, final ConnectivityEvent event, + final WithDittoHeaders response, final List actions) { return new StagedCommand(command, event, response, ActorRef.noSender(), actions); } /** * @return a dummy placeholder event. */ - public static ConnectivityEvent dummyEvent() { + public static ConnectivityEvent dummyEvent() { return DUMMY_EVENT; } /** * @return the wrapped command. */ - public ConnectivityCommand getCommand() { + public ConnectivityCommand getCommand() { return command; } /** * @return the event to persist, apply or publish. */ - public ConnectivityEvent getEvent() { + public ConnectivityEvent getEvent() { return event; } /** * @return the response to send to the original sender, or the signal to forward to client actors. */ - public WithDittoHeaders getResponse() { + public WithDittoHeaders getResponse() { return response; } @@ -132,7 +132,7 @@ public StagedCommand withSenderUnlessDefined(final ActorRef newSender) { * @param response the response. * @return the copy. */ - public StagedCommand withResponse(final WithDittoHeaders response) { + public StagedCommand withResponse(final WithDittoHeaders response) { return new StagedCommand(command, event, response, sender, actions); } diff --git a/services/connectivity/messaging/src/main/java/org/eclipse/ditto/services/connectivity/messaging/persistence/strategies/commands/AbstractConnectivityCommandStrategy.java b/services/connectivity/messaging/src/main/java/org/eclipse/ditto/services/connectivity/messaging/persistence/strategies/commands/AbstractConnectivityCommandStrategy.java index b36a8f378d..722818bffa 100644 --- a/services/connectivity/messaging/src/main/java/org/eclipse/ditto/services/connectivity/messaging/persistence/strategies/commands/AbstractConnectivityCommandStrategy.java +++ b/services/connectivity/messaging/src/main/java/org/eclipse/ditto/services/connectivity/messaging/persistence/strategies/commands/AbstractConnectivityCommandStrategy.java @@ -35,8 +35,8 @@ * * @param the type of the handled command */ -abstract class AbstractConnectivityCommandStrategy - extends AbstractCommandStrategy> { +abstract class AbstractConnectivityCommandStrategy> + extends AbstractCommandStrategy>> { AbstractConnectivityCommandStrategy(final Class theMatchingClass) { super(theMatchingClass); @@ -54,14 +54,14 @@ protected Optional calculateRelativeMetadata(@Nullable final Connectio } ConnectionNotAccessibleException notAccessible(final Context context, - final WithDittoHeaders command) { + final WithDittoHeaders command) { return ConnectionNotAccessibleException.newBuilder(context.getState().id()) .dittoHeaders(command.getDittoHeaders()) .build(); } static Optional validate(final Context context, - final ConnectivityCommand command, final Connection connection) { + final ConnectivityCommand command, final Connection connection) { try { context.getState().getValidator().accept(command, () -> connection); return Optional.empty(); diff --git a/services/connectivity/messaging/src/main/java/org/eclipse/ditto/services/connectivity/messaging/persistence/strategies/commands/AbstractEphemeralStrategy.java b/services/connectivity/messaging/src/main/java/org/eclipse/ditto/services/connectivity/messaging/persistence/strategies/commands/AbstractEphemeralStrategy.java index d3f38b3870..b435c5df85 100644 --- a/services/connectivity/messaging/src/main/java/org/eclipse/ditto/services/connectivity/messaging/persistence/strategies/commands/AbstractEphemeralStrategy.java +++ b/services/connectivity/messaging/src/main/java/org/eclipse/ditto/services/connectivity/messaging/persistence/strategies/commands/AbstractEphemeralStrategy.java @@ -34,26 +34,27 @@ * * @param the type of the handled command */ -abstract class AbstractEphemeralStrategy extends AbstractConnectivityCommandStrategy { +abstract class AbstractEphemeralStrategy> + extends AbstractConnectivityCommandStrategy { AbstractEphemeralStrategy(final Class theMatchingClass) { super(theMatchingClass); } - abstract WithDittoHeaders getResponse(final ConnectionState connectionId, final DittoHeaders headers); + abstract WithDittoHeaders getResponse(final ConnectionState connectionId, final DittoHeaders headers); abstract List getActions(); @Override - protected Result doApply(final Context context, + protected Result> doApply(final Context context, @Nullable final Connection connection, final long nextRevision, final C command, @Nullable final Metadata metadata) { - final ConnectivityEvent event = StagedCommand.dummyEvent(); - final WithDittoHeaders response = getResponse(context.getState(), command.getDittoHeaders()); + final ConnectivityEvent event = StagedCommand.dummyEvent(); + final WithDittoHeaders response = getResponse(context.getState(), command.getDittoHeaders()); final List actions = getActions(); return newMutationResult(StagedCommand.of(command, event, response, actions), event, response); } diff --git a/services/connectivity/messaging/src/main/java/org/eclipse/ditto/services/connectivity/messaging/persistence/strategies/commands/AbstractSingleActionStrategy.java b/services/connectivity/messaging/src/main/java/org/eclipse/ditto/services/connectivity/messaging/persistence/strategies/commands/AbstractSingleActionStrategy.java index 25392b1ea4..a887d7b4b8 100644 --- a/services/connectivity/messaging/src/main/java/org/eclipse/ditto/services/connectivity/messaging/persistence/strategies/commands/AbstractSingleActionStrategy.java +++ b/services/connectivity/messaging/src/main/java/org/eclipse/ditto/services/connectivity/messaging/persistence/strategies/commands/AbstractSingleActionStrategy.java @@ -33,7 +33,7 @@ * * @param the type of the handled command */ -abstract class AbstractSingleActionStrategy +abstract class AbstractSingleActionStrategy> extends AbstractConnectivityCommandStrategy { AbstractSingleActionStrategy(final Class theMatchingClass) { @@ -46,13 +46,13 @@ abstract class AbstractSingleActionStrategy abstract ConnectionAction getAction(); @Override - protected Result doApply(final Context context, + protected Result> doApply(final Context context, @Nullable final Connection connection, final long nextRevision, final C command, @Nullable final Metadata metadata) { - final ConnectivityEvent event = StagedCommand.dummyEvent(); + final ConnectivityEvent event = StagedCommand.dummyEvent(); final List actions = Collections.singletonList(getAction()); return newMutationResult(StagedCommand.of(command, event, command, actions), event, command); } diff --git a/services/connectivity/messaging/src/main/java/org/eclipse/ditto/services/connectivity/messaging/persistence/strategies/commands/CloseConnectionStrategy.java b/services/connectivity/messaging/src/main/java/org/eclipse/ditto/services/connectivity/messaging/persistence/strategies/commands/CloseConnectionStrategy.java index 70226f9ba2..f957d9cee8 100644 --- a/services/connectivity/messaging/src/main/java/org/eclipse/ditto/services/connectivity/messaging/persistence/strategies/commands/CloseConnectionStrategy.java +++ b/services/connectivity/messaging/src/main/java/org/eclipse/ditto/services/connectivity/messaging/persistence/strategies/commands/CloseConnectionStrategy.java @@ -46,7 +46,7 @@ final class CloseConnectionStrategy extends AbstractConnectivityCommandStrategy< } @Override - protected Result doApply(final Context context, + protected Result> doApply(final Context context, @Nullable final Connection connection, final long nextRevision, final CloseConnection command, diff --git a/services/connectivity/messaging/src/main/java/org/eclipse/ditto/services/connectivity/messaging/persistence/strategies/commands/ConnectionConflictStrategy.java b/services/connectivity/messaging/src/main/java/org/eclipse/ditto/services/connectivity/messaging/persistence/strategies/commands/ConnectionConflictStrategy.java index 349c13a2ae..039afd9b33 100644 --- a/services/connectivity/messaging/src/main/java/org/eclipse/ditto/services/connectivity/messaging/persistence/strategies/commands/ConnectionConflictStrategy.java +++ b/services/connectivity/messaging/src/main/java/org/eclipse/ditto/services/connectivity/messaging/persistence/strategies/commands/ConnectionConflictStrategy.java @@ -35,7 +35,7 @@ final class ConnectionConflictStrategy extends AbstractConnectivityCommandStrate } @Override - protected Result doApply(final Context context, + protected Result> doApply(final Context context, @Nullable final Connection entity, final long nextRevision, final CreateConnection command, diff --git a/services/connectivity/messaging/src/main/java/org/eclipse/ditto/services/connectivity/messaging/persistence/strategies/commands/ConnectionCreatedStrategies.java b/services/connectivity/messaging/src/main/java/org/eclipse/ditto/services/connectivity/messaging/persistence/strategies/commands/ConnectionCreatedStrategies.java index 87de2db2a2..254fd78615 100644 --- a/services/connectivity/messaging/src/main/java/org/eclipse/ditto/services/connectivity/messaging/persistence/strategies/commands/ConnectionCreatedStrategies.java +++ b/services/connectivity/messaging/src/main/java/org/eclipse/ditto/services/connectivity/messaging/persistence/strategies/commands/ConnectionCreatedStrategies.java @@ -27,7 +27,8 @@ * Strategies to handle signals as an existing connection. */ public class ConnectionCreatedStrategies - extends AbstractCommandStrategies> { + extends + AbstractCommandStrategies, Connection, ConnectionState, Result>> { private static final ConnectionCreatedStrategies CREATED_STRATEGIES = newCreatedStrategies(); @@ -63,16 +64,16 @@ private static ConnectionCreatedStrategies newCreatedStrategies() { } @Override - public boolean isDefined(final ConnectivityCommand command) { + public boolean isDefined(final ConnectivityCommand command) { // always defined so as to forward signals. return true; } @Override - public Result unhandled(final Context context, + public Result> unhandled(final Context context, @Nullable final Connection entity, final long nextRevision, - final ConnectivityCommand command) { + final ConnectivityCommand command) { return ResultFactory.newErrorResult(ConnectionNotAccessibleException .newBuilder(context.getState().id()) @@ -81,7 +82,7 @@ public Result unhandled(final Context contex } @Override - protected Result getEmptyResult() { + protected Result> getEmptyResult() { return ResultFactory.emptyResult(); } diff --git a/services/connectivity/messaging/src/main/java/org/eclipse/ditto/services/connectivity/messaging/persistence/strategies/commands/ConnectionDeletedStrategies.java b/services/connectivity/messaging/src/main/java/org/eclipse/ditto/services/connectivity/messaging/persistence/strategies/commands/ConnectionDeletedStrategies.java index 8a43facf27..2771625425 100644 --- a/services/connectivity/messaging/src/main/java/org/eclipse/ditto/services/connectivity/messaging/persistence/strategies/commands/ConnectionDeletedStrategies.java +++ b/services/connectivity/messaging/src/main/java/org/eclipse/ditto/services/connectivity/messaging/persistence/strategies/commands/ConnectionDeletedStrategies.java @@ -27,7 +27,8 @@ * Strategies to handle signals as a nonexistent connection. */ public class ConnectionDeletedStrategies - extends AbstractCommandStrategies> { + extends + AbstractCommandStrategies, Connection, ConnectionState, Result>> { private static final ConnectionDeletedStrategies DELETED_STRATEGIES = newDeletedStrategies(); @@ -51,10 +52,10 @@ private static ConnectionDeletedStrategies newDeletedStrategies() { } @Override - public Result unhandled(final Context context, + public Result> unhandled(final Context context, @Nullable final Connection entity, final long nextRevision, - final ConnectivityCommand command) { + final ConnectivityCommand command) { context.getLog().withCorrelationId(command) .warning("Received command for deleted connection, rejecting: <{}>", command); @@ -64,13 +65,13 @@ public Result unhandled(final Context contex } @Override - public boolean isDefined(final ConnectivityCommand command) { + public boolean isDefined(final ConnectivityCommand command) { // always defined so as to log ignored signals on debug level. return true; } @Override - protected Result getEmptyResult() { + protected Result> getEmptyResult() { return ResultFactory.emptyResult(); } diff --git a/services/connectivity/messaging/src/main/java/org/eclipse/ditto/services/connectivity/messaging/persistence/strategies/commands/CreateConnectionStrategy.java b/services/connectivity/messaging/src/main/java/org/eclipse/ditto/services/connectivity/messaging/persistence/strategies/commands/CreateConnectionStrategy.java index bfdaf3f54c..b1ded045d5 100644 --- a/services/connectivity/messaging/src/main/java/org/eclipse/ditto/services/connectivity/messaging/persistence/strategies/commands/CreateConnectionStrategy.java +++ b/services/connectivity/messaging/src/main/java/org/eclipse/ditto/services/connectivity/messaging/persistence/strategies/commands/CreateConnectionStrategy.java @@ -51,7 +51,7 @@ final class CreateConnectionStrategy extends AbstractConnectivityCommandStrategy } @Override - protected Result doApply(final Context context, + protected Result> doApply(final Context context, @Nullable final Connection entity, final long nextRevision, final CreateConnection command, diff --git a/services/connectivity/messaging/src/main/java/org/eclipse/ditto/services/connectivity/messaging/persistence/strategies/commands/DeleteConnectionStrategy.java b/services/connectivity/messaging/src/main/java/org/eclipse/ditto/services/connectivity/messaging/persistence/strategies/commands/DeleteConnectionStrategy.java index a5b6da2207..72c8a25b72 100644 --- a/services/connectivity/messaging/src/main/java/org/eclipse/ditto/services/connectivity/messaging/persistence/strategies/commands/DeleteConnectionStrategy.java +++ b/services/connectivity/messaging/src/main/java/org/eclipse/ditto/services/connectivity/messaging/persistence/strategies/commands/DeleteConnectionStrategy.java @@ -47,7 +47,7 @@ final class DeleteConnectionStrategy extends AbstractConnectivityCommandStrategy } @Override - protected Result doApply(final Context context, + protected Result> doApply(final Context context, @Nullable final Connection connection, final long nextRevision, final DeleteConnection command, diff --git a/services/connectivity/messaging/src/main/java/org/eclipse/ditto/services/connectivity/messaging/persistence/strategies/commands/ModifyConnectionStrategy.java b/services/connectivity/messaging/src/main/java/org/eclipse/ditto/services/connectivity/messaging/persistence/strategies/commands/ModifyConnectionStrategy.java index b1f0dbd6cf..d3088febf1 100644 --- a/services/connectivity/messaging/src/main/java/org/eclipse/ditto/services/connectivity/messaging/persistence/strategies/commands/ModifyConnectionStrategy.java +++ b/services/connectivity/messaging/src/main/java/org/eclipse/ditto/services/connectivity/messaging/persistence/strategies/commands/ModifyConnectionStrategy.java @@ -54,7 +54,7 @@ final class ModifyConnectionStrategy extends AbstractConnectivityCommandStrategy } @Override - protected Result doApply(final Context context, + protected Result> doApply(final Context context, @Nullable final Connection entity, final long nextRevision, final ModifyConnection command, diff --git a/services/connectivity/messaging/src/main/java/org/eclipse/ditto/services/connectivity/messaging/persistence/strategies/commands/OpenConnectionStrategy.java b/services/connectivity/messaging/src/main/java/org/eclipse/ditto/services/connectivity/messaging/persistence/strategies/commands/OpenConnectionStrategy.java index 2b3fd1efdf..890eca1f11 100644 --- a/services/connectivity/messaging/src/main/java/org/eclipse/ditto/services/connectivity/messaging/persistence/strategies/commands/OpenConnectionStrategy.java +++ b/services/connectivity/messaging/src/main/java/org/eclipse/ditto/services/connectivity/messaging/persistence/strategies/commands/OpenConnectionStrategy.java @@ -48,7 +48,7 @@ final class OpenConnectionStrategy extends AbstractConnectivityCommandStrategy doApply(final Context context, + protected Result> doApply(final Context context, @Nullable final Connection connection, final long nextRevision, final OpenConnection command, diff --git a/services/connectivity/messaging/src/main/java/org/eclipse/ditto/services/connectivity/messaging/persistence/strategies/commands/RetrieveConnectionStrategy.java b/services/connectivity/messaging/src/main/java/org/eclipse/ditto/services/connectivity/messaging/persistence/strategies/commands/RetrieveConnectionStrategy.java index d8bb7c4d2b..10c178870c 100644 --- a/services/connectivity/messaging/src/main/java/org/eclipse/ditto/services/connectivity/messaging/persistence/strategies/commands/RetrieveConnectionStrategy.java +++ b/services/connectivity/messaging/src/main/java/org/eclipse/ditto/services/connectivity/messaging/persistence/strategies/commands/RetrieveConnectionStrategy.java @@ -33,7 +33,7 @@ final class RetrieveConnectionStrategy extends AbstractConnectivityCommandStrate } @Override - protected Result doApply(final Context context, + protected Result> doApply(final Context context, @Nullable final Connection entity, final long nextRevision, final RetrieveConnection command, diff --git a/services/connectivity/messaging/src/main/java/org/eclipse/ditto/services/connectivity/messaging/persistence/strategies/commands/StagedCommandStrategy.java b/services/connectivity/messaging/src/main/java/org/eclipse/ditto/services/connectivity/messaging/persistence/strategies/commands/StagedCommandStrategy.java index 5d354f9cac..3dfa365efa 100644 --- a/services/connectivity/messaging/src/main/java/org/eclipse/ditto/services/connectivity/messaging/persistence/strategies/commands/StagedCommandStrategy.java +++ b/services/connectivity/messaging/src/main/java/org/eclipse/ditto/services/connectivity/messaging/persistence/strategies/commands/StagedCommandStrategy.java @@ -33,7 +33,7 @@ final class StagedCommandStrategy extends AbstractConnectivityCommandStrategy doApply(final Context context, + protected Result> doApply(final Context context, @Nullable final Connection entity, final long nextRevision, final StagedCommand command, diff --git a/services/connectivity/messaging/src/main/java/org/eclipse/ditto/services/connectivity/messaging/persistence/strategies/commands/TestConnectionConflictStrategy.java b/services/connectivity/messaging/src/main/java/org/eclipse/ditto/services/connectivity/messaging/persistence/strategies/commands/TestConnectionConflictStrategy.java index a4700cd672..d45cb3e240 100644 --- a/services/connectivity/messaging/src/main/java/org/eclipse/ditto/services/connectivity/messaging/persistence/strategies/commands/TestConnectionConflictStrategy.java +++ b/services/connectivity/messaging/src/main/java/org/eclipse/ditto/services/connectivity/messaging/persistence/strategies/commands/TestConnectionConflictStrategy.java @@ -35,7 +35,7 @@ final class TestConnectionConflictStrategy extends AbstractConnectivityCommandSt } @Override - protected Result doApply(final Context context, + protected Result> doApply(final Context context, @Nullable final Connection entity, final long nextRevision, final TestConnection command, diff --git a/services/connectivity/messaging/src/main/java/org/eclipse/ditto/services/connectivity/messaging/persistence/strategies/commands/TestConnectionStrategy.java b/services/connectivity/messaging/src/main/java/org/eclipse/ditto/services/connectivity/messaging/persistence/strategies/commands/TestConnectionStrategy.java index e71ed7e2c6..a85ce36d5c 100644 --- a/services/connectivity/messaging/src/main/java/org/eclipse/ditto/services/connectivity/messaging/persistence/strategies/commands/TestConnectionStrategy.java +++ b/services/connectivity/messaging/src/main/java/org/eclipse/ditto/services/connectivity/messaging/persistence/strategies/commands/TestConnectionStrategy.java @@ -48,7 +48,7 @@ final class TestConnectionStrategy extends AbstractConnectivityCommandStrategy doApply(final Context context, + protected Result> doApply(final Context context, @Nullable final Connection entity, final long nextRevision, final TestConnection command, diff --git a/services/connectivity/messaging/src/main/java/org/eclipse/ditto/services/connectivity/messaging/persistence/strategies/events/ConnectionEventStrategies.java b/services/connectivity/messaging/src/main/java/org/eclipse/ditto/services/connectivity/messaging/persistence/strategies/events/ConnectionEventStrategies.java index 01c44ada84..e2edfbcd39 100644 --- a/services/connectivity/messaging/src/main/java/org/eclipse/ditto/services/connectivity/messaging/persistence/strategies/events/ConnectionEventStrategies.java +++ b/services/connectivity/messaging/src/main/java/org/eclipse/ditto/services/connectivity/messaging/persistence/strategies/events/ConnectionEventStrategies.java @@ -24,7 +24,7 @@ /** * Strategies to modify a connection by events. */ -public final class ConnectionEventStrategies extends AbstractEventStrategies { +public final class ConnectionEventStrategies extends AbstractEventStrategies, Connection> { private static final ConnectionEventStrategies INSTANCE = new ConnectionEventStrategies(); diff --git a/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/PolicyPersistenceActor.java b/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/PolicyPersistenceActor.java index 838fc8ac0e..0bbf295c07 100755 --- a/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/PolicyPersistenceActor.java +++ b/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/PolicyPersistenceActor.java @@ -64,7 +64,7 @@ * PersistentActor which "knows" the state of a single {@link Policy}. */ public final class PolicyPersistenceActor - extends AbstractShardedPersistenceActor { + extends AbstractShardedPersistenceActor, Policy, PolicyId, PolicyId, PolicyEvent> { /** * The prefix of the persistenceId for Policies. @@ -128,7 +128,7 @@ public String snapshotPluginId() { } @Override - protected Class getEventClass() { + protected Class getEventClass() { return PolicyEvent.class; } @@ -143,12 +143,12 @@ protected PolicyCommandStrategies getCreatedStrategy() { } @Override - protected CommandStrategy> getDeletedStrategy() { + protected CommandStrategy, Policy, PolicyId, Result>> getDeletedStrategy() { return PolicyCommandStrategies.getCreatePolicyStrategy(policyConfig); } @Override - protected EventStrategy getEventStrategy() { + protected EventStrategy, Policy> getEventStrategy() { return PolicyEventStrategies.getInstance(); } @@ -168,12 +168,12 @@ protected boolean entityExistsAsDeleted() { } @Override - protected DittoRuntimeExceptionBuilder newNotAccessibleExceptionBuilder() { + protected DittoRuntimeExceptionBuilder newNotAccessibleExceptionBuilder() { return PolicyNotAccessibleException.newBuilder(entityId); } @Override - protected void publishEvent(final PolicyEvent event) { + protected void publishEvent(final PolicyEvent event) { pubSubMediator.tell(DistPubSubAccess.publishViaGroup(PolicyEvent.TYPE_PREFIX, event), getSender()); final boolean policyEnforcerInvalidatedPreemptively = Boolean.parseBoolean(event.getDittoHeaders() diff --git a/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/AbstractPolicyCommandStrategy.java b/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/AbstractPolicyCommandStrategy.java index d925bafb32..efca2f0e5e 100644 --- a/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/AbstractPolicyCommandStrategy.java +++ b/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/AbstractPolicyCommandStrategy.java @@ -60,7 +60,7 @@ * {@link org.eclipse.ditto.services.models.policies.commands.sudo.SudoCommand} are handled which are no PolicyCommands. */ abstract class AbstractPolicyCommandStrategy> - extends AbstractConditionHeaderCheckingCommandStrategy { + extends AbstractConditionHeaderCheckingCommandStrategy> { static SubjectType TOKEN_INTEGRATION = PoliciesModelFactory.newSubjectType("actions/activateTokenIntegration"); @@ -239,7 +239,7 @@ protected SubjectExpiry roundPolicySubjectExpiry(final SubjectExpiry expiry) { * @param command the command which caused the change of the policy entries. * @return an Optional with ErrorResponse if a subject was invalid, an empty Optional if everything was valid. */ - protected static Optional> checkForAlreadyExpiredSubject(final Iterable entries, + protected static Optional>> checkForAlreadyExpiredSubject(final Iterable entries, final DittoHeaders dittoHeaders, final Command command) { return StreamSupport.stream(entries.spliterator(), false) diff --git a/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/ActivateSubjectStrategy.java b/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/ActivateSubjectStrategy.java index fb291a219f..0950daa192 100644 --- a/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/ActivateSubjectStrategy.java +++ b/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/ActivateSubjectStrategy.java @@ -50,7 +50,7 @@ final class ActivateSubjectStrategy extends AbstractPolicyCommandStrategy doApply(final Context context, + protected Result> doApply(final Context context, @Nullable final Policy policy, final long nextRevision, final ActivateSubject command, diff --git a/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/ActivateSubjectsStrategy.java b/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/ActivateSubjectsStrategy.java index dcd7a2aa9a..d47c115c1a 100644 --- a/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/ActivateSubjectsStrategy.java +++ b/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/ActivateSubjectsStrategy.java @@ -55,7 +55,7 @@ final class ActivateSubjectsStrategy extends AbstractPolicyCommandStrategy doApply(final Context context, + protected Result> doApply(final Context context, @Nullable final Policy policy, final long nextRevision, final ActivateSubjects command, diff --git a/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/CreatePolicyStrategy.java b/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/CreatePolicyStrategy.java index 2aeb9d4c14..d1d1f2f183 100644 --- a/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/CreatePolicyStrategy.java +++ b/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/CreatePolicyStrategy.java @@ -48,7 +48,7 @@ final class CreatePolicyStrategy extends AbstractPolicyCommandStrategy doApply(final Context context, + protected Result> doApply(final Context context, @Nullable final Policy entity, final long nextRevision, final CreatePolicy command, @@ -69,7 +69,7 @@ protected Result doApply(final Context context, } final Policy newPolicyWithLifecycle = newPolicyBuilder.build(); - final Optional> alreadyExpiredSubject = + final Optional>> alreadyExpiredSubject = checkForAlreadyExpiredSubject(newPolicyWithLifecycle, dittoHeaders, command); if (alreadyExpiredSubject.isPresent()) { return alreadyExpiredSubject.get(); diff --git a/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/DeletePolicyEntryStrategy.java b/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/DeletePolicyEntryStrategy.java index 8d8d32f312..d338f659a9 100644 --- a/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/DeletePolicyEntryStrategy.java +++ b/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/DeletePolicyEntryStrategy.java @@ -45,7 +45,7 @@ final class DeletePolicyEntryStrategy extends AbstractPolicyCommandStrategy doApply(final Context context, + protected Result> doApply(final Context context, @Nullable final Policy policy, final long nextRevision, final DeletePolicyEntry command, diff --git a/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/DeletePolicyStrategy.java b/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/DeletePolicyStrategy.java index 5b295435c1..f9e4ff2d7b 100644 --- a/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/DeletePolicyStrategy.java +++ b/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/DeletePolicyStrategy.java @@ -40,7 +40,7 @@ final class DeletePolicyStrategy extends AbstractPolicyCommandStrategy doApply(final Context context, + protected Result> doApply(final Context context, @Nullable final Policy entity, final long nextRevision, final DeletePolicy command, diff --git a/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/DeleteResourceStrategy.java b/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/DeleteResourceStrategy.java index fb27315ab7..8fb4c7fb62 100644 --- a/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/DeleteResourceStrategy.java +++ b/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/DeleteResourceStrategy.java @@ -46,7 +46,7 @@ final class DeleteResourceStrategy extends AbstractPolicyCommandStrategy doApply(final Context context, + protected Result> doApply(final Context context, @Nullable final Policy policy, final long nextRevision, final DeleteResource command, diff --git a/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/DeleteSubjectStrategy.java b/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/DeleteSubjectStrategy.java index 5e317362c2..560725e4e7 100644 --- a/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/DeleteSubjectStrategy.java +++ b/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/DeleteSubjectStrategy.java @@ -46,7 +46,7 @@ final class DeleteSubjectStrategy extends AbstractPolicyCommandStrategy doApply(final Context context, + protected Result> doApply(final Context context, @Nullable final Policy policy, final long nextRevision, final DeleteSubject command, diff --git a/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/ModifyPolicyEntriesStrategy.java b/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/ModifyPolicyEntriesStrategy.java index e86ecd1a39..333b5ca7cd 100644 --- a/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/ModifyPolicyEntriesStrategy.java +++ b/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/ModifyPolicyEntriesStrategy.java @@ -53,7 +53,7 @@ final class ModifyPolicyEntriesStrategy extends AbstractPolicyCommandStrategy doApply(final Context context, + protected Result> doApply(final Context context, @Nullable final Policy entity, final long nextRevision, final ModifyPolicyEntries command, @@ -79,7 +79,7 @@ protected Result doApply(final Context context, final ModifyPolicyEntries adjustedCommand = ModifyPolicyEntries.of(command.getEntityId(), adjustedEntries, dittoHeaders); - final Optional> alreadyExpiredSubject = + final Optional>> alreadyExpiredSubject = checkForAlreadyExpiredSubject(policyEntries, dittoHeaders, command); if (alreadyExpiredSubject.isPresent()) { return alreadyExpiredSubject.get(); diff --git a/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/ModifyPolicyEntryStrategy.java b/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/ModifyPolicyEntryStrategy.java index de4674b608..4ca16dba44 100644 --- a/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/ModifyPolicyEntryStrategy.java +++ b/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/ModifyPolicyEntryStrategy.java @@ -51,7 +51,7 @@ final class ModifyPolicyEntryStrategy extends AbstractPolicyCommandStrategy doApply(final Context context, + protected Result> doApply(final Context context, @Nullable final Policy policy, final long nextRevision, final ModifyPolicyEntry command, @@ -90,7 +90,7 @@ protected Result doApply(final Context context, dittoHeaders); final Policy newPolicy = nonNullPolicy.setEntry(adjustedPolicyEntry); - final Optional> alreadyExpiredSubject = + final Optional>> alreadyExpiredSubject = checkForAlreadyExpiredSubject(newPolicy, dittoHeaders, command); if (alreadyExpiredSubject.isPresent()) { return alreadyExpiredSubject.get(); diff --git a/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/ModifyPolicyStrategy.java b/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/ModifyPolicyStrategy.java index 196c408d76..490f81de7e 100644 --- a/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/ModifyPolicyStrategy.java +++ b/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/ModifyPolicyStrategy.java @@ -49,7 +49,7 @@ final class ModifyPolicyStrategy extends AbstractPolicyCommandStrategy doApply(final Context context, + protected Result> doApply(final Context context, @Nullable final Policy entity, final long nextRevision, final ModifyPolicy command, @@ -79,7 +79,7 @@ protected Result doApply(final Context context, return ResultFactory.newErrorResult(e, adjustedCommand); } - final Optional> alreadyExpiredSubject = + final Optional>> alreadyExpiredSubject = checkForAlreadyExpiredSubject(modifiedPolicyWithImplicits, dittoHeaders, command); if (alreadyExpiredSubject.isPresent()) { return alreadyExpiredSubject.get(); diff --git a/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/ModifyResourceStrategy.java b/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/ModifyResourceStrategy.java index ca5e354fa4..f71b0c1c4f 100644 --- a/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/ModifyResourceStrategy.java +++ b/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/ModifyResourceStrategy.java @@ -46,7 +46,7 @@ final class ModifyResourceStrategy extends AbstractPolicyCommandStrategy doApply(final Context context, + protected Result> doApply(final Context context, @Nullable final Policy policy, final long nextRevision, final ModifyResource command, diff --git a/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/ModifyResourcesStrategy.java b/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/ModifyResourcesStrategy.java index 3704b7819e..551140db21 100644 --- a/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/ModifyResourcesStrategy.java +++ b/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/ModifyResourcesStrategy.java @@ -53,7 +53,7 @@ final class ModifyResourcesStrategy extends AbstractPolicyCommandStrategy doApply(final Context context, + protected Result> doApply(final Context context, @Nullable final Policy policy, final long nextRevision, final ModifyResources command, diff --git a/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/ModifySubjectStrategy.java b/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/ModifySubjectStrategy.java index b12b5ed511..541eeae69c 100644 --- a/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/ModifySubjectStrategy.java +++ b/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/ModifySubjectStrategy.java @@ -46,7 +46,7 @@ final class ModifySubjectStrategy extends AbstractPolicyCommandStrategy doApply(final Context context, + protected Result> doApply(final Context context, @Nullable final Policy policy, final long nextRevision, final ModifySubject command, @@ -67,7 +67,7 @@ protected Result doApply(final Context context, final Policy newPolicy = nonNullPolicy.setSubjectFor(label, adjustedSubject); - final Optional> alreadyExpiredSubject = + final Optional>> alreadyExpiredSubject = checkForAlreadyExpiredSubject(newPolicy, dittoHeaders, command); if (alreadyExpiredSubject.isPresent()) { return alreadyExpiredSubject.get(); diff --git a/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/ModifySubjectsStrategy.java b/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/ModifySubjectsStrategy.java index dde7434098..75a8118ccc 100644 --- a/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/ModifySubjectsStrategy.java +++ b/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/ModifySubjectsStrategy.java @@ -50,7 +50,7 @@ final class ModifySubjectsStrategy extends AbstractPolicyCommandStrategy doApply(final Context context, + protected Result> doApply(final Context context, @Nullable final Policy policy, final long nextRevision, final ModifySubjects command, @@ -69,7 +69,7 @@ protected Result doApply(final Context context, final Policy newPolicy = nonNullPolicy.setSubjectsFor(label, adjustedSubjects); - final Optional> alreadyExpiredSubject = + final Optional>> alreadyExpiredSubject = checkForAlreadyExpiredSubject(newPolicy, dittoHeaders, command); if (alreadyExpiredSubject.isPresent()) { return alreadyExpiredSubject.get(); diff --git a/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/PolicyCommandStrategies.java b/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/PolicyCommandStrategies.java index bdb3acfecc..cbdffc3ff3 100755 --- a/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/PolicyCommandStrategies.java +++ b/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/PolicyCommandStrategies.java @@ -29,7 +29,7 @@ * Command strategies of {@code PolicyPersistenceActor}. */ public final class PolicyCommandStrategies - extends AbstractCommandStrategies> { + extends AbstractCommandStrategies, Policy, PolicyId, Result>> { @Nullable private static volatile PolicyCommandStrategies instance; @Nullable private static volatile CreatePolicyStrategy createPolicyStrategy; @@ -94,7 +94,7 @@ public static PolicyCommandStrategies getInstance(final PolicyConfig policyConfi * @param policyConfig the PolicyConfig of the Policy service to apply. * @return command strategy to create a policy. */ - public static CommandStrategy> getCreatePolicyStrategy( + public static CommandStrategy>> getCreatePolicyStrategy( final PolicyConfig policyConfig) { CreatePolicyStrategy localCreatePolicyStrategy = createPolicyStrategy; if (null == localCreatePolicyStrategy) { @@ -109,7 +109,7 @@ public static CommandStrategy getEmptyResult() { + protected Result> getEmptyResult() { return ResultFactory.emptyResult(); } diff --git a/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/PolicyConflictStrategy.java b/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/PolicyConflictStrategy.java index b3dca71907..f45111e13c 100644 --- a/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/PolicyConflictStrategy.java +++ b/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/PolicyConflictStrategy.java @@ -38,7 +38,7 @@ final class PolicyConflictStrategy extends AbstractPolicyCommandStrategy doApply(final Context context, + protected Result> doApply(final Context context, @Nullable final Policy entity, final long nextRevision, final CreatePolicy command, diff --git a/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/RetrievePolicyEntriesStrategy.java b/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/RetrievePolicyEntriesStrategy.java index c9576f4b81..5ab4b1affc 100644 --- a/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/RetrievePolicyEntriesStrategy.java +++ b/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/RetrievePolicyEntriesStrategy.java @@ -39,7 +39,7 @@ final class RetrievePolicyEntriesStrategy extends } @Override - protected Result doApply(final Context context, + protected Result> doApply(final Context context, @Nullable final Policy policy, final long nextRevision, final RetrievePolicyEntries command, diff --git a/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/RetrievePolicyEntryStrategy.java b/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/RetrievePolicyEntryStrategy.java index a9db250a41..26fd3e9d50 100644 --- a/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/RetrievePolicyEntryStrategy.java +++ b/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/RetrievePolicyEntryStrategy.java @@ -40,7 +40,7 @@ final class RetrievePolicyEntryStrategy extends } @Override - protected Result doApply(final Context context, + protected Result> doApply(final Context context, @Nullable final Policy policy, final long nextRevision, final RetrievePolicyEntry command, diff --git a/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/RetrievePolicyStrategy.java b/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/RetrievePolicyStrategy.java index 7e9bc9229e..13cc5f9db9 100644 --- a/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/RetrievePolicyStrategy.java +++ b/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/RetrievePolicyStrategy.java @@ -37,7 +37,7 @@ final class RetrievePolicyStrategy extends AbstractPolicyQueryCommandStrategy doApply(final Context context, + protected Result> doApply(final Context context, @Nullable final Policy entity, final long nextRevision, final RetrievePolicy command, diff --git a/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/RetrieveResourceStrategy.java b/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/RetrieveResourceStrategy.java index e8e9582359..38c6d9fed3 100644 --- a/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/RetrieveResourceStrategy.java +++ b/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/RetrieveResourceStrategy.java @@ -41,7 +41,7 @@ final class RetrieveResourceStrategy extends AbstractPolicyQueryCommandStrategy< } @Override - protected Result doApply(final Context context, + protected Result> doApply(final Context context, @Nullable final Policy policy, final long nextRevision, final RetrieveResource command, diff --git a/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/RetrieveResourcesStrategy.java b/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/RetrieveResourcesStrategy.java index d71401e4ae..c371765b65 100644 --- a/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/RetrieveResourcesStrategy.java +++ b/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/RetrieveResourcesStrategy.java @@ -41,7 +41,7 @@ final class RetrieveResourcesStrategy extends AbstractPolicyQueryCommandStrategy } @Override - protected Result doApply(final Context context, + protected Result> doApply(final Context context, @Nullable final Policy policy, final long nextRevision, final RetrieveResources command, diff --git a/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/RetrieveSubjectStrategy.java b/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/RetrieveSubjectStrategy.java index 490a644f7d..cd1b71ff62 100644 --- a/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/RetrieveSubjectStrategy.java +++ b/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/RetrieveSubjectStrategy.java @@ -43,7 +43,7 @@ final class RetrieveSubjectStrategy extends AbstractPolicyQueryCommandStrategy doApply(final Context context, + protected Result> doApply(final Context context, @Nullable final Policy policy, final long nextRevision, final RetrieveSubject command, diff --git a/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/RetrieveSubjectsStrategy.java b/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/RetrieveSubjectsStrategy.java index d6dc607bad..e5dca0c881 100644 --- a/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/RetrieveSubjectsStrategy.java +++ b/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/RetrieveSubjectsStrategy.java @@ -41,7 +41,7 @@ final class RetrieveSubjectsStrategy extends AbstractPolicyQueryCommandStrategy< } @Override - protected Result doApply(final Context context, + protected Result> doApply(final Context context, @Nullable final Policy policy, final long nextRevision, final RetrieveSubjects command, diff --git a/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/SudoRetrievePolicyRevisionStrategy.java b/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/SudoRetrievePolicyRevisionStrategy.java index dc505302dc..8062bc9777 100644 --- a/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/SudoRetrievePolicyRevisionStrategy.java +++ b/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/SudoRetrievePolicyRevisionStrategy.java @@ -42,7 +42,7 @@ final class SudoRetrievePolicyRevisionStrategy extends AbstractPolicyQueryComman } @Override - protected Result doApply(final Context context, + protected Result> doApply(final Context context, @Nullable final Policy entity, final long nextRevision, final SudoRetrievePolicyRevision command, diff --git a/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/SudoRetrievePolicyStrategy.java b/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/SudoRetrievePolicyStrategy.java index e997d99c1f..c65a69f6cf 100644 --- a/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/SudoRetrievePolicyStrategy.java +++ b/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/SudoRetrievePolicyStrategy.java @@ -37,7 +37,7 @@ final class SudoRetrievePolicyStrategy extends AbstractPolicyQueryCommandStrateg } @Override - protected Result doApply(final Context context, + protected Result> doApply(final Context context, @Nullable final Policy entity, final long nextRevision, final SudoRetrievePolicy command, diff --git a/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/events/PolicyEventStrategies.java b/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/events/PolicyEventStrategies.java index dad4400ef4..16de6968a3 100755 --- a/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/events/PolicyEventStrategies.java +++ b/services/policies/persistence/src/main/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/events/PolicyEventStrategies.java @@ -36,7 +36,7 @@ /** * Holds all {@link org.eclipse.ditto.signals.events.policies.PolicyEvent} strategies. */ -public final class PolicyEventStrategies extends AbstractEventStrategies { +public final class PolicyEventStrategies extends AbstractEventStrategies, Policy> { private static final PolicyEventStrategies INSTANCE = new PolicyEventStrategies(); diff --git a/services/policies/persistence/src/test/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/AbstractPolicyCommandStrategyTest.java b/services/policies/persistence/src/test/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/AbstractPolicyCommandStrategyTest.java index 3e9ba54ed8..306c2ef8a7 100644 --- a/services/policies/persistence/src/test/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/AbstractPolicyCommandStrategyTest.java +++ b/services/policies/persistence/src/test/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/AbstractPolicyCommandStrategyTest.java @@ -64,30 +64,32 @@ protected static CommandStrategy.Context getDefaultContext() { return DefaultContext.getInstance(TestConstants.Policy.POLICY_ID, logger); } - protected static > T assertModificationResult(final CommandStrategy underTest, + protected static , T extends PolicyEvent> T assertModificationResult( + final CommandStrategy>> underTest, @Nullable final Policy policy, - final Command command, + final C command, final Class expectedEventClass, - final CommandResponse expectedCommandResponse) { + final CommandResponse expectedCommandResponse) { return assertModificationResult(underTest, policy, command, expectedEventClass, expectedCommandResponse, false); } - protected static , R extends PolicyCommandResponse> void assertModificationResult( - final CommandStrategy underTest, + protected static , T extends PolicyEvent, R extends PolicyCommandResponse> + void assertModificationResult( + final CommandStrategy>> underTest, @Nullable final Policy policy, - final Command command, + final C command, final Class expectedEventClass, final Consumer eventSatisfactions, final Class expectedResponseClass, final Consumer responseSatisfactions) { final CommandStrategy.Context context = getDefaultContext(); - final Result result = applyStrategy(underTest, context, policy, command); + final Result> result = applyStrategy(underTest, context, policy, command); final ArgumentCaptor event = ArgumentCaptor.forClass(expectedEventClass); final ArgumentCaptor response = ArgumentCaptor.forClass(expectedResponseClass); - final ResultVisitor mock = mock(Dummy.class); + final ResultVisitor> mock = mock(Dummy.class); result.accept(mock); verify(mock).onMutation(any(), event.capture(), response.capture(), anyBoolean(), eq(false)); @@ -95,45 +97,48 @@ protected static , R extends PolicyCommandResponse> assertThat(response.getValue()).isInstanceOf(expectedResponseClass); assertThat(event.getValue()) - .describedAs("Event satisfactions failed for expected event of type '%s'", expectedEventClass.getSimpleName()) + .describedAs("Event satisfactions failed for expected event of type '%s'", + expectedEventClass.getSimpleName()) .satisfies(eventSatisfactions); assertThat(response.getValue()) - .describedAs("Response predicate failed for expected response of type '%s'", expectedResponseClass.getSimpleName()) + .describedAs("Response predicate failed for expected response of type '%s'", + expectedResponseClass.getSimpleName()) .satisfies(responseSatisfactions); } - protected static > T assertModificationResult(final CommandStrategy underTest, + protected static , T extends PolicyEvent> T assertModificationResult( + final CommandStrategy>> underTest, @Nullable final Policy policy, - final Command command, + final C command, final Class expectedEventClass, - final CommandResponse expectedCommandResponse, + final CommandResponse expectedCommandResponse, final boolean becomeDeleted) { final CommandStrategy.Context context = getDefaultContext(); - final Result result = applyStrategy(underTest, context, policy, command); + final Result> result = applyStrategy(underTest, context, policy, command); return assertModificationResult(result, expectedEventClass, expectedCommandResponse, becomeDeleted); } - protected static void assertErrorResult( - final CommandStrategy> underTest, + protected static > void assertErrorResult( + final CommandStrategy>> underTest, @Nullable final Policy policy, final C command, final DittoRuntimeException expectedException) { - final ResultVisitor mock = mock(Dummy.class); + final ResultVisitor> mock = mock(Dummy.class); applyStrategy(underTest, getDefaultContext(), policy, command).accept(mock); verify(mock).onError(eq(expectedException), eq(command)); } - private static > T assertModificationResult(final Result result, + private static > T assertModificationResult(final Result> result, final Class eventClazz, - final WithDittoHeaders expectedResponse, + final WithDittoHeaders expectedResponse, final boolean becomeDeleted) { final ArgumentCaptor event = ArgumentCaptor.forClass(eventClazz); - final ResultVisitor mock = mock(Dummy.class); + final ResultVisitor> mock = mock(Dummy.class); result.accept(mock); @@ -142,8 +147,8 @@ private static > T assertModificationResult(final Resul return event.getValue(); } - private static Result applyStrategy( - final CommandStrategy> underTest, + private static > Result> applyStrategy( + final CommandStrategy>> underTest, final CommandStrategy.Context context, @Nullable final Policy policy, final C command) { @@ -151,11 +156,11 @@ private static Result applyStrategy( return underTest.apply(context, policy, NEXT_REVISION, command); } - interface Dummy extends ResultVisitor {} + interface Dummy extends ResultVisitor> {} protected static DittoHeaders appendETagToDittoHeaders(final Object object, final DittoHeaders dittoHeaders) { - return dittoHeaders.toBuilder().eTag(EntityTag.fromEntity(object).get()).build(); + return dittoHeaders.toBuilder().eTag(EntityTag.fromEntity(object).orElseThrow()).build(); } } diff --git a/services/policies/persistence/src/test/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/PolicyConflictStrategyTest.java b/services/policies/persistence/src/test/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/PolicyConflictStrategyTest.java index 1f557b8cd6..837d0a6204 100644 --- a/services/policies/persistence/src/test/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/PolicyConflictStrategyTest.java +++ b/services/policies/persistence/src/test/java/org/eclipse/ditto/services/policies/persistence/actors/strategies/commands/PolicyConflictStrategyTest.java @@ -60,7 +60,7 @@ public void createConflictResultWithoutPrecondition() { final Policy policy = PoliciesModelFactory.newPolicyBuilder(policyId).setRevision(25L).build(); final CommandStrategy.Context context = DefaultContext.getInstance(policyId, mockLoggingAdapter()); final CreatePolicy command = CreatePolicy.of(policy, DittoHeaders.empty()); - final Result result = underTest.apply(context, policy, 26L, command); + final Result> result = underTest.apply(context, policy, 26L, command); result.accept(new ExpectErrorVisitor(PolicyConflictException.class)); } @@ -74,7 +74,7 @@ public void createPreconditionFailedResultWithPrecondition() { final CreatePolicy command = CreatePolicy.of(policy, DittoHeaders.newBuilder() .ifNoneMatch(EntityTagMatchers.fromStrings("*")) .build()); - final Result result = underTest.apply(context, policy, 26L, command); + final Result> result = underTest.apply(context, policy, 26L, command); result.accept(new ExpectErrorVisitor(PolicyPreconditionFailedException.class)); } @@ -84,7 +84,7 @@ private static DittoDiagnosticLoggingAdapter mockLoggingAdapter() { return mock; } - private static final class ExpectErrorVisitor implements ResultVisitor { + private static final class ExpectErrorVisitor implements ResultVisitor> { private final Class clazz; diff --git a/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/ThingPersistenceActor.java b/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/ThingPersistenceActor.java index a4e65b11e5..1912569ba5 100755 --- a/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/ThingPersistenceActor.java +++ b/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/ThingPersistenceActor.java @@ -47,7 +47,7 @@ * PersistentActor which "knows" the state of a single {@link Thing}. */ public final class ThingPersistenceActor - extends AbstractShardedPersistenceActor { + extends AbstractShardedPersistenceActor, Thing, ThingId, ThingId, ThingEvent> { /** * The prefix of the persistenceId for Things. @@ -64,7 +64,7 @@ public final class ThingPersistenceActor */ static final String SNAPSHOT_PLUGIN_ID = "akka-contrib-mongodb-persistence-things-snapshots"; - private static AckExtractor> ACK_EXTRACTOR = + private static final AckExtractor> ACK_EXTRACTOR = AckExtractor.of(ThingEvent::getEntityId, ThingEvent::getDittoHeaders); private final ThingConfig thingConfig; @@ -123,7 +123,7 @@ public String snapshotPluginId() { } @Override - protected Class getEventClass() { + protected Class getEventClass() { return ThingEvent.class; } @@ -138,12 +138,12 @@ protected ThingCommandStrategies getCreatedStrategy() { } @Override - protected CommandStrategy> getDeletedStrategy() { + protected CommandStrategy>> getDeletedStrategy() { return ThingCommandStrategies.getCreateThingStrategy(); } @Override - protected EventStrategy getEventStrategy() { + protected EventStrategy, Thing> getEventStrategy() { return ThingEventStrategies.getInstance(); } @@ -163,7 +163,7 @@ protected boolean entityExistsAsDeleted() { } @Override - protected DittoRuntimeExceptionBuilder newNotAccessibleExceptionBuilder() { + protected DittoRuntimeExceptionBuilder newNotAccessibleExceptionBuilder() { return ThingNotAccessibleException.newBuilder(entityId); } @@ -177,7 +177,7 @@ protected void recoveryCompleted(final RecoveryCompleted event) { } @Override - protected void publishEvent(final ThingEvent event) { + protected void publishEvent(final ThingEvent event) { distributedPub.publishWithAcks(event, ACK_EXTRACTOR, getSender()); } @@ -188,7 +188,7 @@ protected JsonSchemaVersion getEntitySchemaVersion(final Thing entity) { private static Thing enhanceThingWithLifecycle(final Thing thing) { final ThingBuilder.FromCopy thingBuilder = ThingsModelFactory.newThingBuilder(thing); - if (!thing.getLifecycle().isPresent()) { + if (thing.getLifecycle().isEmpty()) { thingBuilder.setLifecycle(ThingLifecycle.ACTIVE); } diff --git a/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/AbstractThingCommandStrategy.java b/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/AbstractThingCommandStrategy.java index 010d36fef4..3b0237609d 100644 --- a/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/AbstractThingCommandStrategy.java +++ b/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/AbstractThingCommandStrategy.java @@ -36,7 +36,7 @@ */ @Immutable abstract class AbstractThingCommandStrategy> - extends AbstractConditionHeaderCheckingCommandStrategy { + extends AbstractConditionHeaderCheckingCommandStrategy> { private static final ConditionalHeadersValidator VALIDATOR = ThingsConditionalHeadersValidatorProvider.getInstance(); diff --git a/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/CreateThingStrategy.java b/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/CreateThingStrategy.java index 61f40afb2e..471bea6897 100644 --- a/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/CreateThingStrategy.java +++ b/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/CreateThingStrategy.java @@ -82,7 +82,7 @@ public boolean isDefined(final Context context, @Nullable final Thing t } @Override - protected Result doApply(final Context context, + protected Result> doApply(final Context context, @Nullable final Thing thing, final long nextRevision, final CreateThing command, @@ -101,7 +101,7 @@ protected Result doApply(final Context context, } // before persisting, check if the Thing is valid and reject if not: - final Result validateThingError = + final Result> validateThingError = validateThing(context, command.getImplementedSchemaVersion(), newThing, command); if (validateThingError != null) { return validateThingError; @@ -188,8 +188,8 @@ private Thing enhanceNewThingWithFallbackAcl(final Thing newThing, final Authori } @Nullable - private Result validateThing(final Context context, final JsonSchemaVersion version, final Thing thing, - final CreateThing command) { + private Result> validateThing(final Context context, final JsonSchemaVersion version, + final Thing thing, final CreateThing command) { final DittoHeaders headers = command.getDittoHeaders(); final Optional accessControlList = thing.getAccessControlList(); if (JsonSchemaVersion.V_1.equals(version)) { diff --git a/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/DeleteAclEntryStrategy.java b/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/DeleteAclEntryStrategy.java index 5d95d3e8c5..45d6591758 100644 --- a/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/DeleteAclEntryStrategy.java +++ b/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/DeleteAclEntryStrategy.java @@ -48,7 +48,7 @@ final class DeleteAclEntryStrategy extends AbstractThingCommandStrategy doApply(final Context context, + protected Result> doApply(final Context context, @Nullable final Thing thing, final long nextRevision, final DeleteAclEntry command, @@ -71,7 +71,7 @@ private Optional extractAcl(@Nullable final Thing thing, fina .filter(acl -> acl.contains(authSubject)); } - private Result getDeleteAclEntryResult(final AccessControlList acl, final Context context, + private Result> getDeleteAclEntryResult(final AccessControlList acl, final Context context, final long nextRevision, final DeleteAclEntry command, @Nullable final Thing thing, @Nullable final Metadata metadata) { diff --git a/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/DeleteAttributeStrategy.java b/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/DeleteAttributeStrategy.java index 0d024e840a..cf43726a5b 100644 --- a/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/DeleteAttributeStrategy.java +++ b/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/DeleteAttributeStrategy.java @@ -46,7 +46,7 @@ final class DeleteAttributeStrategy extends AbstractThingCommandStrategy doApply(final Context context, + protected Result> doApply(final Context context, @Nullable final Thing thing, final long nextRevision, final DeleteAttribute command, @@ -63,7 +63,7 @@ protected Result doApply(final Context context, command.getDittoHeaders()), command)); } - private Result getDeleteAttributeResult(final Context context, final long nextRevision, + private Result> getDeleteAttributeResult(final Context context, final long nextRevision, final DeleteAttribute command, @Nullable final Thing thing, @Nullable final Metadata metadata) { final ThingId thingId = context.getState(); final JsonPointer attrPointer = command.getAttributePointer(); diff --git a/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/DeleteAttributesStrategy.java b/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/DeleteAttributesStrategy.java index bb9dc76931..ba9e7ea304 100644 --- a/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/DeleteAttributesStrategy.java +++ b/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/DeleteAttributesStrategy.java @@ -46,7 +46,7 @@ final class DeleteAttributesStrategy } @Override - protected Result doApply(final Context context, + protected Result> doApply(final Context context, @Nullable final Thing thing, final long nextRevision, final DeleteAttributes command, @@ -62,7 +62,7 @@ private Optional extractAttributes(final @Nullable Thing thing) { return getEntityOrThrow(thing).getAttributes(); } - private Result getDeleteAttributesResult(final Context context, final long nextRevision, + private Result> getDeleteAttributesResult(final Context context, final long nextRevision, final DeleteAttributes command, @Nullable final Thing thing, @Nullable final Metadata metadata) { final ThingId thingId = context.getState(); final DittoHeaders dittoHeaders = command.getDittoHeaders(); diff --git a/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/DeleteFeatureDefinitionStrategy.java b/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/DeleteFeatureDefinitionStrategy.java index a8d68a3a01..09b6299c11 100644 --- a/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/DeleteFeatureDefinitionStrategy.java +++ b/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/DeleteFeatureDefinitionStrategy.java @@ -45,7 +45,7 @@ final class DeleteFeatureDefinitionStrategy extends AbstractThingCommandStrategy } @Override - protected Result doApply(final Context context, + protected Result> doApply(final Context context, @Nullable final Thing thing, final long nextRevision, final DeleteFeatureDefinition command, @@ -60,7 +60,7 @@ protected Result doApply(final Context context, command.getDittoHeaders()), command)); } - private Result getDeleteFeatureDefinitionResult(final Feature feature, final Context context, + private Result> getDeleteFeatureDefinitionResult(final Feature feature, final Context context, final long nextRevision, final DeleteFeatureDefinition command, @Nullable final Thing thing, @Nullable final Metadata metadata) { final DittoHeaders dittoHeaders = command.getDittoHeaders(); @@ -70,12 +70,12 @@ private Result getDeleteFeatureDefinitionResult(final Feature featur return feature.getDefinition() .map(featureDefinition -> { - final ThingEvent event = + final ThingEvent event = FeatureDefinitionDeleted.of(thingId, featureId, nextRevision, getEventTimestamp(), dittoHeaders, metadata); - final WithDittoHeaders response = appendETagHeaderIfProvided(command, + final WithDittoHeaders response = appendETagHeaderIfProvided(command, DeleteFeatureDefinitionResponse.of(thingId, featureId, dittoHeaders), thing); - return ResultFactory.newMutationResult(command, event, response); + return ResultFactory.>newMutationResult(command, event, response); }) .orElseGet(() -> ResultFactory.newErrorResult( ExceptionFactory.featureDefinitionNotFound(thingId, featureId, dittoHeaders), command)); diff --git a/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/DeleteFeatureDesiredPropertiesStrategy.java b/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/DeleteFeatureDesiredPropertiesStrategy.java index d4fb80a492..c8849ab9a3 100644 --- a/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/DeleteFeatureDesiredPropertiesStrategy.java +++ b/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/DeleteFeatureDesiredPropertiesStrategy.java @@ -46,7 +46,7 @@ final class DeleteFeatureDesiredPropertiesStrategy } @Override - protected Result doApply(final Context context, + protected Result> doApply(final Context context, @Nullable final Thing thing, final long nextRevision, final DeleteFeatureDesiredProperties command, @@ -67,7 +67,7 @@ private Optional extractFeature(final DeleteFeatureDesiredProperties co .flatMap(features -> features.getFeature(command.getFeatureId())); } - private Result getDeleteFeatureDesiredPropertiesResult(final Feature feature, + private Result> getDeleteFeatureDesiredPropertiesResult(final Feature feature, final Context context, final long nextRevision, final DeleteFeatureDesiredProperties command, @@ -80,12 +80,12 @@ private Result getDeleteFeatureDesiredPropertiesResult(final Feature return feature.getDesiredProperties() .map(desiredProperties -> { - final ThingEvent event = + final ThingEvent event = FeatureDesiredPropertiesDeleted.of(thingId, featureId, nextRevision, getEventTimestamp(), dittoHeaders, metadata); - final WithDittoHeaders response = appendETagHeaderIfProvided(command, + final WithDittoHeaders response = appendETagHeaderIfProvided(command, DeleteFeatureDesiredPropertiesResponse.of(thingId, featureId, dittoHeaders), thing); - return ResultFactory.newMutationResult(command, event, response); + return ResultFactory.>newMutationResult(command, event, response); }) .orElseGet(() -> ResultFactory.newErrorResult( ExceptionFactory.featureDesiredPropertiesNotFound(thingId, featureId, dittoHeaders), command)); diff --git a/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/DeleteFeatureDesiredPropertyStrategy.java b/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/DeleteFeatureDesiredPropertyStrategy.java index 0b2c05ee99..fb10cd56bf 100644 --- a/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/DeleteFeatureDesiredPropertyStrategy.java +++ b/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/DeleteFeatureDesiredPropertyStrategy.java @@ -46,7 +46,7 @@ final class DeleteFeatureDesiredPropertyStrategy extends AbstractThingCommandStr } @Override - protected Result doApply(final Context context, + protected Result> doApply(final Context context, @Nullable final Thing thing, final long nextRevision, final DeleteFeatureDesiredProperty command, @@ -65,7 +65,7 @@ private Optional extractFeature(final DeleteFeatureDesiredProperty comm .flatMap(features -> features.getFeature(command.getFeatureId())); } - private Result getDeleteFeatureDesiredPropertyResult(final Feature feature, + private Result> getDeleteFeatureDesiredPropertyResult(final Feature feature, final Context context, final long nextRevision, final DeleteFeatureDesiredProperty command, @@ -79,11 +79,11 @@ private Result getDeleteFeatureDesiredPropertyResult(final Feature f return feature.getDesiredProperties() .flatMap(desiredProperties -> desiredProperties.getValue(desiredPropertyPointer)) - .map(FeatureDesiredProperty -> { - final ThingEvent event = + .>>map(FeatureDesiredProperty -> { + final ThingEvent event = FeatureDesiredPropertyDeleted.of(thingId, featureId, desiredPropertyPointer, nextRevision, getEventTimestamp(), dittoHeaders, metadata); - final WithDittoHeaders response = appendETagHeaderIfProvided(command, + final WithDittoHeaders response = appendETagHeaderIfProvided(command, DeleteFeatureDesiredPropertyResponse.of(thingId, featureId, desiredPropertyPointer, dittoHeaders), thing); return ResultFactory.newMutationResult(command, event, response); diff --git a/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/DeleteFeaturePropertiesStrategy.java b/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/DeleteFeaturePropertiesStrategy.java index 614c61ae59..b3b0d4d325 100644 --- a/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/DeleteFeaturePropertiesStrategy.java +++ b/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/DeleteFeaturePropertiesStrategy.java @@ -45,7 +45,7 @@ final class DeleteFeaturePropertiesStrategy extends AbstractThingCommandStrategy } @Override - protected Result doApply(final Context context, + protected Result> doApply(final Context context, @Nullable final Thing thing, final long nextRevision, final DeleteFeatureProperties command, @@ -66,7 +66,7 @@ private Optional extractFeature(final DeleteFeatureProperties command, .flatMap(features -> features.getFeature(command.getFeatureId())); } - private Result getDeleteFeaturePropertiesResult(final Feature feature, final Context context, + private Result> getDeleteFeaturePropertiesResult(final Feature feature, final Context context, final long nextRevision, final DeleteFeatureProperties command, @Nullable final Thing thing, @Nullable final Metadata metadata) { final DittoHeaders dittoHeaders = command.getDittoHeaders(); @@ -76,12 +76,12 @@ private Result getDeleteFeaturePropertiesResult(final Feature featur return feature.getProperties() .map(featureProperties -> { - final ThingEvent event = + final ThingEvent event = FeaturePropertiesDeleted.of(thingId, featureId, nextRevision, getEventTimestamp(), dittoHeaders, metadata); - final WithDittoHeaders response = appendETagHeaderIfProvided(command, + final WithDittoHeaders response = appendETagHeaderIfProvided(command, DeleteFeaturePropertiesResponse.of(thingId, featureId, dittoHeaders), thing); - return ResultFactory.newMutationResult(command, event, response); + return ResultFactory.>newMutationResult(command, event, response); }) .orElseGet(() -> ResultFactory.newErrorResult( ExceptionFactory.featurePropertiesNotFound(thingId, featureId, dittoHeaders), command)); diff --git a/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/DeleteFeaturePropertyStrategy.java b/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/DeleteFeaturePropertyStrategy.java index e6dcd68802..e1bd1e0113 100644 --- a/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/DeleteFeaturePropertyStrategy.java +++ b/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/DeleteFeaturePropertyStrategy.java @@ -46,7 +46,7 @@ final class DeleteFeaturePropertyStrategy extends AbstractThingCommandStrategy doApply(final Context context, + protected Result> doApply(final Context context, @Nullable final Thing thing, final long nextRevision, final DeleteFeatureProperty command, @@ -65,7 +65,7 @@ private Optional extractFeature(final DeleteFeatureProperty command, fi .flatMap(features -> features.getFeature(command.getFeatureId())); } - private Result getDeleteFeaturePropertyResult(final Feature feature, final Context context, + private Result> getDeleteFeaturePropertyResult(final Feature feature, final Context context, final long nextRevision, final DeleteFeatureProperty command, @Nullable final Thing thing, @Nullable final Metadata metadata) { @@ -77,12 +77,12 @@ private Result getDeleteFeaturePropertyResult(final Feature feature, return feature.getProperties() .flatMap(featureProperties -> featureProperties.getValue(propertyPointer)) .map(featureProperty -> { - final ThingEvent event = + final ThingEvent event = FeaturePropertyDeleted.of(thingId, featureId, propertyPointer, nextRevision, getEventTimestamp(), dittoHeaders, metadata); - final WithDittoHeaders response = appendETagHeaderIfProvided(command, + final WithDittoHeaders response = appendETagHeaderIfProvided(command, DeleteFeaturePropertyResponse.of(thingId, featureId, propertyPointer, dittoHeaders), thing); - return ResultFactory.newMutationResult(command, event, response); + return ResultFactory.>newMutationResult(command, event, response); }) .orElseGet(() -> ResultFactory.newErrorResult( ExceptionFactory.featurePropertyNotFound(thingId, featureId, propertyPointer, dittoHeaders), diff --git a/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/DeleteFeatureStrategy.java b/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/DeleteFeatureStrategy.java index 8115d97e37..4ca7831913 100644 --- a/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/DeleteFeatureStrategy.java +++ b/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/DeleteFeatureStrategy.java @@ -45,7 +45,7 @@ final class DeleteFeatureStrategy extends AbstractThingCommandStrategy doApply(final Context context, + protected Result> doApply(final Context context, @Nullable final Thing thing, final long nextRevision, final DeleteFeature command, @@ -67,7 +67,7 @@ private Optional extractFeature(final DeleteFeature command, @Nullable .flatMap(features -> features.getFeature(featureId)); } - private Result getDeleteFeatureResult(final Context context, final long nextRevision, + private Result> getDeleteFeatureResult(final Context context, final long nextRevision, final DeleteFeature command, @Nullable final Thing thing, @Nullable final Metadata metadata) { final ThingId thingId = context.getState(); diff --git a/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/DeleteFeaturesStrategy.java b/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/DeleteFeaturesStrategy.java index 7c32262383..6460dc94c0 100644 --- a/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/DeleteFeaturesStrategy.java +++ b/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/DeleteFeaturesStrategy.java @@ -45,7 +45,7 @@ final class DeleteFeaturesStrategy extends AbstractThingCommandStrategy doApply(final Context context, + protected Result> doApply(final Context context, @Nullable final Thing thing, final long nextRevision, final DeleteFeatures command, @@ -55,7 +55,7 @@ protected Result doApply(final Context context, return extractFeatures(thing) .map(features -> - ResultFactory.newMutationResult(command, + ResultFactory.>newMutationResult(command, getEventToPersist(context, nextRevision, dittoHeaders, metadata), getResponse(context, command, thing)) ) @@ -68,13 +68,13 @@ private Optional extractFeatures(final @Nullable Thing thing) { return getEntityOrThrow(thing).getFeatures(); } - private static ThingEvent getEventToPersist(final Context context, final long nextRevision, + private static ThingEvent getEventToPersist(final Context context, final long nextRevision, final DittoHeaders dittoHeaders, @Nullable final Metadata metadata) { return FeaturesDeleted.of(context.getState(), nextRevision, getEventTimestamp(), dittoHeaders, metadata); } - private WithDittoHeaders getResponse(final Context context, final DeleteFeatures command, + private WithDittoHeaders getResponse(final Context context, final DeleteFeatures command, @Nullable final Thing thing) { return appendETagHeaderIfProvided(command, DeleteFeaturesResponse.of(context.getState(), command.getDittoHeaders()), thing); diff --git a/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/DeleteThingDefinitionStrategy.java b/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/DeleteThingDefinitionStrategy.java index dccf93725f..5a7ecd01e7 100644 --- a/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/DeleteThingDefinitionStrategy.java +++ b/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/DeleteThingDefinitionStrategy.java @@ -47,7 +47,7 @@ final class DeleteThingDefinitionStrategy } @Override - protected Result doApply(final Context context, + protected Result> doApply(final Context context, @Nullable final Thing thing, final long nextRevision, final DeleteThingDefinition command, @@ -65,7 +65,7 @@ private Optional extractDefinition(final @Nullable Thing thing) return getEntityOrThrow(thing).getDefinition(); } - private Result getDeleteDefinitionResult(final Context context, final long nextRevision, + private Result> getDeleteDefinitionResult(final Context context, final long nextRevision, final DeleteThingDefinition command, @Nullable final Thing thing, @Nullable final Metadata metadata) { final ThingId thingId = context.getState(); diff --git a/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/DeleteThingStrategy.java b/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/DeleteThingStrategy.java index fad474ab66..1d1f4853a1 100644 --- a/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/DeleteThingStrategy.java +++ b/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/DeleteThingStrategy.java @@ -44,7 +44,7 @@ final class DeleteThingStrategy extends AbstractThingCommandStrategy doApply(final Context context, + protected Result> doApply(final Context context, @Nullable final Thing thing, final long nextRevision, final DeleteThing command, diff --git a/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/ModifyAclEntryStrategy.java b/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/ModifyAclEntryStrategy.java index b067e5238d..6b4d77340a 100644 --- a/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/ModifyAclEntryStrategy.java +++ b/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/ModifyAclEntryStrategy.java @@ -50,7 +50,7 @@ final class ModifyAclEntryStrategy extends AbstractThingCommandStrategy doApply(final Context context, + protected Result> doApply(final Context context, @Nullable final Thing thing, final long nextRevision, final ModifyAclEntry command, @@ -74,7 +74,7 @@ private static Validator getAclValidator(final AccessControlList acl) { return AclValidator.newInstance(acl, Thing.MIN_REQUIRED_PERMISSIONS); } - private Result getModifyOrCreateResult(final AccessControlList acl, final Context context, + private Result> getModifyOrCreateResult(final AccessControlList acl, final Context context, final long nextRevision, final ModifyAclEntry command, @Nullable final Thing thing, @Nullable final Metadata metadata) { @@ -85,7 +85,7 @@ private Result getModifyOrCreateResult(final AccessControlList acl, return getCreateResult(context, nextRevision, command, thing, metadata); } - private Result getModifyResult(final Context context, final long nextRevision, + private Result> getModifyResult(final Context context, final long nextRevision, final ModifyAclEntry command, @Nullable final Thing thing, @Nullable final Metadata metadata) { final ThingId thingId = context.getState(); final AclEntry aclEntry = command.getAclEntry(); @@ -99,7 +99,7 @@ private Result getModifyResult(final Context context, final return ResultFactory.newMutationResult(command, event, response); } - private Result getCreateResult(final Context context, final long nextRevision, + private Result> getCreateResult(final Context context, final long nextRevision, final ModifyAclEntry command, @Nullable final Thing thing, @Nullable final Metadata metadata) { final ThingId thingId = context.getState(); final AclEntry aclEntry = command.getAclEntry(); diff --git a/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/ModifyAclStrategy.java b/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/ModifyAclStrategy.java index 04a63c1b75..874ebda7fb 100644 --- a/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/ModifyAclStrategy.java +++ b/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/ModifyAclStrategy.java @@ -47,7 +47,7 @@ final class ModifyAclStrategy extends AbstractThingCommandStrategy { } @Override - protected Result doApply(final Context context, + protected Result> doApply(final Context context, @Nullable final Thing thing, final long nextRevision, final ModifyAcl command, diff --git a/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/ModifyAttributeStrategy.java b/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/ModifyAttributeStrategy.java index 3dd1f3c5a8..a18f6dd0eb 100644 --- a/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/ModifyAttributeStrategy.java +++ b/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/ModifyAttributeStrategy.java @@ -49,7 +49,7 @@ final class ModifyAttributeStrategy extends AbstractThingCommandStrategy doApply(final Context context, + protected Result> doApply(final Context context, @Nullable final Thing thing, final long nextRevision, final ModifyAttribute command, @@ -81,7 +81,7 @@ protected Result doApply(final Context context, .orElseGet(() -> getCreateResult(context, nextRevision, command, thing, metadata)); } - private Result getModifyResult(final Context context, final long nextRevision, + private Result> getModifyResult(final Context context, final long nextRevision, final ModifyAttribute command, @Nullable final Thing thing, @Nullable final Metadata metadata) { final ThingId thingId = context.getState(); @@ -97,7 +97,7 @@ private Result getModifyResult(final Context context, final return ResultFactory.newMutationResult(command, event, response); } - private Result getCreateResult(final Context context, final long nextRevision, + private Result> getCreateResult(final Context context, final long nextRevision, final ModifyAttribute command, @Nullable final Thing thing, @Nullable final Metadata metadata) { final ThingId thingId = context.getState(); diff --git a/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/ModifyAttributesStrategy.java b/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/ModifyAttributesStrategy.java index f48eff1d95..96f5d64f10 100644 --- a/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/ModifyAttributesStrategy.java +++ b/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/ModifyAttributesStrategy.java @@ -48,7 +48,7 @@ final class ModifyAttributesStrategy extends AbstractThingCommandStrategy doApply(final Context context, + protected Result> doApply(final Context context, @Nullable final Thing thing, final long nextRevision, final ModifyAttributes command, @@ -79,7 +79,7 @@ protected Result doApply(final Context context, .orElseGet(() -> getCreateResult(context, nextRevision, command, thing, metadata)); } - private Result getModifyResult(final Context context, final long nextRevision, + private Result> getModifyResult(final Context context, final long nextRevision, final ModifyAttributes command, @Nullable final Thing thing, @Nullable final Metadata metadata) { final ThingId thingId = context.getState(); final DittoHeaders dittoHeaders = command.getDittoHeaders(); @@ -93,7 +93,7 @@ private Result getModifyResult(final Context context, final return ResultFactory.newMutationResult(command, event, response); } - private Result getCreateResult(final Context context, final long nextRevision, + private Result> getCreateResult(final Context context, final long nextRevision, final ModifyAttributes command, @Nullable final Thing thing, @Nullable final Metadata metadata) { final ThingId thingId = context.getState(); final Attributes attributes = command.getAttributes(); diff --git a/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/ModifyFeatureDefinitionStrategy.java b/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/ModifyFeatureDefinitionStrategy.java index 11ec6be6ef..9e9d602a46 100644 --- a/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/ModifyFeatureDefinitionStrategy.java +++ b/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/ModifyFeatureDefinitionStrategy.java @@ -46,7 +46,7 @@ final class ModifyFeatureDefinitionStrategy extends AbstractThingCommandStrategy } @Override - protected Result doApply(final Context context, + protected Result> doApply(final Context context, @Nullable final Thing thing, final long nextRevision, final ModifyFeatureDefinition command, @@ -66,7 +66,7 @@ private Optional extractFeature(final ModifyFeatureDefinition command, .flatMap(features -> features.getFeature(command.getFeatureId())); } - private Result getModifyOrCreateResult(final Feature feature, final Context context, + private Result> getModifyOrCreateResult(final Feature feature, final Context context, final long nextRevision, final ModifyFeatureDefinition command, @Nullable final Thing thing, @Nullable final Metadata metadata) { @@ -75,7 +75,7 @@ private Result getModifyOrCreateResult(final Feature feature, final .orElseGet(() -> getCreateResult(context, nextRevision, command, thing, metadata)); } - private Result getModifyResult(final Context context, final long nextRevision, + private Result> getModifyResult(final Context context, final long nextRevision, final ModifyFeatureDefinition command, @Nullable final Thing thing, @Nullable final Metadata metadata) { final ThingId thingId = context.getState(); @@ -91,7 +91,7 @@ private Result getModifyResult(final Context context, final return ResultFactory.newMutationResult(command, event, response); } - private Result getCreateResult(final Context context, final long nextRevision, + private Result> getCreateResult(final Context context, final long nextRevision, final ModifyFeatureDefinition command, @Nullable final Thing thing, @Nullable final Metadata metadata) { final ThingId thingId = context.getState(); diff --git a/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/ModifyFeatureDesiredPropertiesStrategy.java b/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/ModifyFeatureDesiredPropertiesStrategy.java index 533ec94142..148a446131 100644 --- a/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/ModifyFeatureDesiredPropertiesStrategy.java +++ b/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/ModifyFeatureDesiredPropertiesStrategy.java @@ -50,7 +50,7 @@ final class ModifyFeatureDesiredPropertiesStrategy } @Override - protected Result doApply(final Context context, + protected Result> doApply(final Context context, @Nullable final Thing thing, final long nextRevision, final ModifyFeatureDesiredProperties command, @@ -94,7 +94,7 @@ private Optional extractFeature(final ModifyFeatureDesiredProperties co .flatMap(features -> features.getFeature(command.getFeatureId())); } - private Result getModifyOrCreateResult(final Feature feature, + private Result> getModifyOrCreateResult(final Feature feature, final Context context, final long nextRevision, final ModifyFeatureDesiredProperties command, @@ -106,7 +106,7 @@ private Result getModifyOrCreateResult(final Feature feature, .orElseGet(() -> getCreateResult(context, nextRevision, command, thing, metadata)); } - private Result getModifyResult(final Context context, + private Result> getModifyResult(final Context context, final long nextRevision, final ModifyFeatureDesiredProperties command, @Nullable final Thing thing, @@ -125,7 +125,7 @@ private Result getModifyResult(final Context context, return ResultFactory.newMutationResult(command, event, response); } - private Result getCreateResult(final Context context, + private Result> getCreateResult(final Context context, final long nextRevision, final ModifyFeatureDesiredProperties command, @Nullable final Thing thing, diff --git a/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/ModifyFeatureDesiredPropertyStrategy.java b/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/ModifyFeatureDesiredPropertyStrategy.java index 273937e28b..58588e835e 100644 --- a/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/ModifyFeatureDesiredPropertyStrategy.java +++ b/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/ModifyFeatureDesiredPropertyStrategy.java @@ -50,7 +50,7 @@ final class ModifyFeatureDesiredPropertyStrategy extends AbstractThingCommandStr } @Override - protected Result doApply(final Context context, + protected Result> doApply(final Context context, @Nullable final Thing thing, final long nextRevision, final ModifyFeatureDesiredProperty command, @@ -93,7 +93,7 @@ private Optional extractFeature(final ModifyFeatureDesiredProperty comm .flatMap(features -> features.getFeature(command.getFeatureId())); } - private Result getModifyOrCreateResult(final Feature feature, + private Result> getModifyOrCreateResult(final Feature feature, final Context context, final long nextRevision, final ModifyFeatureDesiredProperty command, @@ -106,7 +106,7 @@ private Result getModifyOrCreateResult(final Feature feature, .orElseGet(() -> getCreateResult(context, nextRevision, command, thing, metadata)); } - private Result getModifyResult(final Context context, + private Result> getModifyResult(final Context context, final long nextRevision, final ModifyFeatureDesiredProperty command, @Nullable final Thing thing, @@ -127,7 +127,7 @@ private Result getModifyResult(final Context context, return ResultFactory.newMutationResult(command, event, response); } - private Result getCreateResult(final Context context, + private Result> getCreateResult(final Context context, final long nextRevision, final ModifyFeatureDesiredProperty command, @Nullable final Thing thing, diff --git a/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/ModifyFeaturePropertiesStrategy.java b/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/ModifyFeaturePropertiesStrategy.java index 6fa0b07b31..cce2d893cf 100644 --- a/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/ModifyFeaturePropertiesStrategy.java +++ b/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/ModifyFeaturePropertiesStrategy.java @@ -49,7 +49,7 @@ final class ModifyFeaturePropertiesStrategy extends AbstractThingCommandStrategy } @Override - protected Result doApply(final Context context, + protected Result> doApply(final Context context, @Nullable final Thing thing, final long nextRevision, final ModifyFeatureProperties command, @@ -90,7 +90,7 @@ private Optional extractFeature(final ModifyFeatureProperties command, .flatMap(features -> features.getFeature(command.getFeatureId())); } - private Result getModifyOrCreateResult(final Feature feature, final Context context, + private Result> getModifyOrCreateResult(final Feature feature, final Context context, final long nextRevision, final ModifyFeatureProperties command, @Nullable final Thing thing, @Nullable final Metadata metadata) { @@ -99,7 +99,7 @@ private Result getModifyOrCreateResult(final Feature feature, final .orElseGet(() -> getCreateResult(context, nextRevision, command, thing, metadata)); } - private Result getModifyResult(final Context context, final long nextRevision, + private Result> getModifyResult(final Context context, final long nextRevision, final ModifyFeatureProperties command, @Nullable final Thing thing, @Nullable final Metadata metadata) { final ThingId thingId = context.getState(); @@ -115,7 +115,7 @@ private Result getModifyResult(final Context context, final return ResultFactory.newMutationResult(command, event, response); } - private Result getCreateResult(final Context context, final long nextRevision, + private Result> getCreateResult(final Context context, final long nextRevision, final ModifyFeatureProperties command, @Nullable final Thing thing, @Nullable final Metadata metadata) { final ThingId thingId = context.getState(); diff --git a/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/ModifyFeaturePropertyStrategy.java b/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/ModifyFeaturePropertyStrategy.java index b280f8d17d..246e7faf82 100644 --- a/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/ModifyFeaturePropertyStrategy.java +++ b/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/ModifyFeaturePropertyStrategy.java @@ -50,7 +50,7 @@ final class ModifyFeaturePropertyStrategy extends AbstractThingCommandStrategy doApply(final Context context, + protected Result> doApply(final Context context, @Nullable final Thing thing, final long nextRevision, final ModifyFeatureProperty command, @@ -88,7 +88,7 @@ private Optional extractFeature(final ModifyFeatureProperty command, @N .flatMap(features -> features.getFeature(command.getFeatureId())); } - private Result getModifyOrCreateResult(final Feature feature, final Context context, + private Result> getModifyOrCreateResult(final Feature feature, final Context context, final long nextRevision, final ModifyFeatureProperty command, @Nullable final Thing thing, @Nullable final Metadata metadata) { @@ -98,7 +98,7 @@ private Result getModifyOrCreateResult(final Feature feature, final .orElseGet(() -> getCreateResult(context, nextRevision, command, thing, metadata)); } - private Result getModifyResult(final Context context, final long nextRevision, + private Result> getModifyResult(final Context context, final long nextRevision, final ModifyFeatureProperty command, @Nullable final Thing thing, @Nullable final Metadata metadata) { final String featureId = command.getFeatureId(); @@ -115,7 +115,7 @@ private Result getModifyResult(final Context context, final return ResultFactory.newMutationResult(command, event, response); } - private Result getCreateResult(final Context context, final long nextRevision, + private Result> getCreateResult(final Context context, final long nextRevision, final ModifyFeatureProperty command, @Nullable final Thing thing, @Nullable final Metadata metadata) { final String featureId = command.getFeatureId(); diff --git a/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/ModifyFeatureStrategy.java b/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/ModifyFeatureStrategy.java index 8748e9b5f8..95274c6812 100644 --- a/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/ModifyFeatureStrategy.java +++ b/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/ModifyFeatureStrategy.java @@ -48,7 +48,7 @@ final class ModifyFeatureStrategy extends AbstractThingCommandStrategy doApply(final Context context, + protected Result> doApply(final Context context, @Nullable final Thing thing, final long nextRevision, final ModifyFeature command, @@ -85,7 +85,7 @@ private Optional extractFeature(final ModifyFeature command, @Nullable .flatMap(features -> features.getFeature(command.getFeatureId())); } - private Result getModifyResult(final Context context, final long nextRevision, + private Result> getModifyResult(final Context context, final long nextRevision, final ModifyFeature command, @Nullable final Thing thing, @Nullable final Metadata metadata) { final DittoHeaders dittoHeaders = command.getDittoHeaders(); @@ -100,7 +100,7 @@ private Result getModifyResult(final Context context, final return ResultFactory.newMutationResult(command, event, response); } - private Result getCreateResult(final Context context, final long nextRevision, + private Result> getCreateResult(final Context context, final long nextRevision, final ModifyFeature command, @Nullable final Thing thing, @Nullable final Metadata metadata) { final DittoHeaders dittoHeaders = command.getDittoHeaders(); diff --git a/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/ModifyFeaturesStrategy.java b/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/ModifyFeaturesStrategy.java index fa10c801ea..8eddf673bb 100644 --- a/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/ModifyFeaturesStrategy.java +++ b/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/ModifyFeaturesStrategy.java @@ -48,7 +48,7 @@ final class ModifyFeaturesStrategy extends AbstractThingCommandStrategy doApply(final Context context, + protected Result> doApply(final Context context, @Nullable final Thing thing, final long nextRevision, final ModifyFeatures command, @@ -77,7 +77,7 @@ protected Result doApply(final Context context, .orElseGet(() -> getCreateResult(context, nextRevision, command, thing, metadata)); } - private Result getModifyResult(final Context context, final long nextRevision, + private Result> getModifyResult(final Context context, final long nextRevision, final ModifyFeatures command, @Nullable final Thing thing, @Nullable final Metadata metadata) { final DittoHeaders dittoHeaders = command.getDittoHeaders(); @@ -91,7 +91,7 @@ private Result getModifyResult(final Context context, final return ResultFactory.newMutationResult(command, event, response); } - private Result getCreateResult(final Context context, final long nextRevision, + private Result> getCreateResult(final Context context, final long nextRevision, final ModifyFeatures command, @Nullable final Thing thing, @Nullable final Metadata metadata) { final Features features = command.getFeatures(); diff --git a/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/ModifyPolicyIdStrategy.java b/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/ModifyPolicyIdStrategy.java index 5f3ac13d0d..49e24f3b1e 100644 --- a/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/ModifyPolicyIdStrategy.java +++ b/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/ModifyPolicyIdStrategy.java @@ -46,7 +46,7 @@ final class ModifyPolicyIdStrategy extends AbstractThingCommandStrategy doApply(final Context context, + protected Result> doApply(final Context context, @Nullable final Thing thing, final long nextRevision, final ModifyPolicyId command, @@ -61,7 +61,7 @@ private Optional extractPolicyId(final @Nullable Thing thing) { return getEntityOrThrow(thing).getPolicyEntityId(); } - private Result getModifyResult(final Context context, final long nextRevision, + private Result> getModifyResult(final Context context, final long nextRevision, final ModifyPolicyId command, @Nullable final Thing thing, @Nullable final Metadata metadata) { final ThingId thingId = context.getState(); @@ -76,7 +76,7 @@ private Result getModifyResult(final Context context, final return ResultFactory.newMutationResult(command, event, response); } - private Result getCreateResult(final Context context, final long nextRevision, + private Result> getCreateResult(final Context context, final long nextRevision, final ModifyPolicyId command, @Nullable final Thing thing, @Nullable final Metadata metadata) { final ThingId thingId = context.getState(); diff --git a/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/ModifyThingDefinitionStrategy.java b/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/ModifyThingDefinitionStrategy.java index 741a2f2451..dda15ec824 100644 --- a/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/ModifyThingDefinitionStrategy.java +++ b/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/ModifyThingDefinitionStrategy.java @@ -46,7 +46,7 @@ final class ModifyThingDefinitionStrategy extends AbstractThingCommandStrategy doApply(final Context context, + protected Result> doApply(final Context context, @Nullable final Thing thing, final long nextRevision, final ModifyThingDefinition command, @@ -61,7 +61,7 @@ private Optional extractDefinition(final @Nullable Thing thing) return getEntityOrThrow(thing).getDefinition(); } - private Result getModifyResult(final Context context, final long nextRevision, + private Result> getModifyResult(final Context context, final long nextRevision, final ModifyThingDefinition command, @Nullable final Thing thing, @Nullable final Metadata metadata) { final ThingId thingId = context.getState(); @@ -76,7 +76,7 @@ private Result getModifyResult(final Context context, final return ResultFactory.newMutationResult(command, event, response); } - private Result getCreateResult(final Context context, final long nextRevision, + private Result> getCreateResult(final Context context, final long nextRevision, final ModifyThingDefinition command, @Nullable final Thing thing, @Nullable final Metadata metadata) { final ThingId thingId = context.getState(); diff --git a/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/ModifyThingStrategy.java b/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/ModifyThingStrategy.java index 1f66e86879..58e77648a1 100644 --- a/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/ModifyThingStrategy.java +++ b/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/ModifyThingStrategy.java @@ -55,7 +55,7 @@ final class ModifyThingStrategy extends AbstractThingCommandStrategy doApply(final Context context, + protected Result> doApply(final Context context, @Nullable final Thing thing, final long nextRevision, final ModifyThing command, @@ -78,7 +78,7 @@ protected Result doApply(final Context context, return handleModifyExistingWithV2Command(context, nonNullThing, eventTs, nextRevision, command, metadata); } - private Result handleModifyExistingWithV1Command(final Context context, final Thing thing, + private Result> handleModifyExistingWithV1Command(final Context context, final Thing thing, final Instant eventTs, final long nextRevision, final ModifyThing command, @Nullable final Metadata metadata) { @@ -89,7 +89,7 @@ private Result handleModifyExistingWithV1Command(final Context handleModifyExistingV1WithV1Command(final Context context, + private Result> handleModifyExistingV1WithV1Command(final Context context, final Thing thing, final Instant eventTs, final long nextRevision, final ModifyThing command, @Nullable final Metadata metadata) { @@ -111,9 +111,9 @@ private Result handleModifyExistingV1WithV1Command(final ContextthingModified = ThingModified.of(mergedThing, nextRevision, eventTs, dittoHeaders, metadata); - final WithDittoHeaders response = + final WithDittoHeaders response = appendETagHeaderIfProvided(command, ModifyThingResponse.modified(thingId, dittoHeaders), mergedThing); return ResultFactory.newMutationResult(command, thingModified, response); @@ -126,9 +126,9 @@ private Result handleModifyExistingV1WithV1Command(final ContextthingModified = ThingModified.of(modifiedThing, nextRevision, eventTs, dittoHeaders, metadata); - final WithDittoHeaders response = + final WithDittoHeaders response = appendETagHeaderIfProvided(command, ModifyThingResponse.modified(thingId, dittoHeaders), modifiedThing); return ResultFactory.newMutationResult(command, thingModified, response); @@ -136,7 +136,7 @@ private Result handleModifyExistingV1WithV1Command(final Context handleModifyExistingV2WithV1Command(final Context context, + private Result> handleModifyExistingV2WithV1Command(final Context context, final Thing thing, final Instant eventTs, final long nextRevision, final ModifyThing command, @Nullable final Metadata metadata) { @@ -158,7 +158,7 @@ private static Thing removeACL(final Thing thing, final long nextRevision) { .build(); } - private Result handleModifyExistingWithV2Command(final Context context, final Thing thing, + private Result> handleModifyExistingWithV2Command(final Context context, final Thing thing, final Instant eventTs, final long nextRevision, final ModifyThing command, @Nullable final Metadata metadata) { @@ -172,7 +172,7 @@ private Result handleModifyExistingWithV2Command(final Context handleModifyExistingV1WithV2Command(final Context context, + private Result> handleModifyExistingV1WithV2Command(final Context context, final Thing thing, final Instant eventTs, final long nextRevision, final ModifyThing command, @Nullable final Metadata metadata) { @@ -189,7 +189,7 @@ private Result handleModifyExistingV1WithV2Command(final Context handleModifyExistingV2WithV2Command(final Context context, + private Result> handleModifyExistingV2WithV2Command(final Context context, final Thing thing, final Instant eventTs, final long nextRevision, final ModifyThing command, @Nullable final Metadata metadata) { @@ -203,7 +203,7 @@ private Result handleModifyExistingV2WithV2Command(final Context applyModifyCommand(final Context context, final Thing thing, + private Result> applyModifyCommand(final Context context, final Thing thing, final Instant eventTs, final long nextRevision, final ModifyThing command, @Nullable final Metadata metadata) { @@ -265,7 +265,7 @@ private static Thing copyPolicyId(final CommandStrategy.Context ctx, fi } @Override - public Result unhandled(final Context context, @Nullable final Thing thing, + public Result> unhandled(final Context context, @Nullable final Thing thing, final long nextRevision, final ModifyThing command) { return newErrorResult(new ThingNotAccessibleException(context.getState(), command.getDittoHeaders()), command); } diff --git a/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/RetrieveAclEntryStrategy.java b/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/RetrieveAclEntryStrategy.java index 4af85735e5..d8b873bed8 100644 --- a/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/RetrieveAclEntryStrategy.java +++ b/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/RetrieveAclEntryStrategy.java @@ -45,7 +45,7 @@ final class RetrieveAclEntryStrategy extends AbstractThingCommandStrategy doApply(final Context context, + protected Result> doApply(final Context context, @Nullable final Thing thing, final long nextRevision, final RetrieveAclEntry command, @@ -57,9 +57,9 @@ protected Result doApply(final Context context, return extractAclEntry(command, thing) .map(aclEntry -> { - final WithDittoHeaders response = appendETagHeaderIfProvided(command, + final WithDittoHeaders response = appendETagHeaderIfProvided(command, RetrieveAclEntryResponse.of(thingId, aclEntry, dittoHeaders), thing); - return ResultFactory.newQueryResult(command, response); + return ResultFactory.>newQueryResult(command, response); }) .orElseGet(() -> ResultFactory.newErrorResult( ExceptionFactory.aclEntryNotFound(thingId, authorizationSubject, dittoHeaders), command)); diff --git a/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/RetrieveAclStrategy.java b/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/RetrieveAclStrategy.java index 8d299a9415..7a019bdbec 100644 --- a/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/RetrieveAclStrategy.java +++ b/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/RetrieveAclStrategy.java @@ -45,7 +45,7 @@ final class RetrieveAclStrategy extends AbstractThingCommandStrategy doApply(final Context context, + protected Result> doApply(final Context context, @Nullable final Thing thing, final long nextRevision, final RetrieveAcl command, @@ -55,7 +55,7 @@ protected Result doApply(final Context context, .map(acl -> acl.toJson(command.getImplementedSchemaVersion())) .orElseGet(JsonFactory::newObject); - final WithDittoHeaders response = appendETagHeaderIfProvided(command, + final WithDittoHeaders response = appendETagHeaderIfProvided(command, RetrieveAclResponse.of(context.getState(), aclJson, command.getDittoHeaders()), thing); return ResultFactory.newQueryResult(command, response); diff --git a/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/RetrieveAttributeStrategy.java b/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/RetrieveAttributeStrategy.java index 1f4405b05c..dd586d7470 100644 --- a/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/RetrieveAttributeStrategy.java +++ b/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/RetrieveAttributeStrategy.java @@ -45,7 +45,7 @@ final class RetrieveAttributeStrategy extends AbstractThingCommandStrategy doApply(final Context context, + protected Result> doApply(final Context context, @Nullable final Thing thing, final long nextRevision, final RetrieveAttribute command, @@ -61,7 +61,7 @@ private Optional extractAttributes(final @Nullable Thing thing) { return getEntityOrThrow(thing).getAttributes(); } - private Result getAttributeValueResult(final JsonObject attributes, final ThingId thingId, + private Result> getAttributeValueResult(final JsonObject attributes, final ThingId thingId, final RetrieveAttribute command, @Nullable final Thing thing) { final JsonPointer attributePointer = command.getAttributePointer(); @@ -69,7 +69,7 @@ private Result getAttributeValueResult(final JsonObject attributes, return attributes.getValue(attributePointer) .map(value -> RetrieveAttributeResponse.of(thingId, attributePointer, value, dittoHeaders)) - .>map(response -> + .>>map(response -> ResultFactory.newQueryResult(command, appendETagHeaderIfProvided(command, response, thing))) .orElseGet(() -> ResultFactory.newErrorResult( ExceptionFactory.attributeNotFound(thingId, attributePointer, dittoHeaders), command)); diff --git a/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/RetrieveAttributesStrategy.java b/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/RetrieveAttributesStrategy.java index 82778854a6..5a7aecef1a 100644 --- a/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/RetrieveAttributesStrategy.java +++ b/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/RetrieveAttributesStrategy.java @@ -44,7 +44,7 @@ final class RetrieveAttributesStrategy extends AbstractThingCommandStrategy doApply(final Context context, + protected Result> doApply(final Context context, @Nullable final Thing thing, final long nextRevision, final RetrieveAttributes command, @@ -56,7 +56,7 @@ protected Result doApply(final Context context, return extractAttributes(thing) .map(attributes -> getAttributesJson(attributes, command)) .map(attributesJson -> RetrieveAttributesResponse.of(thingId, attributesJson, dittoHeaders)) - .>map(response -> + .>>map(response -> ResultFactory.newQueryResult(command, appendETagHeaderIfProvided(command, response, thing)) ) .orElseGet(() -> diff --git a/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/RetrieveFeatureDefinitionStrategy.java b/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/RetrieveFeatureDefinitionStrategy.java index 3356f87a00..cdc71f0f56 100644 --- a/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/RetrieveFeatureDefinitionStrategy.java +++ b/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/RetrieveFeatureDefinitionStrategy.java @@ -43,7 +43,7 @@ final class RetrieveFeatureDefinitionStrategy extends AbstractThingCommandStrate } @Override - protected Result doApply(final Context context, + protected Result> doApply(final Context context, @Nullable final Thing thing, final long nextRevision, final RetrieveFeatureDefinition command, @@ -63,7 +63,7 @@ private Optional extractFeature(final RetrieveFeatureDefinition command .flatMap(features -> features.getFeature(command.getFeatureId())); } - private Result getFeatureDefinition(final Feature feature, final ThingId thingId, + private Result> getFeatureDefinition(final Feature feature, final ThingId thingId, final RetrieveFeatureDefinition command, @Nullable final Thing thing) { final String featureId = feature.getId(); @@ -72,7 +72,7 @@ private Result getFeatureDefinition(final Feature feature, final Thi return feature.getDefinition() .map(featureDefinition -> RetrieveFeatureDefinitionResponse.of(thingId, featureId, featureDefinition, dittoHeaders)) - .>map(response -> + .>>map(response -> ResultFactory.newQueryResult(command, appendETagHeaderIfProvided(command, response, thing))) .orElseGet(() -> ResultFactory.newErrorResult( ExceptionFactory.featureDefinitionNotFound(thingId, featureId, dittoHeaders), command)); diff --git a/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/RetrieveFeatureDesiredPropertiesStrategy.java b/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/RetrieveFeatureDesiredPropertiesStrategy.java index a54f6f6a79..818af85882 100644 --- a/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/RetrieveFeatureDesiredPropertiesStrategy.java +++ b/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/RetrieveFeatureDesiredPropertiesStrategy.java @@ -46,7 +46,7 @@ final class RetrieveFeatureDesiredPropertiesStrategy } @Override - protected Result doApply(final Context context, + protected Result> doApply(final Context context, @Nullable final Thing thing, final long nextRevision, final RetrieveFeatureDesiredProperties command, @@ -68,7 +68,7 @@ private Optional extractFeature(final RetrieveFeatureDesiredProperties .flatMap(features -> features.getFeature(command.getFeatureId())); } - private Result getFeatureDesiredProperties(final Feature feature, + private Result> getFeatureDesiredProperties(final Feature feature, final ThingId thingId, final RetrieveFeatureDesiredProperties command, @Nullable final Thing thing) { @@ -80,7 +80,7 @@ private Result getFeatureDesiredProperties(final Feature feature, .map(desiredProperties -> getFeatureDesiredPropertiesJson(desiredProperties, command)) .map(desiredPropertiesJson -> RetrieveFeatureDesiredPropertiesResponse.of(thingId, featureId, desiredPropertiesJson, dittoHeaders)) - .>map(response -> + .>>map(response -> ResultFactory.newQueryResult(command, appendETagHeaderIfProvided(command, response, thing))) .orElseGet(() -> ResultFactory.newErrorResult( ExceptionFactory.featureDesiredPropertiesNotFound(thingId, featureId, dittoHeaders), command)); diff --git a/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/RetrieveFeatureDesiredPropertyStrategy.java b/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/RetrieveFeatureDesiredPropertyStrategy.java index 7b48e877e5..35a5e93013 100644 --- a/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/RetrieveFeatureDesiredPropertyStrategy.java +++ b/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/RetrieveFeatureDesiredPropertyStrategy.java @@ -46,7 +46,7 @@ final class RetrieveFeatureDesiredPropertyStrategy } @Override - protected Result doApply(final Context context, + protected Result> doApply(final Context context, @Nullable final Thing thing, final long nextRevision, final RetrieveFeatureDesiredProperty command, @@ -68,7 +68,7 @@ private Optional extractFeature(final RetrieveFeatureDesiredProperty co .flatMap(features -> features.getFeature(command.getFeatureId())); } - private Result getRetrieveFeatureDesiredPropertyResult(final Feature feature, + private Result> getRetrieveFeatureDesiredPropertyResult(final Feature feature, final Context context, final RetrieveFeatureDesiredProperty command, @Nullable final Thing thing) { @@ -81,7 +81,7 @@ private Result getRetrieveFeatureDesiredPropertyResult(final Feature command.getDittoHeaders()), command)); } - private Result getRetrieveFeatureDesiredPropertyResult(final JsonObject featureProperties, + private Result> getRetrieveFeatureDesiredPropertyResult(final JsonObject featureProperties, final Context context, final RetrieveFeatureDesiredProperty command, @Nullable final Thing thing) { @@ -93,7 +93,7 @@ private Result getRetrieveFeatureDesiredPropertyResult(final JsonObj return featureProperties.getValue(propertyPointer) .map(featureDesiredProperty -> RetrieveFeatureDesiredPropertyResponse.of(context.getState(), featureId, propertyPointer, featureDesiredProperty, dittoHeaders)) - .>map(response -> + .>>map(response -> ResultFactory.newQueryResult(command, appendETagHeaderIfProvided(command, response, thing))) .orElseGet(() -> ResultFactory.newErrorResult( ExceptionFactory.featureDesiredPropertyNotFound(context.getState(), featureId, propertyPointer, diff --git a/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/RetrieveFeaturePropertiesStrategy.java b/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/RetrieveFeaturePropertiesStrategy.java index 8c9931a1af..30c2c518f5 100644 --- a/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/RetrieveFeaturePropertiesStrategy.java +++ b/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/RetrieveFeaturePropertiesStrategy.java @@ -45,7 +45,7 @@ final class RetrieveFeaturePropertiesStrategy extends AbstractThingCommandStrate } @Override - protected Result doApply(final Context context, + protected Result> doApply(final Context context, @Nullable final Thing thing, final long nextRevision, final RetrieveFeatureProperties command, @@ -65,7 +65,7 @@ private Optional extractFeature(final RetrieveFeatureProperties command .flatMap(features -> features.getFeature(command.getFeatureId())); } - private Result getFeatureProperties(final Feature feature, final ThingId thingId, + private Result> getFeatureProperties(final Feature feature, final ThingId thingId, final RetrieveFeatureProperties command, @Nullable final Thing thing) { final String featureId = feature.getId(); @@ -75,7 +75,7 @@ private Result getFeatureProperties(final Feature feature, final Thi .map(featureProperties -> getFeaturePropertiesJson(featureProperties, command)) .map(featurePropertiesJson -> RetrieveFeaturePropertiesResponse.of(thingId, featureId, featurePropertiesJson, dittoHeaders)) - .>map(response -> + .>>map(response -> ResultFactory.newQueryResult(command, appendETagHeaderIfProvided(command, response, thing))) .orElseGet(() -> ResultFactory.newErrorResult( ExceptionFactory.featurePropertiesNotFound(thingId, featureId, dittoHeaders), command)); diff --git a/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/RetrieveFeaturePropertyStrategy.java b/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/RetrieveFeaturePropertyStrategy.java index 459b4693e2..25c93ad9a6 100644 --- a/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/RetrieveFeaturePropertyStrategy.java +++ b/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/RetrieveFeaturePropertyStrategy.java @@ -45,7 +45,7 @@ final class RetrieveFeaturePropertyStrategy extends AbstractThingCommandStrategy } @Override - protected Result doApply(final Context context, + protected Result> doApply(final Context context, @Nullable final Thing thing, final long nextRevision, final RetrieveFeatureProperty command, @@ -65,7 +65,7 @@ private Optional extractFeature(final RetrieveFeatureProperty command, .flatMap(features -> features.getFeature(command.getFeatureId())); } - private Result getRetrieveFeaturePropertyResult(final Feature feature, final Context context, + private Result> getRetrieveFeaturePropertyResult(final Feature feature, final Context context, final RetrieveFeatureProperty command, @Nullable final Thing thing) { return feature.getProperties() @@ -75,7 +75,7 @@ private Result getRetrieveFeaturePropertyResult(final Feature featur command.getDittoHeaders()), command)); } - private Result getRetrieveFeaturePropertyResult(final JsonObject featureProperties, + private Result> getRetrieveFeaturePropertyResult(final JsonObject featureProperties, final Context context, final RetrieveFeatureProperty command, @Nullable final Thing thing) { @@ -86,7 +86,7 @@ private Result getRetrieveFeaturePropertyResult(final JsonObject fea return featureProperties.getValue(propertyPointer) .map(featureProperty -> RetrieveFeaturePropertyResponse.of(context.getState(), featureId, propertyPointer, featureProperty, dittoHeaders)) - .>map(response -> + .>>map(response -> ResultFactory.newQueryResult(command, appendETagHeaderIfProvided(command, response, thing))) .orElseGet(() -> ResultFactory.newErrorResult( ExceptionFactory.featurePropertyNotFound(context.getState(), featureId, propertyPointer, diff --git a/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/RetrieveFeatureStrategy.java b/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/RetrieveFeatureStrategy.java index 81fe40dd4c..38330e3149 100644 --- a/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/RetrieveFeatureStrategy.java +++ b/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/RetrieveFeatureStrategy.java @@ -45,7 +45,7 @@ final class RetrieveFeatureStrategy extends AbstractThingCommandStrategy doApply(final Context context, + protected Result> doApply(final Context context, @Nullable final Thing thing, final long nextRevision, final RetrieveFeature command, @@ -63,7 +63,7 @@ private Optional extractFeatures(final @Nullable Thing thing) { return getEntityOrThrow(thing).getFeatures(); } - private Result getFeatureResult(final Features features, final ThingId thingId, + private Result> getFeatureResult(final Features features, final ThingId thingId, final RetrieveFeature command, @Nullable final Thing thing) { final String featureId = command.getFeatureId(); @@ -72,7 +72,7 @@ private Result getFeatureResult(final Features features, final Thing return features.getFeature(featureId) .map(feature -> getFeatureJson(feature, command)) .map(featureJson -> RetrieveFeatureResponse.of(thingId, featureId, featureJson, dittoHeaders)) - .>map(response -> + .>>map(response -> ResultFactory.newQueryResult(command, appendETagHeaderIfProvided(command, response, thing))) .orElseGet(() -> ResultFactory.newErrorResult( ExceptionFactory.featureNotFound(thingId, featureId, dittoHeaders), command)); diff --git a/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/RetrieveFeaturesStrategy.java b/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/RetrieveFeaturesStrategy.java index f39edcc7b8..5c84b277f1 100644 --- a/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/RetrieveFeaturesStrategy.java +++ b/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/RetrieveFeaturesStrategy.java @@ -44,7 +44,7 @@ final class RetrieveFeaturesStrategy extends AbstractThingCommandStrategy doApply(final Context context, + protected Result> doApply(final Context context, @Nullable final Thing thing, final long nextRevision, final RetrieveFeatures command, @@ -56,7 +56,7 @@ protected Result doApply(final Context context, return extractFeatures(thing) .map(features -> getFeaturesJson(features, command)) .map(featuresJson -> RetrieveFeaturesResponse.of(thingId, featuresJson, dittoHeaders)) - .>map(response -> + .>>map(response -> ResultFactory.newQueryResult(command, appendETagHeaderIfProvided(command, response, thing))) .orElseGet(() -> ResultFactory .newErrorResult(ExceptionFactory.featuresNotFound(thingId, dittoHeaders), command)); diff --git a/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/RetrievePolicyIdStrategy.java b/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/RetrievePolicyIdStrategy.java index 944c6e383b..293e1d81c5 100644 --- a/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/RetrievePolicyIdStrategy.java +++ b/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/RetrievePolicyIdStrategy.java @@ -43,7 +43,7 @@ final class RetrievePolicyIdStrategy extends AbstractThingCommandStrategy doApply(final Context context, + protected Result> doApply(final Context context, @Nullable final Thing thing, final long nextRevision, final RetrievePolicyId command, @@ -52,7 +52,7 @@ protected Result doApply(final Context context, return extractPolicyId(thing) .map(policyId -> RetrievePolicyIdResponse.of(context.getState(), policyId, command.getDittoHeaders())) - .>map(response -> + .>>map(response -> ResultFactory.newQueryResult(command, appendETagHeaderIfProvided(command, response, thing))) .orElseGet(() -> ResultFactory.newErrorResult( PolicyIdNotAccessibleException.newBuilder(context.getState()) diff --git a/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/RetrieveThingDefinitionStrategy.java b/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/RetrieveThingDefinitionStrategy.java index c78055d8bb..78eb9a4493 100644 --- a/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/RetrieveThingDefinitionStrategy.java +++ b/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/RetrieveThingDefinitionStrategy.java @@ -44,7 +44,7 @@ final class RetrieveThingDefinitionStrategy extends AbstractThingCommandStrategy @Override - protected Result doApply(final Context context, + protected Result> doApply(final Context context, @Nullable final Thing thing, final long nextRevision, final RetrieveThingDefinition command, @@ -53,7 +53,7 @@ protected Result doApply(final Context context, return extractDefinition(thing) .map(definition -> RetrieveThingDefinitionResponse.of(context.getState(), definition, command.getDittoHeaders())) - .>map(response -> + .>>map(response -> ResultFactory.newQueryResult(command, appendETagHeaderIfProvided(command, response, thing))) .orElseGet(() -> ResultFactory.newErrorResult( ThingDefinitionNotAccessibleException.newBuilder(context.getState()) diff --git a/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/RetrieveThingStrategy.java b/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/RetrieveThingStrategy.java index 8e2a1fa6a9..108b518bd5 100644 --- a/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/RetrieveThingStrategy.java +++ b/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/RetrieveThingStrategy.java @@ -56,7 +56,7 @@ public boolean isDefined(final Context context, @Nullable final Thing t } @Override - protected Result doApply(final Context context, + protected Result> doApply(final Context context, @Nullable final Thing thing, final long nextRevision, final RetrieveThing command, @@ -66,7 +66,7 @@ protected Result doApply(final Context context, appendETagHeaderIfProvided(command, getRetrieveThingResponse(thing, command), thing)); } - private static WithDittoHeaders getRetrieveThingResponse(@Nullable final Thing thing, + private static WithDittoHeaders getRetrieveThingResponse(@Nullable final Thing thing, final ThingQueryCommand command) { if (thing != null) { return RetrieveThingResponse.of(command.getThingEntityId(), getThingJson(thing, command), @@ -87,7 +87,7 @@ private static ThingNotAccessibleException notAccessible(final ThingQueryCommand } @Override - public Result unhandled(final Context context, @Nullable final Thing thing, + public Result> unhandled(final Context context, @Nullable final Thing thing, final long nextRevision, final RetrieveThing command) { return ResultFactory.newErrorResult( new ThingNotAccessibleException(context.getState(), command.getDittoHeaders()), command); diff --git a/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/SudoRetrieveThingStrategy.java b/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/SudoRetrieveThingStrategy.java index 811b87c4e8..93f585b005 100644 --- a/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/SudoRetrieveThingStrategy.java +++ b/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/SudoRetrieveThingStrategy.java @@ -56,7 +56,7 @@ public boolean isDefined(final Context context, @Nullable final Thing t } @Override - protected Result doApply(final Context context, + protected Result> doApply(final Context context, @Nullable final Thing thing, final long nextRevision, final SudoRetrieveThing command, @@ -81,7 +81,7 @@ private static JsonSchemaVersion determineSchemaVersion(final SudoRetrieveThing } @Override - public Result unhandled(final Context context, @Nullable final Thing thing, + public Result> unhandled(final Context context, @Nullable final Thing thing, final long nextRevision, final SudoRetrieveThing command) { return ResultFactory.newErrorResult( new ThingNotAccessibleException(context.getState(), command.getDittoHeaders()), command); diff --git a/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/ThingCommandStrategies.java b/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/ThingCommandStrategies.java index c42d493ebb..ad16ccd5a1 100644 --- a/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/ThingCommandStrategies.java +++ b/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/ThingCommandStrategies.java @@ -26,7 +26,7 @@ * The collection of the command strategies of {@code ThingPersistenceActor}. */ public final class ThingCommandStrategies - extends AbstractCommandStrategies> { + extends AbstractCommandStrategies, Thing, ThingId, Result>> { private static final ThingCommandStrategies INSTANCE = new ThingCommandStrategies(); @@ -61,7 +61,7 @@ public static ThingCommandStrategies getInstance() { * * @return the instance. */ - public static CommandStrategy> getCreateThingStrategy() { + public static CommandStrategy>> getCreateThingStrategy() { return CreateThingStrategy.getInstance(); } @@ -138,7 +138,7 @@ private void addSudoStrategies() { } @Override - protected Result getEmptyResult() { + protected Result> getEmptyResult() { return ResultFactory.emptyResult(); } } diff --git a/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/ThingConflictStrategy.java b/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/ThingConflictStrategy.java index c765d6b688..14a753839b 100644 --- a/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/ThingConflictStrategy.java +++ b/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/ThingConflictStrategy.java @@ -58,7 +58,7 @@ protected Optional calculateRelativeMetadata(@Nullable final Thing ent } @Override - protected Result doApply(final Context context, + protected Result> doApply(final Context context, @Nullable final Thing thing, final long nextRevision, final CreateThing command, diff --git a/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/events/AbstractThingEventStrategy.java b/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/events/AbstractThingEventStrategy.java index 74e752ccea..60afaf11c1 100644 --- a/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/events/AbstractThingEventStrategy.java +++ b/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/events/AbstractThingEventStrategy.java @@ -83,7 +83,7 @@ private Metadata mergeMetadata(@Nullable final Thing thing, final T event) { * Apply the specified event to the also specified ThingBuilder. * The builder has already the specified revision set as well as the event's timestamp. * - * @param event the ThingEvent to be applied. + * @param event the ThingEventto be applied. * @param thingBuilder builder which is derived from the {@code event}'s Thing with the revision and event * timestamp already set. * @return the updated {@code thingBuilder} after applying {@code event}. diff --git a/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/events/ThingEventStrategies.java b/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/events/ThingEventStrategies.java index 11317ec04f..092ce6da19 100644 --- a/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/events/ThingEventStrategies.java +++ b/services/things/persistence/src/main/java/org/eclipse/ditto/services/things/persistence/actors/strategies/events/ThingEventStrategies.java @@ -61,7 +61,7 @@ * This Singleton strategy handles all {@link org.eclipse.ditto.signals.events.things.ThingEvent}s. */ @Immutable -public final class ThingEventStrategies extends AbstractEventStrategies { +public final class ThingEventStrategies extends AbstractEventStrategies, Thing> { private static final ThingEventStrategies INSTANCE = new ThingEventStrategies(); diff --git a/services/things/persistence/src/test/java/org/eclipse/ditto/services/things/persistence/actors/PersistenceActorTestBaseWithSnapshotting.java b/services/things/persistence/src/test/java/org/eclipse/ditto/services/things/persistence/actors/PersistenceActorTestBaseWithSnapshotting.java index bcec40f549..1d754cde30 100644 --- a/services/things/persistence/src/test/java/org/eclipse/ditto/services/things/persistence/actors/PersistenceActorTestBaseWithSnapshotting.java +++ b/services/things/persistence/src/test/java/org/eclipse/ditto/services/things/persistence/actors/PersistenceActorTestBaseWithSnapshotting.java @@ -77,10 +77,10 @@ public abstract class PersistenceActorTestBaseWithSnapshotting extends Persisten private static final String ACTIVITY_CHECK_DELETED_INTERVAL = ACTIVITY_CHECK_PREFIX + "deleted-interval"; private ThingMongoEventAdapter eventAdapter; - private ThingsJournalTestHelper journalTestHelper; + private ThingsJournalTestHelper> journalTestHelper; private ThingsSnapshotTestHelper snapshotTestHelper; - private Map, BiFunction> commandToEventMapperRegistry; + private Map>, BiFunction, Thing, ThingEvent>> commandToEventMapperRegistry; Config createNewDefaultTestConfig() { return ConfigFactory.empty() @@ -130,7 +130,7 @@ protected void setup(final Config customConfig) { commandToEventMapperRegistry.put(DeleteThing.class, (command, thing) -> { final DeleteThing deleteCommand = (DeleteThing) command; return ThingDeleted.of(deleteCommand.getThingEntityId(), - thing.getRevision().get().toLong(), + thing.getRevision().orElseThrow().toLong(), thing.getModified().orElse(null), DittoHeaders.empty(), thing.getMetadata().orElse(null)); @@ -165,9 +165,9 @@ void assertSnapshotsEmpty(final ThingId thingId) { assertSnapshots(thingId, Collections.emptyList()); } - void assertJournal(final ThingId thingId, final List expectedEvents) { + void assertJournal(final ThingId thingId, final List> expectedEvents) { retryOnAssertionError(() -> { - final List actualEvents = journalTestHelper.getAllEvents(thingId); + final List> actualEvents = journalTestHelper.getAllEvents(thingId); Assertions.assertListWithIndexInfo(actualEvents, (actual, expected) -> { assertThat(actual) .hasType(expected.getType()) @@ -191,11 +191,11 @@ static Thing toDeletedThing(final Thing thing, final int newRevision) { return thing.toBuilder().setRevision(newRevision).setLifecycle(ThingLifecycle.DELETED).build(); } - Event toEvent(final Command command, final Thing templateThing) { - final Class clazz = command.getClass(); - final BiFunction commandToEventFunction = commandToEventMapperRegistry.get(clazz); + Event toEvent(final Command command, final Thing templateThing) { + final BiFunction, Thing, ThingEvent> commandToEventFunction = + commandToEventMapperRegistry.get(command.getClass()); if (commandToEventFunction == null) { - throw new UnsupportedOperationException("Mapping not yet implemented for type: " + clazz); + throw new UnsupportedOperationException("Mapping not yet implemented for type: " + command.getClass()); } return commandToEventFunction.apply(command, templateThing); @@ -214,8 +214,8 @@ private static void retryOnAssertionError(final Runnable r) { Assertions.retryOnAssertionError(r, PERSISTENCE_ASSERT_WAIT_AT_MOST_MS, PERSISTENCE_ASSERT_RETRY_DELAY_MS); } - private ThingEvent convertJournalEntryToEvent(final BsonDocument dbObject, final long sequenceNumber) { - final ThingEvent head = (ThingEvent) eventAdapter.fromJournal(dbObject, null).events().head(); + private ThingEvent convertJournalEntryToEvent(final BsonDocument dbObject, final long sequenceNumber) { + final ThingEvent head = (ThingEvent) eventAdapter.fromJournal(dbObject, null).events().head(); return head.setRevision(sequenceNumber); } diff --git a/services/things/persistence/src/test/java/org/eclipse/ditto/services/things/persistence/actors/ThingPersistenceActorCleanupTest.java b/services/things/persistence/src/test/java/org/eclipse/ditto/services/things/persistence/actors/ThingPersistenceActorCleanupTest.java index 2f7028de2d..dcde8f7983 100644 --- a/services/things/persistence/src/test/java/org/eclipse/ditto/services/things/persistence/actors/ThingPersistenceActorCleanupTest.java +++ b/services/things/persistence/src/test/java/org/eclipse/ditto/services/things/persistence/actors/ThingPersistenceActorCleanupTest.java @@ -58,7 +58,7 @@ public final class ThingPersistenceActorCleanupTest extends PersistenceActorTest @Test public void cleanupDeletesUntilButExcludingLatestSnapshot() { setup(createNewDefaultTestConfig()); - final List expectedEvents = new ArrayList<>(); + final List> expectedEvents = new ArrayList<>(); final LinkedList expectedSnapshots = new LinkedList<>(); new TestKit(actorSystem) { @@ -117,13 +117,13 @@ public void cleanupDeletesUntilButExcludingLatestSnapshot() { // only events after the latest snapshot should survive final long revision = latestSnapshot; - final List expectedEventsAfterCleanup = expectedEvents.stream() + final List> expectedEventsAfterCleanup = expectedEvents.stream() .filter(e -> e.getRevision() > revision) .collect(Collectors.toList()); assertJournal(thingId, expectedEventsAfterCleanup); } - private Event sendModifyThing(final Thing modifiedThing, final ActorRef underTest, + private Event sendModifyThing(final Thing modifiedThing, final ActorRef underTest, final int revisionNumber) { final ModifyThing modifyThingCommand = ModifyThing.of(modifiedThing.getEntityId() @@ -141,7 +141,7 @@ private Event sendModifyThing(final Thing modifiedThing, final ActorRef underTes @Test public void testDeletedThingIsCleanedUpCorrectly() { setup(createNewDefaultTestConfig()); - final List expectedEvents = new ArrayList<>(); + final List> expectedEvents = new ArrayList<>(); new TestKit(actorSystem) { { @@ -170,7 +170,7 @@ public void testDeletedThingIsCleanedUpCorrectly() { final Thing expectedDeletedSnapshot = toDeletedThing(thingCreated, 2); assertSnapshots(thingId, Collections.singletonList(expectedDeletedSnapshot)); - final Event deletedEvent = toEvent(deleteThing, expectedDeletedSnapshot); + final Event deletedEvent = toEvent(deleteThing, expectedDeletedSnapshot); expectedEvents.add(deletedEvent); assertJournal(thingId, expectedEvents); diff --git a/services/things/persistence/src/test/java/org/eclipse/ditto/services/things/persistence/actors/ThingPersistenceActorSnapshottingTest.java b/services/things/persistence/src/test/java/org/eclipse/ditto/services/things/persistence/actors/ThingPersistenceActorSnapshottingTest.java index 228e26b4a0..6dfdc7f701 100755 --- a/services/things/persistence/src/test/java/org/eclipse/ditto/services/things/persistence/actors/ThingPersistenceActorSnapshottingTest.java +++ b/services/things/persistence/src/test/java/org/eclipse/ditto/services/things/persistence/actors/ThingPersistenceActorSnapshottingTest.java @@ -87,7 +87,7 @@ public void deletedThingIsSnapshotWithCorrectDataAndCanBeRecreated() { .orElseThrow(IllegalStateException::new); assertThingInResponse(thingCreated, thing, 1); - final Event expectedCreatedEvent = toEvent(createThing, thingCreated); + final Event expectedCreatedEvent = toEvent(createThing, thingCreated); assertJournal(thingId, Collections.singletonList(expectedCreatedEvent)); assertSnapshotsEmpty(thingId); @@ -97,7 +97,7 @@ public void deletedThingIsSnapshotWithCorrectDataAndCanBeRecreated() { final Thing expectedDeletedSnapshot = toDeletedThing(thingCreated, 2); assertSnapshots(thingId, Collections.singletonList(expectedDeletedSnapshot)); - final Event expectedDeletedEvent = toEvent(deleteThing, expectedDeletedSnapshot); + final Event expectedDeletedEvent = toEvent(deleteThing, expectedDeletedSnapshot); // created-event has been deleted due to snapshot assertJournal(thingId, Arrays.asList(expectedCreatedEvent, expectedDeletedEvent)); @@ -123,7 +123,7 @@ public void deletedThingIsSnapshotWithCorrectDataAndCanBeRecreated() { final Thing actualThing = reCreateThingResponse.getThingCreated().orElse(null); assertThingInResponse(actualThing, thing, 3); - final Event expectedReCreatedEvent = toEvent(createThing, actualThing); + final Event expectedReCreatedEvent = toEvent(createThing, actualThing); assertJournal(thingId, Arrays.asList(expectedCreatedEvent, expectedDeletedEvent, expectedReCreatedEvent)); assertSnapshots(thingId, Collections.singletonList(expectedDeletedSnapshot)); @@ -164,7 +164,7 @@ public void thingInArbitraryStateIsSnapshotCorrectly() { LOGGER.info("Expecting Event made it to Journal and snapshots are empty. .."); - final Event expectedCreatedEvent = toEvent(createThing, actualThing); + final Event expectedCreatedEvent = toEvent(createThing, actualThing); assertJournal(thingId, Collections.singletonList(expectedCreatedEvent)); assertSnapshotsEmpty(thingId); @@ -182,7 +182,7 @@ public void thingInArbitraryStateIsSnapshotCorrectly() { LOGGER.info("Expecting Event made it to Journal and snapshots contain Thing.."); - final Event expectedModifiedEvent = toEvent(modifyThing, thingForModify); + final Event expectedModifiedEvent = toEvent(modifyThing, thingForModify); assertJournal(thingId, Arrays.asList(expectedCreatedEvent, expectedModifiedEvent)); assertSnapshots(thingId, Collections.singletonList(thingForModify)); diff --git a/services/things/persistence/src/test/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/AbstractCommandStrategyTest.java b/services/things/persistence/src/test/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/AbstractCommandStrategyTest.java index c6d01c8058..ee1066c3f5 100644 --- a/services/things/persistence/src/test/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/AbstractCommandStrategyTest.java +++ b/services/things/persistence/src/test/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/AbstractCommandStrategyTest.java @@ -66,68 +66,70 @@ protected static CommandStrategy.Context getDefaultContext() { return DefaultContext.getInstance(THING_ID, logger); } - protected static > T assertModificationResult(final CommandStrategy underTest, + protected static , T extends ThingModifiedEvent> T assertModificationResult( + final CommandStrategy>> underTest, @Nullable final Thing thing, - final Command command, + final C command, final Class expectedEventClass, - final CommandResponse expectedCommandResponse) { + final CommandResponse expectedCommandResponse) { return assertModificationResult(underTest, thing, command, expectedEventClass, expectedCommandResponse, false); } - protected static > T assertModificationResult(final CommandStrategy underTest, + protected static , T extends ThingModifiedEvent> T assertModificationResult( + final CommandStrategy>> underTest, @Nullable final Thing thing, - final Command command, + final C command, final Class expectedEventClass, - final CommandResponse expectedCommandResponse, + final CommandResponse expectedCommandResponse, final boolean becomeDeleted) { final CommandStrategy.Context context = getDefaultContext(); - final Result result = applyStrategy(underTest, context, thing, command); + final Result> result = applyStrategy(underTest, context, thing, command); return assertModificationResult(result, expectedEventClass, expectedCommandResponse, becomeDeleted); } - protected static void assertErrorResult( - final CommandStrategy> underTest, + protected static > void assertErrorResult( + final CommandStrategy>> underTest, @Nullable final Thing thing, final C command, final DittoRuntimeException expectedException) { - final ResultVisitor mock = mock(Dummy.class); + final ResultVisitor> mock = mock(Dummy.class); applyStrategy(underTest, getDefaultContext(), thing, command).accept(mock); verify(mock).onError(eq(expectedException), eq(command)); } - protected static void assertQueryResult( - final CommandStrategy> underTest, + protected static > void assertQueryResult( + final CommandStrategy>> underTest, @Nullable final Thing thing, final C command, - final CommandResponse expectedCommandResponse) { + final CommandResponse expectedCommandResponse) { assertInfoResult(applyStrategy(underTest, getDefaultContext(), thing, command), expectedCommandResponse); } - protected static void assertUnhandledResult( - final AbstractCommandStrategy> underTest, + protected static > void assertUnhandledResult( + final AbstractCommandStrategy>> underTest, @Nullable final Thing thing, final C command, final DittoRuntimeException expectedResponse) { - final ResultVisitor mock = mock(Dummy.class); + final ResultVisitor> mock = mock(Dummy.class); underTest.unhandled(getDefaultContext(), thing, NEXT_REVISION, command).accept(mock); verify(mock).onError(eq(expectedResponse), eq(command)); } - private static > T assertModificationResult(final Result result, + private static > T assertModificationResult(final Result> result, final Class eventClazz, - final WithDittoHeaders expectedResponse, + final WithDittoHeaders expectedResponse, final boolean becomeDeleted) { final ArgumentCaptor event = ArgumentCaptor.forClass(eventClazz); - final ResultVisitor mock = mock(Dummy.class); + final ResultVisitor> mock = mock(Dummy.class); result.accept(mock); @@ -136,14 +138,14 @@ private static > T assertModificationResult(fina return event.getValue(); } - private static void assertInfoResult(final Result result, final WithDittoHeaders infoResponse) { - final ResultVisitor mock = mock(Dummy.class); + private static void assertInfoResult(final Result> result, final WithDittoHeaders infoResponse) { + final ResultVisitor> mock = mock(Dummy.class); result.accept(mock); verify(mock).onQuery(any(), eq(infoResponse)); } - private static Result applyStrategy( - final CommandStrategy> underTest, + private static > Result> applyStrategy( + final CommandStrategy>> underTest, final CommandStrategy.Context context, final @Nullable Thing thing, final C command) { @@ -151,6 +153,6 @@ private static Result applyStrategy( return underTest.apply(context, thing, NEXT_REVISION, command); } - interface Dummy extends ResultVisitor {} + interface Dummy extends ResultVisitor> {} } diff --git a/services/things/persistence/src/test/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/ResultFactoryTest.java b/services/things/persistence/src/test/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/ResultFactoryTest.java index 9987f8c303..9a89740d15 100644 --- a/services/things/persistence/src/test/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/ResultFactoryTest.java +++ b/services/things/persistence/src/test/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/ResultFactoryTest.java @@ -36,7 +36,7 @@ */ public final class ResultFactoryTest { - private final ResultVisitor mock = mock(Dummy.class); + private final ResultVisitor> mock = mock(Dummy.class); private final ThingQueryCommand thingQueryCommand = mock(ThingQueryCommand.class); private final ThingModifyCommand thingModifyCommand = mock(ThingModifyCommand.class); private final ThingModifiedEvent thingModifiedEvent = mock(ThingModifiedEvent.class); @@ -50,7 +50,7 @@ public void assertImmutability() { @Test public void notifyQueryResponse() { - final Result result = ResultFactory.newQueryResult(thingQueryCommand, response); + final Result> result = ResultFactory.newQueryResult(thingQueryCommand, response); result.accept(mock); verify(mock).onQuery(eq(thingQueryCommand), eq(response)); } @@ -58,7 +58,7 @@ public void notifyQueryResponse() { @Test public void notifyException() { final Command command = mock(Command.class); - final Result result = ResultFactory.newErrorResult(exception, command); + final Result> result = ResultFactory.newErrorResult(exception, command); result.accept(this.mock); verify(this.mock).onError(eq(exception), eq(command)); } @@ -79,7 +79,7 @@ public void notifyMutationResponseWithBecomingDeleted() { } private void assertNotifyMutationResponse(final boolean becomeCreated, final boolean becomeDeleted) { - final Result result = + final Result> result = ResultFactory.newMutationResult(thingModifyCommand, thingModifiedEvent, response, becomeCreated, becomeDeleted); result.accept(mock); @@ -87,7 +87,7 @@ private void assertNotifyMutationResponse(final boolean becomeCreated, final boo eq(becomeDeleted)); } - interface Dummy extends ResultVisitor { + interface Dummy extends ResultVisitor> { } } diff --git a/services/things/persistence/src/test/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/ThingConflictStrategyTest.java b/services/things/persistence/src/test/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/ThingConflictStrategyTest.java index f18ba955e3..ba31717cab 100644 --- a/services/things/persistence/src/test/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/ThingConflictStrategyTest.java +++ b/services/things/persistence/src/test/java/org/eclipse/ditto/services/things/persistence/actors/strategies/commands/ThingConflictStrategyTest.java @@ -56,7 +56,7 @@ public void createConflictResultWithoutPrecondition() { final Thing thing = ThingsModelFactory.newThingBuilder().setId(thingId).setRevision(25L).build(); final CommandStrategy.Context context = DefaultContext.getInstance(thingId, mockLoggingAdapter()); final CreateThing command = CreateThing.of(thing, null, DittoHeaders.empty()); - final Result result = underTest.apply(context, thing, 26L, command); + final Result> result = underTest.apply(context, thing, 26L, command); result.accept(new ExpectErrorVisitor(ThingConflictException.class)); } @@ -69,7 +69,7 @@ public void createPreconditionFailedResultWithPrecondition() { final CreateThing command = CreateThing.of(thing, null, DittoHeaders.newBuilder() .ifNoneMatch(EntityTagMatchers.fromStrings("*")) .build()); - final Result result = underTest.apply(context, thing, 26L, command); + final Result> result = underTest.apply(context, thing, 26L, command); result.accept(new ExpectErrorVisitor(ThingPreconditionFailedException.class)); } @@ -79,7 +79,7 @@ private static DittoDiagnosticLoggingAdapter mockLoggingAdapter() { return mock; } - private static final class ExpectErrorVisitor implements ResultVisitor { + private static final class ExpectErrorVisitor implements ResultVisitor> { private final Class clazz; @@ -88,13 +88,13 @@ private ExpectErrorVisitor(final Class clazz) { } @Override - public void onMutation(final Command command, final ThingEvent event, final WithDittoHeaders response, + public void onMutation(final Command command, final ThingEvent event, final WithDittoHeaders response, final boolean becomeCreated, final boolean becomeDeleted) { throw new AssertionError("Expect error, got mutation: " + event); } @Override - public void onQuery(final Command command, final WithDittoHeaders response) { + public void onQuery(final Command command, final WithDittoHeaders response) { throw new AssertionError("Expect error, got query: " + response); } diff --git a/services/utils/persistent-actors/src/main/java/org/eclipse/ditto/services/utils/persistentactors/AbstractPersistenceSupervisor.java b/services/utils/persistent-actors/src/main/java/org/eclipse/ditto/services/utils/persistentactors/AbstractPersistenceSupervisor.java index 0d2f23c9dc..a6a1c0faef 100644 --- a/services/utils/persistent-actors/src/main/java/org/eclipse/ditto/services/utils/persistentactors/AbstractPersistenceSupervisor.java +++ b/services/utils/persistent-actors/src/main/java/org/eclipse/ditto/services/utils/persistentactors/AbstractPersistenceSupervisor.java @@ -52,10 +52,9 @@ public abstract class AbstractPersistenceSupervisor extends @Nullable private E entityId; @Nullable private Props persistenceActorProps; - @Nullable private ShutdownBehaviour shutdownBehaviour; @Nullable private ActorRef child; - private ExponentialBackOffConfig exponentialBackOffConfig; + private final ExponentialBackOffConfig exponentialBackOffConfig; private Instant lastRestart; private Duration restartDelay; @@ -123,9 +122,8 @@ public void preStart() throws Exception { try { entityId = getEntityId(); persistenceActorProps = getPersistenceActorProps(entityId); - shutdownBehaviour = getShutdownBehaviour(entityId); startChild(Control.START_CHILD); - becomeActive(shutdownBehaviour); + becomeActive(getShutdownBehaviour(entityId)); } catch (final Exception e) { log.error(e, "Failed to determine entity ID; becoming corrupted."); becomeCorrupted(); @@ -252,7 +250,7 @@ private void replyUnavailableException(final Object message) { log.warning("Received message during downtime of child actor for Entity with ID <{}>: <{}>", entityId, message); final DittoRuntimeExceptionBuilder builder = getUnavailableExceptionBuilder(entityId); if (message instanceof WithDittoHeaders) { - builder.dittoHeaders(((WithDittoHeaders) message).getDittoHeaders()); + builder.dittoHeaders(((WithDittoHeaders) message).getDittoHeaders()); } getSender().tell(builder.build(), getSelf()); } diff --git a/services/utils/persistent-actors/src/main/java/org/eclipse/ditto/services/utils/persistentactors/AbstractShardedPersistenceActor.java b/services/utils/persistent-actors/src/main/java/org/eclipse/ditto/services/utils/persistentactors/AbstractShardedPersistenceActor.java index 2a7c9516a0..a621bfa668 100755 --- a/services/utils/persistent-actors/src/main/java/org/eclipse/ditto/services/utils/persistentactors/AbstractShardedPersistenceActor.java +++ b/services/utils/persistent-actors/src/main/java/org/eclipse/ditto/services/utils/persistentactors/AbstractShardedPersistenceActor.java @@ -56,11 +56,11 @@ * @param the base type of the Events this actor emits */ public abstract class AbstractShardedPersistenceActor< - C extends Command, + C extends Command, S, I extends EntityId, K, - E extends Event> extends AbstractPersistentActorWithTimersAndCleanup implements ResultVisitor { + E extends Event> extends AbstractPersistentActorWithTimersAndCleanup implements ResultVisitor { private final SnapshotAdapter snapshotAdapter; private final Receive handleEvents; @@ -87,6 +87,7 @@ public abstract class AbstractShardedPersistenceActor< * @param entityId the entity ID. * @param snapshotAdapter the entity's snapshot adapter. */ + @SuppressWarnings("unchecked") protected AbstractShardedPersistenceActor(final I entityId, final SnapshotAdapter snapshotAdapter) { this.entityId = entityId; this.snapshotAdapter = snapshotAdapter; @@ -97,7 +98,7 @@ protected AbstractShardedPersistenceActor(final I entityId, final SnapshotAdapte handleEvents = ReceiveBuilder.create() .match(getEventClass(), event -> { - entity = getEventStrategy().handle(event, entity, getRevisionNumber()); + entity = getEventStrategy().handle((E) event, entity, getRevisionNumber()); onEntityModified(); }) .build(); @@ -124,7 +125,7 @@ protected void onEntityModified() { /** * @return class of the events persisted by this actor. */ - protected abstract Class getEventClass(); + protected abstract Class getEventClass(); /** * @return the context for handling commands based on the actor's current state. @@ -166,7 +167,7 @@ protected void onEntityModified() { /** * @return An exception builder to respond to unexpected commands addressed to a nonexistent entity. */ - protected abstract DittoRuntimeExceptionBuilder newNotAccessibleExceptionBuilder(); + protected abstract DittoRuntimeExceptionBuilder newNotAccessibleExceptionBuilder(); /** * Publish an event. @@ -293,7 +294,7 @@ protected void persistAndApplyEvent(final E event, final BiConsumer handle final DittoHeaders newHeaders = event.getDittoHeaders().toBuilder() .schemaVersion(getEntitySchemaVersion(entity)) .build(); - modifiedEvent = (E) event.setDittoHeaders(newHeaders); + modifiedEvent = event.setDittoHeaders(newHeaders); } else { modifiedEvent = event; } @@ -381,13 +382,13 @@ private void handleByCommandStrategy(final C command) { handleByStrategy(command, getCreatedStrategy()); } - private ReceiveBuilder handleByStrategyReceiveBuilder( + private > ReceiveBuilder handleByStrategyReceiveBuilder( final CommandStrategy> strategy) { return ReceiveBuilder.create() .match(strategy.getMatchingClass(), command -> handleByStrategy(command, strategy)); } - private void handleByStrategy(final T command, + private > void handleByStrategy(final T command, final CommandStrategy> strategy) { log.debug("Handling by strategy: <{}>", command); accessCounter++; @@ -402,7 +403,7 @@ private void handleByStrategy(final T command, } @Override - public void onMutation(final Command command, final E event, final WithDittoHeaders response, + public void onMutation(final Command command, final E event, final WithDittoHeaders response, final boolean becomeCreated, final boolean becomeDeleted) { persistAndApplyEvent(event, (persistedEvent, resultingEntity) -> { @@ -426,14 +427,14 @@ private boolean shouldSendResponse(final DittoHeaders dittoHeaders) { } @Override - public void onQuery(final Command command, final WithDittoHeaders response) { + public void onQuery(final Command command, final WithDittoHeaders response) { if (command.getDittoHeaders().isResponseRequired()) { notifySender(response); } } @Override - public void onError(final DittoRuntimeException error, final Command errorCausingCommand) { + public void onError(final DittoRuntimeException error, final Command errorCausingCommand) { if (shouldSendResponse(errorCausingCommand.getDittoHeaders())) { notifySender(error); } @@ -491,11 +492,11 @@ private void applyEvent(final E event) { publishEvent(event); } - private void notifySender(final WithDittoHeaders message) { + private void notifySender(final WithDittoHeaders message) { notifySender(getSender(), message); } - private void notifySender(final ActorRef sender, final WithDittoHeaders message) { + private void notifySender(final ActorRef sender, final WithDittoHeaders message) { accessCounter++; sender.tell(message, getSelf()); } @@ -524,9 +525,9 @@ protected long getLatestSnapshotSequenceNumber() { } private void notAccessible(final Object message) { - final DittoRuntimeExceptionBuilder builder = newNotAccessibleExceptionBuilder(); + final DittoRuntimeExceptionBuilder builder = newNotAccessibleExceptionBuilder(); if (message instanceof WithDittoHeaders) { - builder.dittoHeaders(((WithDittoHeaders) message).getDittoHeaders()); + builder.dittoHeaders(((WithDittoHeaders) message).getDittoHeaders()); } notifySender(builder.build()); } diff --git a/services/utils/persistent-actors/src/main/java/org/eclipse/ditto/services/utils/persistentactors/commands/AbstractCommandStrategies.java b/services/utils/persistent-actors/src/main/java/org/eclipse/ditto/services/utils/persistentactors/commands/AbstractCommandStrategies.java index c186916046..1049b02cca 100644 --- a/services/utils/persistent-actors/src/main/java/org/eclipse/ditto/services/utils/persistentactors/commands/AbstractCommandStrategies.java +++ b/services/utils/persistent-actors/src/main/java/org/eclipse/ditto/services/utils/persistentactors/commands/AbstractCommandStrategies.java @@ -32,7 +32,7 @@ * @param the type of the results */ @Immutable -public abstract class AbstractCommandStrategies +public abstract class AbstractCommandStrategies, S, K, R extends Result> extends AbstractCommandStrategy { protected final Map, CommandStrategy> strategies; @@ -43,8 +43,9 @@ public abstract class AbstractCommandStrategies theMatchingClass) { - super(theMatchingClass); + @SuppressWarnings({"unchecked", "rawtypes"}) + protected AbstractCommandStrategies(final Class theMatchingClass) { + super((Class) theMatchingClass); strategies = new HashMap<>(); } @@ -102,7 +103,8 @@ protected R doApply(final Context context, @Nullable final S entity, final lo } @Nullable - private CommandStrategy getAppropriateStrategy(final Class commandClass) { + @SuppressWarnings("unchecked") + private CommandStrategy getAppropriateStrategy(final Class commandClass) { return (CommandStrategy) strategies.get(commandClass); } diff --git a/services/utils/persistent-actors/src/main/java/org/eclipse/ditto/services/utils/persistentactors/commands/AbstractCommandStrategy.java b/services/utils/persistent-actors/src/main/java/org/eclipse/ditto/services/utils/persistentactors/commands/AbstractCommandStrategy.java index 4be9340e91..d0a4c34c6e 100644 --- a/services/utils/persistent-actors/src/main/java/org/eclipse/ditto/services/utils/persistentactors/commands/AbstractCommandStrategy.java +++ b/services/utils/persistent-actors/src/main/java/org/eclipse/ditto/services/utils/persistentactors/commands/AbstractCommandStrategy.java @@ -35,7 +35,7 @@ * @param the type of the result */ @Immutable -public abstract class AbstractCommandStrategy +public abstract class AbstractCommandStrategy, S, K, R extends Result> implements CommandStrategy { private final Class matchingClass; diff --git a/services/utils/persistent-actors/src/main/java/org/eclipse/ditto/services/utils/persistentactors/commands/CommandStrategy.java b/services/utils/persistent-actors/src/main/java/org/eclipse/ditto/services/utils/persistentactors/commands/CommandStrategy.java index 447742553f..a207799187 100644 --- a/services/utils/persistent-actors/src/main/java/org/eclipse/ditto/services/utils/persistentactors/commands/CommandStrategy.java +++ b/services/utils/persistent-actors/src/main/java/org/eclipse/ditto/services/utils/persistentactors/commands/CommandStrategy.java @@ -26,7 +26,7 @@ * @param the type of the context * @param the type of the results */ -public interface CommandStrategy { +public interface CommandStrategy, S, K, R extends Result> { /** * @return the message class to react to. diff --git a/services/utils/persistent-actors/src/main/java/org/eclipse/ditto/services/utils/persistentactors/etags/AbstractConditionHeaderCheckingCommandStrategy.java b/services/utils/persistent-actors/src/main/java/org/eclipse/ditto/services/utils/persistentactors/etags/AbstractConditionHeaderCheckingCommandStrategy.java index a9e1d259e8..4ccdec5d13 100644 --- a/services/utils/persistent-actors/src/main/java/org/eclipse/ditto/services/utils/persistentactors/etags/AbstractConditionHeaderCheckingCommandStrategy.java +++ b/services/utils/persistent-actors/src/main/java/org/eclipse/ditto/services/utils/persistentactors/etags/AbstractConditionHeaderCheckingCommandStrategy.java @@ -40,10 +40,10 @@ */ @Immutable public abstract class AbstractConditionHeaderCheckingCommandStrategy< - C extends Command, - S extends Entity, + C extends Command, + S extends Entity, K, - E extends Event> extends AbstractCommandStrategy> implements ETagEntityProvider { + E extends Event> extends AbstractCommandStrategy> implements ETagEntityProvider { /** * Construct a command-strategy with condition header checking.. diff --git a/services/utils/persistent-actors/src/main/java/org/eclipse/ditto/services/utils/persistentactors/events/AbstractEventStrategies.java b/services/utils/persistent-actors/src/main/java/org/eclipse/ditto/services/utils/persistentactors/events/AbstractEventStrategies.java index 2710a715d8..67ec24dc77 100644 --- a/services/utils/persistent-actors/src/main/java/org/eclipse/ditto/services/utils/persistentactors/events/AbstractEventStrategies.java +++ b/services/utils/persistent-actors/src/main/java/org/eclipse/ditto/services/utils/persistentactors/events/AbstractEventStrategies.java @@ -31,7 +31,7 @@ * @param the type of the entity */ @Immutable -public abstract class AbstractEventStrategies implements EventStrategy { +public abstract class AbstractEventStrategies, S> implements EventStrategy { protected final Logger log = LoggerFactory.getLogger(getClass()); diff --git a/services/utils/persistent-actors/src/main/java/org/eclipse/ditto/services/utils/persistentactors/events/EventStrategy.java b/services/utils/persistent-actors/src/main/java/org/eclipse/ditto/services/utils/persistentactors/events/EventStrategy.java index b8eac08f59..f2f1c03f7b 100644 --- a/services/utils/persistent-actors/src/main/java/org/eclipse/ditto/services/utils/persistentactors/events/EventStrategy.java +++ b/services/utils/persistent-actors/src/main/java/org/eclipse/ditto/services/utils/persistentactors/events/EventStrategy.java @@ -23,7 +23,7 @@ * @param the type of the entity */ @FunctionalInterface -public interface EventStrategy { +public interface EventStrategy, S> { /** * Applies an event to an entity. diff --git a/services/utils/persistent-actors/src/main/java/org/eclipse/ditto/services/utils/persistentactors/results/EmptyResult.java b/services/utils/persistent-actors/src/main/java/org/eclipse/ditto/services/utils/persistentactors/results/EmptyResult.java index dd48c1cf85..964c91f1da 100644 --- a/services/utils/persistent-actors/src/main/java/org/eclipse/ditto/services/utils/persistentactors/results/EmptyResult.java +++ b/services/utils/persistent-actors/src/main/java/org/eclipse/ditto/services/utils/persistentactors/results/EmptyResult.java @@ -19,9 +19,9 @@ * * @param type of events. */ -public final class EmptyResult implements Result { +public final class EmptyResult> implements Result { - private static final Object INSTANCE = new EmptyResult(); + private static final Object INSTANCE = new EmptyResult<>(); /** * Returns the singleton instance of an empty {@link Result}. @@ -30,12 +30,12 @@ public final class EmptyResult implements Result { * @return the empty result instance. */ @SuppressWarnings("unchecked") - public static EmptyResult getInstance() { + public static > EmptyResult getInstance() { return (EmptyResult) INSTANCE; } @Override - public void accept(final ResultVisitor visitor) { + public void accept(final ResultVisitor visitor) { visitor.onEmpty(); } diff --git a/services/utils/persistent-actors/src/main/java/org/eclipse/ditto/services/utils/persistentactors/results/ErrorResult.java b/services/utils/persistent-actors/src/main/java/org/eclipse/ditto/services/utils/persistentactors/results/ErrorResult.java index c98904e144..871b648615 100644 --- a/services/utils/persistent-actors/src/main/java/org/eclipse/ditto/services/utils/persistentactors/results/ErrorResult.java +++ b/services/utils/persistent-actors/src/main/java/org/eclipse/ditto/services/utils/persistentactors/results/ErrorResult.java @@ -19,12 +19,12 @@ /** * Result signifying an error. */ -public final class ErrorResult implements Result { +public final class ErrorResult> implements Result { - private final Command errorCausingCommand; + private final Command errorCausingCommand; private final DittoRuntimeException dittoRuntimeException; - ErrorResult(final DittoRuntimeException dittoRuntimeException, final Command errorCausingCommand) { + ErrorResult(final DittoRuntimeException dittoRuntimeException, final Command errorCausingCommand) { this.dittoRuntimeException = dittoRuntimeException; this.errorCausingCommand = errorCausingCommand; } diff --git a/services/utils/persistent-actors/src/main/java/org/eclipse/ditto/services/utils/persistentactors/results/MutationResult.java b/services/utils/persistent-actors/src/main/java/org/eclipse/ditto/services/utils/persistentactors/results/MutationResult.java index cc7d774c31..b6cbc80e7c 100644 --- a/services/utils/persistent-actors/src/main/java/org/eclipse/ditto/services/utils/persistentactors/results/MutationResult.java +++ b/services/utils/persistent-actors/src/main/java/org/eclipse/ditto/services/utils/persistentactors/results/MutationResult.java @@ -21,15 +21,15 @@ * * @param type of the event. */ -public final class MutationResult implements Result { +public final class MutationResult> implements Result { - private final Command command; + private final Command command; private final E eventToPersist; - private final WithDittoHeaders response; + private final WithDittoHeaders response; private final boolean becomeCreated; private final boolean becomeDeleted; - MutationResult(final Command command, final E eventToPersist, final WithDittoHeaders response, + MutationResult(final Command command, final E eventToPersist, final WithDittoHeaders response, final boolean becomeCreated, final boolean becomeDeleted) { this.command = command; this.eventToPersist = eventToPersist; diff --git a/services/utils/persistent-actors/src/main/java/org/eclipse/ditto/services/utils/persistentactors/results/QueryResult.java b/services/utils/persistent-actors/src/main/java/org/eclipse/ditto/services/utils/persistentactors/results/QueryResult.java index 5b16e64585..ae5e479ab0 100644 --- a/services/utils/persistent-actors/src/main/java/org/eclipse/ditto/services/utils/persistentactors/results/QueryResult.java +++ b/services/utils/persistent-actors/src/main/java/org/eclipse/ditto/services/utils/persistentactors/results/QueryResult.java @@ -21,12 +21,12 @@ * * @param type of events (irrelevant). */ -public final class QueryResult implements Result { +public final class QueryResult> implements Result { - private final Command command; - private final WithDittoHeaders response; + private final Command command; + private final WithDittoHeaders response; - QueryResult(final Command command, final WithDittoHeaders response) { + QueryResult(final Command command, final WithDittoHeaders response) { this.command = command; this.response = response; } diff --git a/services/utils/persistent-actors/src/main/java/org/eclipse/ditto/services/utils/persistentactors/results/Result.java b/services/utils/persistent-actors/src/main/java/org/eclipse/ditto/services/utils/persistentactors/results/Result.java index b93c8aaab6..d05d5d16cb 100644 --- a/services/utils/persistent-actors/src/main/java/org/eclipse/ditto/services/utils/persistentactors/results/Result.java +++ b/services/utils/persistent-actors/src/main/java/org/eclipse/ditto/services/utils/persistentactors/results/Result.java @@ -17,7 +17,7 @@ /** * The result of applying the strategy to the given command. */ -public interface Result { +public interface Result> { /** * Evaluate the result by a visitor. @@ -29,7 +29,7 @@ public interface Result { /** * @return the empty result */ - static Result empty() { + static > Result empty() { return ResultFactory.emptyResult(); } diff --git a/services/utils/persistent-actors/src/main/java/org/eclipse/ditto/services/utils/persistentactors/results/ResultFactory.java b/services/utils/persistent-actors/src/main/java/org/eclipse/ditto/services/utils/persistentactors/results/ResultFactory.java index 7af13f7600..1886a6673c 100644 --- a/services/utils/persistent-actors/src/main/java/org/eclipse/ditto/services/utils/persistentactors/results/ResultFactory.java +++ b/services/utils/persistent-actors/src/main/java/org/eclipse/ditto/services/utils/persistentactors/results/ResultFactory.java @@ -38,8 +38,8 @@ private ResultFactory() { * @param type of the event. * @return the result. */ - public static Result newMutationResult(final Command command, final E eventToPersist, - final WithDittoHeaders response) { + public static > Result newMutationResult(final Command command, final E eventToPersist, + final WithDittoHeaders response) { return new MutationResult<>(command, eventToPersist, response, false, false); } @@ -55,9 +55,9 @@ public static Result newMutationResult(final Command comman * @param type of the event. * @return the result. */ - public static Result newMutationResult(final Command command, + public static > Result newMutationResult(final Command command, final E eventToPersist, - final WithDittoHeaders response, + final WithDittoHeaders response, final boolean becomeCreated, final boolean becomeDeleted) { @@ -72,8 +72,8 @@ public static Result newMutationResult(final Command comman * @param type of events (irrelevant). * @return the result. */ - public static Result newErrorResult(final DittoRuntimeException dittoRuntimeException, - final Command errorCausingCommand) { + public static > Result newErrorResult(final DittoRuntimeException dittoRuntimeException, + final Command errorCausingCommand) { return new ErrorResult<>(dittoRuntimeException, errorCausingCommand); } @@ -85,7 +85,8 @@ public static Result newErrorResult(final DittoRuntimeExcep * @param type of events (irrelevant). * @return the result. */ - public static Result newQueryResult(final Command command, final WithDittoHeaders response) { + public static > Result newQueryResult(final Command command, + final WithDittoHeaders response) { return new QueryResult<>(command, response); } @@ -95,7 +96,7 @@ public static Result newQueryResult(final Command command, * @param type of events (irrelevant). * @return the empty result. */ - public static Result emptyResult() { + public static > Result emptyResult() { return EmptyResult.getInstance(); } diff --git a/services/utils/persistent-actors/src/main/java/org/eclipse/ditto/services/utils/persistentactors/results/ResultVisitor.java b/services/utils/persistent-actors/src/main/java/org/eclipse/ditto/services/utils/persistentactors/results/ResultVisitor.java index e1aad85e75..b9efd6034c 100644 --- a/services/utils/persistent-actors/src/main/java/org/eclipse/ditto/services/utils/persistentactors/results/ResultVisitor.java +++ b/services/utils/persistent-actors/src/main/java/org/eclipse/ditto/services/utils/persistentactors/results/ResultVisitor.java @@ -22,7 +22,7 @@ * * @param type of events. */ -public interface ResultVisitor { +public interface ResultVisitor> { /** * Evaluate the empty result. Do nothing by default. @@ -40,7 +40,7 @@ default void onEmpty() { * @param becomeCreated whether the actor should behave as if the entity is created. * @param becomeDeleted whether the actor should behave as if the entity is deleted. */ - void onMutation(Command command, E event, WithDittoHeaders response, boolean becomeCreated, boolean becomeDeleted); + void onMutation(Command command, E event, WithDittoHeaders response, boolean becomeCreated, boolean becomeDeleted); /** * Evaluate a query result. @@ -48,12 +48,12 @@ default void onEmpty() { * @param command the query command. * @param response the response. */ - void onQuery(Command command, WithDittoHeaders response); + void onQuery(Command command, WithDittoHeaders response); /** * Evaluate an error result. * * @param error the error. */ - void onError(DittoRuntimeException error, Command errorCausingCommand); + void onError(DittoRuntimeException error, Command errorCausingCommand); }