2 * Copyright (c) 2020 Pantheon Technologies, s.r.o. 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.GeneratedProperty
11 import org.opendaylight.mdsal.binding.model.api.GeneratedTransferObject
14 * Template for generating JAVA class.
16 class ListKeyTemplate 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 override final allValuesConstructor() '''
29 public «type.name»(«allProperties.asNonNullArgumentsDeclaration») {
30 «FOR p : allProperties»
31 «CODEHELPERS.importedName».requireValue(«p.fieldName»);
34 «generateRestrictions(type, p.fieldName, p.returnType)»
37 «FOR p : allProperties»
38 «val fieldName = p.fieldName»
39 «IF p.returnType.name.endsWith("[]")»
40 this.«fieldName» = «fieldName».clone();
42 this.«fieldName» = «fieldName»;
48 override final def getterMethod(GeneratedProperty field) {
50 public «field.returnType.importedNonNull» «field.getterMethodName»() {
51 «val fieldName = field.fieldName»
52 «IF field.returnType.name.endsWith("[]")»
53 return «fieldName».clone();