2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017-2019 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.core.PolicyContainer;
32 import org.onap.policy.drools.protocol.coders.TopicCoderFilterConfiguration;
35 * no-op Drools Controller.
37 public class NullDroolsController implements DroolsController {
40 public boolean start() {
45 public boolean stop() {
50 public void shutdown() {
60 public boolean isAlive() {
65 public boolean lock() {
70 public boolean unlock() {
75 public boolean isLocked() {
80 public String getGroupId() {
85 public String getArtifactId() {
86 return NO_ARTIFACT_ID;
90 public String getVersion() {
95 public List<String> getSessionNames() {
96 return new ArrayList<>();
100 public List<String> getCanonicalSessionNames() {
101 return new ArrayList<>();
105 public List<String> getBaseDomainNames() {
106 return Collections.emptyList();
110 public boolean offer(String topic, String event) {
115 public <T> boolean offer(T event) {
120 public boolean deliver(TopicSink sink, Object event) {
121 throw new IllegalStateException(makeInvokeMsg());
125 public Object[] getRecentSourceEvents() {
126 return new String[0];
130 public PolicyContainer getContainer() {
135 public String[] getRecentSinkEvents() {
136 return new String[0];
140 public boolean ownsCoder(Class<? extends Object> coderClass, int modelHash) {
141 throw new IllegalStateException(makeInvokeMsg());
145 public Class<?> fetchModelClass(String className) {
146 throw new IllegalArgumentException(makeInvokeMsg());
150 public boolean isBrained() {
155 public String toString() {
156 StringBuilder builder = new StringBuilder();
157 builder.append("NullDroolsController []");
158 return builder.toString();
162 public void updateToVersion(String newGroupId, String newArtifactId, String newVersion,
163 List<TopicCoderFilterConfiguration> decoderConfigurations,
164 List<TopicCoderFilterConfiguration> encoderConfigurations)
165 throws LinkageError {
166 throw new IllegalArgumentException(makeInvokeMsg());
170 public Map<String, Integer> factClassNames(String sessionName) {
171 return new HashMap<>();
175 public long factCount(String sessionName) {
180 public List<Object> facts(String sessionName, String className, boolean delete) {
181 return new ArrayList<>();
185 public <T> List<T> facts(@NonNull String sessionName, @NonNull Class<T> clazz) {
186 return new ArrayList<>();
190 public List<Object> factQuery(String sessionName, String queryName,
191 String queriedEntity,
192 boolean delete, Object... queryParams) {
193 return new ArrayList<>();
197 public <T> boolean delete(@NonNull String sessionName, @NonNull T fact) {
202 public <T> boolean delete(@NonNull T fact) {
207 public <T> boolean delete(@NonNull String sessionName, @NonNull Class<T> fact) {
212 public <T> boolean delete(@NonNull Class<T> fact) {
216 private String makeInvokeMsg() {
217 return this.getClass().getName() + " invoked";