diff options
Diffstat (limited to 'common/onap-tosca-datatype')
21 files changed, 74 insertions, 96 deletions
diff --git a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/AttributeDefinition.java b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/AttributeDefinition.java index 4352f16ace..aa1392e2ce 100644 --- a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/AttributeDefinition.java +++ b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/AttributeDefinition.java @@ -26,7 +26,7 @@ import lombok.Setter; @Getter @Setter -public class AttributeDefinition implements Cloneable{ +public class AttributeDefinition implements Cloneable { private String type; private String description; diff --git a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/CapabilityDefinition.java b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/CapabilityDefinition.java index 152d9fb05e..4d0a38a77e 100644 --- a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/CapabilityDefinition.java +++ b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/CapabilityDefinition.java @@ -25,7 +25,7 @@ import org.onap.sdc.tosca.services.DataModelCloneUtil; import java.util.List; import java.util.Map; -public class CapabilityDefinition implements Cloneable{ +public class CapabilityDefinition implements Cloneable { private String type; private String description; diff --git a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/Condition.java b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/Condition.java index a394401112..f85ea5c7d2 100644 --- a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/Condition.java +++ b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/Condition.java @@ -22,7 +22,7 @@ import lombok.Data; @Data public class Condition { - private Map<String,Constraint> constraint; + private Map<String, Constraint> constraint; private String period; private Integer evaluations; private String method; diff --git a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/Credential.java b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/Credential.java index 11bb6390fe..217af07d05 100644 --- a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/Credential.java +++ b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/Credential.java @@ -29,7 +29,7 @@ public class Credential { private Map<String, String> keys; private String user; - public Credential(){ + public Credential() { this.token_type = "password"; } diff --git a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/DataType.java b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/DataType.java index bf318a7d3e..acf11c25f9 100644 --- a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/DataType.java +++ b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/DataType.java @@ -27,7 +27,7 @@ public class DataType { private String derived_from; private String version; - Map<String, String> metadata; + private Map<String, String> metadata; private String description; private List<Constraint> constraints; private Map<String, PropertyDefinition> properties; diff --git a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/DefinitionOfDataType.java b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/DefinitionOfDataType.java index 9d00532a30..44da720fc4 100644 --- a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/DefinitionOfDataType.java +++ b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/DefinitionOfDataType.java @@ -20,16 +20,16 @@ import java.util.List; import java.util.Objects; import org.onap.sdc.tosca.services.DataModelCloneUtil; -public class DefinitionOfDataType implements Cloneable{ - - protected String type; - protected String description; - protected Object value; - protected Boolean required; - protected Object _default; - protected Status status; - protected List<Constraint> constraints; - protected EntrySchema entry_schema; +public class DefinitionOfDataType implements Cloneable { + + private String type; + private String description; + private Object value; + private Boolean required; + private Object _default; + private Status status; + private List<Constraint> constraints; + private EntrySchema entry_schema; public String getType() { return type; diff --git a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/Implementation.java b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/Implementation.java index 1449f2086e..80a2a22b25 100644 --- a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/Implementation.java +++ b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/Implementation.java @@ -22,7 +22,7 @@ import java.util.Objects; import org.onap.sdc.tosca.services.DataModelCloneUtil; -public class Implementation implements Cloneable{ +public class Implementation implements Cloneable { private String primary; private List<String> dependencies; diff --git a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/InterfaceDefinition.java b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/InterfaceDefinition.java index c46cc6a5f5..9bb35d81eb 100644 --- a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/InterfaceDefinition.java +++ b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/InterfaceDefinition.java @@ -52,8 +52,8 @@ public abstract class InterfaceDefinition extends Interface { for (Map.Entry<String, Object> entry : interfaceAsMap.entrySet()) { Optional<Map.Entry<String, ? extends OperationDefinition>> operationDefinition = createOperation(entry.getKey(), entry.getValue(), fieldNames, - interfaceDefinition instanceof InterfaceDefinitionType ? OperationDefinitionType.class : - OperationDefinitionTemplate.class); + interfaceDefinition instanceof InterfaceDefinitionType ? OperationDefinitionType.class + : OperationDefinitionTemplate.class); operationDefinition .ifPresent(operation -> interfaceDefinition.addOperation(operation.getKey(), operation.getValue())); } diff --git a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/InterfaceDefinitionType.java b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/InterfaceDefinitionType.java index 5f0ea6ae92..3d691bed0f 100644 --- a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/InterfaceDefinitionType.java +++ b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/InterfaceDefinitionType.java @@ -19,6 +19,7 @@ package org.onap.sdc.tosca.datatypes.model; import java.util.HashMap; import java.util.Map; +import java.util.Objects; import java.util.Optional; import org.apache.commons.collections4.MapUtils; import org.onap.sdc.tosca.services.DataModelCloneUtil; @@ -70,27 +71,18 @@ public class InterfaceDefinitionType extends InterfaceDefinition { if (this == o) { return true; } - if (!(o instanceof InterfaceDefinitionType)) { + if (o == null || getClass() != o.getClass()) { return false; } - InterfaceDefinitionType that = (InterfaceDefinitionType) o; - - if (getType() != null ? !getType().equals(that.getType()) : that.getType() != null) { - return false; - } - if (getInputs() != null ? !getInputs().equals(that.getInputs()) : that.getInputs() != null) { - return false; - } - return getOperations() != null ? getOperations().equals(that.getOperations()) : that.getOperations() == null; + return Objects.equals(type, that.type) + && Objects.equals(inputs, that.inputs) + && Objects.equals(operations, that.operations); } @Override public int hashCode() { - int result = getType() != null ? getType().hashCode() : 0; - result = 31 * result + (getInputs() != null ? getInputs().hashCode() : 0); - result = 31 * result + (getOperations() != null ? getOperations().hashCode() : 0); - return result; + return Objects.hash(type, inputs, operations); } @Override diff --git a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/InterfaceType.java b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/InterfaceType.java index 57906140cf..07c4031b34 100644 --- a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/InterfaceType.java +++ b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/InterfaceType.java @@ -65,7 +65,7 @@ public class InterfaceType extends Interface { throw new ToscaRuntimeException(CONVERT_INTERFACE_TYPE_OBJECT_ERROR + toscaInterfaceTypeObj.toString()); } } catch (Exception exc) { - throw new ToscaRuntimeException(CONVERT_INTERFACE_TYPE_OBJECT_ERROR + toscaInterfaceTypeObj.toString(),exc); + throw new ToscaRuntimeException(CONVERT_INTERFACE_TYPE_OBJECT_ERROR + toscaInterfaceTypeObj.toString(), exc); } } diff --git a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/OperationDefinition.java b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/OperationDefinition.java index 42cc7158ec..8114686168 100644 --- a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/OperationDefinition.java +++ b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/OperationDefinition.java @@ -24,7 +24,7 @@ import java.util.Objects; public class OperationDefinition implements Cloneable { - protected String description; + private String description; public String getDescription() { return description; diff --git a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/PropertyDefinition.java b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/PropertyDefinition.java index 84c1586454..0c1f804efa 100644 --- a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/PropertyDefinition.java +++ b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/PropertyDefinition.java @@ -39,8 +39,8 @@ package org.onap.sdc.tosca.datatypes.model; public class PropertyDefinition extends DefinitionOfDataType { public PropertyDefinition() { - this.status = Status.SUPPORTED; - this.required = true; + setStatus(Status.SUPPORTED); + setRequired(true); } @Override diff --git a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/PropertyType.java b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/PropertyType.java index aaaae31f4e..facdb2a7b1 100644 --- a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/PropertyType.java +++ b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/PropertyType.java @@ -30,9 +30,9 @@ public enum PropertyType { SCALAR_UNIT_SIZE("scalar-unit.size"), SCALAR_UNIT_FREQUENCY("scalar-unit.frequency"); - private static final Map<String, PropertyType> mMap = + private static final Map<String, PropertyType> M_MAP = Collections.unmodifiableMap(initializeMapping()); - private static final Set<String> simplePropertyTypes = + private static final Set<String> SIMPLE_PROPERTY_TYPES = Collections.unmodifiableSet(initializeSimplePropertyTypes()); private String displayName; @@ -59,14 +59,15 @@ public enum PropertyType { * @return PropertyType */ public static PropertyType getPropertyTypeByDisplayName(String displayName) { - if (mMap.containsKey(displayName)) { - return mMap.get(displayName); + if (M_MAP.containsKey(displayName)) { + return M_MAP.get(displayName); } return null; } private static Set<String> initializeSimplePropertyTypes() { - Set<String> simplePropertyTypes = new HashSet<>(4); + final int setSize = 4; + Set<String> simplePropertyTypes = new HashSet<>(setSize); simplePropertyTypes.add(STRING.getDisplayName().toLowerCase()); simplePropertyTypes.add(INTEGER.getDisplayName().toLowerCase()); simplePropertyTypes.add(FLOAT.getDisplayName().toLowerCase()); @@ -75,12 +76,11 @@ public enum PropertyType { } public static Set<String> getSimplePropertyTypes() { - return simplePropertyTypes; + return SIMPLE_PROPERTY_TYPES; } public String getDisplayName() { return displayName; } - } diff --git a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/Status.java b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/Status.java index 222fdd0a61..b58f13c3a5 100644 --- a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/Status.java +++ b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/Status.java @@ -31,7 +31,7 @@ public enum Status { EXPERIMENTAL("experimental"), experimental("experimental"), DEPRECATED("deprecated"), - deprecated("deprecated"),; + deprecated("deprecated"); private String displayName; Status(String displayName) { diff --git a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/Trigger.java b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/Trigger.java index 9d6d9d8eac..440429461b 100644 --- a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/Trigger.java +++ b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/Trigger.java @@ -20,6 +20,8 @@ package org.onap.sdc.tosca.datatypes.model; +import java.util.Objects; + public class Trigger { private String description; @@ -29,48 +31,6 @@ public class Trigger { private Condition condition; private Object action; - @Override - public int hashCode() { - int result = getDescription() != null ? getDescription().hashCode() : 0; - result = 31 * result + getEvent_type().hashCode(); - result = 31 * result + (getSchedule() != null ? getSchedule().hashCode() : 0); - result = 31 * result + (getTarget_filter() != null ? getTarget_filter().hashCode() : 0); - result = 31 * result + (getCondition() != null ? getCondition().hashCode() : 0); - result = 31 * result + getAction().hashCode(); - return result; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (!(o instanceof Trigger)) { - return false; - } - - Trigger trigger = (Trigger) o; - - if (getDescription() != null ? !getDescription().equals(trigger.getDescription()) : - trigger.getDescription() != null) { - return false; - } - if (!getEvent_type().equals(trigger.getEvent_type())) { - return false; - } - if (getSchedule() != null ? !getSchedule().equals(trigger.getSchedule()) : trigger.getSchedule() != null) { - return false; - } - if (getTarget_filter() != null ? !getTarget_filter().equals(trigger.getTarget_filter()) : - trigger.getTarget_filter() != null) { - return false; - } - if (getCondition() != null ? !getCondition().equals(trigger.getCondition()) : trigger.getCondition() != null) { - return false; - } - return getAction().equals(trigger.getAction()); - } - public String getDescription() { return description; } @@ -119,4 +79,26 @@ public class Trigger { public void setAction(Object action) { this.action = action; } + + @Override + public int hashCode() { + return Objects.hash(description, event_type, schedule, target_filter, condition, action); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Trigger trigger = (Trigger) o; + return Objects.equals(description, trigger.description) + && Objects.equals(event_type, trigger.event_type) + && Objects.equals(schedule, trigger.schedule) + && Objects.equals(target_filter, trigger.target_filter) + && Objects.equals(condition, trigger.condition) + && Objects.equals(action, trigger.action); + } } diff --git a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/extension/ServiceFilter.java b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/extension/ServiceFilter.java index 6c57d2b285..572af3d16c 100644 --- a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/extension/ServiceFilter.java +++ b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/extension/ServiceFilter.java @@ -21,7 +21,7 @@ import org.onap.sdc.tosca.datatypes.model.NodeFilter; public class ServiceFilter extends NodeFilter { - Object tosca_id; + private Object tosca_id; public Object getTosca_id() { return tosca_id; diff --git a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/extension/SubstitutionMappingExt.java b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/extension/SubstitutionMappingExt.java index 1fa3719571..d60931d180 100644 --- a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/extension/SubstitutionMappingExt.java +++ b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/extension/SubstitutionMappingExt.java @@ -41,8 +41,8 @@ public class SubstitutionMappingExt extends SubstitutionMapping { SubstitutionMappingExt that = (SubstitutionMappingExt) o; - return getSubstitution_filter() != null ? getSubstitution_filter().equals(that.getSubstitution_filter()) : - that.getSubstitution_filter() == null; + return getSubstitution_filter() != null ? getSubstitution_filter().equals(that.getSubstitution_filter()) + : that.getSubstitution_filter() == null; } @Override diff --git a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/heatextend/PropertyTypeExt.java b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/heatextend/PropertyTypeExt.java index ffe06e6b9a..8d1b5525de 100644 --- a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/heatextend/PropertyTypeExt.java +++ b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/heatextend/PropertyTypeExt.java @@ -34,7 +34,7 @@ public enum PropertyTypeExt { */ JSON("json"); - private static final Map<String, PropertyTypeExt> mMap = + private static final Map<String, PropertyTypeExt> M_MAP = Collections.unmodifiableMap(initializeMapping()); private String displayName; @@ -63,8 +63,8 @@ public enum PropertyTypeExt { * @return the property type by display name */ public static PropertyTypeExt getPropertyTypeByDisplayName(String displayName) { - if (mMap.containsKey(displayName)) { - return mMap.get(displayName); + if (M_MAP.containsKey(displayName)) { + return M_MAP.get(displayName); } return null; } diff --git a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/services/CommonUtil.java b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/services/CommonUtil.java index fdbcb253dc..bb26e6a2b9 100644 --- a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/services/CommonUtil.java +++ b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/services/CommonUtil.java @@ -35,7 +35,7 @@ import org.apache.commons.beanutils.BeanUtils; public class CommonUtil { private static final String DEFAULT = "default"; - private static final String _DEFAULT = "_default"; + private static final String UNDERSCORE_DEFAULT = "_default"; private static ImmutableSet<Class<?>> complexClassType = ImmutableSet.of(Map.class, String.class, Integer.class, Float.class, Double.class, Set.class, Object.class, List.class); @@ -85,7 +85,7 @@ public class CommonUtil { if (objectAsMap.containsKey(DEFAULT)) { Object defaultValue = objectAsMap.get(DEFAULT); objectAsMap.remove(DEFAULT); - objectAsMap.put(_DEFAULT, defaultValue); + objectAsMap.put(UNDERSCORE_DEFAULT, defaultValue); } return objectAsMap; } diff --git a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/services/DataModelCloneUtil.java b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/services/DataModelCloneUtil.java index b05fdb5b35..c41282ff0d 100644 --- a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/services/DataModelCloneUtil.java +++ b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/services/DataModelCloneUtil.java @@ -165,7 +165,7 @@ public class DataModelCloneUtil { } else if (mapEntry.getValue() instanceof List) { List cloneObj = yamlUtil.yamlToObject(yamlUtil.objectToYaml(mapEntry.getValue()), List.class); cloneMap.put(mapEntry.getKey(), cloneObj); - } else if (mapEntry.getValue() instanceof Cloneable){ + } else if (mapEntry.getValue() instanceof Cloneable) { throw new ToscaRuntimeException("Clone Not Supported Exception"); } else { cloneMap.put(mapEntry.getKey(), mapEntry.getValue()); diff --git a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/services/YamlUtil.java b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/services/YamlUtil.java index cd19ff9ec0..4030d3acd1 100644 --- a/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/services/YamlUtil.java +++ b/common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/services/YamlUtil.java @@ -32,7 +32,11 @@ import org.yaml.snakeyaml.representer.Representer; import java.beans.IntrospectionException; import java.io.IOException; import java.io.InputStream; -import java.util.*; +import java.util.AbstractMap; +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.Map; +import java.util.Set; /** * The type Yaml util. |