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