--- /dev/null
+/*\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.GeneratedType;\r
+\r
+public class CompositeKeyGenerator implements CodeGenerator {\r
+\r
+ @Override\r
+ public Writer generate(GeneratedType type) throws IOException {\r
+ final Writer writer = new StringWriter();\r
+ final List<Constant> fields = type.getConstantDefinitions();\r
+\r
+ writer.write(GeneratorUtil.createClassDeclarationWithPkgName(\r
+ type.getPackageName(), type.getName(), ""));\r
+ writer.write(NL);\r
+ writer.write(NL);\r
+\r
+ if (fields != null) {\r
+ for (Constant field : fields) {\r
+ writer.write(GeneratorUtil.createField(field, TAB) + NL);\r
+ }\r
+ writer.write(NL);\r
+\r
+ for (Constant field : fields) {\r
+ writer.write(GeneratorUtil.createGetter(field, TAB) + NL);\r
+ }\r
+ writer.write(NL);\r
+\r
+ writer.write(GeneratorUtil.createHashCode(fields, TAB) + NL);\r
+ writer.write(GeneratorUtil.createEquals(type, fields, TAB) + NL);\r
+ writer.write(GeneratorUtil.createToString(type, fields, TAB) + NL);\r
+\r
+ writer.write(RCB);\r
+ }\r
+\r
+ return writer;\r
+ }\r
+\r
+}\r