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