2 * ============LICENSE_START=======================================================
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
12 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
22 package org.onap.policy.controlloop.policy.guard.builder;
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;
32 public interface ControlLoopGuardBuilder {
35 * Adds one or more guard policies to the Control Loop Guard.
37 * @param policies policies to add
38 * @return builder object
39 * @throws BuilderException builder exception
41 public ControlLoopGuardBuilder addGuardPolicy(GuardPolicy... policies) throws BuilderException;
44 * Removes one or more guard policies from the Control Loop Guard.
46 * @param policies policies to add
47 * @return builder object
48 * @throws BuilderException builder exception
50 public ControlLoopGuardBuilder removeGuardPolicy(GuardPolicy... policies) throws BuilderException;
53 * Removes all guard policies from the Control Loop Guard.
55 * @return builder object
56 * @throws BuilderException builder exception
58 public ControlLoopGuardBuilder removeAllGuardPolicies() throws BuilderException;
61 * Adds one or more time limit constraints to the guard policy.
63 * @param id (guard policy id)
64 * @param constraints the constraints to add
65 * @return builder object
66 * @throws BuilderException builder exception
68 public ControlLoopGuardBuilder addLimitConstraint(String id, Constraint... constraints) throws BuilderException;
71 * Removes one or more time limit constraints from the guard policy.
73 * @param id (guard policy id)
74 * @param constraints constraints to remove
75 * @return builder object
76 * @throws BuilderException builder exception
78 public ControlLoopGuardBuilder removeLimitConstraint(String id, Constraint... constraints) throws BuilderException;
81 * Removes all time limit constraints from the guard policy.
83 * @param id (guard policy id)
84 * @return builder object
85 * @throws BuilderException builder exception
87 public ControlLoopGuardBuilder removeAllLimitConstraints(String id) throws BuilderException;
90 * Simply return a copy of control loop guard.
92 * @return ControlLoopGuard
94 public ControlLoopGuard getControlLoopGuard();
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
105 public Results buildSpecification();
108 * The Factory is used to build a ControlLoopGuardBuilder implementation.
111 public static class Factory {
114 //Do Nothing Private Constructor.
117 * Build the control loop guard.
119 * @param guard the guard
120 * @return ControlLoopGuardBuilder object
123 public static ControlLoopGuardBuilder buildControlLoopGuard(Guard guard) {
125 return new ControlLoopGuardBuilderImpl(guard);