aboutsummaryrefslogtreecommitdiffstats
path: root/auth
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2021-08-23 17:10:00 -0400
committerJim Hahn <jrh3@att.com>2021-08-24 09:22:38 -0400
commit53fe02c107eae2f45abfee02e5b56a8ab3c09523 (patch)
tree35c9646b7c629485f6241ed1b48b853305e585ac /auth
parentc3d0b33c9facf49e37e9ab58412227ff44c66363 (diff)
More lombok for apex-pdp
Added lombok to auth thru context-management, excluding basic-model and context-model. Issue-ID: POLICY-3391 Change-Id: I1c3a69d52d3bc65a99126ad44126e5a97424c66f Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'auth')
-rw-r--r--auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/CliEditorContants.java11
-rw-r--r--auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/CodeGenCliEditor.java38
-rw-r--r--auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/CodeGenCliEditorBuilder.java144
-rw-r--r--auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/CodeGeneratorCliEditor.java126
-rw-r--r--auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/EventDeclaration.java40
-rw-r--r--auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/EventDeclarationBuilder.java107
-rw-r--r--auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/PolicyStateDef.java45
-rw-r--r--auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/PolicyStateDefBuilder.java149
-rw-r--r--auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/PolicyStateTask.java39
-rw-r--r--auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/PolicyStateTaskBuilder.java106
-rw-r--r--auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/TaskDeclaration.java42
-rw-r--r--auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/TaskDeclarationBuilder.java118
-rw-r--r--auth/cli-codegen/src/test/java/org/onap/policy/apex/auth/clicodegen/CodeGeneratorCliEditorTest.java74
-rw-r--r--auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/ApexCommandLineEditorMain.java23
-rw-r--r--auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/ApexModelProperties.java136
-rw-r--r--auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CommandLineArgument.java119
-rw-r--r--auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CommandLineArgumentValue.java47
-rw-r--r--auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CommandLineCommand.java202
-rw-r--r--auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/KeywordNode.java96
-rw-r--r--auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/utils/CliUtils.java13
-rw-r--r--auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/CommandLineCommandTest.java16
21 files changed, 397 insertions, 1294 deletions
diff --git a/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/CliEditorContants.java b/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/CliEditorContants.java
index b123d9186..f2b4cbeea 100644
--- a/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/CliEditorContants.java
+++ b/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/CliEditorContants.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,7 +21,11 @@
package org.onap.policy.apex.auth.clicodegen;
-public class CliEditorContants {
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
+
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class CliEditorContants {
public static final String FINALIZER_LOGIC_NAME = "finalizerLogicName";
@@ -127,8 +132,4 @@ public class CliEditorContants {
public static final String SCOPE = "scope";
public static final String DEFINITIONS = "definitions";
-
- private CliEditorContants() {
- // Private constructor to prevent subclassing
- }
}
diff --git a/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/CodeGenCliEditor.java b/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/CodeGenCliEditor.java
new file mode 100644
index 000000000..c889ac474
--- /dev/null
+++ b/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/CodeGenCliEditor.java
@@ -0,0 +1,38 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2018 Samsung Electronics Co., Ltd. All rights reserved.
+ * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.apex.auth.clicodegen;
+
+import lombok.Builder;
+import lombok.Getter;
+
+@Getter
+@Builder
+public class CodeGenCliEditor {
+ private String name;
+ private String version;
+ private String uuid;
+ private String description;
+ private String scope;
+ private boolean writable;
+ private String schemaName;
+ private String schemaVersion;
+}
diff --git a/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/CodeGenCliEditorBuilder.java b/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/CodeGenCliEditorBuilder.java
deleted file mode 100644
index 933ecd56f..000000000
--- a/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/CodeGenCliEditorBuilder.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2018 Samsung Electronics Co., Ltd. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.apex.auth.clicodegen;
-
-public class CodeGenCliEditorBuilder {
- private String name;
- private String version;
- private String uuid;
- private String description;
- private String scope;
- private boolean writable;
- private String schemaName;
- private String schemaVersion;
-
- /**
- * Set name.
- * @param name the name of the context album
- * @return CodeGenCliEditorBuilder
- */
- public CodeGenCliEditorBuilder setName(String name) {
- this.name = name;
- return this;
- }
-
- /**
- * Set version.
- * @param version the version of the context album
- * @return CodeGenCliEditorBuilder
- */
- public CodeGenCliEditorBuilder setVersion(String version) {
- this.version = version;
- return this;
- }
-
- /**
- * Set uuid.
- * @param uuid a UUID for the declaration
- * @return CodeGenCliEditorBuilder
- */
- public CodeGenCliEditorBuilder setUuid(String uuid) {
- this.uuid = uuid;
- return this;
- }
-
- /**
- * Set description.
- * @param description a description for the context album
- * @return CodeGenCliEditorBuilder
- */
- public CodeGenCliEditorBuilder setDescription(String description) {
- this.description = description;
- return this;
- }
-
- /**
- * Set scope.
- * @param scope the scope
- * @return CodeGenCliEditorBuilder
- */
- public CodeGenCliEditorBuilder setScope(String scope) {
- this.scope = scope;
- return this;
- }
-
- /**
- * Set writable.
- * @param writable a flag for writable context
- * @return CodeGenCliEditorBuilder
- */
- public CodeGenCliEditorBuilder setWritable(boolean writable) {
- this.writable = writable;
- return this;
- }
-
- /**
- * Set schemaname.
- * @param schemaName the name of the schema
- * @return CodeGenCliEditorBuilder
- */
- public CodeGenCliEditorBuilder setSchemaName(String schemaName) {
- this.schemaName = schemaName;
- return this;
- }
-
- /**
- * Set schema version.
- * @param schemaVersion the version of the declaration
- * @return CodeGenCliEditorBuilder
- */
- public CodeGenCliEditorBuilder setSchemaVersion(String schemaVersion) {
- this.schemaVersion = schemaVersion;
- return this;
- }
-
- public String getName() {
- return name;
- }
-
- public String getVersion() {
- return version;
- }
-
- public String getUuid() {
- return uuid;
- }
-
- public String getDescription() {
- return description;
- }
-
- public String getScope() {
- return scope;
- }
-
- public boolean isWritable() {
- return writable;
- }
-
- public String getSchemaName() {
- return schemaName;
- }
-
- public String getSchemaVersion() {
- return schemaVersion;
- }
-}
diff --git a/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/CodeGeneratorCliEditor.java b/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/CodeGeneratorCliEditor.java
index 6ad5fbc3c..87124cb8b 100644
--- a/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/CodeGeneratorCliEditor.java
+++ b/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/CodeGeneratorCliEditor.java
@@ -3,6 +3,7 @@
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2019 Samsung Electronics Co., Ltd.
* Modifications Copyright (C) 2019-2021 Nordix Foundation.
+ * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -77,6 +78,7 @@ import static org.onap.policy.apex.auth.clicodegen.CliEditorContants.VERSION;
import static org.onap.policy.apex.auth.clicodegen.CliEditorContants.WRITABLE;
import java.util.List;
+import lombok.Getter;
import org.stringtemplate.v4.ST;
import org.stringtemplate.v4.STGroupFile;
@@ -102,6 +104,7 @@ public class CodeGeneratorCliEditor {
/**
* The ST for the model, loaded from the STG.
*/
+ @Getter
private final ST model;
/**
@@ -141,15 +144,6 @@ public class CodeGeneratorCliEditor {
}
/**
- * Returns the model.
- *
- * @return the model
- */
- public ST getModel() {
- return model;
- }
-
- /**
* Sets the default name space.
*
* @param nameSpace new name space, ignored if blank
@@ -185,18 +179,18 @@ public class CodeGeneratorCliEditor {
/**
* Adds a new context album declaration to the model.
*
- * @param codeGenCliEditorBuilder The parameters for the context album
+ * @param codeGenCliEditor The parameters for the context album
*/
- public void addContextAlbumDeclaration(CodeGenCliEditorBuilder codeGenCliEditorBuilder) {
+ public void addContextAlbumDeclaration(CodeGenCliEditor codeGenCliEditor) {
final var st = stg.getInstanceOf("ctxAlbumDecl");
- st.add(NAME, codeGenCliEditorBuilder.getName());
- st.add(VERSION, codeGenCliEditorBuilder.getVersion());
- st.add(UUID, codeGenCliEditorBuilder.getUuid());
- st.add(DESCRIPTION, codeGenCliEditorBuilder.getDescription());
- st.add(SCOPE, codeGenCliEditorBuilder.getScope());
- st.add(WRITABLE, codeGenCliEditorBuilder.isWritable());
- st.add(SCHEMA_NAME, codeGenCliEditorBuilder.getSchemaName());
- st.add(SCHEMA_VERSION, codeGenCliEditorBuilder.getSchemaVersion());
+ st.add(NAME, codeGenCliEditor.getName());
+ st.add(VERSION, codeGenCliEditor.getVersion());
+ st.add(UUID, codeGenCliEditor.getUuid());
+ st.add(DESCRIPTION, codeGenCliEditor.getDescription());
+ st.add(SCOPE, codeGenCliEditor.getScope());
+ st.add(WRITABLE, codeGenCliEditor.isWritable());
+ st.add(SCHEMA_NAME, codeGenCliEditor.getSchemaName());
+ st.add(SCHEMA_VERSION, codeGenCliEditor.getSchemaVersion());
model.add(DECLARATION, st);
}
@@ -245,20 +239,20 @@ public class CodeGeneratorCliEditor {
/**
* Adds a new event declaration to the model.
*
- * @param eventDeclarationBuilder param object for event declaration
+ * @param eventDeclaration param object for event declaration
*/
- public void addEventDeclaration(EventDeclarationBuilder eventDeclarationBuilder) {
+ public void addEventDeclaration(EventDeclaration eventDeclaration) {
final var st = stg.getInstanceOf("eventDecl");
- st.add(NAME, eventDeclarationBuilder.getName());
- st.add(VERSION, eventDeclarationBuilder.getVersion());
- st.add(UUID, eventDeclarationBuilder.getUuid());
- st.add(DESCRIPTION, eventDeclarationBuilder.getDescription());
- st.add(SOURCE, eventDeclarationBuilder.getSource());
- st.add(TARGET, eventDeclarationBuilder.getTarget());
- st.add(FIELDS, eventDeclarationBuilder.getFields());
-
- if (eventDeclarationBuilder.getNameSpace() != null) {
- st.add(NAME_SPACE, eventDeclarationBuilder.getNameSpace());
+ st.add(NAME, eventDeclaration.getName());
+ st.add(VERSION, eventDeclaration.getVersion());
+ st.add(UUID, eventDeclaration.getUuid());
+ st.add(DESCRIPTION, eventDeclaration.getDescription());
+ st.add(SOURCE, eventDeclaration.getSource());
+ st.add(TARGET, eventDeclaration.getTarget());
+ st.add(FIELDS, eventDeclaration.getFields());
+
+ if (eventDeclaration.getNameSpace() != null) {
+ st.add(NAME_SPACE, eventDeclaration.getNameSpace());
} else if (defaultNamespace != null) {
st.add(NAME_SPACE, defaultNamespace);
}
@@ -269,19 +263,19 @@ public class CodeGeneratorCliEditor {
/**
* Adds a new task declaration to the model.
*
- * @param taskDeclarationBuilder builder for the task declaration parameters
+ * @param taskDeclaration task declaration parameters
*/
- public void addTaskDeclaration(TaskDeclarationBuilder taskDeclarationBuilder) {
+ public void addTaskDeclaration(TaskDeclaration taskDeclaration) {
final var st = stg.getInstanceOf("taskDecl");
- st.add(NAME, taskDeclarationBuilder.getName());
- st.add(VERSION, taskDeclarationBuilder.getVersion());
- st.add(UUID, taskDeclarationBuilder.getUuid());
- st.add(DESCRIPTION, taskDeclarationBuilder.getDescription());
- st.add(INFIELDS, taskDeclarationBuilder.getInfields());
- st.add(OUTFIELDS, taskDeclarationBuilder.getOutfields());
- st.add(LOGIC, taskDeclarationBuilder.getLogic());
- st.add(PARAMS, taskDeclarationBuilder.getParameters());
- st.add(CONTEXT_REFS, taskDeclarationBuilder.getContextRefs());
+ st.add(NAME, taskDeclaration.getName());
+ st.add(VERSION, taskDeclaration.getVersion());
+ st.add(UUID, taskDeclaration.getUuid());
+ st.add(DESCRIPTION, taskDeclaration.getDescription());
+ st.add(INFIELDS, taskDeclaration.getInfields());
+ st.add(OUTFIELDS, taskDeclaration.getOutfields());
+ st.add(LOGIC, taskDeclaration.getLogic());
+ st.add(PARAMS, taskDeclaration.getParameters());
+ st.add(CONTEXT_REFS, taskDeclaration.getContextRefs());
model.add(DECLARATION, st);
}
@@ -392,19 +386,19 @@ public class CodeGeneratorCliEditor {
/**
* Creates a new policy state task definition for a task which belongs to a state which belongs to a policy.
*
- * @param policyStateTaskBuilder builder for the state task parameters
+ * @param policyStateTask state task parameters
* @return a CLI command for a policy state task definition
*/
- public ST createPolicyStateTask(PolicyStateTaskBuilder policyStateTaskBuilder) {
+ public ST createPolicyStateTask(PolicyStateTask policyStateTask) {
final var st = stg.getInstanceOf("policyStateTask");
- st.add(POLICY_NAME, policyStateTaskBuilder.getPolicyName());
- st.add(VERSION, policyStateTaskBuilder.getVersion());
- st.add(STATE_NAME, policyStateTaskBuilder.getStateName());
- st.add(TASK_LOCAL_NAME, policyStateTaskBuilder.getTaskLocalName());
- st.add(TASK_NAME, policyStateTaskBuilder.getTaskName());
- st.add(TASK_VERSION, policyStateTaskBuilder.getTaskVersion());
- st.add(OUTPUT_TYPE, policyStateTaskBuilder.getOutputType());
- st.add(OUTPUT_NAME, policyStateTaskBuilder.getOutputName());
+ st.add(POLICY_NAME, policyStateTask.getPolicyName());
+ st.add(VERSION, policyStateTask.getVersion());
+ st.add(STATE_NAME, policyStateTask.getStateName());
+ st.add(TASK_LOCAL_NAME, policyStateTask.getTaskLocalName());
+ st.add(TASK_NAME, policyStateTask.getTaskName());
+ st.add(TASK_VERSION, policyStateTask.getTaskVersion());
+ st.add(OUTPUT_TYPE, policyStateTask.getOutputType());
+ st.add(OUTPUT_NAME, policyStateTask.getOutputName());
return st;
}
@@ -437,23 +431,23 @@ public class CodeGeneratorCliEditor {
/**
* Creates a new policy state definition for a state which belongs to a policy.
*
- * @param policyStateDefBuilder builder for the state definition parameters
+ * @param policyStateDef state definition parameters
* @return a CLI command for a policy state definition
*/
- public ST createPolicyStateDef(PolicyStateDefBuilder policyStateDefBuilder) {
+ public ST createPolicyStateDef(PolicyStateDef policyStateDef) {
final var st = stg.getInstanceOf("policyStateDef");
- st.add(POLICY_NAME, policyStateDefBuilder.getPolicyName());
- st.add(VERSION, policyStateDefBuilder.getVersion());
- st.add(STATE_NAME, policyStateDefBuilder.getStateName());
- st.add(TRIGGER_NAME, policyStateDefBuilder.getTriggerName());
- st.add(TRIGGER_VERSION, policyStateDefBuilder.getTriggerVersion());
- st.add(DEFAULT_TASK, policyStateDefBuilder.getDefaultTask());
- st.add(DEFAULT_TASK_VERSION, policyStateDefBuilder.getDefaultTaskVersion());
- st.add(OUTPUTS, policyStateDefBuilder.getOutputs());
- st.add(TASKS, policyStateDefBuilder.getTasks());
- st.add(TS_LOGIC, policyStateDefBuilder.getTsLogic());
- st.add(FINALIZER_LOGICS, policyStateDefBuilder.getFinalizerLogics());
- st.add(CTX_REFS, policyStateDefBuilder.getCtxRefs());
+ st.add(POLICY_NAME, policyStateDef.getPolicyName());
+ st.add(VERSION, policyStateDef.getVersion());
+ st.add(STATE_NAME, policyStateDef.getStateName());
+ st.add(TRIGGER_NAME, policyStateDef.getTriggerName());
+ st.add(TRIGGER_VERSION, policyStateDef.getTriggerVersion());
+ st.add(DEFAULT_TASK, policyStateDef.getDefaultTask());
+ st.add(DEFAULT_TASK_VERSION, policyStateDef.getDefaultTaskVersion());
+ st.add(OUTPUTS, policyStateDef.getOutputs());
+ st.add(TASKS, policyStateDef.getTasks());
+ st.add(TS_LOGIC, policyStateDef.getTsLogic());
+ st.add(FINALIZER_LOGICS, policyStateDef.getFinalizerLogics());
+ st.add(CTX_REFS, policyStateDef.getCtxRefs());
return st;
}
diff --git a/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/EventDeclaration.java b/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/EventDeclaration.java
new file mode 100644
index 000000000..55d649205
--- /dev/null
+++ b/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/EventDeclaration.java
@@ -0,0 +1,40 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2018 Samsung Electronics Co., Ltd. All rights reserved.
+ * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.apex.auth.clicodegen;
+
+import java.util.List;
+import lombok.Builder;
+import lombok.Getter;
+import org.stringtemplate.v4.ST;
+
+@Getter
+@Builder
+public class EventDeclaration {
+ private String name;
+ private String version;
+ private String uuid;
+ private String description;
+ private String nameSpace;
+ private String source;
+ private String target;
+ private List<ST> fields;
+}
diff --git a/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/EventDeclarationBuilder.java b/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/EventDeclarationBuilder.java
deleted file mode 100644
index 93b5a406e..000000000
--- a/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/EventDeclarationBuilder.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2018 Samsung Electronics Co., Ltd. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.apex.auth.clicodegen;
-
-import java.util.List;
-import org.stringtemplate.v4.ST;
-
-public class EventDeclarationBuilder {
- private String name;
- private String version;
- private String uuid;
- private String description;
- private String nameSpace;
- private String source;
- private String target;
- private List<ST> fields;
-
- public String getName() {
- return name;
- }
-
- public String getVersion() {
- return version;
- }
-
- public String getUuid() {
- return uuid;
- }
-
- public String getDescription() {
- return description;
- }
-
- public String getNameSpace() {
- return nameSpace;
- }
-
- public String getSource() {
- return source;
- }
-
- public String getTarget() {
- return target;
- }
-
- public List<ST> getFields() {
- return fields;
- }
-
- public EventDeclarationBuilder setName(String name) {
- this.name = name;
- return this;
- }
-
- public EventDeclarationBuilder setVersion(String version) {
- this.version = version;
- return this;
- }
-
- public EventDeclarationBuilder setUuid(String uuid) {
- this.uuid = uuid;
- return this;
- }
-
- public EventDeclarationBuilder setDescription(String description) {
- this.description = description;
- return this;
- }
-
- public EventDeclarationBuilder setNameSpace(String nameSpace) {
- this.nameSpace = nameSpace;
- return this;
- }
-
- public EventDeclarationBuilder setSource(String source) {
- this.source = source;
- return this;
- }
-
- public EventDeclarationBuilder setTarget(String target) {
- this.target = target;
- return this;
- }
-
- public EventDeclarationBuilder setFields(List<ST> fields) {
- this.fields = fields;
- return this;
- }
-}
diff --git a/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/PolicyStateDef.java b/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/PolicyStateDef.java
new file mode 100644
index 000000000..5edf92b70
--- /dev/null
+++ b/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/PolicyStateDef.java
@@ -0,0 +1,45 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Samsung Electronics Co., Ltd. All rights reserved.
+ * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.apex.auth.clicodegen;
+
+import java.util.List;
+import lombok.Builder;
+import lombok.Getter;
+import org.stringtemplate.v4.ST;
+
+@Getter
+@Builder
+public class PolicyStateDef {
+
+ private String policyName;
+ private String version;
+ private String stateName;
+ private String triggerName;
+ private String triggerVersion;
+ private String defaultTask;
+ private String defaultTaskVersion;
+ private List<ST> outputs;
+ private List<ST> tasks;
+ private List<ST> tsLogic;
+ private List<ST> finalizerLogics;
+ private List<ST> ctxRefs;
+}
diff --git a/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/PolicyStateDefBuilder.java b/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/PolicyStateDefBuilder.java
deleted file mode 100644
index ea5cc6610..000000000
--- a/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/PolicyStateDefBuilder.java
+++ /dev/null
@@ -1,149 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2019 Samsung Electronics Co., Ltd. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.apex.auth.clicodegen;
-
-import java.util.List;
-import org.stringtemplate.v4.ST;
-
-public class PolicyStateDefBuilder {
-
- private String policyName;
- private String version;
- private String stateName;
- private String triggerName;
- private String triggerVersion;
- private String defaultTask;
- private String defaultTaskVersion;
- private List<ST> outputs;
- private List<ST> tasks;
- private List<ST> tsLogic;
- private List<ST> finalizerLogics;
- private List<ST> ctxRefs;
-
-
- public String getPolicyName() {
- return policyName;
- }
-
- public String getVersion() {
- return version;
- }
-
- public String getStateName() {
- return stateName;
- }
-
- public String getTriggerName() {
- return triggerName;
- }
-
- public String getTriggerVersion() {
- return triggerVersion;
- }
-
- public String getDefaultTask() {
- return defaultTask;
- }
-
- public String getDefaultTaskVersion() {
- return defaultTaskVersion;
- }
-
- public List<ST> getOutputs() {
- return outputs;
- }
-
- public List<ST> getTasks() {
- return tasks;
- }
-
- public List<ST> getTsLogic() {
- return tsLogic;
- }
-
- public List<ST> getFinalizerLogics() {
- return finalizerLogics;
- }
-
- public List<ST> getCtxRefs() {
- return ctxRefs;
- }
-
- public PolicyStateDefBuilder setPolicyName(String policyName) {
- this.policyName = policyName;
- return this;
- }
-
- public PolicyStateDefBuilder setVersion(String version) {
- this.version = version;
- return this;
- }
-
- public PolicyStateDefBuilder setStateName(String stateName) {
- this.stateName = stateName;
- return this;
- }
-
- public PolicyStateDefBuilder setTriggerName(String triggerName) {
- this.triggerName = triggerName;
- return this;
- }
-
- public PolicyStateDefBuilder setTriggerVersion(String triggerVersion) {
- this.triggerVersion = triggerVersion;
- return this;
- }
-
- public PolicyStateDefBuilder setDefaultTask(String defaultTask) {
- this.defaultTask = defaultTask;
- return this;
- }
-
- public PolicyStateDefBuilder setDefaultTaskVersion(String defaultTaskVersion) {
- this.defaultTaskVersion = defaultTaskVersion;
- return this;
- }
-
- public PolicyStateDefBuilder setOutputs(List<ST> outputs) {
- this.outputs = outputs;
- return this;
- }
-
- public PolicyStateDefBuilder setTasks(List<ST> tasks) {
- this.tasks = tasks;
- return this;
- }
-
- public PolicyStateDefBuilder setTsLogic(List<ST> tsLogic) {
- this.tsLogic = tsLogic;
- return this;
- }
-
- public PolicyStateDefBuilder setFinalizerLogics(List<ST> finalizerLogics) {
- this.finalizerLogics = finalizerLogics;
- return this;
- }
-
- public PolicyStateDefBuilder setCtxRefs(List<ST> ctxRefs) {
- this.ctxRefs = ctxRefs;
- return this;
- }
-}
diff --git a/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/PolicyStateTask.java b/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/PolicyStateTask.java
new file mode 100644
index 000000000..414a2f277
--- /dev/null
+++ b/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/PolicyStateTask.java
@@ -0,0 +1,39 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Samsung Electronics Co., Ltd. All rights reserved.
+ * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.apex.auth.clicodegen;
+
+import lombok.Builder;
+import lombok.Getter;
+
+@Getter
+@Builder
+public class PolicyStateTask {
+
+ private String policyName;
+ private String version;
+ private String stateName;
+ private String taskLocalName;
+ private String taskName;
+ private String taskVersion;
+ private String outputType;
+ private String outputName;
+}
diff --git a/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/PolicyStateTaskBuilder.java b/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/PolicyStateTaskBuilder.java
deleted file mode 100644
index 0ac7a3e98..000000000
--- a/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/PolicyStateTaskBuilder.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2019 Samsung Electronics Co., Ltd. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.apex.auth.clicodegen;
-
-public class PolicyStateTaskBuilder {
-
- private String policyName;
- private String version;
- private String stateName;
- private String taskLocalName;
- private String taskName;
- private String taskVersion;
- private String outputType;
- private String outputName;
-
- public String getPolicyName() {
- return policyName;
- }
-
- public String getVersion() {
- return version;
- }
-
- public String getStateName() {
- return stateName;
- }
-
- public String getTaskLocalName() {
- return taskLocalName;
- }
-
- public String getTaskName() {
- return taskName;
- }
-
- public String getTaskVersion() {
- return taskVersion;
- }
-
- public String getOutputType() {
- return outputType;
- }
-
- public String getOutputName() {
- return outputName;
- }
-
- public PolicyStateTaskBuilder setPolicyName(String policyName) {
- this.policyName = policyName;
- return this;
- }
-
- public PolicyStateTaskBuilder setVersion(String version) {
- this.version = version;
- return this;
- }
-
- public PolicyStateTaskBuilder setStateName(String stateName) {
- this.stateName = stateName;
- return this;
- }
-
- public PolicyStateTaskBuilder setTaskLocalName(String taskLocalName) {
- this.taskLocalName = taskLocalName;
- return this;
- }
-
- public PolicyStateTaskBuilder setTaskName(String taskName) {
- this.taskName = taskName;
- return this;
- }
-
- public PolicyStateTaskBuilder setTaskVersion(String taskVersion) {
- this.taskVersion = taskVersion;
- return this;
- }
-
- public PolicyStateTaskBuilder setOutputType(String outputType) {
- this.outputType = outputType;
- return this;
- }
-
- public PolicyStateTaskBuilder setOutputName(String outputName) {
- this.outputName = outputName;
- return this;
- }
-
-}
diff --git a/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/TaskDeclaration.java b/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/TaskDeclaration.java
new file mode 100644
index 000000000..ed03d4c5f
--- /dev/null
+++ b/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/TaskDeclaration.java
@@ -0,0 +1,42 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Samsung Electronics Co., Ltd. All rights reserved.
+ * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.apex.auth.clicodegen;
+
+import java.util.List;
+import lombok.Builder;
+import lombok.Getter;
+import org.stringtemplate.v4.ST;
+
+@Getter
+@Builder
+public class TaskDeclaration {
+
+ private String name;
+ private String version;
+ private String uuid;
+ private String description;
+ private List<ST> infields;
+ private List<ST> outfields;
+ private ST logic;
+ private List<ST> parameters;
+ private List<ST> contextRefs;
+}
diff --git a/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/TaskDeclarationBuilder.java b/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/TaskDeclarationBuilder.java
deleted file mode 100644
index 566fa03d8..000000000
--- a/auth/cli-codegen/src/main/java/org/onap/policy/apex/auth/clicodegen/TaskDeclarationBuilder.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2019 Samsung Electronics Co., Ltd. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.apex.auth.clicodegen;
-
-import java.util.List;
-import org.stringtemplate.v4.ST;
-
-public class TaskDeclarationBuilder {
-
- private String name;
- private String version;
- private String uuid;
- private String description;
- private List<ST> infields;
- private List<ST> outfields;
- private ST logic;
- private List<ST> parameters;
- private List<ST> contextRefs;
-
- public String getName() {
- return name;
- }
-
- public String getVersion() {
- return version;
- }
-
- public String getUuid() {
- return uuid;
- }
-
- public String getDescription() {
- return description;
- }
-
- public List<ST> getInfields() {
- return infields;
- }
-
- public List<ST> getOutfields() {
- return outfields;
- }
-
- public ST getLogic() {
- return logic;
- }
-
- public List<ST> getParameters() {
- return parameters;
- }
-
- public List<ST> getContextRefs() {
- return contextRefs;
- }
-
- public TaskDeclarationBuilder setName(String name) {
- this.name = name;
- return this;
- }
-
- public TaskDeclarationBuilder setVersion(String version) {
- this.version = version;
- return this;
- }
-
- public TaskDeclarationBuilder setUuid(String uuid) {
- this.uuid = uuid;
- return this;
- }
-
- public TaskDeclarationBuilder setDescription(String description) {
- this.description = description;
- return this;
- }
-
- public TaskDeclarationBuilder setInfields(List<ST> infields) {
- this.infields = infields;
- return this;
- }
-
- public TaskDeclarationBuilder setOutfields(List<ST> outfields) {
- this.outfields = outfields;
- return this;
- }
-
- public TaskDeclarationBuilder setLogic(ST logic) {
- this.logic = logic;
- return this;
- }
-
- public TaskDeclarationBuilder setParameters(List<ST> parameters) {
- this.parameters = parameters;
- return this;
- }
-
- public TaskDeclarationBuilder setContextRefs(List<ST> contextRefs) {
- this.contextRefs = contextRefs;
- return this;
- }
-}
diff --git a/auth/cli-codegen/src/test/java/org/onap/policy/apex/auth/clicodegen/CodeGeneratorCliEditorTest.java b/auth/cli-codegen/src/test/java/org/onap/policy/apex/auth/clicodegen/CodeGeneratorCliEditorTest.java
index d6cf1686b..8ad8b0213 100644
--- a/auth/cli-codegen/src/test/java/org/onap/policy/apex/auth/clicodegen/CodeGeneratorCliEditorTest.java
+++ b/auth/cli-codegen/src/test/java/org/onap/policy/apex/auth/clicodegen/CodeGeneratorCliEditorTest.java
@@ -4,6 +4,7 @@
* Modifications Copyright (C) 2019 Samsung Electronics Co., Ltd.
* Modifications Copyright (C) 2020 Nordix Foundation
* Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
+ * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -111,9 +112,9 @@ public class CodeGeneratorCliEditorTest {
final List<ST> parameters = getParametersForTask(codeGen, t);
final List<ST> contextRefs = getCtxtRefsForTask(codeGen, t);
- codeGen.addTaskDeclaration(new TaskDeclarationBuilder().setName(kig.getName(key))
- .setVersion(kig.getVersion(key)).setUuid(kig.getUuid(key)).setDescription(kig.getDesc(key))
- .setLogic(logic).setParameters(parameters).setContextRefs(contextRefs));
+ codeGen.addTaskDeclaration(TaskDeclaration.builder().name(kig.getName(key))
+ .version(kig.getVersion(key)).uuid(kig.getUuid(key)).description(kig.getDesc(key))
+ .logic(logic).parameters(parameters).contextRefs(contextRefs).build());
}
// 3: events
@@ -122,15 +123,16 @@ public class CodeGeneratorCliEditorTest {
final List<ST> fields = getParametersForEvent(codeGen, e);
codeGen.addEventDeclaration(
- new EventDeclarationBuilder()
- .setName(kig.getName(key))
- .setVersion(kig.getVersion(key))
- .setUuid(kig.getUuid(key))
- .setDescription(kig.getDesc(key))
- .setNameSpace(e.getNameSpace())
- .setSource(e.getSource())
- .setTarget(e.getTarget())
- .setFields(fields));
+ EventDeclaration.builder()
+ .name(kig.getName(key))
+ .version(kig.getVersion(key))
+ .uuid(kig.getUuid(key))
+ .description(kig.getDesc(key))
+ .nameSpace(e.getNameSpace())
+ .source(e.getSource())
+ .target(e.getTarget())
+ .fields(fields)
+ .build());
}
// 4: context albums
@@ -138,15 +140,16 @@ public class CodeGeneratorCliEditorTest {
final AxArtifactKey key = a.getKey();
codeGen.addContextAlbumDeclaration(
- new CodeGenCliEditorBuilder()
- .setName(kig.getName(key))
- .setVersion(kig.getVersion(key))
- .setUuid(kig.getUuid(key))
- .setDescription(kig.getDesc(key))
- .setScope(a.getScope())
- .setWritable(a.isWritable())
- .setSchemaName(kig.getName(a.getItemSchema()))
- .setSchemaVersion(kig.getVersion(a.getItemSchema())));
+ CodeGenCliEditor.builder()
+ .name(kig.getName(key))
+ .version(kig.getVersion(key))
+ .uuid(kig.getUuid(key))
+ .description(kig.getDesc(key))
+ .scope(a.getScope())
+ .writable(a.isWritable())
+ .schemaName(kig.getName(a.getItemSchema()))
+ .schemaVersion(kig.getVersion(a.getItemSchema()))
+ .build());
}
// 5: policies
@@ -261,14 +264,14 @@ public class CodeGeneratorCliEditorTest {
final List<ST> tsLogic = getTslForState(cg, st);
final List<ST> ctxRefs = getCtxtRefsForState(cg, st);
- final ST val = cg.createPolicyStateDef(new PolicyStateDefBuilder()
- .setPolicyName(kig.getPName(skey)).setVersion(kig.getPVersion(skey))
- .setStateName(kig.getLName(skey)).setTriggerName(kig.getName(st.getTrigger()))
- .setTriggerVersion(kig.getVersion(st.getTrigger()))
- .setDefaultTask(kig.getName(st.getDefaultTask()))
- .setDefaultTaskVersion(kig.getVersion(st.getDefaultTask())).setOutputs(outputs)
- .setTasks(tasks).setTsLogic(tsLogic).setFinalizerLogics(finalizerLogics)
- .setCtxRefs(ctxRefs));
+ final ST val = cg.createPolicyStateDef(PolicyStateDef.builder()
+ .policyName(kig.getPName(skey)).version(kig.getPVersion(skey))
+ .stateName(kig.getLName(skey)).triggerName(kig.getName(st.getTrigger()))
+ .triggerVersion(kig.getVersion(st.getTrigger()))
+ .defaultTask(kig.getName(st.getDefaultTask()))
+ .defaultTaskVersion(kig.getVersion(st.getDefaultTask())).outputs(outputs)
+ .tasks(tasks).tsLogic(tsLogic).finalizerLogics(finalizerLogics)
+ .ctxRefs(ctxRefs).build());
ret.add(val);
}
@@ -353,12 +356,13 @@ public class CodeGeneratorCliEditorTest {
final AxStateTaskReference tr = e.getValue();
final AxReferenceKey trkey = tr.getKey();
- final ST val = cg.createPolicyStateTask(new PolicyStateTaskBuilder()
- .setPolicyName(kig.getPName(skey)).setVersion(kig.getPVersion(skey))
- .setStateName(kig.getLName(skey)).setTaskLocalName(kig.getLName(trkey))
- .setTaskName(kig.getName(tkey)).setTaskVersion(kig.getVersion(tkey))
- .setOutputType(tr.getStateTaskOutputType().name())
- .setOutputName(kig.getLName(tr.getOutput())));
+ final ST val = cg.createPolicyStateTask(PolicyStateTask.builder()
+ .policyName(kig.getPName(skey)).version(kig.getPVersion(skey))
+ .stateName(kig.getLName(skey)).taskLocalName(kig.getLName(trkey))
+ .taskName(kig.getName(tkey)).taskVersion(kig.getVersion(tkey))
+ .outputType(tr.getStateTaskOutputType().name())
+ .outputName(kig.getLName(tr.getOutput()))
+ .build());
ret.add(val);
}
diff --git a/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/ApexCommandLineEditorMain.java b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/ApexCommandLineEditorMain.java
index 424f5853f..6409c2500 100644
--- a/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/ApexCommandLineEditorMain.java
+++ b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/ApexCommandLineEditorMain.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2019-2021 Nordix Foundation.
+ * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -25,6 +26,8 @@ import java.io.IOException;
import java.util.Arrays;
import java.util.Set;
import java.util.TreeSet;
+import lombok.Getter;
+import lombok.Setter;
import org.onap.policy.apex.auth.clieditor.utils.CliUtils;
import org.onap.policy.apex.model.utilities.json.JsonHandler;
import org.slf4j.ext.XLogger;
@@ -49,6 +52,8 @@ public class ApexCommandLineEditorMain {
private ApexModelProperties apexModelProperties;
// The number of errors encountered in command processing
+ @Getter
+ @Setter
private int errorCount = 0;
/**
@@ -165,24 +170,6 @@ public class ApexCommandLineEditorMain {
}
/**
- * Get the number of errors encountered in command processing.
- *
- * @return the number of errors
- */
- public int getErrorCount() {
- return errorCount;
- }
-
- /**
- * Sets the number of errors encountered in command processing.
- *
- * @param errorCount the number of errors
- */
- public void setErrorCount(final int errorCount) {
- this.errorCount = errorCount;
- }
-
- /**
* The main method, kicks off the editor.
*
* @param args the arguments
diff --git a/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/ApexModelProperties.java b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/ApexModelProperties.java
index d618b159b..d54e91c5d 100644
--- a/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/ApexModelProperties.java
+++ b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/ApexModelProperties.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2021 Nordix Foundation.
+ * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,12 +23,18 @@
package org.onap.policy.apex.auth.clieditor;
import java.util.Properties;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
/**
* This class contains the definitions of Apex model properties.
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
+@Getter
+@Setter
+@ToString
public class ApexModelProperties {
/** The default version that will be used for concepts. */
public static final String DEFAULT_CONCEPT_VERSION = "0.0.1";
@@ -82,133 +89,4 @@ public class ApexModelProperties {
// @formatter:on
return properties;
}
-
- /**
- * Gets the default concept version.
- *
- * @return the default concept version
- */
- public String getDefaultConceptVersion() {
- return defaultConceptVersion;
- }
-
- /**
- * Sets the default concept version.
- *
- * @param defaultConceptVersion the default concept version
- */
- public void setDefaultConceptVersion(final String defaultConceptVersion) {
- this.defaultConceptVersion = defaultConceptVersion;
- }
-
- /**
- * Gets the default event namespace.
- *
- * @return the default event namespace
- */
- public String getDefaultEventNamespace() {
- return defaultEventNamespace;
- }
-
- /**
- * Sets the default event namespace.
- *
- * @param defaultEventNamespace the default event namespace
- */
- public void setDefaultEventNamespace(final String defaultEventNamespace) {
- this.defaultEventNamespace = defaultEventNamespace;
- }
-
- /**
- * Gets the default event source.
- *
- * @return the default event source
- */
- public String getDefaultEventSource() {
- return defaultEventSource;
- }
-
- /**
- * Sets the default event source.
- *
- * @param defaultEventSource the default event source
- */
- public void setDefaultEventSource(final String defaultEventSource) {
- this.defaultEventSource = defaultEventSource;
- }
-
- /**
- * Gets the default event target.
- *
- * @return the default event target
- */
- public String getDefaultEventTarget() {
- return defaultEventTarget;
- }
-
- /**
- * Sets the default event target.
- *
- * @param defaultEventTarget the default event target
- */
- public void setDefaultEventTarget(final String defaultEventTarget) {
- this.defaultEventTarget = defaultEventTarget;
- }
-
- /**
- * Gets the default logic block start tag.
- *
- * @return the default logic block start tag
- */
- public String getDefaultLogicBlockStartTag() {
- return defaultLogicBlockStartTag;
- }
-
- /**
- * Gets the default logic block end tag.
- *
- * @return the default logic block end tag
- */
- public String getDefaultLogicBlockEndTag() {
- return defaultLogicBlockEndTag;
- }
-
- /**
- * Gets the default policy template type.
- *
- * @return the default policy template
- */
- public String getDefaultPolicyTemplate() {
- return defaultPolicyTemplate;
- }
-
- /**
- * Sets the default policy template type.
- *
- * @param defaultPolicyTemplate the new default policy template
- */
- public void setDefaultPolicyTemplate(final String defaultPolicyTemplate) {
- this.defaultPolicyTemplate = defaultPolicyTemplate;
- }
-
- /**
- * Gets the default macro file tag.
- *
- * @return the default macro file end tag
- */
- public String getDefaultMacroFileTag() {
- return defaultMacroFileTag;
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public String toString() {
- return "ApexModelProperties [defaultConceptVersion=" + defaultConceptVersion + ", defaultEventNamespace="
- + defaultEventNamespace + ", defaultEventSource=" + defaultEventSource + ", defaultEventTarget="
- + defaultEventTarget + ", defaultLogicBlockStartTag=" + defaultLogicBlockStartTag
- + ", defaultLogicBlockEndTag=" + defaultLogicBlockEndTag + ", defaultPolicyTemplate="
- + defaultPolicyTemplate + ", defaultMacroFileTag=" + defaultMacroFileTag + "]";
- }
}
diff --git a/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CommandLineArgument.java b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CommandLineArgument.java
index 772cd506e..ec70fe8f5 100644
--- a/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CommandLineArgument.java
+++ b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CommandLineArgument.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,13 +22,20 @@
package org.onap.policy.apex.auth.clieditor;
-import org.onap.policy.common.utils.validation.Assertions;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.NonNull;
+import lombok.ToString;
+import org.apache.commons.lang3.builder.CompareToBuilder;
/**
* This class holds the definition of an argument of a CLI command.
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
+@Getter
+@ToString
+@EqualsAndHashCode
public class CommandLineArgument implements Comparable<CommandLineArgument> {
private final String argumentName;
private final boolean nullable;
@@ -66,33 +74,6 @@ public class CommandLineArgument implements Comparable<CommandLineArgument> {
}
/**
- * Gets the argument name.
- *
- * @return the argument name
- */
- public String getArgumentName() {
- return argumentName;
- }
-
- /**
- * Checks if the argument is nullable.
- *
- * @return true, if checks if the argument is nullable
- */
- public boolean isNullable() {
- return nullable;
- }
-
- /**
- * Gets the argument description.
- *
- * @return the argument description
- */
- public String getDescription() {
- return description;
- }
-
- /**
* Gets the argument help.
*
* @return the argument help
@@ -109,83 +90,15 @@ public class CommandLineArgument implements Comparable<CommandLineArgument> {
* {@inheritDoc}.
*/
@Override
- public String toString() {
- return "CLIArgument [argumentName=" + argumentName + ", nullable=" + nullable + ", description=" + description
- + "]";
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public int compareTo(final CommandLineArgument otherArgument) {
- Assertions.argumentNotNull(otherArgument, "comparison object may not be null");
-
+ public int compareTo(@NonNull final CommandLineArgument otherArgument) {
if (this == otherArgument) {
return 0;
}
- if (getClass() != otherArgument.getClass()) {
- return this.hashCode() - otherArgument.hashCode();
- }
-
- final CommandLineArgument other = otherArgument;
-
- if (!argumentName.equals(other.argumentName)) {
- return argumentName.compareTo(other.argumentName);
- }
- if (nullable != other.nullable) {
- return (this.hashCode() - other.hashCode());
- }
- return description.compareTo(otherArgument.description);
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public int hashCode() {
- final var prime = 31;
- var result = 1;
- result = prime * result + ((argumentName == null) ? 0 : argumentName.hashCode());
- result = prime * result + ((description == null) ? 0 : description.hashCode());
- result = prime * result + (nullable ? 1231 : 1237);
- return result;
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
-
- if (obj == null) {
- return false;
- }
-
- if (getClass() != obj.getClass()) {
- return false;
- }
-
- CommandLineArgument other = (CommandLineArgument) obj;
- if (argumentName == null) {
- if (other.argumentName != null) {
- return false;
- }
- } else if (!argumentName.equals(other.argumentName)) {
- return false;
- }
-
- if (description == null) {
- if (other.description != null) {
- return false;
- }
- } else if (!description.equals(other.description)) {
- return false;
- }
-
- return nullable == other.nullable;
+ return new CompareToBuilder()
+ .append(argumentName, otherArgument.argumentName)
+ .append(nullable, otherArgument.nullable)
+ .append(description, otherArgument.description)
+ .append(getClass(), otherArgument.getClass())
+ .toComparison();
}
}
diff --git a/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CommandLineArgumentValue.java b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CommandLineArgumentValue.java
index 732f88c8e..c1c82fd27 100644
--- a/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CommandLineArgumentValue.java
+++ b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CommandLineArgumentValue.java
@@ -1,30 +1,36 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
+ *
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
package org.onap.policy.apex.auth.clieditor;
+import lombok.Getter;
+import lombok.ToString;
+
/**
* This class represents an argument used on a command and its value.
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
+@Getter
+@ToString
public class CommandLineArgumentValue {
private final CommandLineArgument cliArgument;
private boolean specified;
@@ -43,33 +49,6 @@ public class CommandLineArgumentValue {
}
/**
- * Gets the argument for which this object is a value.
- *
- * @return the argument for which this object is a value
- */
- public CommandLineArgument getCliArgument() {
- return cliArgument;
- }
-
- /**
- * Checks if the argument value is specified.
- *
- * @return true, if the argument value is specified
- */
- public boolean isSpecified() {
- return specified;
- }
-
- /**
- * Gets the argument value.
- *
- * @return the argument value
- */
- public String getValue() {
- return value;
- }
-
- /**
* Sets the argument value.
*
* @param value the argument value
@@ -78,12 +57,4 @@ public class CommandLineArgumentValue {
this.value = value;
specified = true;
}
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public String toString() {
- return "CLIArgumentValue [cliArgument=" + cliArgument + ", specified=" + specified + ", value=" + value + "]";
- }
}
diff --git a/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CommandLineCommand.java b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CommandLineCommand.java
index 37806af66..25e4c9363 100644
--- a/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CommandLineCommand.java
+++ b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CommandLineCommand.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2019-2021 Nordix Foundation.
+ * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,7 +24,13 @@ package org.onap.policy.apex.auth.clieditor;
import java.util.ArrayList;
import java.util.List;
-import org.onap.policy.common.utils.validation.Assertions;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.NonNull;
+import lombok.Setter;
+import lombok.ToString;
+import org.apache.commons.lang3.builder.CompareToBuilder;
+import org.onap.policy.apex.model.utilities.CollectionUtils;
/**
* This class represents a single Apex CLI command that is issued to the Apex Editor Java API
@@ -31,6 +38,10 @@ import org.onap.policy.common.utils.validation.Assertions;
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
+@Getter
+@Setter
+@ToString
+@EqualsAndHashCode
public class CommandLineCommand implements Comparable<CommandLineCommand> {
private String name = "";
private final List<String> keywordlist = new ArrayList<>();
@@ -71,96 +82,6 @@ public class CommandLineCommand implements Comparable<CommandLineCommand> {
}
/**
- * Gets the name of the editor command.
- *
- * @return the name of the editor command
- */
- public String getName() {
- return name;
- }
-
- /**
- * Sets the name of the editor command.
- *
- * @param name the name of the editor command
- */
- public void setName(final String name) {
- this.name = name;
- }
-
- /**
- * Gets the list of keywords for this command.
- *
- * @return the list of keywords for this command
- */
- public List<String> getKeywordlist() {
- return keywordlist;
- }
-
- /**
- * Gets the list of arguments for this command.
- *
- * @return the list of arguments for this command
- */
- public List<CommandLineArgument> getArgumentList() {
- return argumentList;
- }
-
- /**
- * Gets the method of the method that executes this command in the Java API.
- *
- * @return the method of the method that executes this command in the Java API
- */
- public String getApiMethod() {
- return apiMethod;
- }
-
- /**
- * Sets the method of the method that executes this command in the Java API.
- *
- * @param apiMethod the method of the method that executes this command in the Java API
- */
- public void setApiMethod(final String apiMethod) {
- this.apiMethod = apiMethod;
- }
-
- /**
- * Gets the description of the command.
- *
- * @return the description of the command
- */
- public String getDescription() {
- return description;
- }
-
- /**
- * Sets the description of the command.
- *
- * @param description the description of the command
- */
- public void setDescription(final String description) {
- this.description = description;
- }
-
- /**
- * Checks if this command is a system command.
- *
- * @return true, if this command is a system command
- */
- public boolean isSystemCommand() {
- return systemCommand;
- }
-
- /**
- * Sets whether this command is a system command.
- *
- * @param systemCommand whether this command is a system command
- */
- public void setSystemCommand(final boolean systemCommand) {
- this.systemCommand = systemCommand;
- }
-
- /**
* Gets help for this command.
*
* @return the help for this command
@@ -190,99 +111,16 @@ public class CommandLineCommand implements Comparable<CommandLineCommand> {
* {@inheritDoc}.
*/
@Override
- public String toString() {
- return "CLICommand [name=" + name + ",keywordlist=" + keywordlist + ", argumentList=" + argumentList
- + ", apiMethod=" + apiMethod + ", systemCommand=" + systemCommand + ", description=" + description
- + "]";
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public int compareTo(final CommandLineCommand otherCommand) {
- Assertions.argumentNotNull(otherCommand, "comparison object may not be null");
-
+ public int compareTo(@NonNull final CommandLineCommand otherCommand) {
if (this == otherCommand) {
return 0;
}
- if (getClass() != otherCommand.getClass()) {
- return this.hashCode() - otherCommand.hashCode();
- }
-
- int result = compareKeywordList(otherCommand);
- if (result != 0) {
- return result;
- }
-
- if (!argumentList.equals(otherCommand.argumentList)) {
- return (argumentList.hashCode() - otherCommand.argumentList.hashCode());
- }
-
- if (systemCommand != otherCommand.systemCommand) {
- return (this.hashCode() - otherCommand.hashCode());
- }
-
- return apiMethod.compareTo(otherCommand.apiMethod);
- }
-
- /**
- * Compare the keyword lists of the commands.
- *
- * @param otherCommand the command to compare with
- * @return the int
- */
- private int compareKeywordList(final CommandLineCommand otherCommand) {
- for (int i = 0, j = 0;; i++, j++) {
- if (i < keywordlist.size() && j < otherCommand.keywordlist.size()) {
- if (!keywordlist.get(i).equals(otherCommand.keywordlist.get(j))) {
- return keywordlist.get(i).compareTo(otherCommand.keywordlist.get(j));
- }
- } else if (i == keywordlist.size() && j == otherCommand.keywordlist.size()) {
- break;
- } else if (i == keywordlist.size()) {
- return -1;
- } else {
- return 1;
- }
- }
-
- return 0;
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public int hashCode() {
- final var prime = 31;
- var result = 1;
- result = prime * result + ((apiMethod == null) ? 0 : apiMethod.hashCode());
- result = prime * result + argumentList.hashCode();
- result = prime * result + ((description == null) ? 0 : description.hashCode());
- result = prime * result + keywordlist.hashCode();
- result = prime * result + ((name == null) ? 0 : name.hashCode());
- result = prime * result + (systemCommand ? 1231 : 1237);
- return result;
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
-
- if (obj == null) {
- return false;
- }
-
- if (getClass() != obj.getClass()) {
- return false;
- }
-
- return this.compareTo((CommandLineCommand) obj) == 0;
+ return new CompareToBuilder()
+ .append(systemCommand, otherCommand.systemCommand)
+ .append(apiMethod, otherCommand.apiMethod)
+ .append(CollectionUtils.compareLists(keywordlist, otherCommand.keywordlist), 0)
+ .append(CollectionUtils.compareLists(argumentList, otherCommand.argumentList), 0)
+ .append(getClass(), otherCommand.getClass())
+ .toComparison();
}
}
diff --git a/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/KeywordNode.java b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/KeywordNode.java
index 0a99eb067..1959cb21d 100644
--- a/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/KeywordNode.java
+++ b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/KeywordNode.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2019-2021 Nordix Foundation.
+ * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,10 +24,15 @@ package org.onap.policy.apex.auth.clieditor;
import java.util.ArrayList;
import java.util.List;
-import java.util.NavigableMap;
import java.util.Set;
import java.util.TreeMap;
import java.util.TreeSet;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.NonNull;
+import lombok.ToString;
+import org.apache.commons.lang3.builder.CompareToBuilder;
+import org.onap.policy.apex.model.utilities.TreeMapUtils;
import org.onap.policy.common.utils.validation.Assertions;
/**
@@ -34,6 +40,9 @@ import org.onap.policy.common.utils.validation.Assertions;
* keyword itself and all its children are held as a recursive tree. This class is used to manage
* interactive sub-modes in the Apex CLI editor.
*/
+@Getter
+@ToString
+@EqualsAndHashCode
public class KeywordNode implements Comparable<KeywordNode> {
private final String keyword;
private final TreeMap<String, KeywordNode> children;
@@ -106,41 +115,6 @@ public class KeywordNode implements Comparable<KeywordNode> {
}
/**
- * Gets the keyword of this keyword node.
- *
- * @return the keyword of this keyword node
- */
- public String getKeyword() {
- return keyword;
- }
-
- /**
- * Gets the children of this keyword node.
- *
- * @return the children of this keyword node
- */
- public NavigableMap<String, KeywordNode> getChildren() {
- return children;
- }
-
- /**
- * Gets the command of this keyword node.
- *
- * @return the command of this keyword node
- */
- public CommandLineCommand getCommand() {
- return command;
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public String toString() {
- return "CommandKeywordNode [keyword=" + keyword + ", children=" + children + ", command=" + command + "]";
- }
-
- /**
* Gets the commands.
*
* @return the commands
@@ -162,51 +136,15 @@ public class KeywordNode implements Comparable<KeywordNode> {
* {@inheritDoc}.
*/
@Override
- public int compareTo(final KeywordNode otherKeywordNode) {
- Assertions.argumentNotNull(otherKeywordNode, "comparison object may not be null");
-
+ public int compareTo(@NonNull final KeywordNode otherKeywordNode) {
if (this == otherKeywordNode) {
return 0;
}
- if (getClass() != otherKeywordNode.getClass()) {
- return this.hashCode() - otherKeywordNode.hashCode();
- }
-
- final var other = otherKeywordNode;
-
- if (!keyword.equals(other.keyword)) {
- return keyword.compareTo(other.keyword);
- }
- if (!children.equals(other.children)) {
- return (children.hashCode() - other.children.hashCode());
- }
- return command.compareTo(otherKeywordNode.command);
- }
-
- @Override
- public int hashCode() {
- final var prime = 31;
- var result = 1;
- result = prime * result + ((children == null) ? 0 : children.hashCode());
- result = prime * result + ((command == null) ? 0 : command.hashCode());
- result = prime * result + ((keyword == null) ? 0 : keyword.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
-
- if (obj == null) {
- return false;
- }
-
- if (getClass() != obj.getClass()) {
- return false;
- }
-
- return this.compareTo((KeywordNode) obj) == 0;
+ return new CompareToBuilder()
+ .append(keyword, otherKeywordNode.keyword)
+ .append(command, otherKeywordNode.command)
+ .append(TreeMapUtils.compareMaps(children, otherKeywordNode.children), 0)
+ .append(getClass(), otherKeywordNode.getClass())
+ .toComparison();
}
}
diff --git a/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/utils/CliUtils.java b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/utils/CliUtils.java
index 22c541c3a..74147dd41 100644
--- a/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/utils/CliUtils.java
+++ b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/utils/CliUtils.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019-2021 Nordix Foundation.
+ * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -29,6 +30,8 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map.Entry;
import java.util.Properties;
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
import org.apache.commons.cli.HelpFormatter;
import org.apache.commons.cli.Options;
import org.apache.commons.lang3.StringUtils;
@@ -46,7 +49,8 @@ import org.slf4j.LoggerFactory;
*
* @author Ajith Sreekumar (ajith.sreekumar@est.tech)
*/
-public class CliUtils {
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class CliUtils {
private static final Logger LOGGER = LoggerFactory.getLogger(CliUtils.class);
// Recurring string constants
@@ -54,13 +58,6 @@ public class CliUtils {
private static final int MAX_HELP_LINE_LENGTH = 120;
/**
- * Private constructor to prevent sub-classing.
- */
- private CliUtils() {
- // This class cannot be initialized
- }
-
- /**
* Method to create apex policy in TOSCA service template.
*
* @param parameters containing paths to the apex config and tosca template skeleton file
diff --git a/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/CommandLineCommandTest.java b/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/CommandLineCommandTest.java
index 15b2b98f3..c3789b5e3 100644
--- a/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/CommandLineCommandTest.java
+++ b/auth/cli-editor/src/test/java/org/onap/policy/apex/auth/clieditor/CommandLineCommandTest.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (c) 2020-2021 Nordix Foundation.
+ * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,6 +21,7 @@
package org.onap.policy.apex.auth.clieditor;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertThrows;
@@ -47,8 +49,8 @@ public class CommandLineCommandTest {
assertEquals("testDescription", commandLineCommand.getDescription());
assertEquals("TestName", commandLineCommand.getName());
assertEquals(
- "CLICommand [name=TestName,keywordlist=[], argumentList=[], apiMethod=, systemCommand=true,"
- + " description=testDescription]", commandLineCommand.toString());
+ "CommandLineCommand(name=TestName, keywordlist=[], argumentList=[], apiMethod=, systemCommand=true,"
+ + " description=testDescription)", commandLineCommand.toString());
}
@Test(expected = CommandLineException.class)
@@ -96,22 +98,22 @@ public class CommandLineCommandTest {
assertEquals(0, commandLineCommand.compareTo(commandLineCommand));
CommandLineCommand otherCommand = new CommandLineCommand();
otherCommand.setSystemCommand(true);
- assertEquals(6, commandLineCommand.compareTo(otherCommand));
+ assertThat(commandLineCommand.compareTo(otherCommand)).isNotZero();
otherCommand.getArgumentList().add(new CommandLineArgument("testArgument"));
- assertEquals(-609496833, commandLineCommand.compareTo(otherCommand));
+ assertThat(commandLineCommand.compareTo(otherCommand)).isNotZero();
}
@Test
public void testCompareKeywordList() {
CommandLineCommand otherCommand = new CommandLineCommand();
otherCommand.getKeywordlist().add("test");
- assertEquals(-1, commandLineCommand.compareTo(otherCommand));
+ assertThat(commandLineCommand.compareTo(otherCommand)).isNotZero();
commandLineCommand.getKeywordlist().add("test");
assertEquals(0, commandLineCommand.compareTo(otherCommand));
commandLineCommand.getKeywordlist().add("test2");
- assertEquals(1, commandLineCommand.compareTo(otherCommand));
+ assertThat(commandLineCommand.compareTo(otherCommand)).isNotZero();
otherCommand.getKeywordlist().add("test3");
- assertEquals(-1, commandLineCommand.compareTo(otherCommand));
+ assertThat(commandLineCommand.compareTo(otherCommand)).isNotZero();
}
@Test