Fix checkstyle violations in sdc-main/common 32/91532/2
authormichal.banka <michal.banka@nokia.com>
Tue, 16 Jul 2019 11:51:00 +0000 (13:51 +0200)
committerTomasz Golabek <tomasz.golabek@nokia.com>
Wed, 17 Jul 2019 08:21:51 +0000 (08:21 +0000)
Change-Id: I3e132cf4bffd77f9910bf6eff2026c3267873b11
Issue-ID: SDC-2454
Signed-off-by: michal.banka <michal.banka@nokia.com>
30 files changed:
checkstyle-suppressions.xml [new file with mode: 0644]
common/onap-common-configuration-management/onap-configuration-management-api/src/main/java/org/onap/config/api/ConfigurationLoader.java
common/onap-common-configuration-management/onap-configuration-management-core/src/main/java/org/onap/config/ConfigurationUtils.java
common/onap-common-configuration-management/onap-configuration-management-core/src/main/java/org/onap/config/impl/ConfigurationImpl.java
common/onap-common-configuration-management/onap-configuration-management-core/src/main/java/org/onap/config/impl/ConfigurationRepository.java
common/onap-generic-artifact-browser/onap-generic-artifact-browser-service/src/main/java/org/onap/sdc/gab/GABServiceImpl.java
common/onap-generic-artifact-browser/onap-generic-artifact-browser-service/src/main/java/org/onap/sdc/gab/model/GABQuery.java
common/onap-generic-artifact-browser/onap-generic-artifact-browser-service/src/main/java/org/onap/sdc/gab/model/GABResultEntry.java
common/onap-generic-artifact-browser/onap-generic-artifact-browser-service/src/main/java/org/onap/sdc/gab/yaml/YamlParser.java
common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/AttributeDefinition.java
common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/CapabilityDefinition.java
common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/Condition.java
common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/Credential.java
common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/DataType.java
common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/DefinitionOfDataType.java
common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/Implementation.java
common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/InterfaceDefinition.java
common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/InterfaceDefinitionType.java
common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/InterfaceType.java
common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/OperationDefinition.java
common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/PropertyDefinition.java
common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/PropertyType.java
common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/Status.java
common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/Trigger.java
common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/extension/ServiceFilter.java
common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/extension/SubstitutionMappingExt.java
common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/heatextend/PropertyTypeExt.java
common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/services/CommonUtil.java
common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/services/DataModelCloneUtil.java
common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/services/YamlUtil.java

diff --git a/checkstyle-suppressions.xml b/checkstyle-suppressions.xml
new file mode 100644 (file)
index 0000000..c83a6fa
--- /dev/null
@@ -0,0 +1,43 @@
+<?xml version="1.0"?>
+<!--
+   ============LICENSE_START=======================================================
+   SDC
+   ================================================================================
+   Copyright (C) 2019 Nokia. 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.
+   ============LICENSE_END=========================================================
+  -->
+
+<!DOCTYPE suppressions PUBLIC
+        "-//Checkstyle//DTD SuppressionFilter Configuration 1.0//EN"
+        "https://checkstyle.org/dtds/suppressions_1_0.dtd">
+<suppressions>
+    <suppress checks=".*" files="\.java" lines="1-20"/>
+    <suppress checks=".*" files="\.properties"/>
+    <suppress checks="javadoc" files="\.java"/>
+    <suppress checks="LineLength" files="\.java"/>
+    <suppress checks="HiddenField" files="\.java"/>
+    <suppress checks="FinalClass" files="\.java"/>
+    <suppress checks="FinalParameters" files="\.java"/>
+    <suppress checks="AvoidInlineConditionals" files="\.java"/>
+    <suppress checks="DesignForExtension" files="\.java"/>
+    <suppress checks="ImportOrder" files="\.java"/>
+    <suppress checks="LocalVariableName" files="\.java"/>
+    <suppress checks="AbbreviationAsWordInName" files="\.java"/>
+    <!--Checkstyle requirements that don't match SnakeYAML parser requirements-->
+    <suppress checks="ParameterName" files="common/onap-tosca-datatype/.*/*.java"/>
+    <suppress checks="MethodName" files="common/onap-tosca-datatype/.*/*.java"/>
+    <suppress checks="MemberName" files="common/onap-tosca-datatype/.*/*.java"/>
+
+</suppressions>
\ No newline at end of file
index b186491..991ec5f 100644 (file)
@@ -433,12 +433,13 @@ public class ConfigurationUtils {
         Pattern pattern = Pattern.compile("^.*\\$\\{(.*)\\}.*");
         Matcher matcher = pattern.matcher(data);
         if (matcher.matches()) {
+            final int substringStartIndex = 4;
             String key = matcher.group(1);
             String value;
             if (key.toUpperCase().startsWith("ENV:")) {
-                value = System.getenv(key.substring(4));
+                value = System.getenv(key.substring(substringStartIndex));
             } else if (key.toUpperCase().startsWith("SYS:")) {
-                value = System.getProperty(key.substring(4));
+                value = System.getProperty(key.substring(substringStartIndex));
             } else {
                 value = ConfigurationUtils.getCollectionString(
                         ConfigurationManager.lookup().getAsStringValues(tenant, namespace, key).toString());
@@ -513,8 +514,8 @@ public class ConfigurationUtils {
         if (List.class.isAssignableFrom(clazz)) {
             return getConcreteCollection(List.class);
         }
-        throw new IllegalArgumentException("Only corresponding array classes and any are allowed as argument." +
-                "assignable from TransferQueue, BlockingQueue, Deque, Queue, SortedSet, Set, List class");
+        throw new IllegalArgumentException("Only corresponding array classes and any are allowed as argument."
+                "assignable from TransferQueue, BlockingQueue, Deque, Queue, SortedSet, Set, List class");
     }
 
     public static Collection getConcreteCollection(Class clazz) {
@@ -535,8 +536,8 @@ public class ConfigurationUtils {
             case "java.util.concurrent.BlockingQueue":
                 return new LinkedBlockingQueue<>();
             default:
-                throw new IllegalArgumentException("Only corresponding array classes and any are allowed as argument." +
-                        "assignable from TransferQueue, BlockingQueue, Deque, Queue, SortedSet, Set, List class");
+                throw new IllegalArgumentException("Only corresponding array classes and any are allowed as argument."
+                        "assignable from TransferQueue, BlockingQueue, Deque, Queue, SortedSet, Set, List class");
         }
     }
 
index 6cad62e..9a3fbd2 100644 (file)
@@ -44,7 +44,7 @@ public class ConfigurationImpl implements org.onap.config.api.Configuration {
 
     private static final String KEY_CANNOT_BE_NULL = "Key can't be null.";
 
-    private static final NonConfigResource nonConfigResource = new NonConfigResource();
+    private static final NonConfigResource NON_CONFIG_RESOURCE = new NonConfigResource();
 
     static {
 
@@ -70,7 +70,7 @@ public class ConfigurationImpl implements org.onap.config.api.Configuration {
                 }
                 moduleConfig.addConfig(url);
             } else {
-                nonConfigResource.add(url);
+                NON_CONFIG_RESOURCE.add(url);
             }
         }
         String configLocation = System.getProperty("config.location");
@@ -88,7 +88,7 @@ public class ConfigurationImpl implements org.onap.config.api.Configuration {
                     }
                     moduleConfig.addConfig(file);
                 } else {
-                    nonConfigResource.add(file);
+                    NON_CONFIG_RESOURCE.add(file);
                 }
             }
         }
@@ -397,13 +397,17 @@ public class ConfigurationImpl implements org.onap.config.api.Configuration {
                             clazzToInstantiate = field.getType();
                         }
                         Constructor construct = getConstructorWithArguments(clazzToInstantiate, Collection.class);
+
                         if (construct != null) {
                             construct.setAccessible(true);
                             field.set(objToReturn, construct.newInstance(list));
-                        } else if ((construct = getConstructorWithArguments(clazzToInstantiate, Integer.class,
-                                Boolean.class, Collection.class)) != null) {
-                            construct.setAccessible(true);
-                            field.set(objToReturn, construct.newInstance(list.size(), true, list));
+                        } else {
+                            construct = getConstructorWithArguments(clazzToInstantiate, Integer.class,
+                                    Boolean.class, Collection.class);
+                            if (construct != null) {
+                                construct.setAccessible(true);
+                                field.set(objToReturn, construct.newInstance(list.size(), true, list));
+                            }
                         }
                     }
                 } else if (Map.class.isAssignableFrom(field.getType())) {
@@ -454,7 +458,7 @@ public class ConfigurationImpl implements org.onap.config.api.Configuration {
         if (String.class.equals(clazz)) {
             if (obj.toString().startsWith("@") && ConfigurationUtils.isExternalLookup(processingHint)) {
                 String contents = ConfigurationUtils.getFileContents(
-                        nonConfigResource.locate(obj.toString().substring(1).trim()));
+                        NON_CONFIG_RESOURCE.locate(obj.toString().substring(1).trim()));
                 if (contents == null) {
                     contents = ConfigurationUtils.getFileContents(obj.toString().substring(1).trim());
                 }
index 5863cae..63c3b75 100644 (file)
@@ -35,7 +35,7 @@ import org.onap.config.Constants;
 
 public final class ConfigurationRepository {
 
-    private static final ConfigurationRepository repo = new ConfigurationRepository();
+    private static final ConfigurationRepository REPO = new ConfigurationRepository();
 
     private final Set<String> tenants = Collections.synchronizedSet(new HashSet<>());
 
@@ -63,7 +63,7 @@ public final class ConfigurationRepository {
     }
 
     public static ConfigurationRepository lookup() {
-        return repo;
+        return REPO;
     }
 
     public Set<String> getTenants() {
@@ -119,20 +119,20 @@ public final class ConfigurationRepository {
 
         private final Map<String, FileBasedConfigurationBuilder<FileBasedConfiguration>> overrideConfiguration =
                 new LinkedHashMap<>();
-        BasicConfigurationBuilder<Configuration> builder;
-        Timestamp lastConfigurationBuildTime;
-        Configuration config;
-        Configuration composite;
+        private BasicConfigurationBuilder<Configuration> builder;
+        private Timestamp lastConfigurationBuildTime;
+        private Configuration config;
+        private Configuration composite;
 
-        public ConfigurationHolder(BasicConfigurationBuilder builder) {
+        ConfigurationHolder(BasicConfigurationBuilder builder) {
             this.builder = builder;
         }
 
-        public ConfigurationHolder(Configuration builder) {
+        ConfigurationHolder(Configuration builder) {
             this.config = builder;
         }
 
-        public void addOverrideConfiguration(String path, BasicConfigurationBuilder<FileBasedConfiguration> builder) {
+        void addOverrideConfiguration(String path, BasicConfigurationBuilder<FileBasedConfiguration> builder) {
             overrideConfiguration.put(path.toUpperCase(), (FileBasedConfigurationBuilder) builder);
             getEffectiveConfiguration(config, overrideConfiguration.values());
         }
index 7f6c353..0a8a206 100644 (file)
@@ -21,6 +21,7 @@
 package org.onap.sdc.gab;
 
 import java.io.IOException;
+
 import org.onap.sdc.gab.model.GABQuery;
 import org.onap.sdc.gab.model.GABQuery.GABQueryType;
 import org.onap.sdc.gab.model.GABResults;
@@ -35,8 +36,8 @@ public class GABServiceImpl implements GABService {
         }
     }
 
-    private GABYamlParser parse(GABQuery gabQuery, GABYamlParser gabYamlParser){
-        return gabQuery.getType() == GABQueryType.PATH ?
-            gabYamlParser.parseFile(gabQuery.getDocument()) : gabYamlParser.parseContent(gabQuery.getDocument());
+    private GABYamlParser parse(GABQuery gabQuery, GABYamlParser gabYamlParser) {
+        return gabQuery.getType() == GABQueryType.PATH
+                ? gabYamlParser.parseFile(gabQuery.getDocument()) : gabYamlParser.parseContent(gabQuery.getDocument());
     }
 }
index f306e09..cbe7ef3 100644 (file)
@@ -35,7 +35,7 @@ public class GABQuery {
      * PATH - when provided path to the yaml file
      * CONTENT - when provided yaml file content
      */
-    public enum GABQueryType{
+    public enum GABQueryType {
         PATH, CONTENT
     }
 
index 0d35759..ec4ff13 100644 (file)
@@ -53,7 +53,7 @@ import org.yaml.snakeyaml.Yaml;
  */
 public class YamlParser implements AutoCloseable {
 
-    private static Logger LOGGER = Logger.getLogger(YamlParser.class.getName());
+    private static final Logger LOGGER = Logger.getLogger(YamlParser.class.getName());
 
     private Stream<Object> parsedYamlContent;
     private InputStream inputStream;
@@ -121,7 +121,7 @@ public class YamlParser implements AutoCloseable {
     List<List<SimpleEntry<String, ? extends Collection<Object>>>> collect() throws IOException {
         try {
             return parsedYamlContent.map(containsKeys).filter(notEmptyListPredicate()).collect(Collectors.toList());
-        } catch(Exception e){
+        } catch (Exception e) {
             LOGGER.log(Level.WARNING, "Unexpected document content. Please check body of the yaml file.", e);
             throw new IOException("Unexpected document content");
         }
index 4352f16..aa1392e 100644 (file)
@@ -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;
index 152d9fb..4d0a38a 100644 (file)
@@ -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;
index a394401..f85ea5c 100644 (file)
@@ -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;
index 11bb639..217af07 100644 (file)
@@ -29,7 +29,7 @@ public class Credential {
   private Map<String, String> keys;
   private String user;
 
-  public Credential(){
+  public Credential() {
     this.token_type = "password";
   }
 
index bf318a7..acf11c2 100644 (file)
@@ -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;
index 9d00532..44da720 100644 (file)
@@ -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;
index 1449f20..80a2a22 100644 (file)
@@ -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;
index c46cc6a..9bb35d8 100644 (file)
@@ -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()));
         }
index 5f0ea6a..3d691be 100644 (file)
@@ -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
index 5790614..07c4031 100644 (file)
@@ -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);
         }
 
     }
index 42cc715..8114686 100644 (file)
@@ -24,7 +24,7 @@ import java.util.Objects;
 
 public class OperationDefinition implements Cloneable {
 
-    protected String description;
+    private String description;
 
     public String getDescription() {
         return description;
index 84c1586..0c1f804 100644 (file)
@@ -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
index aaaae31..facdb2a 100644 (file)
@@ -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;
   }
 
-
 }
index 222fdd0..b58f13c 100644 (file)
@@ -31,7 +31,7 @@ public enum Status {
   EXPERIMENTAL("experimental"),
   experimental("experimental"),
   DEPRECATED("deprecated"),
-  deprecated("deprecated"),;
+  deprecated("deprecated");
   private String displayName;
 
   Status(String displayName) {
index 9d6d9d8..4404294 100644 (file)
@@ -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);
+    }
 }
index 6c57d2b..572af3d 100644 (file)
@@ -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;
index 1fa3719..d60931d 100644 (file)
@@ -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
index ffe06e6..8d1b552 100644 (file)
@@ -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;
   }
index fdbcb25..bb26e6a 100644 (file)
@@ -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;
     }
index b05fdb5..c41282f 100644 (file)
@@ -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());
index cd19ff9..4030d3a 100644 (file)
@@ -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.