2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017-2018 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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.onap.policy.controlloop.policy.guard.builder;
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;
31 public interface ControlLoopGuardBuilder {
34 * Adds one or more guard policies to the Control Loop Guard.
36 * @param policies policies to add
37 * @return builder object
38 * @throws BuilderException builder exception
40 public ControlLoopGuardBuilder addGuardPolicy(GuardPolicy... policies) throws BuilderException;
43 * Removes one or more guard policies from the Control Loop Guard.
45 * @param policies policies to add
46 * @return builder object
47 * @throws BuilderException builder exception
49 public ControlLoopGuardBuilder removeGuardPolicy(GuardPolicy... policies) throws BuilderException;
52 * Removes all guard policies from the Control Loop Guard.
54 * @return builder object
55 * @throws BuilderException builder exception
57 public ControlLoopGuardBuilder removeAllGuardPolicies() throws BuilderException;
60 * Adds one or more time limit constraints to the guard policy.
62 * @param id (guard policy id)
63 * @param constraints the constraints to add
64 * @return builder object
65 * @throws BuilderException builder exception
67 public ControlLoopGuardBuilder addLimitConstraint(String id, Constraint... constraints) throws BuilderException;
70 * Removes one or more time limit constraints from the guard policy.
72 * @param id (guard policy id)
73 * @param constraints constraints to remove
74 * @return builder object
75 * @throws BuilderException builder exception
77 public ControlLoopGuardBuilder removeLimitConstraint(String id, Constraint... constraints) throws BuilderException;
80 * Removes all time limit constraints from the guard policy.
82 * @param id (guard policy id)
83 * @return builder object
84 * @throws BuilderException builder exception
86 public ControlLoopGuardBuilder removeAllLimitConstraints(String id) throws BuilderException;
89 * Simply return a copy of control loop guard.
91 * @return ControlLoopGuard
93 public ControlLoopGuard getControlLoopGuard();
96 * This will compile and build the YAML specification for the Control Loop Guard.
97 * Please iterate the Results object for details.
98 * The Results object will contains warnings and errors.
99 * If the specification compiled successfully, you will be able to retrieve the
104 public Results buildSpecification();
107 * The Factory is used to build a ControlLoopGuardBuilder implementation.
110 public static class Factory {
113 //Do Nothing Private Constructor.
116 * Build the control loop guard.
118 * @param guard the guard
119 * @return ControlLoopGuardBuilder object
122 public static ControlLoopGuardBuilder buildControlLoopGuard(Guard guard) {
124 return new ControlLoopGuardBuilderImpl(guard);