Fix checkstyle violations in sdc/jtosca
[sdc/sdc-tosca.git] / src / main / java / org / onap / sdc / toscaparser / api / functions / GetOperationOutput.java
index 2acc79a..06a28d6 100644 (file)
@@ -7,9 +7,9 @@
  * 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.
@@ -35,132 +35,126 @@ import java.util.ArrayList;
 
 public class GetOperationOutput extends Function {
 
-       public GetOperationOutput(TopologyTemplate ttpl, Object context, String name, ArrayList<Object> args) {
-               super(ttpl,context,name,args);
-       }
-
-       @Override
-       public void validate() {
-           if(args.size() == 4) {
-               _findNodeTemplate((String)args.get(0));
-               String interfaceName = _findInterfaceName((String)args.get(1));
-               _findOperationName(interfaceName,(String)args.get(2));
-           }
-           else {
-               ThreadLocalsHolder.getCollector().appendValidationIssue(new JToscaValidationIssue("JE159",
-                   "ValueError: Illegal arguments for function \"get_operation_output\". " +
-                   "Expected arguments: \"template_name\",\"interface_name\"," +
-                   "\"operation_name\",\"output_variable_name\"")); 
-           }
-       }
-       
-       private String _findInterfaceName(String _interfaceName) {
-               boolean bFound = false;
-               for(String sect: InterfacesDef.SECTIONS) {
-                       if(sect.equals(_interfaceName)) {
-                               bFound = true;
-                               break;
-                       }
-               }
-           if(bFound) {
-               return _interfaceName;
-           }
-           else {
-               ThreadLocalsHolder.getCollector().appendValidationIssue(new JToscaValidationIssue("JE160", String.format(
-                       "ValueError: invalid interface name \"%s\" in \"get_operation_output\"",
-                       _interfaceName))); 
-               return null;
-           }
-       }
-
-       private String _findOperationName(String interfaceName,String operationName) {
-               
-           if(interfaceName.equals("Configure") ||
-              interfaceName.equals("tosca.interfaces.node.relationship.Configure")) {
-                       boolean bFound = false;
-                       for(String sect: StatefulEntityType.interfacesRelationshipConfigureOperations) {
-                               if(sect.equals(operationName)) {
-                                       bFound = true;
-                                       break;
-                               }
-                       }
-                   if(bFound) {
-                       return operationName;
-                   }
-               else {
-                   ThreadLocalsHolder.getCollector().appendValidationIssue(new JToscaValidationIssue("JE161", String.format(
-                       "ValueError: Invalid operation of Configure interface \"%s\" in \"get_operation_output\"",
-                       operationName))); 
-                   return null;
-               }
-           }
-           if(interfaceName.equals("Standard") ||
-              interfaceName.equals("tosca.interfaces.node.lifecycle.Standard")) {
-                       boolean bFound = false;
-                       for(String sect: StatefulEntityType.interfacesNodeLifecycleOperations) {
-                               if(sect.equals(operationName)) {
-                                       bFound = true;
-                                       break;
-                               }
-                       }
-                   if(bFound) {
-                       return operationName;
-                   }
-               else {
-                   ThreadLocalsHolder.getCollector().appendValidationIssue(new JToscaValidationIssue("JE162", String.format(
-                       "ValueError: Invalid operation of Configure interface \"%s\" in \"get_operation_output\"",
-                       operationName))); 
-                   return null;
-               }
-           }
-           else {
-               ThreadLocalsHolder.getCollector().appendValidationIssue(new JToscaValidationIssue("JE163", String.format(
-                       "ValueError: Invalid interface name \"%s\" in \"get_operation_output\"",
-                       interfaceName))); 
-               return null;
-           }
-       }
-       
-       private NodeTemplate _findNodeTemplate(String nodeTemplateName) {
-           if(nodeTemplateName.equals(TARGET)) {
-               if(!(((EntityTemplate)context).getTypeDefinition() instanceof RelationshipType)) {
-                   ThreadLocalsHolder.getCollector().appendValidationIssue(new JToscaValidationIssue("JE164", 
-                       "KeyError: \"TARGET\" keyword can only be used in context " +
-                                  " to \"Relationships\" target node")); 
-                   return null;
-               }
-               return ((RelationshipTemplate)context).getTarget();
-           }
-           if(nodeTemplateName.equals(SOURCE)) {
-               if(!(((EntityTemplate)context).getTypeDefinition() instanceof RelationshipType)) {
-                   ThreadLocalsHolder.getCollector().appendValidationIssue(new JToscaValidationIssue("JE165", 
-                       "KeyError: \"SOURCE\" keyword can only be used in context " +
-                                  " to \"Relationships\" source node")); 
-                   return null;
-               }
-               return ((RelationshipTemplate)context).getTarget();
-           }
-           String name;
-           if(nodeTemplateName.equals(SELF) && !(context instanceof ArrayList)) {
-               name = ((NodeTemplate)context).getName();
-           }
-           else {
-               name = nodeTemplateName;
-           }
-           for(NodeTemplate nt: toscaTpl.getNodeTemplates()) {
-               if(nodeTemplateName.equals(name)) {
-                   return nt;
-               }
-           }
-           ThreadLocalsHolder.getCollector().appendValidationIssue(new JToscaValidationIssue("JE166", String.format(
-               "KeyError: Node template \"%s\" was not found",nodeTemplateName))); 
-       return null;
+    public GetOperationOutput(TopologyTemplate ttpl, Object context, String name, ArrayList<Object> args) {
+        super(ttpl, context, name, args);
     }
 
-       @Override
-       public Object result() {
-               return this;
-       }
+    @Override
+    public void validate() {
+        if (args.size() == 4) {
+            _findNodeTemplate((String) args.get(0));
+            String interfaceName = _findInterfaceName((String) args.get(1));
+            _findOperationName(interfaceName, (String) args.get(2));
+        } else {
+            ThreadLocalsHolder.getCollector().appendValidationIssue(new JToscaValidationIssue("JE159",
+                    "ValueError: Illegal arguments for function \"get_operation_output\". " +
+                            "Expected arguments: \"template_name\",\"interface_name\"," +
+                            "\"operation_name\",\"output_variable_name\""));
+        }
+    }
+
+    private String _findInterfaceName(String _interfaceName) {
+        boolean bFound = false;
+        for (String sect : InterfacesDef.SECTIONS) {
+            if (sect.equals(_interfaceName)) {
+                bFound = true;
+                break;
+            }
+        }
+        if (bFound) {
+            return _interfaceName;
+        } else {
+            ThreadLocalsHolder.getCollector().appendValidationIssue(new JToscaValidationIssue("JE160", String.format(
+                    "ValueError: invalid interface name \"%s\" in \"get_operation_output\"",
+                    _interfaceName)));
+            return null;
+        }
+    }
+
+    private String _findOperationName(String interfaceName, String operationName) {
+
+        if (interfaceName.equals("Configure") ||
+                interfaceName.equals("tosca.interfaces.node.relationship.Configure")) {
+            boolean bFound = false;
+            for (String sect : StatefulEntityType.INTERFACE_RELATIONSHIP_CONFIGURE_OPERATIONS) {
+                if (sect.equals(operationName)) {
+                    bFound = true;
+                    break;
+                }
+            }
+            if (bFound) {
+                return operationName;
+            } else {
+                ThreadLocalsHolder.getCollector().appendValidationIssue(new JToscaValidationIssue("JE161", String.format(
+                        "ValueError: Invalid operation of Configure interface \"%s\" in \"get_operation_output\"",
+                        operationName)));
+                return null;
+            }
+        }
+        if (interfaceName.equals("Standard") ||
+                interfaceName.equals("tosca.interfaces.node.lifecycle.Standard")) {
+            boolean bFound = false;
+            for (String sect : StatefulEntityType.INTERFACE_NODE_LIFECYCLE_OPERATIONS) {
+                if (sect.equals(operationName)) {
+                    bFound = true;
+                    break;
+                }
+            }
+            if (bFound) {
+                return operationName;
+            } else {
+                ThreadLocalsHolder.getCollector().appendValidationIssue(new JToscaValidationIssue("JE162", String.format(
+                        "ValueError: Invalid operation of Configure interface \"%s\" in \"get_operation_output\"",
+                        operationName)));
+                return null;
+            }
+        } else {
+            ThreadLocalsHolder.getCollector().appendValidationIssue(new JToscaValidationIssue("JE163", String.format(
+                    "ValueError: Invalid interface name \"%s\" in \"get_operation_output\"",
+                    interfaceName)));
+            return null;
+        }
+    }
+
+    private NodeTemplate _findNodeTemplate(String nodeTemplateName) {
+        if (nodeTemplateName.equals(TARGET)) {
+            if (!(((EntityTemplate) context).getTypeDefinition() instanceof RelationshipType)) {
+                ThreadLocalsHolder.getCollector().appendValidationIssue(new JToscaValidationIssue("JE164",
+                        "KeyError: \"TARGET\" keyword can only be used in context " +
+                                " to \"Relationships\" target node"));
+                return null;
+            }
+            return ((RelationshipTemplate) context).getTarget();
+        }
+        if (nodeTemplateName.equals(SOURCE)) {
+            if (!(((EntityTemplate) context).getTypeDefinition() instanceof RelationshipType)) {
+                ThreadLocalsHolder.getCollector().appendValidationIssue(new JToscaValidationIssue("JE165",
+                        "KeyError: \"SOURCE\" keyword can only be used in context " +
+                                " to \"Relationships\" source node"));
+                return null;
+            }
+            return ((RelationshipTemplate) context).getTarget();
+        }
+        String name;
+        if (nodeTemplateName.equals(SELF) && !(context instanceof ArrayList)) {
+            name = ((NodeTemplate) context).getName();
+        } else {
+            name = nodeTemplateName;
+        }
+        for (NodeTemplate nt : toscaTpl.getNodeTemplates()) {
+            if (nodeTemplateName.equals(name)) {
+                return nt;
+            }
+        }
+        ThreadLocalsHolder.getCollector().appendValidationIssue(new JToscaValidationIssue("JE166", String.format(
+                "KeyError: Node template \"%s\" was not found", nodeTemplateName)));
+        return null;
+    }
+
+    @Override
+    public Object result() {
+        return this;
+    }
 
 }