2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017-2021 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.drools.controller.internal;
23 import java.util.ArrayList;
24 import java.util.Collections;
25 import java.util.HashMap;
26 import java.util.List;
28 import lombok.NonNull;
29 import lombok.ToString;
30 import org.onap.policy.common.endpoints.event.comm.TopicSink;
31 import org.onap.policy.drools.controller.DroolsController;
32 import org.onap.policy.drools.controller.DroolsControllerConstants;
33 import org.onap.policy.drools.core.PolicyContainer;
34 import org.onap.policy.drools.protocol.coders.TopicCoderFilterConfiguration;
37 * no-op Drools Controller.
40 public class NullDroolsController implements DroolsController {
43 public boolean start() {
48 public boolean stop() {
53 public void shutdown() {
63 public boolean isAlive() {
68 public boolean lock() {
73 public boolean unlock() {
78 public boolean isLocked() {
83 public String getGroupId() {
84 return DroolsControllerConstants.NO_GROUP_ID;
88 public String getArtifactId() {
89 return DroolsControllerConstants.NO_ARTIFACT_ID;
93 public String getVersion() {
94 return DroolsControllerConstants.NO_VERSION;
98 public List<String> getSessionNames() {
99 return new ArrayList<>();
103 public List<String> getCanonicalSessionNames() {
104 return new ArrayList<>();
108 public List<String> getBaseDomainNames() {
109 return Collections.emptyList();
113 public boolean offer(String topic, String event) {
118 public <T> boolean offer(T event) {
123 public boolean deliver(TopicSink sink, Object event) {
124 throw new IllegalStateException(makeInvokeMsg());
128 public Object[] getRecentSourceEvents() {
129 return new String[0];
133 public PolicyContainer getContainer() {
138 public String[] getRecentSinkEvents() {
139 return new String[0];
143 public boolean ownsCoder(Class<?> coderClass, int modelHash) {
144 throw new IllegalStateException(makeInvokeMsg());
148 public Class<?> fetchModelClass(String className) {
149 throw new IllegalArgumentException(makeInvokeMsg());
153 public boolean isBrained() {
158 public void updateToVersion(String newGroupId, String newArtifactId, String newVersion,
159 List<TopicCoderFilterConfiguration> decoderConfigurations,
160 List<TopicCoderFilterConfiguration> encoderConfigurations)
161 throws LinkageError {
162 throw new IllegalArgumentException(makeInvokeMsg());
166 public Map<String, Integer> factClassNames(String sessionName) {
167 return new HashMap<>();
171 public long factCount(String sessionName) {
176 public List<Object> facts(String sessionName, String className, boolean delete) {
177 return new ArrayList<>();
181 public <T> List<T> facts(@NonNull String sessionName, @NonNull Class<T> clazz) {
182 return new ArrayList<>();
186 public List<Object> factQuery(String sessionName, String queryName,
187 String queriedEntity,
188 boolean delete, Object... queryParams) {
189 return new ArrayList<>();
193 public <T> boolean delete(@NonNull String sessionName, @NonNull T fact) {
198 public <T> boolean delete(@NonNull T fact) {
203 public <T> boolean delete(@NonNull String sessionName, @NonNull Class<T> fact) {
208 public <T> boolean delete(@NonNull Class<T> fact) {
213 public <T> boolean exists(@NonNull String sessionName, @NonNull T fact) {
218 public <T> boolean exists(@NonNull T fact) {
222 private String makeInvokeMsg() {
223 return this.getClass().getName() + " invoked";