0ce3e665358f3b35a9722fa42c43ee16b615635d
[mdsal.git] / binding2 / mdsal-binding2-java-api-generator / src / main / twirl / org / opendaylight / mdsal / binding / javav2 / java / api / generator / classTemplateRestrictions.scala.txt
1 @*
2  * Copyright (c) 2016 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
9 @import org.opendaylight.mdsal.binding.javav2.java.api.generator.util.TextTemplateUtil.getRestrictions
10 @import org.opendaylight.mdsal.binding.javav2.java.api.generator.util.TextTemplateUtil.paramValue
11 @import org.opendaylight.mdsal.binding.javav2.java.api.generator.rangeGenerators.AbstractRangeGenerator
12 @import org.opendaylight.mdsal.binding.javav2.java.api.generator.rangeGenerators.LengthGenerator
13 @import org.opendaylight.mdsal.binding.javav2.model.api.Type
14
15 @(currentType: Type, paramName: String, returnType: Type, rangeGenerator: AbstractRangeGenerator[_])
16 @if(getRestrictions(currentType) != null) {
17     @if(getRestrictions(currentType).getLengthConstraint.isPresent || getRestrictions(currentType).getRangeConstraint.isPresent) {
18     if (@{paramName} != null) {
19         @if(getRestrictions(currentType).getLengthConstraint.isPresent) {
20             @{LengthGenerator.generateLengthCheckerCall(paramName, paramValue(returnType, paramName))}
21         }
22         @if(getRestrictions(currentType).getRangeConstraint.isPresent) {
23             @{rangeGenerator.generateRangeCheckerCall(paramName, paramValue(returnType, paramName))}
24         }
25     }
26     }
27 }