BUG-1485: Move restriction generation
[yangtools.git] / code-generator / binding-java-api-generator / src / main / java / org / opendaylight / yangtools / sal / java / api / generator / BaseTemplate.xtend
index d98b52fc471bd2b6ac4f152cae09be14d1dc6a20..c93f428131430a53f47be3459e83f4c502b700be 100644 (file)
@@ -328,50 +328,6 @@ abstract class BaseTemplate {
         return sb.toString
     }
 
-    def generateRestrictions(Type type, String paramName, Type returnType) '''
-        «val restrictions = type.getRestrictions»
-        «IF restrictions !== null»
-            «val boolean isNestedType = !(returnType instanceof ConcreteType)»
-            «IF !restrictions.lengthConstraints.empty»
-                «generateLengthRestriction(returnType, restrictions, paramName, isNestedType)»
-            «ENDIF»
-            «IF !restrictions.rangeConstraints.empty»
-                «generateRangeRestriction(returnType, paramName, isNestedType)»
-            «ENDIF»
-        «ENDIF»
-    '''
-
-    def private generateLengthRestriction(Type returnType, Restrictions restrictions, String paramName, boolean isNestedType) '''
-        «val clazz = restrictions.lengthConstraints.iterator.next.min.class»
-        if («paramName» != null) {
-            «printLengthConstraint(returnType, clazz, paramName, isNestedType, returnType.name.contains("["))»
-            boolean isValidLength = false;
-            for («Range.importedName»<«clazz.importedNumber»> r : «IF isNestedType»«returnType.importedName».«ENDIF»length()) {
-                if (r.contains(_constraint)) {
-                    isValidLength = true;
-                }
-            }
-            if (!isValidLength) {
-                throw new IllegalArgumentException(String.format("Invalid length: %s, expected: %s.", «paramName», «IF isNestedType»«returnType.importedName».«ENDIF»length()));
-            }
-        }
-    '''
-
-    def private generateRangeRestriction(Type returnType, String paramName, boolean isNestedType) '''
-        if («paramName» != null) {
-            «printRangeConstraint(returnType, paramName, isNestedType)»
-            boolean isValidRange = false;
-            for («Range.importedName»<«returnType.importedNumber»> r : «IF isNestedType»«returnType.importedName».«ENDIF»range()) {
-                if (r.contains(_constraint)) {
-                    isValidRange = true;
-                }
-            }
-            if (!isValidRange) {
-                throw new IllegalArgumentException(String.format("Invalid range: %s, expected: %s.", «paramName», «IF isNestedType»«returnType.importedName».«ENDIF»range()));
-            }
-        }
-    '''
-
     /**
      * Print length constraint.
      * This should always be a BigInteger (only string and binary can have length restriction)