summaryrefslogtreecommitdiffstats
path: root/auth/cli-editor/src/main/java
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/cli-editor/src/main/java
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/cli-editor/src/main/java')
-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
7 files changed, 79 insertions, 557 deletions
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