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