import java.util.Arrays;
import java.util.List;
import java.util.Map;
-import lombok.Getter;
import org.onap.policy.common.parameters.ValidationResult;
-import org.onap.policy.controlloop.actorserviceprovider.Operation;
import org.onap.policy.controlloop.actorserviceprovider.Util;
import org.onap.policy.controlloop.actorserviceprovider.parameters.BidirectionalTopicConfig;
import org.onap.policy.controlloop.actorserviceprovider.parameters.BidirectionalTopicParams;
-import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams;
-import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpParams;
import org.onap.policy.controlloop.actorserviceprovider.parameters.ParameterValidationRuntimeException;
import org.onap.policy.controlloop.actorserviceprovider.topic.BidirectionalTopicHandler;
import org.onap.policy.controlloop.actorserviceprovider.topic.BidirectionalTopicManager;
* Operator that uses a bidirectional topic. Topic operators may share a
* {@link BidirectionalTopicHandler}.
*/
-public class BidirectionalTopicOperator extends OperatorPartial {
-
- /**
- * Function to make an operation.
- */
- @SuppressWarnings("rawtypes")
- private final OperationMaker<BidirectionalTopicConfig, BidirectionalTopicOperation> operationMaker;
+public class BidirectionalTopicOperator
+ extends TypedOperator<BidirectionalTopicConfig, BidirectionalTopicOperation<?, ?>> {
/**
* Manager from which to get the topic handlers.
*/
private final List<SelectorKey> selectorKeys;
- /**
- * Current configuration. This is set by {@link #doConfigure(Map)}.
- */
- @Getter
- private BidirectionalTopicConfig currentConfig;
-
/**
* Constructs the object.
* @param selectorKeys keys used to extract the fields used to select responses for
* this operator
*/
- // @formatter:off
public BidirectionalTopicOperator(String actorName, String name, BidirectionalTopicManager topicManager,
List<SelectorKey> selectorKeys,
- @SuppressWarnings("rawtypes") OperationMaker<BidirectionalTopicConfig, BidirectionalTopicOperation>
- operationMaker) {
- // @formatter:on
+ OperationMaker<BidirectionalTopicConfig, BidirectionalTopicOperation<?, ?>> operationMaker) {
- super(actorName, name);
+ super(actorName, name, operationMaker);
this.topicManager = topicManager;
this.selectorKeys = selectorKeys;
- this.operationMaker = operationMaker;
}
/**
* @param selectorKeys keys used to extract the fields used to select responses for
* this operator
*/
- // @formatter:off
public BidirectionalTopicOperator(String actorName, String name, BidirectionalTopicManager topicManager,
- @SuppressWarnings("rawtypes") OperationMaker<BidirectionalTopicConfig, BidirectionalTopicOperation>
- operationMaker,
+ OperationMaker<BidirectionalTopicConfig, BidirectionalTopicOperation<?, ?>> operationMaker,
SelectorKey... selectorKeys) {
- // @formatter:on
this(actorName, name, topicManager, Arrays.asList(selectorKeys), operationMaker);
}
- /**
- * Translates the parameters to an {@link HttpParams} and then extracts the relevant
- * values.
- */
- @Override
- protected void doConfigure(Map<String, Object> parameters) {
- currentConfig = makeConfiguration(parameters);
- }
-
/**
* Makes a new configuration using the specified parameters.
*
return new BidirectionalTopicConfig(getBlockingExecutor(), params, topicManager, selectorKeys);
}
-
- @Override
- public Operation buildOperation(ControlLoopOperationParams params) {
- if (operationMaker == null) {
- throw new UnsupportedOperationException("cannot make operation for " + getFullName());
- }
-
- verifyRunning();
-
- return operationMaker.apply(params, currentConfig);
- }
}