1 package org.opendaylight.yangtools.sal.java.api.generator
3 import org.opendaylight.yangtools.sal.binding.model.api.Enumeration
5 * Template for generating JAVA enumeration type.
10 * Enumeration which will be transformed to JAVA source code for enumeration
15 * Constructs instance of this class with concrete <code>enums</code>.
17 * @param enumeration which will be transformed to JAVA source code
19 new(Enumeration enums) {
24 * Generates JAVA source code for the enumeration with the package name.
26 * @return JAVA source code for enumeration and for the package name
28 def String generate() {
29 val body = generateBody
31 return pkg.toString + body.toString
35 * Generates only JAVA enumeration source code.
37 * @return string with JAVA enumeration source code
39 def generateAsInnerClass() {
44 * Template method which generates enumeration body (declaration + enumeration items).
46 * @return string with the enumeration body
48 def private generateBody() '''
49 public enum «enums.name» {
50 «FOR v : enums.values SEPARATOR ",\n"»
51 «" "»«v.name»(«v.value»)«
56 private «enums.name»(int value) {
63 * Template method which generates the package name line.
65 * @return string with the package name line
67 def private generatePkg() '''
68 package «enums.packageName»;