2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
\r
4 * This program and the accompanying materials are made available under the
\r
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
\r
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
\r
8 package org.opendaylight.controller.sal.java.api.generator;
\r
10 import static org.opendaylight.controller.sal.java.api.generator.Constants.*;
\r
12 import java.io.IOException;
\r
13 import java.io.StringWriter;
\r
14 import java.io.Writer;
\r
15 import java.util.List;
\r
17 import org.opendaylight.controller.sal.binding.model.api.CodeGenerator;
\r
18 import org.opendaylight.controller.sal.binding.model.api.Constant;
\r
19 import org.opendaylight.controller.sal.binding.model.api.GeneratedType;
\r
21 public class CompositeKeyGenerator implements CodeGenerator {
\r
24 public Writer generate(GeneratedType type) throws IOException {
\r
25 final Writer writer = new StringWriter();
\r
26 final List<Constant> fields = type.getConstantDefinitions();
\r
28 writer.write(GeneratorUtil.createClassDeclarationWithPkgName(
\r
29 type.getPackageName(), type.getName(), ""));
\r
33 if (fields != null) {
\r
34 for (Constant field : fields) {
\r
35 writer.write(GeneratorUtil.createField(field, TAB) + NL);
\r
39 for (Constant field : fields) {
\r
40 writer.write(GeneratorUtil.createGetter(field, TAB) + NL);
\r
44 writer.write(GeneratorUtil.createHashCode(fields, TAB) + NL);
\r
45 writer.write(GeneratorUtil.createEquals(type, fields, TAB) + NL);
\r
46 writer.write(GeneratorUtil.createToString(type, fields, TAB) + NL);
\r