Fix a typo in UnionTemplate
[mdsal.git] / binding / mdsal-binding-java-api-generator / src / main / java / org / opendaylight / mdsal / binding / java / api / generator / EnumGenerator.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.mdsal.binding.java.api.generator;
9
10 import org.opendaylight.mdsal.binding.model.api.CodeGenerator;
11 import org.opendaylight.mdsal.binding.model.api.Enumeration;
12 import org.opendaylight.mdsal.binding.model.api.Type;
13
14 /**
15  * Transformator of the data from the virtual form to JAVA source code. The result source code represents JAVA
16  * enumeration. For generation of the source code is used the template written in XTEND language.
17  */
18 public class EnumGenerator implements CodeGenerator {
19     @Override
20     public boolean isAcceptable(final Type type) {
21         return type instanceof Enumeration;
22     }
23
24     /**
25      * Generates JAVA source code for generated type <code>Type</code>. The code is generated according to the template
26      * source code template which is written in XTEND language.
27      */
28     @Override
29     public String generate(final Type type) {
30         if (type instanceof Enumeration) {
31             final Enumeration enums = (Enumeration) type;
32             final EnumTemplate enumTemplate = new EnumTemplate(enums);
33             return enumTemplate.generate();
34         }
35         return "";
36     }
37
38     @Override
39     public String getUnitName(final Type type) {
40         return type.getName();
41     }
42 }