2 * Copyright (c) 2014 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.mdsal.binding.java.api.generator
10 import org.opendaylight.mdsal.binding.model.api.GeneratedTransferObject
11 import org.opendaylight.mdsal.binding.model.api.AccessModifier
14 * Template for generating JAVA class.
16 class UnionBuilderTemplate extends ClassTemplate {
19 * Creates instance of this class with concrete <code>genType</code>.
21 * @param genType generated transfer object which will be transformed to JAVA class source code
23 new(GeneratedTransferObject genType) {
28 «wrapToDocumentation(formatDataForJavaDoc(type, getClarification()))»
30 public class «type.name» {
31 private «type.name»() {
32 //Exists only to defeat instantiation.
40 def private generateMethods() '''
41 «FOR method : genTO.methodDefinitions»
42 «method.accessModifier.accessModifier»«IF method.static»static«ENDIF»«IF method.final» final«ENDIF» «method.
43 returnType.importedName» «method.name»(«method.parameters.generateParameters») {
44 throw new «UnsupportedOperationException.importedName»("Not yet implemented");
49 def private String getAccessModifier(AccessModifier modifier) {
51 case AccessModifier.PUBLIC: return "public "
52 case AccessModifier.PROTECTED: return "protected "
53 case AccessModifier.PRIVATE: return "private "
58 def private String getClarification() {
61 The purpose of generated class in src/main/java for Union types is to create new instances of unions from a string representation.
62 In some cases it is very difficult to automate it since there can be unions such as (uint32 - uint16), or (string - uint32).
64 The reason behind putting it under src/main/java is:
65 This class is generated in form of a stub and needs to be finished by the user. This class is generated only once to prevent