X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=code-generator%2Fbinding-java-api-generator%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fyangtools%2Fsal%2Fjava%2Fapi%2Fgenerator%2FClassTemplate.xtend;h=25236bcfd1ebcba5b8b7ea8d92f6f5f3ad0172db;hb=6ead361308210a0926250900b644efa4e2ddb19b;hp=d26c3bb8bfeaf92a9131c2306b7d9e3a39e1cb55;hpb=22ec0ee0c676ce4e07716e395cc25e4597b3426f;p=yangtools.git diff --git a/code-generator/binding-java-api-generator/src/main/java/org/opendaylight/yangtools/sal/java/api/generator/ClassTemplate.xtend b/code-generator/binding-java-api-generator/src/main/java/org/opendaylight/yangtools/sal/java/api/generator/ClassTemplate.xtend index d26c3bb8bf..25236bcfd1 100644 --- a/code-generator/binding-java-api-generator/src/main/java/org/opendaylight/yangtools/sal/java/api/generator/ClassTemplate.xtend +++ b/code-generator/binding-java-api-generator/src/main/java/org/opendaylight/yangtools/sal/java/api/generator/ClassTemplate.xtend @@ -1,3 +1,10 @@ +/* + * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ package org.opendaylight.yangtools.sal.java.api.generator import java.util.List @@ -423,6 +430,18 @@ class ClassTemplate extends BaseTemplate { ''' def private generateGetLength() ''' + «IF restrictions != null && !(restrictions.lengthConstraints.empty)» + public static «List.importedName»<«Range.importedName»> getLength() { + final «List.importedName»<«Range.importedName»> result = new «ArrayList.importedName»<>(); + «FOR r : restrictions.lengthConstraints» + result.add(«Range.importedName».closed(«r.min», «r.max»)); + «ENDFOR» + return result; + } + «ENDIF» + ''' + + def private generateGetRange() ''' «IF restrictions != null && !(restrictions.lengthConstraints.empty)» public static «List.importedName»<«Range.importedName»> getLength() { final «List.importedName»<«Range.importedName»> result = new «ArrayList.importedName»<>();