2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.policy.controlloop.actorserviceprovider.impl;
24 import java.util.function.Function;
25 import org.onap.policy.controlloop.actorserviceprovider.Util;
26 import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpActorParams;
29 * Actor that uses HTTP, where the only additional property that an operator needs is a
30 * URL. The actor's operator parameters are expected to be an {@link HttpParams}.
32 * @param <P> type of parameters
34 public class HttpActor<P extends HttpActorParams> extends ActorImpl {
37 * Class of Actor parameters.
39 private final Class<P> paramsClass;
42 * Constructs the object.
44 * @param name actor's name
45 * @param paramsClass class of parameters
47 public HttpActor(String name, Class<P> paramsClass) {
49 this.paramsClass = paramsClass;
53 * Translates the parameters to an {@link HttpActorParams} and then creates a function
54 * that will extract operator-specific parameters.
57 protected Function<String, Map<String, Object>> makeOperatorParameters(Map<String, Object> actorParameters) {
58 String actorName = getName();
61 return Util.translate(actorName, actorParameters, paramsClass)
62 .doValidation(actorName)
63 .makeOperationParameters(actorName);