31ffedea84af347c35dd72ffef3901146be705ac
[policy/apex-pdp.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  *  Copyright (C) 2016-2018 Ericsson. All rights reserved.
4  *  Modifications Copyright (C) 2022 Nordix Foundation.
5  * ================================================================================
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  *      http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  * SPDX-License-Identifier: Apache-2.0
19  * ============LICENSE_END=========================================================
20  */
21
22 package org.onap.policy.apex.model.policymodel.concepts;
23
24 import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey;
25
26 /**
27  * This class holds State Finalizer Logic for {@link AxState} states in Apex. It is a specialization
28  * of the {@link AxLogic} class, so that State Finalizer Logic in Apex states can be strongly typed.
29  *
30  * <p>State Finalizer Logic is used to select the output {@link AxStateOutput} that a state will use.
31  * The logic uses fields emitted by the executed {@link AxTask} task and information from the
32  * context albums available on a state to decide what state output {@link AxStateOutput} to select
33  * in a given context. State Finalizer Logic must marshal the output fields from the task onto the
34  * output event in whatever manner is appropriate for the domain being handled.
35  *
36  * <p>Validation uses standard Apex Logic validation, see validation in {@link AxLogic}.
37  */
38 public class AxStateFinalizerLogic extends AxLogic {
39     private static final long serialVersionUID = 2090324845463750391L;
40
41     /**
42      * The Default Constructor creates a logic instance with a null key, undefined logic flavour and
43      * a null logic string.
44      */
45     public AxStateFinalizerLogic() {
46         super();
47     }
48
49     /**
50      * The Key Constructor creates a logic instance with the given reference key, undefined logic
51      * flavour and a null logic string.
52      *
53      * @param key the reference key of the logic
54      */
55     public AxStateFinalizerLogic(final AxReferenceKey key) {
56         super(key, LOGIC_FLAVOUR_UNDEFINED, "");
57     }
58
59     /**
60      * This Constructor creates a logic instance with a reference key constructed from the parents
61      * key and the logic local name and all of its fields defined.
62      *
63      * @param parentKey the reference key of the parent of this logic
64      * @param logicName the logic name, held as the local name of the reference key of this logic
65      * @param logicFlavour the flavour of this logic
66      * @param logic the actual logic as a string
67      */
68     public AxStateFinalizerLogic(final AxReferenceKey parentKey, final String logicName, final String logicFlavour,
69             final String logic) {
70         super(parentKey, logicName, logicFlavour, logic);
71     }
72
73     /**
74      * This Constructor creates a logic instance with the given reference key and all of its fields
75      * defined.
76      *
77      * @param key the reference key of this logic
78      * @param logicFlavour the flavour of this logic
79      * @param logic the actual logic as a string
80      */
81     public AxStateFinalizerLogic(final AxReferenceKey key, final String logicFlavour, final String logic) {
82         super(key, logicFlavour, logic);
83     }
84
85     /**
86      * This Constructor creates a logic instance by cloning the fields from another logic instance
87      * into this logic instance.
88      *
89      * @param logic the logic instance to clone from
90      */
91     public AxStateFinalizerLogic(final AxLogic logic) {
92         super(new AxReferenceKey(logic.getKey()), logic.getLogicFlavour(), logic.getLogic());
93     }
94
95     /**
96      * This Constructor creates a logic instance with a reference key constructed from the parents
97      * key and the logic local name, the given logic flavour, with the logic being provided by the
98      * given logic reader instance.
99      *
100      * @param parentKey the reference key of the parent of this logic
101      * @param logicName the logic name, held as the local name of the reference key of this logic
102      * @param logicFlavour the flavour of this logic
103      * @param logicReader the logic reader to use to read the logic for this logic instance
104      */
105     public AxStateFinalizerLogic(final AxReferenceKey parentKey, final String logicName, final String logicFlavour,
106             final AxLogicReader logicReader) {
107         super(new AxReferenceKey(parentKey, logicName), logicFlavour, logicReader);
108     }
109
110     /**
111      * This Constructor creates a logic instance with the given reference key and logic flavour, the
112      * logic is provided by the given logic reader instance.
113      *
114      * @param key the reference key of this logic
115      * @param logicFlavour the flavour of this logic
116      * @param logicReader the logic reader to use to read the logic for this logic instance
117      */
118     public AxStateFinalizerLogic(final AxReferenceKey key, final String logicFlavour, final AxLogicReader logicReader) {
119         super(key, logicFlavour, logicReader);
120     }
121 }