Remove executable bits
[mdsal.git] / binding / mdsal-binding-java-api-generator / src / main / java / org / opendaylight / mdsal / binding / java / api / generator / UnionBuilderTemplate.xtend
1 /*
2  * Copyright (c) 2014 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.GeneratedTransferObject
11 import org.opendaylight.mdsal.binding.model.api.AccessModifier
12
13 /**
14  * Template for generating JAVA class.
15  */
16 class UnionBuilderTemplate extends ClassTemplate {
17
18     /**
19      * Creates instance of this class with concrete <code>genType</code>.
20      *
21      * @param genType generated transfer object which will be transformed to JAVA class source code
22      */
23     new(GeneratedTransferObject genType) {
24         super(genType)
25     }
26
27     override body() '''
28         «wrapToDocumentation(formatDataForJavaDoc(type, getClarification()))»
29         public class «type.name» {
30             private «type.name»() {
31                 //Exists only to defeat instantiation.
32             }
33
34             «generateMethods»
35
36         }
37     '''
38
39     def private generateMethods() '''
40         «FOR method : genTO.methodDefinitions»
41             «method.accessModifier.accessModifier»«IF method.static»static«ENDIF»«IF method.final» final«ENDIF» «method.
42             returnType.importedName» «method.name»(«method.parameters.generateParameters») {
43                 throw new «UnsupportedOperationException.importedName»("Not yet implemented");
44             }
45         «ENDFOR»
46     '''
47
48     def private String getAccessModifier(AccessModifier modifier) {
49         switch (modifier) {
50             case AccessModifier.PUBLIC: return "public "
51             case AccessModifier.PROTECTED: return "protected "
52             case AccessModifier.PRIVATE: return "private "
53             default: return ""
54         }
55     }
56
57     def private String getClarification() {
58         return
59         '''
60         The purpose of generated class in src/main/java for Union types is to create new instances of unions from a string representation.
61         In some cases it is very difficult to automate it since there can be unions such as (uint32 - uint16), or (string - uint32).
62
63         The reason behind putting it under src/main/java is:
64         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
65         loss of user code.
66         '''
67     }
68
69 }