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 org.checkerframework.checker.nullness.qual.NonNull;
29 import org.onap.policy.common.endpoints.event.comm.TopicSink;
30 import org.onap.policy.drools.controller.DroolsController;
31 import org.onap.policy.drools.controller.DroolsControllerConstants;
32 import org.onap.policy.drools.core.PolicyContainer;
33 import org.onap.policy.drools.protocol.coders.TopicCoderFilterConfiguration;
36 * no-op Drools Controller.
38 public class NullDroolsController implements DroolsController {
41 public boolean start() {
46 public boolean stop() {
51 public void shutdown() {
61 public boolean isAlive() {
66 public boolean lock() {
71 public boolean unlock() {
76 public boolean isLocked() {
81 public String getGroupId() {
82 return DroolsControllerConstants.NO_GROUP_ID;
86 public String getArtifactId() {
87 return DroolsControllerConstants.NO_ARTIFACT_ID;
91 public String getVersion() {
92 return DroolsControllerConstants.NO_VERSION;
96 public List<String> getSessionNames() {
97 return new ArrayList<>();
101 public List<String> getCanonicalSessionNames() {
102 return new ArrayList<>();
106 public List<String> getBaseDomainNames() {
107 return Collections.emptyList();
111 public boolean offer(String topic, String event) {
116 public <T> boolean offer(T event) {
121 public boolean deliver(TopicSink sink, Object event) {
122 throw new IllegalStateException(makeInvokeMsg());
126 public Object[] getRecentSourceEvents() {
127 return new String[0];
131 public PolicyContainer getContainer() {
136 public String[] getRecentSinkEvents() {
137 return new String[0];
141 public boolean ownsCoder(Class<?> coderClass, int modelHash) {
142 throw new IllegalStateException(makeInvokeMsg());
146 public Class<?> fetchModelClass(String className) {
147 throw new IllegalArgumentException(makeInvokeMsg());
151 public boolean isBrained() {
156 public String toString() {
157 StringBuilder builder = new StringBuilder();
158 builder.append("NullDroolsController []");
159 return builder.toString();
163 public void updateToVersion(String newGroupId, String newArtifactId, String newVersion,
164 List<TopicCoderFilterConfiguration> decoderConfigurations,
165 List<TopicCoderFilterConfiguration> encoderConfigurations)
166 throws LinkageError {
167 throw new IllegalArgumentException(makeInvokeMsg());
171 public Map<String, Integer> factClassNames(String sessionName) {
172 return new HashMap<>();
176 public long factCount(String sessionName) {
181 public List<Object> facts(String sessionName, String className, boolean delete) {
182 return new ArrayList<>();
186 public <T> List<T> facts(@NonNull String sessionName, @NonNull Class<T> clazz) {
187 return new ArrayList<>();
191 public List<Object> factQuery(String sessionName, String queryName,
192 String queriedEntity,
193 boolean delete, Object... queryParams) {
194 return new ArrayList<>();
198 public <T> boolean delete(@NonNull String sessionName, @NonNull T fact) {
203 public <T> boolean delete(@NonNull T fact) {
208 public <T> boolean delete(@NonNull String sessionName, @NonNull Class<T> fact) {
213 public <T> boolean delete(@NonNull Class<T> fact) {
218 public <T> boolean exists(@NonNull String sessionName, @NonNull T fact) {
223 public <T> boolean exists(@NonNull T fact) {
227 private String makeInvokeMsg() {
228 return this.getClass().getName() + " invoked";