Export declared regexes to generated code
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 28 Feb 2018 22:51:02 +0000 (23:51 +0100)
committerAnil Belur <abelur@linuxfoundation.org>
Wed, 19 Jun 2024 00:41:22 +0000 (10:41 +1000)
commitc258b4345cba59c73cc26a964c9b87166fdefa6d
tree5971c69e213d12c3d45352241cd208b0f0ae9781
parentc75f5172db6f4a704b757f9f603c8b8ed3fdc6e4
Export declared regexes to generated code

This patch exports declared pattern regular expressions to binding
generators, thus allowing them to report violations using the declared
string rather than the mangled Pattern string we use to implement
enforcement.

As it turns out there is place for improvement with generated code
size, as decoding pattern negation requires a bit of repetition
as well as needing to capture additional strings. Since we can take
advantage of common code library, do not encapsulate single expressions
in an array.

This patch battles those ill effects by exposing CodeHelpers class
from yang-binding, which hosts common code blocks for reuse by
generated code. This means classes generated by this and newer codegen
plugins require a matching or newer version of yang-binding at runtime.

JIRA: MDSAL-313
Change-Id: I8abb33660c5182703f2db5faf0eee7e08ce15f06
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
binding/mdsal-binding-java-api-generator/pom.xml
binding/mdsal-binding-java-api-generator/src/main/java/org/opendaylight/mdsal/binding/java/api/generator/BuilderTemplate.xtend
binding/mdsal-binding-java-api-generator/src/main/java/org/opendaylight/mdsal/binding/java/api/generator/ClassTemplate.xtend
binding/mdsal-binding-java-api-generator/src/main/java/org/opendaylight/mdsal/binding/java/api/generator/Constants.java
binding/mdsal-binding-java-api-generator/src/main/java/org/opendaylight/mdsal/binding/java/api/generator/GeneratorUtil.java
binding/mdsal-binding-java-api-generator/src/test/java/org/opendaylight/mdsal/binding/java/api/generator/test/CompilationTestUtils.java
binding/mdsal-binding-java-api-generator/src/test/java/org/opendaylight/mdsal/binding/java/api/generator/test/TypedefCompilationTest.java
binding/yang-binding/src/main/java/org/opendaylight/yangtools/yang/binding/CodeHelpers.java [new file with mode: 0644]