51ec51a8f030977649f954fd6f2ba92a102ae0bd
[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 javax.xml.bind.annotation.XmlAccessType;
25 import javax.xml.bind.annotation.XmlAccessorType;
26 import javax.xml.bind.annotation.XmlRootElement;
27 import javax.xml.bind.annotation.XmlType;
28 import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey;
29
30 /**
31  * This class holds State Finalizer Logic for {@link AxState} states in Apex. It is a specialization
32  * of the {@link AxLogic} class, so that State Finalizer Logic in Apex states can be strongly typed.
33  *
34  * <p>State Finalizer Logic is used to select the output {@link AxStateOutput} that a state will use.
35  * The logic uses fields emitted by the executed {@link AxTask} task and information from the
36  * context albums available on a state to decide what state output {@link AxStateOutput} to select
37  * in a given context. State Finalizer Logic must marshal the output fields from the task onto the
38  * output event in whatever manner is appropriate for the domain being handled.
39  *
40  * <p>Validation uses standard Apex Logic validation, see validation in {@link AxLogic}.
41  */
42 @XmlAccessorType(XmlAccessType.FIELD)
43 @XmlRootElement(name = "apexStateFinalizerLogic", namespace = "http://www.onap.org/policy/apex-pdp")
44 @XmlType(name = "AxStateFinalizerLogic", namespace = "http://www.onap.org/policy/apex-pdp")
45
46 public class AxStateFinalizerLogic extends AxLogic {
47     private static final long serialVersionUID = 2090324845463750391L;
48
49     /**
50      * The Default Constructor creates a logic instance with a null key, undefined logic flavour and
51      * a null logic string.
52      */
53     public AxStateFinalizerLogic() {
54         super();
55     }
56
57     /**
58      * The Key Constructor creates a logic instance with the given reference key, undefined logic
59      * flavour and a null logic string.
60      *
61      * @param key the reference key of the logic
62      */
63     public AxStateFinalizerLogic(final AxReferenceKey key) {
64         super(key, LOGIC_FLAVOUR_UNDEFINED, "");
65     }
66
67     /**
68      * This Constructor creates a logic instance with a reference key constructed from the parents
69      * key and the logic local name and all of its fields defined.
70      *
71      * @param parentKey the reference key of the parent of this logic
72      * @param logicName the logic name, held as the local name of the reference key of this logic
73      * @param logicFlavour the flavour of this logic
74      * @param logic the actual logic as a string
75      */
76     public AxStateFinalizerLogic(final AxReferenceKey parentKey, final String logicName, final String logicFlavour,
77             final String logic) {
78         super(parentKey, logicName, logicFlavour, logic);
79     }
80
81     /**
82      * This Constructor creates a logic instance with the given reference key and all of its fields
83      * defined.
84      *
85      * @param key the reference key of this logic
86      * @param logicFlavour the flavour of this logic
87      * @param logic the actual logic as a string
88      */
89     public AxStateFinalizerLogic(final AxReferenceKey key, final String logicFlavour, final String logic) {
90         super(key, logicFlavour, logic);
91     }
92
93     /**
94      * This Constructor creates a logic instance by cloning the fields from another logic instance
95      * into this logic instance.
96      *
97      * @param logic the logic instance to clone from
98      */
99     public AxStateFinalizerLogic(final AxLogic logic) {
100         super(new AxReferenceKey(logic.getKey()), logic.getLogicFlavour(), logic.getLogic());
101     }
102
103     /**
104      * This Constructor creates a logic instance with a reference key constructed from the parents
105      * key and the logic local name, the given logic flavour, with the logic being provided by the
106      * given logic reader instance.
107      *
108      * @param parentKey the reference key of the parent of this logic
109      * @param logicName the logic name, held as the local name of the reference key of this logic
110      * @param logicFlavour the flavour of this logic
111      * @param logicReader the logic reader to use to read the logic for this logic instance
112      */
113     public AxStateFinalizerLogic(final AxReferenceKey parentKey, final String logicName, final String logicFlavour,
114             final AxLogicReader logicReader) {
115         super(new AxReferenceKey(parentKey, logicName), logicFlavour, logicReader);
116     }
117
118     /**
119      * This Constructor creates a logic instance with the given reference key and logic flavour, the
120      * logic is provided by the given logic reader instance.
121      *
122      * @param key the reference key of this logic
123      * @param logicFlavour the flavour of this logic
124      * @param logicReader the logic reader to use to read the logic for this logic instance
125      */
126     public AxStateFinalizerLogic(final AxReferenceKey key, final String logicFlavour, final AxLogicReader logicReader) {
127         super(key, logicFlavour, logicReader);
128     }
129 }