2 * Copyright (c) 2016 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
9 @import org.opendaylight.mdsal.binding2.model.api.GeneratedType
10 @import org.opendaylight.mdsal.binding2.model.api.GeneratedProperty
11 @import org.opendaylight.mdsal.binding2.java.api.generator.util.TextTemplateUtil.fieldName
12 @import org.opendaylight.mdsal.binding2.java.api.generator.util.TextTemplateUtil.asArguments
13 @import org.opendaylight.mdsal.binding2.generator.util.Types.getOuterClassName
15 @(baseType: GeneratedType, importedNames: Map[String, String], finalProperties: List[GeneratedProperty],
16 parentProperties: List[GeneratedProperty], properties: List[GeneratedProperty], propertyList: String)
17 @for(property <- parentProperties) {
18 public @{baseType.getName}(@{importedNames.get(property.getName)} @{fieldName(property)}) {
19 super(@{fieldName(property)});
22 @for(property <- finalProperties) {
23 @if("char[]".equals(property.getReturnType.getName)) {
25 * Constructor provided only for using in JMX. Don't use it for
26 * construction new object of this union type.
28 @@@{importedNames.get("constructorProperties")}("@{property.getName}")
29 public @{baseType.getName}({importedNames.get(property.getName)} @{fieldName(property)}) {
30 @{importedNames.get("string")} defVal = new @{importedNames.get("string")}(@{fieldName(property)});
31 @{baseType.getName} defInst = @{typeBuilder}.getDefaultInstance(defVal);
32 @for(otherProperty <- finalProperties) {
33 this.@{fieldName(otherProperty)} =
34 @if("value".equals(otherProperty.getName)) {
35 @if(importedNames.get(otherProperty.getName).contains("[]")) {
36 @{fieldName(otherProperty)} == null ? null : @{fieldName(otherProperty)}.clone();
38 @{fieldName(otherProperty)};
41 defInst.@{fieldName(otherProperty)};
46 @*TO DO parentProperties + #[property] as argument to method below see unionTemplate 84 *@
47 public @{baseType.getName}() {
48 super(@{asArguments(parentProperties)});
49 this.@{fieldName(property)} = @{fieldName(property)};
50 @for(otherProperty <- finalProperties) {
51 @if(property != otherProperty && !"value".equals(otherProperty.getName)) {
52 this.@{fieldName(otherProperty)} = null;
58 @if(!properties.isEmpty && !parentProperties.isEmpty) {
60 * Creates a copy from Source Object.
62 * @@param source Source object
64 public @{baseType.getName}
67 @if(!parentProperties.isEmpty()) {super(source);}
71 @if(properties.isEmpty && !parentProperties.isEmpty) {
73 * Creates a new instance from @{importedNames.get("superType")}
75 * @@param source Source object
77 public @{baseType.getName}(@{importedNames.get("superType")} source) {
83 @if(getOuterClassName(baseType) != null) {
84 @{getOuterClassName(baseType)}@{baseType.getName}Builder
86 @{baseType.getName}Builder