a6c92ee1a5a41a124a65c1d49b72c5e12d875f03
[policy/models.git] / models-interactions / model-yaml / src / main / java / org / onap / policy / controlloop / policy / guard / builder / ControlLoopGuardBuilder.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * policy-yaml
4  * ================================================================================
5  * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
6  * Modifications Copyright (C) 2019 Nordix Foundation.
7  * ================================================================================
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  * 
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  * 
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  * ============LICENSE_END=========================================================
20  */
21
22 package org.onap.policy.controlloop.policy.guard.builder;
23
24 import org.onap.policy.controlloop.policy.builder.BuilderException;
25 import org.onap.policy.controlloop.policy.builder.Results;
26 import org.onap.policy.controlloop.policy.guard.Constraint;
27 import org.onap.policy.controlloop.policy.guard.ControlLoopGuard;
28 import org.onap.policy.controlloop.policy.guard.Guard;
29 import org.onap.policy.controlloop.policy.guard.GuardPolicy;
30 import org.onap.policy.controlloop.policy.guard.builder.impl.ControlLoopGuardBuilderImpl;
31
32 public interface ControlLoopGuardBuilder {
33     
34     /**
35      * Adds one or more guard policies to the Control Loop Guard.
36      * 
37      * @param policies policies to add
38      * @return  builder object
39      * @throws BuilderException builder exception
40      */
41     public ControlLoopGuardBuilder  addGuardPolicy(GuardPolicy... policies) throws BuilderException;
42     
43     /**
44      * Removes one or more guard policies from the Control Loop Guard.
45      * 
46      * @param policies policies to add
47      * @return  builder object
48      * @throws BuilderException builder exception
49      */
50     public ControlLoopGuardBuilder  removeGuardPolicy(GuardPolicy... policies) throws BuilderException;
51     
52     /**
53      * Removes all guard policies from the Control Loop Guard.
54      * 
55      * @return  builder object
56      * @throws BuilderException builder exception
57      */
58     public ControlLoopGuardBuilder  removeAllGuardPolicies() throws BuilderException;
59     
60     /**
61      * Adds one or more time limit constraints to the guard policy.
62      * 
63      * @param id (guard policy id)
64      * @param constraints the constraints to add
65      * @return builder object
66      * @throws BuilderException builder exception
67      */
68     public ControlLoopGuardBuilder  addLimitConstraint(String id, Constraint... constraints) throws BuilderException;
69     
70     /**
71      * Removes one or more time limit constraints from the guard policy.
72      * 
73      * @param id (guard policy id)
74      * @param constraints constraints to remove
75      * @return builder object
76      * @throws BuilderException builder exception
77      */
78     public ControlLoopGuardBuilder  removeLimitConstraint(String id, Constraint... constraints) throws BuilderException;
79     
80     /**
81      * Removes all time limit constraints from the guard policy.
82      * 
83      * @param id (guard policy id)
84      * @return builder object
85      * @throws BuilderException builder exception
86      */
87     public ControlLoopGuardBuilder  removeAllLimitConstraints(String id) throws BuilderException;
88     
89     /**
90      *  Simply return a copy of control loop guard.
91      *  
92      *  @return ControlLoopGuard
93      */
94     public ControlLoopGuard getControlLoopGuard();  
95     
96     /**
97      * This will compile and build the YAML specification for the Control Loop Guard. 
98      * Please iterate the Results object for details.
99      * The Results object will contains warnings and errors. 
100      * If the specification compiled successfully, you will be able to retrieve the
101      * YAML.
102      * 
103      * @return Results
104      */
105     public Results  buildSpecification();
106     
107     /**
108      * The Factory is used to build a ControlLoopGuardBuilder implementation.
109      *
110      */
111     public static class Factory {
112         
113         private Factory(){
114             //Do Nothing Private Constructor. 
115         }
116         /**
117          * Build the control loop guard.
118          * 
119          * @param guard the guard
120          * @return ControlLoopGuardBuilder object
121          */
122         
123         public static ControlLoopGuardBuilder   buildControlLoopGuard(Guard guard) {
124             
125             return  new ControlLoopGuardBuilderImpl(guard);
126             
127         }
128     }
129 }