2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.controller.sal.java.api.generator;
10 import static org.opendaylight.controller.sal.java.api.generator.Constants.*;
12 import java.io.IOException;
13 import java.io.StringWriter;
14 import java.io.Writer;
16 import org.opendaylight.controller.sal.binding.model.api.CodeGenerator;
17 import org.opendaylight.controller.sal.binding.model.api.Enumeration;
18 import org.opendaylight.controller.sal.binding.model.api.Type;
20 public class EnumGenerator implements CodeGenerator {
23 public Writer generate(Type type) throws IOException {
24 final Writer writer = new StringWriter();
26 if (type instanceof Enumeration) {
27 Enumeration enums = (Enumeration) type;
28 writer.write(GeneratorUtil.createPackageDeclaration(enums
30 writer.write(NL + NL);
31 writer.write(GeneratorUtil.createEnum(enums, ""));
37 public Writer generateInnerEnumeration(Type type, String indent) throws IOException {
38 final Writer writer = new StringWriter();
40 if (type instanceof Enumeration) {
41 Enumeration enums = (Enumeration) type;
42 writer.write(GeneratorUtil.createEnum(enums, indent));