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.controlloop;
23 import java.io.Serializable;
25 import java.util.concurrent.ConcurrentHashMap;
26 import lombok.AccessLevel;
29 import org.onap.policy.aai.AaiCqResponse;
30 import org.onap.policy.controlloop.VirtualControlLoopEvent;
33 * Context associated with a control loop event.
37 public class ControlLoopEventContext implements Serializable {
38 private static final long serialVersionUID = 1L;
40 @Setter(AccessLevel.NONE)
41 private final VirtualControlLoopEvent event;
43 private AaiCqResponse aaiCqResponse;
45 // TODO may remove this if it proves not to be needed
46 @Getter(AccessLevel.NONE)
47 @Setter(AccessLevel.NONE)
48 private Map<String, Serializable> properties = new ConcurrentHashMap<>();
51 * Constructs the object.
53 * @param event event with which this is associated
55 public ControlLoopEventContext(VirtualControlLoopEvent event) {
60 * Determines if the context contains a property.
62 * @param name name of the property of interest
63 * @return {@code true} if the context contains the property, {@code false} otherwise
65 public boolean contains(String name) {
66 return properties.containsKey(name);
70 * Gets a property, casting it to the desired type.
72 * @param <T> desired type
73 * @param name name of the property whose value is to be retrieved
74 * @return the property's value, or {@code null} if it does not yet have a value
76 @SuppressWarnings("unchecked")
77 public <T> T getProperty(String name) {
78 return (T) properties.get(name);
82 * Sets a property's value.
84 * @param name property name
85 * @param value new property value
87 public void setProperty(String name, Serializable value) {
88 properties.put(name, value);