Merge "OF plugin classes must have a strict dependency on Connection Service"
[controller.git] / opendaylight / sal / yang-prototype / code-generator / binding-java-api-generator / src / main / java / org / opendaylight / controller / sal / java / api / generator / InterfaceGenerator.java
index 8a0054bd8afd1f244d970d1c7643fcf4cb748dab..381b1575781d2991f4da11280a507475070b4c42 100644 (file)
@@ -1,61 +1,32 @@
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.controller.sal.java.api.generator;\r
-\r
-import static org.opendaylight.controller.sal.java.api.generator.Constants.*;\r
-\r
-import java.io.IOException;\r
-import java.io.StringWriter;\r
-import java.io.Writer;\r
-import java.util.List;\r
-\r
-import org.opendaylight.controller.sal.binding.model.api.CodeGenerator;\r
-import org.opendaylight.controller.sal.binding.model.api.Constant;\r
-import org.opendaylight.controller.sal.binding.model.api.Enumeration;\r
-import org.opendaylight.controller.sal.binding.model.api.GeneratedType;\r
-import org.opendaylight.controller.sal.binding.model.api.MethodSignature;\r
-\r
-public class InterfaceGenerator implements CodeGenerator {\r
-\r
-    public Writer generate(GeneratedType type) throws IOException {\r
-        Writer writer = new StringWriter();\r
-        final List<Constant> constants = type.getConstantDefinitions();\r
-        final List<MethodSignature> methods = type.getMethodDefinitions();\r
-        final List<Enumeration> enums = type.getEnumDefintions();\r
-\r
-        writer.write(GeneratorUtil.createIfcDeclarationWithPkgName(\r
-                type.getPackageName(), type.getName(), ""));\r
-        writer.write(NL);\r
-\r
-        if (constants != null) {\r
-            for (Constant c : constants) {\r
-                writer.write(GeneratorUtil.createConstant(c, TAB) + NL);\r
-            }\r
-            writer.write(NL);\r
-        }\r
-\r
-        if (methods != null) {\r
-            for (MethodSignature m : methods) {\r
-                writer.write(GeneratorUtil.createMethodDeclaration(m, TAB) + NL);\r
-            }\r
-            writer.write(NL);\r
-        }\r
-\r
-        if (enums != null) {\r
-            for (Enumeration e : enums) {\r
-                writer.write(GeneratorUtil.createEnum(e, TAB) + NL);\r
-            }\r
-            writer.write(NL);\r
-        }\r
-\r
-        writer.write(RCB);\r
-\r
-        return writer;\r
-    }\r
-\r
-}\r
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.sal.java.api.generator;
+
+import java.io.IOException;
+import java.io.StringWriter;
+import java.io.Writer;
+
+import org.opendaylight.controller.sal.binding.model.api.CodeGenerator;
+import org.opendaylight.controller.sal.binding.model.api.GeneratedTransferObject;
+import org.opendaylight.controller.sal.binding.model.api.GeneratedType;
+import org.opendaylight.controller.sal.binding.model.api.Type;
+
+public final class InterfaceGenerator implements CodeGenerator {
+
+    @Override
+    public Writer generate(Type type) throws IOException {
+        final Writer writer = new StringWriter();
+        if (type instanceof GeneratedType && !(type instanceof GeneratedTransferObject)) {
+            final GeneratedType genType = (GeneratedType) type;
+            final InterfaceTemplate interfaceTemplate = new InterfaceTemplate(genType);
+            writer.write(interfaceTemplate.generate().toString());
+        }
+        return writer;
+    }
+    
+}