summaryrefslogtreecommitdiffstats
path: root/src/main/java/org/onap/sdc/dcae/composition/restmodels/ruleeditor/UnaryFieldAction.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org/onap/sdc/dcae/composition/restmodels/ruleeditor/UnaryFieldAction.java')
-rw-r--r--src/main/java/org/onap/sdc/dcae/composition/restmodels/ruleeditor/UnaryFieldAction.java67
1 files changed, 14 insertions, 53 deletions
diff --git a/src/main/java/org/onap/sdc/dcae/composition/restmodels/ruleeditor/UnaryFieldAction.java b/src/main/java/org/onap/sdc/dcae/composition/restmodels/ruleeditor/UnaryFieldAction.java
index 17146ec..c13d101 100644
--- a/src/main/java/org/onap/sdc/dcae/composition/restmodels/ruleeditor/UnaryFieldAction.java
+++ b/src/main/java/org/onap/sdc/dcae/composition/restmodels/ruleeditor/UnaryFieldAction.java
@@ -1,6 +1,5 @@
package org.onap.sdc.dcae.composition.restmodels.ruleeditor;
-import org.apache.commons.lang3.StringUtils;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
@@ -32,46 +31,6 @@ public class UnaryFieldAction extends BaseAction {
this.from = new From(from, regex);
}
- protected class FromField {
- private String value;
-
- public String getValue() {
- return value;
- }
-
- public void setValue(String value) {
- this.value = value;
- }
-
- FromField(String value){
- setValue(value);
- }
-
- private FromField(){}
-
- private boolean isReference(){
- return StringUtils.isNoneBlank(value) && value.startsWith("${") && value.endsWith("}");
- }
-
- private String stripedReference() {
- return value.substring(2, value.length()-1);
- }
-
- boolean referencesTarget(String target) {
- return isReference() && target.equals(stripedReference());
- }
-
- @Override
- public boolean equals(Object obj) {
- return obj == this || !(null == obj || getClass() != obj.getClass()) && Objects.equals(value, ((FromField)obj).value);
- }
-
- @Override
- public int hashCode(){
- return Objects.hash(this.value);
- }
- }
-
protected class From extends FromField {
private String regex;
@@ -119,16 +78,9 @@ public class UnaryFieldAction extends BaseAction {
@Override
public boolean equals(Object obj) {
- if (obj == this) {
- return true;
- }
- if (null == obj || getClass() != obj.getClass()) {
- return false;
- }
- From other = (From) obj;
- return Objects.equals(regex, other.regex)
- && Objects.equals(state, other.state)
- && Objects.equals(values, other.values);
+ return super.equals(obj) && Objects.equals(regex, ((From) obj).regex)
+ && Objects.equals(state, ((From) obj).state)
+ && Objects.equals(values, ((From) obj).values);
}
@Override
@@ -138,13 +90,13 @@ public class UnaryFieldAction extends BaseAction {
}
- public List<String> getFromValues() {
+ public List<String> fromValues() {
return null == from || CollectionUtils.isEmpty(from.values) ? new ArrayList<>() : from.values.stream().map(FromField::getValue).collect(Collectors.toList());
}
@Override
public boolean equals(Object obj) {
- return obj == this || !(null == obj || getClass() != obj.getClass()) && Objects.equals(from, ((UnaryFieldAction)obj).from);
+ return super.equals(obj) && Objects.equals(from, ((UnaryFieldAction)obj).from);
}
@Override
@@ -158,4 +110,13 @@ public class UnaryFieldAction extends BaseAction {
}
public String strippedTarget(){return "";}
+
+ public String regexState() {
+ return from.state;
+ }
+
+ public void regexState(String state) {
+ from.state = state;
+ }
}
+