5251b7acc39832dfe54b2e81ff79b65476298541
[policy/drools-applications.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP
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
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
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=========================================================
19  */
20
21 package org.onap.policy.controlloop.eventmanager;
22
23 import java.io.Serializable;
24 import java.util.concurrent.CompletableFuture;
25 import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome;
26
27 /**
28  * Context used by steps to perform their work.
29  */
30 public interface StepContext {
31
32     /**
33      * Determines if the context contains a property.
34      *
35      * @param name name of the property of interest
36      * @return {@code true} if the context contains the property, {@code false} otherwise
37      */
38     public boolean contains(String name);
39
40     /**
41      * Gets a property, casting it to the desired type.
42      *
43      * @param <T> desired type
44      * @param name name of the property whose value is to be retrieved
45      * @return the property's value, or {@code null} if it does not yet have a value
46      */
47     public <T> T getProperty(String name);
48
49     /**
50      * Sets a property's value.
51      *
52      * @param name property name
53      * @param value new property value
54      */
55     public void setProperty(String name, Serializable value);
56
57     /**
58      * Removes a property.
59      *
60      * @param name property name
61      */
62     public void removeProperty(String name);
63
64     /**
65      * Requests a lock. This requests the lock for the time that remains before the
66      * timeout expires. This avoids having to extend the lock.
67      *
68      * @param targetEntity entity to be locked
69      * @return a future that can be used to await the lock
70      */
71     public CompletableFuture<OperationOutcome> requestLock(String targetEntity);
72 }