Michael Vorburger [Fri, 6 Apr 2018 18:39:36 +0000 (20:39 +0200)]
artifacts mdsal-binding-test-utils <scope>test
Change-Id: Iffc49385dd269f045291c2a22e02fbd904d5bb6e
Signed-off-by: Michael Vorburger <vorburger@redhat.com>
Jie Han [Wed, 4 Apr 2018 03:04:20 +0000 (11:04 +0800)]
Binding v2 - fix wrong imports from binding v1
- It's a mistake to import classes from binding v1
when bug MDSAL-253 ported changes from binding v1,
just fix up.
- Eliminates a mistoken merged yang file.
Change-Id: Ifb094a128d32a45601bb0f1b3af6144e11521897
Signed-off-by: Jie Han <han.jie@zte.com.cn>
Robert Varga [Wed, 7 Mar 2018 14:06:04 +0000 (15:06 +0100)]
Map identities to interfaces, not abstract classes
This changes mapping of identities from abstract class to an interface,
allowing for multiple inheritence, as needed by YANG 1.1.
JIRA: MDSAL-326
Change-Id: I01f636f5f055f929cdcee4ccb61e04ad0a6841b2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Wed, 21 Mar 2018 02:56:33 +0000 (03:56 +0100)]
Rework YangModuleInfo
This patch modernizes YangModuleInfo to not use only strings, but
also yang.common classes. ResourceYangModuleInfo is created to serve
as abstract superclass for generated YangModuleInfo classes.
JIRA: MDSAL-325
Change-Id: I2f28868b7083af17bd23f6fd360ec6673b94d3ea
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Mon, 26 Mar 2018 22:36:19 +0000 (00:36 +0200)]
Add Types.primitiveVoidType()
There is a difference between java.lang.Void.class and void.class,
which the code generator does not reflect and works around by
squashing the types when looking up.
Fix this deficiency by introducing primitiveVoidType(), which
correctly wraps void.class.
Change-Id: Iaa5b76805d63cec2857a12733c84edaf8b61eba2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Sun, 25 Mar 2018 20:37:18 +0000 (22:37 +0200)]
Move getRestrictions() into BaseTemplate
JavaFileTemplate does not need this functionality, it is much better
hosted in BaseTemplate.
Change-Id: I38fb774ea1b5df92d43cd7ddd35b9b16bb015232
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Marek Gradzki [Fri, 23 Mar 2018 08:28:24 +0000 (09:28 +0100)]
Upgrade ietf-inet-types dependency to 2013-07-15
The ietf-restconf already uses ietf-yang-types@2013-07-15,
so bump ietf-inet-types for consistency.
Change-Id: Id9a871a6f7d273efa94dedb1c98451ba27e7ab7d
Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
Robert Varga [Sun, 11 Mar 2018 15:25:40 +0000 (16:25 +0100)]
Improve EnumerationCodec
Now that we have proper information from enumerations, we can use
build the codec map as known at generation time and check it against
the type we are receiving, adding proper warnings.
JIRA: MDSAL-317
Change-Id: Ia5bd3d73e44eba2568818b578bc44985fafb6294
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Wed, 21 Mar 2018 11:31:28 +0000 (12:31 +0100)]
Remove use of CheckedFuture in ModuleInfoBackedContext
Interface contract requires only ListenableFuture, hence we can
safely migrate.
Change-Id: I2454cfda9d88c9cbab51c297ddf0c819d6b13763
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Thu, 22 Mar 2018 17:06:11 +0000 (18:06 +0100)]
Revert "Fix add imports of nested classes"
This reverts commit
ae34daa2a74d6b952f3567341c163a77ca3a5720.
Concatenating imports does not work as the inner class has to
take into account for containing class name, as that takes
precedence over imports.
Change-Id: I6921b5e923bf6bb48d3f1a118e9beb289c6f6932
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Marek Gradzki [Wed, 21 Mar 2018 12:25:38 +0000 (13:25 +0100)]
Remove ietf-inet-types dependency from ietf-interfaces
The ietf-interfaces@2014-05-08.yang depends only
on ietf-yang-types@2013-07-15.yang
Change-Id: I146c0b130ee0a4cb6e7132a8a4ffe4a8f0bc7ccc
Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
Robert Varga [Wed, 31 Jan 2018 01:47:23 +0000 (02:47 +0100)]
Make DOMDataTreeService extensible
DOMDataTreeService is a candidate for optional extensions, which
we support via the extensible object pattern. Add the ability for
DOMDataTreeService to be extended.
Change-Id: Ibc891208850c933b2a61598eddbf88e90625c064
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Jie Han [Thu, 22 Mar 2018 08:05:22 +0000 (16:05 +0800)]
Binding v2 - Fix setter constant naming
- ported from:
https://git.opendaylight.org/gerrit/69658
Change-Id: Ia86cbdc88e6dd6a87430df467b6d61f11010f6c5
Signed-off-by: Jie Han <han.jie@zte.com.cn>
Robert Varga [Wed, 21 Mar 2018 16:26:45 +0000 (17:26 +0100)]
Revert "Rework inlined union generation"
This reverts commit
beef61289ca5b34724f8c8b73ca851f991af7bb7.
Change-Id: Ib1b60da6bae45202671582cd3648d6626d61064b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Wed, 21 Mar 2018 16:26:42 +0000 (17:26 +0100)]
Revert "Fixup test for MDSAL-320"
This reverts commit
61736ccb14776c6ff8a6c6bcea1ac3a7d55e37a4.
Change-Id: Iab35483edff5c3d2618a26fbd3bbee79141ef499
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Tue, 20 Mar 2018 17:30:43 +0000 (18:30 +0100)]
Reintroduce BindingRuntimeContext.getEnumMapping(String)
We dropped this mathod while we still have a user in the controller,
add it back, this time having the ability to work with deeply-nested
enumerations.
Change-Id: Id3449aada7406bca67d24cfd7bde3d58f0206043
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Peter Nosal [Mon, 19 Mar 2018 07:59:37 +0000 (08:59 +0100)]
Change transformation from DOMRpcResult to RpcResult
When RpcResult was created, it was always as successful RpcResult,
this is changed so in presence of RpcErrors, RcpResult is built as
failed RpcResult with RpcErrors and binding result.
Change-Id: I7ee54dfffb271505fd52feee4c6b2235c0ae4964
Signed-off-by: Peter Nosal <peter.nosal@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Tue, 20 Mar 2018 12:59:12 +0000 (13:59 +0100)]
Fixup test for MDSAL-320
This is a namespace cleanup, change the model and namespace to mdsal320
instead of yt320.
JIRA: MDSAL-320
Change-Id: If58588c89b9005878a1a65780b2e22e1b37f4cab
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Tue, 20 Mar 2018 09:19:30 +0000 (10:19 +0100)]
Fix setter constant naming
Bouncing property name through upper/lower case does not really work,
as it breaks with capitalized properties. Also remove the public constant
so we do not retain the input list -- the patterns are not really useful
anyway.
JIRA: MDSAL-323
Change-Id: I7aa5677e27c6dddc13cc25336500ba0b583b021f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Mon, 19 Mar 2018 08:43:11 +0000 (09:43 +0100)]
Rework inlined union generation
Unions internal to a leaf union end up being incompletely generated,
as they lack getValue(), hashCode(), equals() and do not correctly
bind to its enclosing builder -- leading to a generated code not being
compilable.
There are multiple issues here, all of which are addressed in this patch:
- value/hashCode/equals properties are created in the wrong place
- property return type is set to the builder, not its product
- union builder type is not set as a union
- builders for nested types are not correctly emitted
JIRA: MDSAL-320
Change-Id: I60697c74669d4508922ea3ee22e2f0fe5d99b322
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Mon, 19 Mar 2018 01:11:45 +0000 (02:11 +0100)]
Disambiguate generated nested enumerations
In case we have an enumeration defined directly in a leaf of the same
name as its containing generated type (list, container, etc.), we can
end up violating JLS section 8.1 class naming requirements.
Detect this condition and munge the type name by appending a '$' to
prevent this conflict.
Change-Id: Ia68cac2a96ac0a95fa38a83cb1cdc1c09540533b
JIRA: MDSAL-321
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Mon, 12 Mar 2018 20:33:57 +0000 (21:33 +0100)]
Integrate JavaTypeName as Identifier
This changes 'Type' to implement Identifiable<JavaTypeName>, which
allows us to cleanly manage Java type naming and namespace handling.
Type's base mathods are made default and name tracking is reworked
to always be based on JavaTypeName.
JIRA: MDSAL-321
Change-Id: Id8512d38eb2eed9bd2ce4d6b172937bebde03581
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Mon, 12 Mar 2018 18:08:18 +0000 (19:08 +0100)]
Add binding.model.api.Java{Package,Type}Name
This adds the basic concept of a JavaTypeName, which reflects a Java
class or interface -- something that is a 'type. JavaPackageName
is similar, it defines a names Java package.
JIRA: MDSAL-321
Change-Id: Ia914fb001444292e00f6089853e1c434b95043ad
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Sun, 11 Mar 2018 16:30:35 +0000 (17:30 +0100)]
Cache module package name in ModuleContext
Creating this string is expensive and we have multiple call sites
generating it. Centralize its (lazy) allocation.
Change-Id: Ief43c180a7aec798408e9e15602be7f7e1856bd8
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Jie Han [Tue, 30 Jan 2018 08:29:03 +0000 (16:29 +0800)]
MDSAL-292: Binding v2 - Pattern attribute ignored for leaf-list/leaf
- Support pattern constraint for leaf of type string,
add suffix with leaf name to avoid conflicts of constant name
from multiple patterns of different leaf/leaf-lists.
Change-Id: Iafc6f94c08300b19439adbf2dc714a4cd96c9afc
Signed-off-by: Jie Han <han.jie@zte.com.cn>
Jie Han [Fri, 16 Mar 2018 09:40:24 +0000 (17:40 +0800)]
Binding v2 - Export declared regexes to generated code
- Ported from:
https://git.opendaylight.org/gerrit/#/c/68916/20
- Split out an constantTemplate which would be reused
by renderers of class, interface and builder.
- Eliminates TypeConstants and puts PATTERN_CONSTANT_NAME
etc. in BindingMapping.
Change-Id: Id1c0b70e5dd520d27dc764c290b0d7e7d5b14cec
Signed-off-by: Jie Han <han.jie@zte.com.cn>
Jie Han [Tue, 13 Mar 2018 07:46:02 +0000 (15:46 +0800)]
Fix add imports of nested classes
- Use importedName instead of
directly hard code class FQN in the template.
Change-Id: Icb39df83f6c09461a2130c3ba3a9b2151a30fb85
Signed-off-by: Jie Han <han.jie@zte.com.cn>
Jie Han [Fri, 2 Feb 2018 03:11:34 +0000 (11:11 +0800)]
MDSAL-292: Binding v1 - Pattern attribute ignored for leaf-list/leaf
- Support pattern constraint for leaf-list/leaf
- support modifier statement for pattern of yang 1.1
- Add test yang
Change-Id: I1a2f2b24a023479dee8ee9de08374386d38ba17a
Signed-off-by: Jie Han <han.jie@zte.com.cn>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Mon, 19 Mar 2018 01:13:58 +0000 (02:13 +0100)]
Cleanup mdsal-binding-java-api-generator tests
We have a lot of copy&pasted code here, trim it down by providing
convenience classes.
Change-Id: Ic1e63569f10b6eb38e058f64bf49bc9d09ca8762
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Wed, 14 Mar 2018 14:12:24 +0000 (15:12 +0100)]
Fix invalid yang models
This patch eliminates bad test models, which use constructs which
are not valid YANG identifiers.
Change-Id: If0fbf08226d64b76def98421eb4d68e781e97b98
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Sat, 17 Mar 2018 09:32:02 +0000 (10:32 +0100)]
Remove unused import in EnumTemplate
This is a follow-up cleanup to remove unused imports.
Change-Id: Ibae8164ae7c1238b0e3aae6cbb0e256dc2713c40
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Jie Han [Wed, 14 Mar 2018 02:09:06 +0000 (10:09 +0800)]
Binding v2 - Use YangTextSnippet for generation
- Ported from:
https://git.opendaylight.org/gerrit/68031
Change-Id: I85a216bc1b44d1275ab8833b3b734361edd14c17
Signed-off-by: Jie Han <han.jie@zte.com.cn>
Robert Varga [Tue, 13 Mar 2018 14:06:42 +0000 (15:06 +0100)]
Fix yang module naming
This fixes a few warnings around normalized model names.
Change-Id: I305d5e54ab60c02beea52c9bacd8e586909d18c7
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Wed, 14 Feb 2018 19:15:43 +0000 (20:15 +0100)]
Use YangTextSnippet for generation
YangTextSnippet provides an efficient and correct replacement for
YangTemplate. This patch switches to using it, improving generated
class comments.
JIRA: MDSAL-301
Change-Id: I2058eec8e91bcba9356fef49a13c66199a479ed2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Sun, 4 Feb 2018 18:48:59 +0000 (19:48 +0100)]
Bump yangtools to 2.0.2
This patch bumps yangtools dependency to 2.0.2.
Change-Id: I3e4740184eda317ba7adfe54649fc4dba668ccc8
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Sat, 10 Mar 2018 08:47:52 +0000 (09:47 +0100)]
Add Enumeration yang-binding interface
All generated enumerations expose two methods. Capture and document
them in an interface and adjust the template accordingly. Also adds
a forName() static factory method, to keep symmetry with forValue().
JIRA: MDSAL-317
Change-Id: Iebddded0a4e1ec3534e87a878a8f571cd45ebbae
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Fri, 9 Mar 2018 15:59:52 +0000 (16:59 +0100)]
Update Java reserved words to JLS9
This updates the mapping table to reflect the fact that "_" is not
a valid identifier in Java 9.
JIRA: MDSAL-318
Change-Id: Ia8f11868e7f244be0018dae38538d7800313af31
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Fri, 9 Mar 2018 15:55:44 +0000 (16:55 +0100)]
Add alternative enum assigned name mapping
This patch corrects enumeration mapping rules so that any unicode
string can be mapped to a valid Java identifier as per JLS8.
This is done by attempting to apply className() mapping to all names
and using that if it results in valid non-conflicting identifiers.
If a conflict is detected, we use a bijective mapping, which encodes
any conflicting characters using an $-based escaping scheme.
JIRA: MDSAL-309
Change-Id: Ic51405e533eff9af6afc2abaa8d0cc193d718e64
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Sat, 3 Mar 2018 23:09:32 +0000 (00:09 +0100)]
Use concepts.Builder in binding-generator-api
We have three unrelated toInstance() methods. Rename them to build()
and extend yangtools.concepts.Builder.
Change-Id: I6a9008a699df1650dbd5c988d4f3f28fe2b965f0
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Sat, 3 Mar 2018 22:47:33 +0000 (23:47 +0100)]
make sure to eliminate any reference to builders
We are picking up indexing information from ModuleContext, but we
also need to make sure to built these types.
Change-Id: I32c18b31885bcd1391412819e66314e5fa48ae3a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Sat, 3 Mar 2018 18:16:22 +0000 (19:16 +0100)]
Change GeneratedTypeBuilderBase.setSchemaPath()
Using an Iterable here is wasteful, as most uses have a SchemaPath
handy. This way the SchemaPath is not forced to instantiate its
path from root unless necessary.
JIRA: MDSAL-315
Change-Id: Ia41c198d19f63e0f99207dc38deef0b096722b54
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Sat, 3 Mar 2018 17:48:14 +0000 (18:48 +0100)]
Refactor EnumerationBuilderImpl
This class is used by both codegen and runtime, which leads to
a bloated BindingRuntimeContext because we are retaining information
we simply do not need at runtime.
This patch renames the class to CodegenEnumerationBuilder and splits
out AbstractEnumerationBuilder. RuntimeEnumerationBuilder is defined
on top of it.
JIRA: MDSAL-315
Change-Id: I2bc3ca26c8bdc489552e6584b9e2f20aa09093b6
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Sat, 3 Mar 2018 17:07:37 +0000 (18:07 +0100)]
Refactor GeneratedTypeBuilderImpl
GeneratedTypeBuilderImpl is used by both runtime and codegen, capturing
data not needed at runtime leading to a bloated RuntimeContext.
Split out RuntimeGeneratedTOBuilder, renaming the original to
CodegenGeneratedTypeBuilder.
JIRA: MDSAL-315
Change-Id: Iaea5f9ae7b260bc5c9ef37cdb1a74aec52457a22
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Sat, 3 Mar 2018 16:36:07 +0000 (17:36 +0100)]
Refactor GeneratedTOBuilderImpl
This builder is used at both runtime and codegen-time and it captures
information irrelevant to runtime, leading to bloat.
Refactor this class into three classes:
- AbstractGeneratedTypeBuilder for common information
- CodegenGeneratedTOBuilder common + codegen information
- RuntimeGeneratedTOBuilder throwing UnsupportedOperationException
for codegen information
JIRA: MDSAL-315
Change-Id: Ie1d3d075590334cb5b8ce41c059ac2e10cf02d56
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Sat, 3 Mar 2018 14:08:17 +0000 (15:08 +0100)]
Do not generate pattern constraints in runtime types
We do not need this information at run-time, so short-circuit
collection so that we always end up seeing an empty expression
map.
JIRA: MDSAL-312
Change-Id: Ia62d20b247fed69e32321ec42f2cfd68d63d9afc
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Fri, 2 Mar 2018 19:55:58 +0000 (20:55 +0100)]
Split up TypeProviderImpl
This class needs to be split up into compile-time and runtime
implementations to eliminate polluting runtime with information
required only for code generators.
Rename the baseline to AbstractTypeProvider and provide two distinct
subclasses, CodegenTypeProvider and RuntimeTypeProvider.
JIRA: MDSAL-312
Change-Id: Ia3a8b0677dee2252820cd9ee6c709e2e896b135f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Fri, 2 Mar 2018 17:09:44 +0000 (18:09 +0100)]
Split out BindingRuntimeGenerator
BindingRuntimeContext does not require all of the information
captured in a normal BindingGenerator run, such as constants, comments
and similar.
The fact that we do not have separation between compile-time and
run-time granularity of this data comes from history of the codebase,
when BindingRuntimeContext did not exist in its current form and we
infered much of the information from the classes lazily.
Introduce BindingRuntimeGenerator interface and refactor
BindingGeneratorImpl to reflect this split. This leads to faster
BindingRuntimeContext creation, as the call to generateTypes()
is no longer needed.
JIRA: MDSAL-312
Change-Id: Ibb1c22d4e4c9ff90e37d6e10e258f632a9c87ef5
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Thu, 1 Mar 2018 15:48:53 +0000 (16:48 +0100)]
Optimize generated toString()
Rather than inlining the equivalent of a ToStringHelper, add utility
methods to CodeHelpers and use ToStringHelper to generate the string.
Change-Id: If8c8d03d90715e87d25262056c2e6db544e091bb
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Wed, 28 Feb 2018 22:05:47 +0000 (23:05 +0100)]
Optimize range/length generators
This patch improves range/length generators so that share common utility
methods from CodeHelper, eliminating common literals in generated code.
It also adds the ability for generators to import classes, leading to much
more readable code.
Change-Id: I98f103e9c05a1d68f0f4bc4c6c33146cb654e5bb
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Jie Han [Tue, 29 Aug 2017 10:55:15 +0000 (18:55 +0800)]
Binding v2 - Map 'type empty' to yangtools.yang.common.Empty
- make generator map Empty to empty leaf and use prefix 'get'
for getter methos.
- fix codec for type Empty and its derived type correspondingly.
Change-Id: Icbc5c729ce4f035323fffc775f4943bc7ce50989
Signed-off-by: Jie Han <han.jie@zte.com.cn>
Robert Varga [Wed, 28 Feb 2018 22:51:02 +0000 (23:51 +0100)]
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>
Michael Vorburger [Thu, 1 Mar 2018 14:57:29 +0000 (15:57 +0100)]
bump xtendbeans 1.3.0 → 1.3.1
for https://github.com/vorburger/xtendbeans/commit/
52e4b617e9e077763c2bbedc5fd6e202ca87a7e8
see also https://lists.opendaylight.org/pipermail/netvirt-dev/2018-March/006421.html
no other changes are included in this release
Change-Id: I44c5d4a58601b99579597fc7e4c496587a354cee
Signed-off-by: Michael Vorburger <vorburger@redhat.com>
Robert Varga [Wed, 7 Mar 2018 13:40:48 +0000 (14:40 +0100)]
Append result entries directly to result
Instead of using Collectors.toList() and addAll(), use a direct
result:add methodhandle.
Change-Id: Ib055d675c125cac3ed957399709434c0b8255703
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Jie Han [Tue, 29 Aug 2017 02:10:31 +0000 (10:10 +0800)]
Bug 8903: Binding v2 - binding-data-codec does not work with boolean type using typedef
- Ported from
Bug 8903 - binding-data-codec does not work with boolean type using typedef
https://git.opendaylight.org/gerrit/62389
Change-Id: I14820662036aa3536ebfd32ea5d6af2c92d0f995
Signed-off-by: Jie Han <han.jie@zte.com.cn>
Jie Han [Tue, 27 Feb 2018 02:27:01 +0000 (10:27 +0800)]
MDSAL-304: Binding V2 maps identities to java.lang.Class
- Make BaseIdentity an interface, change abstract classs
to interface for identifier binding.
Change-Id: I256f650da0e535fbbe2d1671efdc503b7912f86f
Signed-off-by: Jie Han <han.jie@zte.com.cn>
Tom Pantelis [Fri, 2 Mar 2018 03:35:52 +0000 (22:35 -0500)]
Workaround for Findbugs unconfirmed cast
EntityOwnershipChange inherits the getEntity method from
GenericEntityOwnershipChange whose return type is parameterized
to Entity however Findbugs gets confused with
Entity entity = entityOwnershipChange.getEntity();
and flags a violation for "Unchecked/unconfirmed cast" from
GenericEntity to Entity. I believe this is due to erasure of the
actual return type. To alleviate this, override getEntity() in
EntityOwnershipChange with the actual return type Entity.
Change-Id: I5cf8aa7ab4672c9efb0e13244e698ea9595bfbe5
Signed-off-by: Tom Pantelis <tompantelis@gmail.com>
Robert Varga [Tue, 6 Mar 2018 10:27:48 +0000 (11:27 +0100)]
Revert "Add YangModuleInfoTemplate hashCode/equals"
This reverts commit
16f4a3460a35c4def10c9c78f5eede48d3eaf025.
Change-Id: Id4645c94387b301413566e6a70f1a6bdbed65caf
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Jie Han [Tue, 29 Aug 2017 01:50:00 +0000 (09:50 +0800)]
Bug 8903 - binding-data-codec does not work with boolean type using typedef
Change-Id: Ib47bedea0e6bbebf7c5e3dbbd012b0df3e872a4b
Signed-off-by: Jie Han <han.jie@zte.com.cn>
Jie Han [Mon, 5 Feb 2018 06:38:14 +0000 (14:38 +0800)]
Binding V2 generator - fix choice/case
- Make generated type of choice implement Instantiable.
- Pass down the closest ancestor parent type (childOf) through
choice/cases to their children data nodes.
- Fix generate types from augmentd choice/cases as well as
unit tests.
- Cleanup GenHelperUtil a bit.
Change-Id: Id65d1025a173298dd25e70f36f9c8e3723d460c5
Signed-off-by: Jie Han <han.jie@zte.com.cn>
Jie Han [Thu, 1 Mar 2018 07:13:49 +0000 (15:13 +0800)]
Binding v2 - Cleanup AugmentToGentype
- Cleanup deprecated methods, since uses augment would be
processed as inline nodes in binding v2, we do not need
these methods at all.
Change-Id: Ic8b9e27805fa3bd978e4b069edfe88f8ce891e80
Signed-off-by: Jie Han <han.jie@zte.com.cn>
Jie Han [Thu, 1 Mar 2018 06:06:45 +0000 (14:06 +0800)]
Binding v2 - Eliminate suffix for the binding name of schema nodes in grouping
- It's not necessory to append 'Data' or 'Grouping' to the type name
of nodes in grouping, since they're naturally not in the same path.
for the top directory, one is in 'grp' and the other is in 'data'.
- Suffix also can't be used to resolve name collisions.
See details in JIRA:MDSAL-271
Change-Id: I5c5cc4774644e089bedb200b25c6854f0cf077b7
Signed-off-by: Jie Han <han.jie@zte.com.cn>
Jie Han [Thu, 1 Mar 2018 05:53:27 +0000 (13:53 +0800)]
Binding v2 - Optimize acceptable condition for BuilderGenerator
- Since GeneratedTypeForBuilder mark a type which has its builder,
it is nice to use it for judgment.
Change-Id: Ia09f49b7c3cd88f6bfa606a78d6c108f23d306bd
Signed-off-by: Jie Han <han.jie@zte.com.cn>
Robert Varga [Mon, 5 Mar 2018 08:20:06 +0000 (09:20 +0100)]
Add YangModuleInfoTemplate hashCode/equals
If two instances of the same YangModuleInfo get compared, they should
compare as equals.
Change-Id: I0ba756e411b97cb273ed824b53ce9593d9c4824a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Mon, 5 Mar 2018 08:16:03 +0000 (09:16 +0100)]
Fix YangModuleInfoTemplate
YangModuleInfoTemplate has a wrong check for null, where it should
be checking for Optional.present. Fix that.
Change-Id: I95ccfd7a938b173cd0cc8aa6be997a2afe471056
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Thu, 1 Mar 2018 23:23:38 +0000 (00:23 +0100)]
Split out JavaFileTemplate
This is a useful piece with a bit of logic. Separate it out into
Java, where maintenance is easier. This forces us to define operations
on import map, which is always good.
Change-Id: Idf279352c57a96112b235f700ec7e910bf886461
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Thu, 1 Mar 2018 12:12:54 +0000 (13:12 +0100)]
Fix checkstyle in mdsal-binding-test-model
Fix checkstyle and enable enforcement.
Change-Id: I2680c421ed4703170f6ea0dfdd9a7ee662d4776d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Thu, 1 Mar 2018 15:34:15 +0000 (16:34 +0100)]
Speed up javadoc formatting
Initializing a StringBuilder with a string results in it being
sized to contain only that string -- hence forcing a reallocation
on next append.
This patch updates javadoc formatting code to use a default allocation
and append the initial string afterwards -- leaving some room for
further appends.
Change-Id: I910a3c84d37f462d99815f5ea63700cc78dfd2cc
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Thu, 1 Mar 2018 10:15:06 +0000 (11:15 +0100)]
Do not open-code ImmutableMap.copyOf()
This is a remnant of the early days when we did not want to depend
on Guava. Do not generate open-coded map squashing code but rather
use ImmutableMap.copyOf().
Change-Id: I4700b4c17aecbe604ddf62f817481f0067babf7a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Thu, 1 Mar 2018 09:41:31 +0000 (10:41 +0100)]
Fix deprecation warnings in RangeGenerators
Propagate @Deprecated annotation outward, removing most of the warnings.
Change-Id: I4c4da282bfe4fca1b43c00d2826e3161ac288a2e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Jie Han [Tue, 6 Feb 2018 10:30:59 +0000 (18:30 +0800)]
MDSAL-253: Binding v2 - BindingToNormalizedNodeCodec fails to deserialize union of leafrefs
- Ported from Binding v1:
https://git.opendaylight.org/gerrit/#/c/60698/
Change-Id: I82e9c71a662c228e77668e70c648d048a18922e6
Signed-off-by: Jie Han <han.jie@zte.com.cn>
Robert Varga [Wed, 28 Feb 2018 15:03:09 +0000 (16:03 +0100)]
Invert enforcement patterns when needed
RFC7950 and yang-model-api defines pattern modifier invert-match,
which needs to be taken into account when validating incoming strings.
Mutate the pattern we expose to the codegen such that it captures
the inversion operation. This code is closely related to generated
code and string formats used therein, hence the beef of the
implementation lives in BindingMapping.
JIRA: MDSAL-314
Change-Id: Ie29745d3343f565ac6b1b5716b1ec38dd0f09bc9
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Wed, 28 Feb 2018 12:32:55 +0000 (13:32 +0100)]
Fix a patterns reference
We should be referencing the constant name rather than hard-coding
it in the template.
Change-Id: Ib552b37cdfb4e3f8cef794d764ba8558f6db3df6
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Wed, 28 Feb 2018 15:52:33 +0000 (16:52 +0100)]
Use org.apache.commons.text.StringEscapeUtils
StringEscapeUtils have moved from commons-lang to commons-text,
use them from their new location.
Change-Id: I256e64de78de253592e2cd22cc17b2f66d2d95e5
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Mon, 26 Feb 2018 00:04:00 +0000 (01:04 +0100)]
Eliminate twirl execution from mdsal-binding2-generator-impl
We do not have any templates left, speed up compilation by eliminating
unneeded plugin invocations. Also fixe project import in default Eclipse.
Change-Id: I3416f2cd5ed50e4a914817a205a5ca56a85091da
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Tue, 27 Feb 2018 23:56:28 +0000 (00:56 +0100)]
Silence code generator a bit
We do not need an explicit INFO whenever a service is generated.
Lower the level at which this information is logged to debug.
Change-Id: Ifab29e0cec7519135e1d96adc486134d3204c329
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Wed, 21 Feb 2018 14:49:18 +0000 (15:49 +0100)]
Squash regular expression constants
A heap dump analysis has shown we are retaining default-sized
sparse ArrayLists in ConstantImpl. Make sure we squash them to
a properly-sized ImmutableList.
Change-Id: I0b83440af46bcaad334d55506c2f08e36d9a7727
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Anil Belur [Mon, 26 Feb 2018 07:41:44 +0000 (17:41 +1000)]
Bump versions by x.(y+1).z for next dev cycle
Change-Id: Ib4799fb36fc0de8b41418ccc547eaa3c061c7396
Signed-off-by: Anil Belur <abelur@linuxfoundation.org>
Jie Han [Sat, 24 Feb 2018 07:33:31 +0000 (15:33 +0800)]
MDSAL-301: Binding v2 - Rework javadoc generation
- ported from:
https://git.opendaylight.org/gerrit/68191
https://git.opendaylight.org/gerrit/68254
- Move javadoc generation from mdsal-binding2-generator-impl
to mdsal-binding2-java-api-generator
Change-Id: Ia9a23af5528f7511908d13a0570e8900daeb60a1
Signed-off-by: Jie Han <han.jie@zte.com.cn>
Robert Varga [Fri, 23 Feb 2018 15:43:04 +0000 (16:43 +0100)]
Eliminate XtendHelper and SchemaLock
These classes are not used anywhere, eliminate them.
Change-Id: If3e726219b8a5e62a2138a3d98bc1ebd7d86a405
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Jie Han [Mon, 28 Aug 2017 06:59:50 +0000 (14:59 +0800)]
Binding codec v2 - fix anyxml #3
- Add AnyxmlNodeCodecContext
Change-Id: I76d3cec49cbd98747f666719908be304057bf364
Signed-off-by: Jie Han <han.jie@zte.com.cn>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Jie Han [Mon, 28 Aug 2017 06:46:01 +0000 (14:46 +0800)]
Binding codec v2 - fix anyxml #2
- Add AnyxmlCodec to serialize/deserialize between
Document and DOMSource.
Change-Id: Idf3c6be4fa1e88874aa331b170301fa65ce10e1c
Signed-off-by: Jie Han <han.jie@zte.com.cn>
Jie Han [Mon, 28 Aug 2017 06:34:40 +0000 (14:34 +0800)]
Binding codec v2 - fix anyxml #1
- Support Anyxml node codec
Change-Id: Ic2ff67cf1be56f4e560b929cc695c329268d1d4e
Signed-off-by: Jie Han <han.jie@zte.com.cn>
Jie Han [Thu, 24 Aug 2017 07:25:26 +0000 (15:25 +0800)]
Binding codec v2 - fix notification implements Instantiable
- Call implementedInterface to get class to
get serializer.
Change-Id: I53c7422b0d15167452e9e30a3d3a43557831389a
Signed-off-by: Jie Han <han.jie@zte.com.cn>
Jie Han [Wed, 11 Oct 2017 06:49:05 +0000 (14:49 +0800)]
Binding codec v2 - fix augmentation #7
- add yangs and tests
- add comment
Change-Id: I7bf32c49a68cd7724da4a0cf355a755178f119c1
Signed-off-by: Jie Han <han.jie@zte.com.cn>
Jie Han [Wed, 11 Oct 2017 06:41:10 +0000 (14:41 +0800)]
Binding codec v2 - fix augmentation #6
- Add AbstractStreamWriterGenerator to support multiple
augmentation schemas with the same target path for
one generated type.
Change-Id: Iac5ec67adb6f77da2e181c59c4e6cecb0239fb9d
Signed-off-by: Jie Han <han.jie@zte.com.cn>
Robert Varga [Mon, 29 Jan 2018 17:49:44 +0000 (18:49 +0100)]
Switch to java.util.function.Supplier
This is an internal interface, we can safely switch it to
Java 8 interface rather than the Guava one.
Change-Id: Ie199bb690e80958c859036708ce1945e3ed313f6
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Wed, 14 Feb 2018 13:06:02 +0000 (14:06 +0100)]
Re-organize YANG snippet generation and comment confusion
This is a follow-up cleanup on the previous patch, which has created
an unnecessary interface and tunneling contract. We instead record
the details of why a class was generated, capturing comments correctly
in GeneratedType.comment. mdsal-binding-java-api-generator is then
taught to use this information correctly and generate the YANG snippet
as it sees fit.
Change-Id: I25580c6310d05007fea63e04d70cd12d5c6f9ace
JIRA: MDSAL-301
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Tue, 13 Feb 2018 13:02:44 +0000 (14:02 +0100)]
Eliminate xtend from mdsal-binding-generator-impl
This patch moves YangTextTemplate into mdsal-binding-java-api-generator
and bridges it into BindingGeneratorImpl, without it having to be lug
all the extent stuff around. This slims down the runtime classes by
143kB.
JIRA: MDSAL-301
Change-Id: Ibdafa574c5a825aa7a02b9ecef5352fff78ae035
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Sun, 4 Feb 2018 18:46:17 +0000 (19:46 +0100)]
Cleanup properties
Properties should not be used for versions, clean them up in parent
poms. Everything the users need is communicated via
dependency/pluginManagement.
Also ditches down-revisioned maven-depends-plugin, as that is already
provided by odlparent and removes unneeded site plugin configuration.
Change-Id: I54b507342c995c5e3589171c42e708829acc908b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Tue, 13 Feb 2018 12:19:10 +0000 (13:19 +0100)]
Fix odl-mdsal-dom-broker
It should depend on odl-yangtools-data so it does not package
yang-data-impl.
Change-Id: Ia8d852c24b6fa6e929d84265f8bd1309116f35df
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Jie Han [Wed, 11 Oct 2017 06:35:24 +0000 (14:35 +0800)]
Binding codec v2 - fix augmentation #5
- Since all augmentation with the same target would be
taken into one generated type, the map of type and schema
would not correct at all, just to delete it.
Change-Id: I705383ca58a9ba1e64c77dffdd4470b60d4aca73
Signed-off-by: Jie Han <han.jie@zte.com.cn>
Jie Han [Thu, 24 Aug 2017 10:11:47 +0000 (18:11 +0800)]
Binding codec v2 - fix augmentation #4
- Since uses nodes were processed as-if they were direct
children of parent node, so just to find target node
(added by uses) not its original node which would result
in wrong augmentation type.
Change-Id: I8d74e368e44075eb6e273119c07578ff16a4f1dc
Signed-off-by: Jie Han <han.jie@zte.com.cn>
Jie Han [Wed, 23 Aug 2017 09:19:50 +0000 (17:19 +0800)]
Binding codec v2 - fix augmentation #3
- Since multiple augments with same target were grouped as like
just one augment, all child nodes of them were resolved as methods
to the generated type, so in runtime, it should also find all these
child nodes to add to the new EffectiveAugmentSchema object as
real childs.
Change-Id: I433930be45007e545b2e2fb074af32e118aa7cd4
Signed-off-by: Jie Han <han.jie@zte.com.cn>
Jie Han [Wed, 7 Feb 2018 08:55:16 +0000 (16:55 +0800)]
MDSAL-218: Binding v2 - *Builder classes for 'type union' YANG gen. code should have private constructor
- Do not affect old generated class, one should mannually rebuild to update.
Change-Id: I7682fc19e29e659589b71695403c83094b138e48
Signed-off-by: Jie Han <han.jie@zte.com.cn>
Jie Han [Wed, 7 Feb 2018 08:50:57 +0000 (16:50 +0800)]
MDSAL-218: Binding v1 - *Builder classes for 'type union' YANG gen. code should have private constructor
- Do not affect old generated class, one should mannually rebuild to update.
Change-Id: Ib45f7aca1aa261b2c4bce433b139cd94b91a5066
Signed-off-by: Jie Han <han.jie@zte.com.cn>
Jaime Caamaño Ruiz [Fri, 9 Feb 2018 19:41:25 +0000 (20:41 +0100)]
Delay snapshot backed transaction ready error
Delay snapshot backed transaction ready error to 3PC canCommit.
Change-Id: Ie4004db194483dfa1528258b464df8a2f8fa573e
JIRA: CONTROLLER-1812
Signed-off-by: Jaime Caamaño Ruiz <jcaamano@suse.com>
Jaime Caamaño Ruiz [Fri, 9 Feb 2018 09:47:26 +0000 (10:47 +0100)]
Fix infinite loop on cancel transaction
This patch fixes a problem where you would run into an infinite loop
after cancelling DOMForwardedWriteTransaction following an exception
thrown by the backed transaction ready or submit methods.
Change-Id: I14bcca6727ab2f173d481b84742c4edbf7bf9dd8
JIRA: CONTROLLER-1812
Signed-off-by: Jaime Caamaño Ruiz <jcaamano@suse.com>
Robert Varga [Wed, 7 Feb 2018 15:50:05 +0000 (16:50 +0100)]
Speed up whitespace replacement
Rather than compiling a pattern, pre-compile it once and keep it
around.
Change-Id: Ibb1879d2546f731daa25e536ef45f48bde671f4f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Mon, 5 Feb 2018 01:15:48 +0000 (02:15 +0100)]
Fix a few warnings
- unneeded imports
- potentially static methods
- unneeded @SupressWarnings
Change-Id: I0c80e0a7e917ec9b71147e582df4b6f4c7a698a2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Tue, 30 Jan 2018 18:14:12 +0000 (19:14 +0100)]
MDSAL-269: fix missing identityref union members
Due to a API consistency issue in binding specification typedefs
which point to leafref and identityref types do not get a generated
encapsulation class.
BUG-8449/MDSAL-253 has dealt with the leafref case, but has omitted
identityref case. This patch corrects the situation, providing a bit
of background and a testcase.
Change-Id: Ib4247e0690c2aaa89aef51b3986bf848ce6b8192
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>