yangtools.git
3 months agoOptimize BindingNormalizedNodeCodecRegistry representation checks
Robert Varga [Fri, 16 Aug 2019 13:40:24 +0000 (15:40 +0200)]
Optimize BindingNormalizedNodeCodecRegistry representation checks

isBindingRepresentable() is a hot method, which performs a few
type checks. This patch folds those checks into a single return,
inverting the logic (which is negated anyway at the sole caller).
This cuts the amount of byte code to half, thus aiding inlining.

Futhermore we take advantage of ValueNode covering two cases we
explicitly test for, reducing the number of checks performed.

Finally we reorder the checks to improve their efficiency by
tackling most-common constructs first.

Change-Id: I556d1098a9d7dd043b2f8d756c2388f339f6b8ec
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoOptimize IdentifiableItemCodec a bit
Robert Varga [Mon, 26 Aug 2019 08:47:59 +0000 (10:47 +0200)]
Optimize IdentifiableItemCodec a bit

Do not force instantiation of the backing map, as for single-item
NodeIdentifierWithPredicates it is just wasteful.

Change-Id: I0cc13d0afe2f3329f4757e9da414500de132acf6
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoTake advantage of singleton NodeIdentifierWithPredicates
Robert Varga [Tue, 27 Aug 2019 11:09:43 +0000 (13:09 +0200)]
Take advantage of singleton NodeIdentifierWithPredicates

NodeIdentifierWithPredicates now includes an efficient single-entry
implementation, which is rendering instantiation through
SharedSingletonMap superfluous. Take advantage of this new
constructor.

Change-Id: I9c724ceeef829ac5dc0cfded38410ab417ed4d47
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoRemove BindingCodec and BindingSerializer
Robert Varga [Mon, 26 Aug 2019 09:38:38 +0000 (11:38 +0200)]
Remove BindingCodec and BindingSerializer

These interfaces are not used anywhere, remove them.

Change-Id: I7b302cd4f0e397cbe99f2fc1b3d85103ccd47739
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoMass-migrate binding-dom-codec to IllegalArgumentCodec
Robert Varga [Mon, 26 Aug 2019 08:51:52 +0000 (10:51 +0200)]
Mass-migrate binding-dom-codec to IllegalArgumentCodec

This new interface most closely resembles the old intent behind
concepts.Codec, except it does not quite match nullness guaratees.

JIRA: YANGTOOLS-1017
Change-Id: I7675743ac29834ffa4b15fa70b62d1a3dad2d18b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoMake IdentifiableItemCodec an IllegalArgumentCodec
Robert Varga [Mon, 26 Aug 2019 08:43:25 +0000 (10:43 +0200)]
Make IdentifiableItemCodec an IllegalArgumentCodec

The interface contract matches the expectations, hence we can
cleanly apply the pattern.

JIRA: YANGTOOLS-1017
Change-Id: I7b0efcfa0981646071c3715daa691559f923c285
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoMake IdentityCodec an AbstractIllegalArgumentCodec
Robert Varga [Mon, 26 Aug 2019 08:30:35 +0000 (10:30 +0200)]
Make IdentityCodec an AbstractIllegalArgumentCodec

The behaviour is pretty much the same, except for throwing IAE
on nulls -- this is made consistent to throw a NPE.

JIRA: YANGTOOLS-1017
Change-Id: I23fea88b2c32336400ab1120949507c7442d8076
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoMove Binding codec interfaces
Robert Varga [Mon, 26 Aug 2019 07:14:49 +0000 (09:14 +0200)]
Move Binding codec interfaces

This moves codec interfaces from yang-binding to binding-dom-codec,
as they are an implementation detail and should never have been
exposed here.

Change-Id: I90a24527d60398ea428eff12f4359501865d3b36
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoGuard generator lookup against nulls
Robert Varga [Sat, 24 Aug 2019 08:46:16 +0000 (10:46 +0200)]
Guard generator lookup against nulls

If we encounter an unsupported type we can end up throwing a NPE
without any details. This hardens the lookup to verify we have
a hit, and report the type if we have a miss.

Change-Id: I89cb988d8705772065d12b4074775ad9bc538499
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoRemove unneeded checkstyle/spotbugs declarations
Robert Varga [Thu, 22 Aug 2019 11:05:03 +0000 (13:05 +0200)]
Remove unneeded checkstyle/spotbugs declarations

odlparent is forcing enforcement of both, there is no point
in us repeating the declarations.

Change-Id: I0896e446ab587cb9d5b5b746bae030d58497cf71
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoDisable SpotBugs on select artifacts
Robert Varga [Thu, 22 Aug 2019 11:13:15 +0000 (13:13 +0200)]
Disable SpotBugs on select artifacts

This marks specific artifacts to disable SpotBugs, as these are now
enforced by default.

Change-Id: I2e76979bddaec7c6db9f9460493f2c9f42d8e34f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoRemove the ability to return mutable lists
Robert Varga [Wed, 29 May 2019 12:07:21 +0000 (14:07 +0200)]
Remove the ability to return mutable lists

This patch removes the legacy opt-in to return mutable lists instead
of immutable ones.

JIRA: MDSAL-446
Change-Id: I73c09e036f8c3f92d27e6706ef4133da2c4232a2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoMake wrapped class equals() final
Robert Varga [Mon, 19 Aug 2019 14:21:51 +0000 (16:21 +0200)]
Make wrapped class equals() final

This forbids overriding equals() for wrapper classes, meaning
the first class in hierarchy defines the proper equality
contract, which cannot be overridden.

This means that all objects within that hierarchy are considered
equal if they have the same representation (i.e. fields).

JIRA: MDSAL-440
Change-Id: I0c90ad9553071be8a8fc1109b663fe631b5599b9
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoBump to yangtools-4.0.0-SNAPSHOT
Robert Varga [Mon, 5 Aug 2019 09:04:46 +0000 (11:04 +0200)]
Bump to yangtools-4.0.0-SNAPSHOT

For some of the integration work we'll need a preview of yangtools,
switch to using their snapshots.

Change-Id: I46914e83b96d47353f1512b63e42b51383600e02
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoBump to odlparent-6.0.0-SNAPSHOT
Robert Varga [Mon, 5 Aug 2019 09:01:48 +0000 (11:01 +0200)]
Bump to odlparent-6.0.0-SNAPSHOT

We will need settings from upstream to enable JDK11-specific work,
use odlparent snapshots for now.

Change-Id: If8f9d1118f0441a6b9df89745f2eef8d14c5e78c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoSwitch mutable lists into an opt-in
Robert Varga [Wed, 29 May 2019 12:04:25 +0000 (14:04 +0200)]
Switch mutable lists into an opt-in

This changes the default handling of lists the codec uses, when

org.opendaylight.mdsal.binding.dom.codec.impl.compat-mutable-lists

property is not set. The default is now to use immutable lists
unless the property is explicitly set to "true".

JIRA: MDSAL-446
Change-Id: Ie996be8098b44d109ede9fe78511ad9746cc8e78
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoDo not emit empty lists to NormalizedNodes
Robert Varga [Tue, 18 Jun 2019 19:26:20 +0000 (21:26 +0200)]
Do not emit empty lists to NormalizedNodes

This patch changes the representation of empty Binding lists in
DOM world. Empty lists are equivalent to being non-present, hence
they are not emitted.

This mirrors the getFoo()/nonnullFoo() accessor duality, i.e. empty
lists can be instantiated on-demand as placeholders for nulls.

In DOM world, list nodes are virtual containers, which do not hold
any semantics and are created on demand -- hence it does not make
sense to pass them down to DOM.

This does not create data tree operation changes, as lists are not
directly addressable, hence their WRITE/MERGE semantics are shared
by their parent. Empty merges have not semantic value, as empty
lists disappear on touch. Empty writes end up correctly observing
lifecycle -- empty lists end up disappearing, just as they would
be expected if they have undergone a lifecycle event (such as an
empty merge).

JIRA: MDSAL-456
Change-Id: I78efc4aa4c3b4100ff52490fefe94e2f65f43efc
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoRestructure LengthGenerator.createExpressions()
Robert Varga [Thu, 15 Aug 2019 11:36:49 +0000 (13:36 +0200)]
Restructure LengthGenerator.createExpressions()

SpotBugs is warning about INT_VACUOUS_COMPARISON at the head
of the 'min <= Integer.MAX_VALUE' comparison. This restructures
the logic to eliminate this check.

Change-Id: Ie465bb16443d9912a12a8b2f712851a24d339d78
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoAlign CodecDataObject augmentations toString()
Robert Varga [Wed, 19 Jun 2019 14:18:49 +0000 (16:18 +0200)]
Align CodecDataObject augmentations toString()

Compile-time generated codecs are using only values() from
augmentation in their toString() method. Make sure
AugmentableCodecDataObjects are following the same pattern.

Change-Id: I876dd3f2e8b6e42685198c9e1d4304592da87334
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoDo not include byte-buddy META-INF in shade
Robert Varga [Thu, 15 Aug 2019 12:23:33 +0000 (14:23 +0200)]
Do not include byte-buddy META-INF in shade

We do not want to leak module-info.class from byte-buddy, hence
filter all of its META-INF, as it does not provide anything of
value.

Change-Id: Ie74968147f281f58c5692affcfe6e087d7b3650f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoEliminate 'txt' temporary
Robert Varga [Thu, 15 Aug 2019 11:29:15 +0000 (13:29 +0200)]
Eliminate 'txt' temporary

This variable is not really needed and the way it is used SpotBugs
reports a (valid) dead local store. Eliminate the variable completely.

Change-Id: I4fec53be80a54bedfc7481063bf507c9f10990a8
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoFix use of StringTokenizer methods
Robert Varga [Thu, 15 Aug 2019 11:21:56 +0000 (13:21 +0200)]
Fix use of StringTokenizer methods

Rather than using Enumeration-related methods (*Element()), use
the methods provided by StringTokenizer (*Token()), which have
the same functionality, but are not down-casted to Object.

Change-Id: I5c0c258db8e70cafef058d628c20bf9cbeb26cb0
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoMake AlphabeticallyTypeMemberComparator Serializable
Robert Varga [Thu, 15 Aug 2019 11:07:20 +0000 (13:07 +0200)]
Make AlphabeticallyTypeMemberComparator Serializable

Comparators are recommended to be serializable, this fulfills
the need.

Change-Id: Id038ff9fb96c54ecee7cef22b881396d8302590f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoFix SpotBugs complaing around locale
Robert Varga [Thu, 15 Aug 2019 11:05:50 +0000 (13:05 +0200)]
Fix SpotBugs complaing around locale

We are using english locale, which should work across the platform.

Change-Id: I552d4212d976c5034b76fb27bce887014b5edb9e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoFix InterfaceTemplate documentation
Robert Varga [Thu, 15 Aug 2019 11:04:26 +0000 (13:04 +0200)]
Fix InterfaceTemplate documentation

InterfaceTemplate will fail to instantiate with a NPE if a null
type is ever passed in. Fix documentation and remove dead code.

Change-Id: Ief395cbf0d4d417e8041de39feee1e50d09157e0
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoBindingReflections.getQName() should return nonnull
Robert Varga [Fri, 26 Jul 2019 13:28:38 +0000 (15:28 +0200)]
BindingReflections.getQName() should return nonnull

It is a hard error if we cannot find the QName corresponding to
an BaseIdentity subclass. Fix getQName() to guarantee a non-null
return, throwing ISE if we should ever not find the QName.

Change-Id: I551499a8daec87e74669ba93177ad0e795367eae
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoOptimize whitespace replacement
Robert Varga [Tue, 6 Aug 2019 15:27:33 +0000 (17:27 +0200)]
Optimize whitespace replacement

Rather than doing two replacements, use a single two-character
matcher and a single replacement pass. While we're in the area,
also create a SPACE constant and use it where we mean ' ' as a
char (not a string).

Change-Id: I30d7c16074fe172a834ecf1bb0fe30a18fdc6bac
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoDo not lose newlines/tabs from javadoc
Robert Varga [Tue, 6 Aug 2019 14:24:44 +0000 (16:24 +0200)]
Do not lose newlines/tabs from javadoc

When we are formatting javadoc for a accessor method, we must treat
any newlines/tabs as whitespace and not lose them, otherwise we would
end up with concatenated words.

JIRA: MDSAL-416
Change-Id: I3c0fc296692a141d6787a5cba8b17738a108274e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoUse bulk-close for internal registrations
Robert Varga [Wed, 14 Aug 2019 14:49:59 +0000 (16:49 +0200)]
Use bulk-close for internal registrations

Rather than using wrapped registrations through the public API,
we really want to first remove all modules and then update the
context (if needed).

JIRA: MDSAL-466
Change-Id: Ib281fff7264b3dd11b222095f8286087cb488002
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoDisable updates when we are stopping
Robert Varga [Tue, 6 Aug 2019 17:48:05 +0000 (19:48 +0200)]
Disable updates when we are stopping

We should not be propagating bundle updates when we know we are
stopping. This patch marks that knowledge in the tracker.

JIRA: MDSAL-466
Change-Id: Ie4e8b96907a8909150b4080000888d1d10ce8e54
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoFix checkstyle in javadocs
Robert Varga [Tue, 6 Aug 2019 11:29:45 +0000 (13:29 +0200)]
Fix checkstyle in javadocs

Updated checkstyle is catching more violations, fix them up.

Change-Id: I1048fea86966113184fe49fe707d6d0d328c3508
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoReduce use of java.lang constructors
Robert Varga [Tue, 6 Aug 2019 12:12:19 +0000 (14:12 +0200)]
Reduce use of java.lang constructors

Long/Integer constructors have been deprecated, reduce their use.

Change-Id: I2ce4e63904694d3fe442622b85d831253b4a87fb
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoFixup cast in BindingReflections
Robert Varga [Tue, 6 Aug 2019 11:37:54 +0000 (13:37 +0200)]
Fixup cast in BindingReflections

Use an explicit typed Class instead of raw class.

Change-Id: I613d81fc3162ee3bea4955aa2afacf728e2cfab6
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoRemove javassist-based code
Robert Varga [Thu, 1 Aug 2019 12:52:09 +0000 (14:52 +0200)]
Remove javassist-based code

This removes deprecated use of javassist.

Change-Id: Ia5686ce24052222cadb7465e66916b0db5b05ff3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoBump versions for mdsal-5.0.0
Robert Varga [Thu, 1 Aug 2019 12:34:39 +0000 (14:34 +0200)]
Bump versions for mdsal-5.0.0

This starts the next major version development.

Change-Id: I5b0de45da268a68d89eb2973b276a0a2d43dfbdc
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoBump versions to 4.0.4-SNAPSHOT
Robert Varga [Mon, 29 Jul 2019 11:12:07 +0000 (13:12 +0200)]
Bump versions to 4.0.4-SNAPSHOT

This starts the next development iteration.

Change-Id: I168f77460463cc5a50521f60bdf79a1e802c0f4a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoBump yangtools to 3.0.4
Robert Varga [Mon, 29 Jul 2019 11:11:34 +0000 (13:11 +0200)]
Bump yangtools to 3.0.4

We have validated yangtools-3.0.4, bump to the release version.

Change-Id: Ib56bb6b87e8fd8609d86b310a74fde7f491449c3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoExpose IdentityCodec from BindingCodecTree
Robert Varga [Thu, 25 Jul 2019 19:37:14 +0000 (21:37 +0200)]
Expose IdentityCodec from BindingCodecTree

Transcoding identities is needed to make sense of yangtools
identifiers (such as DatastoreIdentifier) versus binding classes.

Expose this functionality as BindingIdentityCodec from
BindingCodecTree and make use of it.

JIRA: MDSAL-460
Change-Id: I8b4110dd711eb18a2586fd1bd036d09fab13871a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoAdd yanglib-rfc8525
Robert Varga [Thu, 25 Jul 2019 14:04:28 +0000 (16:04 +0200)]
Add yanglib-rfc8525

This adds the necessary support for constructing mount points
described through RFC8525 (NMDA) YANG Library.

JIRA: MDSAL-463
Change-Id: I22b4449f544e3d0225bac59fa3928ecb434f8f13
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoBump yangtools to 3.0.4-SNAPSHOT
Robert Varga [Thu, 25 Jul 2019 10:11:27 +0000 (12:11 +0200)]
Bump yangtools to 3.0.4-SNAPSHOT

This adopts yangtools-3.0.4 for the improvements made to rfc8528
support infrastructure.

Change-Id: Ic51134f1abdf8120a9071b4aeff7a054c707d941
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoRemove trailing semicolons
Robert Varga [Mon, 22 Jul 2019 13:21:48 +0000 (15:21 +0200)]
Remove trailing semicolons

These are throwing off sonar, remove them to keep it happy

Change-Id: I2cd19e34825916721512f956bcfc678953ebfb6f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoBump yangtools to 3.0.3
Robert Varga [Fri, 21 Jun 2019 05:16:48 +0000 (07:16 +0200)]
Bump yangtools to 3.0.3

This picks up the latest yangtools release.

Change-Id: I5baeb81e3d947ba30f887ffd17ea437ec5f51fd3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoBump byte-buddy to 1.9.14
Robert Varga [Mon, 8 Jul 2019 19:04:06 +0000 (21:04 +0200)]
Bump byte-buddy to 1.9.14

https://github.com/raphw/byte-buddy/releases/tag/byte-buddy-1.9.13
https://github.com/raphw/byte-buddy/releases/tag/byte-buddy-1.9.14

Change-Id: Ibef83b93b914945f48902ad54df822a656d41df2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoRemove use of getKeyValues()
Robert Varga [Mon, 24 Jun 2019 10:32:26 +0000 (12:32 +0200)]
Remove use of getKeyValues()

This adjusts callers of deprecated method, fixing warnings and
allowing better integration in future.

Change-Id: I6f5bb82af22cfa94e7c532f596c813058b3511d4
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoModuleInfoBackedContext cache
Robert Varga [Mon, 24 Jun 2019 09:21:26 +0000 (11:21 +0200)]
ModuleInfoBackedContext cache

ModuleInfoBackedContext can be effectively cached based on
the set of class loading strategy and infos that go into it. This
patch adds such a cache.

JIRA: MDSAL-418
Change-Id: Icbb7ac5270c76c374a6e839010090a002b0ab176
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoMigrate ModuleInfo cache to BindingReflections
Robert Varga [Sun, 23 Jun 2019 21:54:34 +0000 (23:54 +0200)]
Migrate ModuleInfo cache to BindingReflections

Reflections are using a cache already, so adding another one does
not really hurt. This allows code reuse between our test suite
and downstreams.

JIRA: MDSAL-418
Change-Id: Id4474a0754f33b880afaff333279969f947df494
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoFlatten submodule hierarchy for YangModuleInfo
Anna Bencurova [Mon, 10 Jun 2019 12:55:49 +0000 (14:55 +0200)]
Flatten submodule hierarchy for YangModuleInfo

YANG inherently contains modules and submodules, where submodules
do not really have further submodules. While YANG 1.0 allowed
inclusion of submodules in other submodules, and that is modeled
in yang-model-api, this practice has been deprecated with YANG 1.1.

If we are faced with multiple such includes, for example both
module and submodule including a second submodule, we could end up
generating superfluous classes, just to represent the second
submodule twice (once for module's purposes and once for submodule's
purposes) -- hence when all of them are collected recursively, we
would end up with two distinct instances for the same source.

Since submodules are not directly visible outside of the main class,
this hierarchy is not public API and is a purely internal thing.

This patch re-organizes generation so that we present all submodules
as dependencies of the main module, which automatically solves the
problem, while also making for nicer class layout, as we do not get
multiply-nested classes.

JIRA: MDSAL-457
Change-Id: Ic78edaf852f3497f3c4c96fdca3a77de30b7f8c1
Signed-off-by: Anna Bencurova <Anna.Bencurova@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoFix superfluous warning
Robert Varga [Tue, 18 Jun 2019 20:07:54 +0000 (22:07 +0200)]
Fix superfluous warning

We can end up warning about choices which are not cached, just
because we have a miss. Fix this up so that we properly handle
rejected caching.

Change-Id: I90589e50a749c65226a1e174409e9fd744d7bc30
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoBump yangtools to 3.0.2
Robert Varga [Wed, 12 Jun 2019 00:44:37 +0000 (02:44 +0200)]
Bump yangtools to 3.0.2

The release brings a number of improvements, bring it in.

Change-Id: I1bbbb09cea86f1d73119ae3948dba4f9e362a485
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoBump versions to 4.0.3-SNAPSHOT
Robert Varga [Fri, 31 May 2019 14:06:54 +0000 (16:06 +0200)]
Bump versions to 4.0.3-SNAPSHOT

This starts the next development iteration.

Change-Id: I8220119b4898fbc8c6a49d13eac79f4080c729e4
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoDo not use NodeIdentifierWithPredicates constructors
Robert Varga [Fri, 31 May 2019 10:02:14 +0000 (12:02 +0200)]
Do not use NodeIdentifierWithPredicates constructors

This migrates all callers to use the static factory methods.

Change-Id: I36f983fb14c9ee61ddcfc152b7f9e106b9178624
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoBump yangtools to 3.0.1
Robert Varga [Fri, 31 May 2019 08:18:36 +0000 (10:18 +0200)]
Bump yangtools to 3.0.1

Pull in the release yangtools version.

Change-Id: I00061f0f724472606489061a72dab61bcd0ad531
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoAllow using ImmutableLists when returning binding objects
Robert Varga [Thu, 2 May 2019 19:48:03 +0000 (21:48 +0200)]
Allow using ImmutableLists when returning binding objects

The general contract of MD-SAL is that we do not leak mutable
collections, as that leads to concurrency issues and provides
an avenue for inconsistencies leaking in.

Unfortunately we have had three offenders, which were using
plain ArrayLists to represent data -- and thus could be used
to subvert our efforts.

This patch adds the ability to use proper ImmutableLists, so that
the data they produce is truly immutable. This also helps footprint
of single-value lists, as those are squashed to a more efficient
implementation.

The default remains the use of mutable lists, but the immutable
versions can be activated through setting system property

org.opendaylight.mdsal.binding.dom.codec.impl.compat-mutable-lists

The property acts as an opt-out, i.e. it is in effect unless it is
specifically set to "false"

JIRA: MDSAL-446
Change-Id: I9d7ebab827314b66539534f8d8200a64ee9b4aff
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoAdd binding support for anydata nodes
Robert Varga [Fri, 24 May 2019 15:42:43 +0000 (17:42 +0200)]
Add binding support for anydata nodes

These nodes are following essentially the same blueprint as
anyxml nodes. Unlike anyxml nodes, we need specific implementation
support to allow streaming the nodes.

JIRA: MDSAL-438
Change-Id: I7ff081c58a9e5198762c67cbb908beec0bae144b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoBump yangtools to 3.0.1-SNAPSHOT
Robert Varga [Mon, 27 May 2019 19:04:05 +0000 (21:04 +0200)]
Bump yangtools to 3.0.1-SNAPSHOT

Preliminary bump of yangtools to 3.0.1, allowing us to take
advatage of incoming interfaces.

Change-Id: Ia3b16e1fd57bffc665c1527eb9153fd2cb87f042
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoFix two typos
Robert Varga [Sat, 11 May 2019 10:00:43 +0000 (12:00 +0200)]
Fix two typos

A simple comment typo and a mistakenly-private constructor.

Change-Id: Iea4d40c23c0a1141c90c7bdbc2ab70cafed689af
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoTake advantage of AbstractAugmentable
Robert Varga [Wed, 1 May 2019 14:34:35 +0000 (16:34 +0200)]
Take advantage of AbstractAugmentable

Rather than hand-rolling Augmentable implementations, take advantage
of AbstractAugmentable as the holder of augmentations -- reducing
the amount of generated code.

Since this leads to generated code not being exposed to augmentation(),
we can now rename the generic argument there to a full-compliant
name.

JIRA: MDSAL-445
Change-Id: I2459489074e9e50e82bd9d1c8eb051f9833b7a0b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoBump version for 4.0.2-SNAPSHOT
Robert Varga [Fri, 10 May 2019 05:12:33 +0000 (07:12 +0200)]
Bump version for 4.0.2-SNAPSHOT

This starts the next development cycle.

Change-Id: If2604811deaf39ce6258d278299b1b1804f39dc8
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoDo not compare NormalizedNodes in CodecDataObject
Robert Varga [Tue, 7 May 2019 08:58:24 +0000 (10:58 +0200)]
Do not compare NormalizedNodes in CodecDataObject

Binding DTOs can be shared across instantiations -- for example
groupings. If we are comparing different instantiations, they
can have different namespaces and thus NormalizedNodes do not
compare as equal -- but Binding considers them equal.

JIRA: MDSAL-442
Change-Id: I9838692a046045b3a7e520bd363bfe54b94a6e66
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoMove common bridging code
Robert Varga [Sun, 5 May 2019 17:52:19 +0000 (19:52 +0200)]
Move common bridging code

Since we'll want to be bridging from multiple class generators,
move the common bridging code into a common interface.

JIRA: MDSAL-443
Change-Id: I1aa7d70ae302d737bb960c06629da5ffe0123fc0
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoHide CodecDataObjectGenerator subclasses
Robert Varga [Sun, 5 May 2019 17:31:33 +0000 (19:31 +0200)]
Hide CodecDataObjectGenerator subclasses

These classes should not be visible, hide them.

JIRA: MDSAL-443
Change-Id: I598c50d5de6e700e76988052d3e6747de933deb0
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoBind CodecDataObject string instances
Robert Varga [Thu, 2 May 2019 14:13:33 +0000 (16:13 +0200)]
Bind CodecDataObject string instances

Heap analysis of the classes we generated on top of CodecDataObject
indicates we have an unnecessarily-large class constant pool. This
boils down our usage of string constants we pass back to
CodecDataObject -- which are coming from QName, but are not guaranteed
to be interned.

Aside from increasing heap consumption, this has a downside of not
requiring deep string comparisons during lookup -- which we want to
avoid if at all possible.

This patch updates generation strategy to create explicit constant
fields, which are bound to direct references to Strings used in
QNames -- resulting in the same objects being used.

JIRA: MDSAL-442
Change-Id: I10ef4ae49525d3f45076260e9438863b5830cf9a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoDo not inline NodeContextSuppliers
Robert Varga [Wed, 1 May 2019 20:46:04 +0000 (22:46 +0200)]
Do not inline NodeContextSuppliers

As it turns out, NodeContextSuppliers really need to be coming
from parent, as we can be rehosting objects into different
namespaces -- in which case a single object will need to be
interpreted in terms of the NodeContextSupplier in its parent,
i.e. with a different schema.

This patch undoes most of Iaf227e78d2b6546d34c2133fc31912c0a8dde4b3
and I9e24c30535c536d70b4eb60035b5aa744fc6ec9d, in that
NodeContextSuppliers are not inlined as constants, but rather
looked up.

Unlike the previous lookup by method name, we are using localName
and Class, just as we do in stremers and hence we are reusing
indices which support streamers.

The ability to inlike NodeContextSuppliers is retained, but since
DataObjectContext does not have enough information from
BindingRuntimeContext, this facility is not used.

JIRA: MDSAL-443
Change-Id: I82bff8657845bdab27aa3aa8c24a949c4758f1bb
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoOptimize DataObjectCodecContext memory footprint
Robert Varga [Thu, 2 May 2019 10:27:58 +0000 (12:27 +0200)]
Optimize DataObjectCodecContext memory footprint

Examining heap dumps while working on MDSAL-442/MDSAL-443 revealed
a slight inefficiency in DataObjectCodecContext: we are forcing
byStreamClass's entrySet to be instantiated for the purposes of
copying it into byBindingArgClassBuilder.

This patch corrects the mistake by using byStreamClassBuilder
as the source of copied entries -- which holds the same content,
but we will be throwing it away.

Furthermore byStreamClass and byBindingArgClass are only distinct
when we have a choice child, hence we also run comparison on the
two builders and reuse byStreamClass if they are equal.

Change-Id: Ie58367f7cc899d49da7f78cd0d4e70fbb064ae99
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoFix raw type warnings in CodecDataObjectBridge
Robert Varga [Thu, 2 May 2019 06:23:33 +0000 (08:23 +0200)]
Fix raw type warnings in CodecDataObjectBridge

CodecDataObjectGenerator is generic, use a wildcard type to prevent
raw type warnings.

JIRA: MDSAL-444
Change-Id: I1d8dffce449a7129e59cc3a70400056fd843b15c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoDefend against nulls in ValueContext
Robert Varga [Wed, 1 May 2019 17:18:57 +0000 (19:18 +0200)]
Defend against nulls in ValueContext

We should never attempt to deserialize null values for keys,
defend against them.

Change-Id: I6439bb6ce22da11476cd4f8bd89e3ec04c05ba96
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoIntroduce AbstractAugmentable
Robert Varga [Wed, 1 May 2019 14:29:00 +0000 (16:29 +0200)]
Introduce AbstractAugmentable

Binding generated code hand-implements handling of augmentations,
which leads to some amount of duplicated code, but notably a lot
of distinct implementations of Augmentatable.augmentation().

We can improve the situation by providing a simple base class which
holds an immutable map of augmentations implementing
AugmentationHolder and Augmentable interfaces.

JIRA: MDSAL-445
Change-Id: I693cd4fbec3d236f039e01448dc4994722b5582d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoDo not use ClassToInstanceMap in AugmentableCodecDataObject
Robert Varga [Wed, 1 May 2019 15:05:46 +0000 (17:05 +0200)]
Do not use ClassToInstanceMap in AugmentableCodecDataObject

ImmutableClassToInstanceMap is implemented using delegation,
which means we end up allocating one more object than we really
need and are also adding an indirection.

Drop back to using a plain ImmutableMap, so as to reduce memory
pressure.

JIRA: MDSAL-442
Change-Id: I6832eb8f012a2d003d3a2158009305a09f6c7832
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoDo not retain java.lang.reflect.Method in ValueNodeCodecContext
Robert Varga [Tue, 30 Apr 2019 15:39:28 +0000 (17:39 +0200)]
Do not retain java.lang.reflect.Method in ValueNodeCodecContext

We only require method references during DataObjectCodecContext,
after which all we need is their name -- hence we index the map
by Method, as we can get the name from there and we can derive
the former string from the underlying schema, just as we did
before.

Change-Id: Icfb6bc3b89ce313ae054e773bd566c03c16d8a31
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoDo not use bound MethodHandle in DataObjectCodecContext
Robert Varga [Tue, 30 Apr 2019 13:08:30 +0000 (15:08 +0200)]
Do not use bound MethodHandle in DataObjectCodecContext

Binding the MethodHandle means we are actually creating two
methodhandles, which is wasteful. Add a dummy CodecDataObject
constructor argument, unifying constructor signatures and allowing
us to use a single methodhandle, passing 'this' at the single
call site.

JIRA: MDSAL-444
Change-Id: Idd94638eb42d219b7370463d91dad3d00409bd5e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoAdd support for EventInstantAware notifications
Robert Varga [Thu, 11 Apr 2019 21:11:17 +0000 (23:11 +0200)]
Add support for EventInstantAware notifications

This patch adds support for transmitting DOMEvent contents to
Binding Notifications through the EventInstantAware interface.

The design is such that binding-dom-adapter recognizes DOMEvent
and extracts the instant from it and uses the appropriate codec
call to instantiate a proxy Notification.

On codec side of things, the NotificationCodecContext maintains
a distinct Proxy, which also implements EventInstantAware and
when asked to create a proxy with an instant uses that instead
of the usual LazyDataObject to handle it. In order to make things
seamless and to not impact other LazyDataObject users, this
alternative proxy is serviced by an intermediate InvocationHandler,
which checks if the call is to eventInstance() and if not, it will
delegate to the normal LazyDataObject instance.

JIRA: MDSAL-282
Change-Id: I0dda9a55e4da6231c9bd3be03121a236ce187e47
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoSwitch NormalizedNode->Binding codegen to ByteBuddy
Robert Varga [Tue, 23 Apr 2019 20:28:22 +0000 (22:28 +0200)]
Switch NormalizedNode->Binding codegen to ByteBuddy

This patch switches code generation for streamers and codec-based
binding objects to use ByteBuddy instead of Javassist.

While this increases the size of our jar considerably, it is
leads to more maintainable and safer code.

JIRA: MDSAL-444
Change-Id: Ib810dd0df6e569b0bb20603a5b0f0180c28ec25c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoTeach BindingNormalizedNodeCache to cache leaf type objects
Robert Varga [Thu, 11 Apr 2019 15:40:28 +0000 (17:40 +0200)]
Teach BindingNormalizedNodeCache to cache leaf type objects

This adds the final bits to enable CachingNormalizedNodeSerializer
to actually cache leaf objects.

JIRA: MDSAL-407
Change-Id: I39bac36395f4e6809342d48a375d441b49cbc3b8
Signed-off-by: Jie Han <han.jie@zte.com.cn>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoRework DataObjectSerializer implementations
Robert Varga [Sat, 20 Apr 2019 12:03:42 +0000 (14:03 +0200)]
Rework DataObjectSerializer implementations

This patch rework generation of DataObjectSerializers to base
them on a common superclass and generates them into a target
CodecClassLoader.

This removes pollution of class loaders, while maintaining the
same level of functionality with slightly less byte code.

It also cleans up external interfaces, as the serializers
generation is a purely-internal implementation detail and is not
exposed to outside world -- hence this patch deprecates all
classes and interfaces involved in that former leak.

JIRA: MDSAL-401
Change-Id: I80daff7e05e7487af7dca4e4bdae6b2893c97037
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoDrop a FIXME in DataContainerCodecPrototype
Robert Varga [Fri, 26 Apr 2019 19:36:30 +0000 (21:36 +0200)]
Drop a FIXME in DataContainerCodecPrototype

Acquisition of the backer is in the hot path now, hence we should
consider if we can safely remove or relax the volatile read here.

Change-Id: I9efe3cd2f45ab97f6c4c9bcc8f18e4cf62542b60
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoCache NodeContextSuppliers in CodecDataObject
Robert Varga [Tue, 23 Apr 2019 10:26:47 +0000 (12:26 +0200)]
Cache NodeContextSuppliers in CodecDataObject

The binding between DataContainerCodecContext and CodecDataObject
is required only to support decoding child leaves, where we are
looking offset-based lookup.

Since each method has a fixed offset, which directly corresponds
to a NodeContextSupplier, we can short-circuit this lookup by
resolving NodeContextSupplier for each method into constant and
then pass it down to CodecDataObject -- thus side-stepping any
lookups and allowing the constant to be properly propagated.

That unfortunately means we need to initialize the generated class
early, so the fields are resolved in a well-controlled environment
-- for which we are using Customizer.customizeLoading() coupled
with a thread-local context managed by CodecDataObjectBridge.

JIRA: MDSAL-443
Change-Id: I9e24c30535c536d70b4eb60035b5aa744fc6ec9d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoOptimize CodecDataObject dispatch
Robert Varga [Mon, 22 Apr 2019 20:47:43 +0000 (22:47 +0200)]
Optimize CodecDataObject dispatch

Now that we are in control of our interface between the DataObject
facade and DataObjectCodecContext rather than being forced to work
off of method name, we can optimize the dispatch towards
NodeContextSupplier (and DataObjectCodecContext size) by using
simple offsets to identify which method is being invoked.

On the generated code side of things, this lowers the pressure we
exert on the constant pool by using simple integers instead of
strings.

On the DataObjectCodecContext side, we ditch a Map in favor of a
simple array -- thus lowering memory overhead while also speeding
up dispatch, as it no longer is a Map lookup, but rather straight
get from an offset.

This necessitates special-casing key() method a bit, but the benefits
outweigh the (slight) ugliness we bring in.

JIRA: MDSAL-442
Change-Id: Iaf227e78d2b6546d34c2133fc31912c0a8dde4b3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoSpeed up BindingReflections.getAugmentations()
Robert Varga [Wed, 24 Apr 2019 09:05:38 +0000 (11:05 +0200)]
Speed up BindingReflections.getAugmentations()

One of the ways in which we can acquire augmentations is through
AugmentationHolder interface. While this is handled through
AugmentationFieldGetter.getGetter(), that is not really efficient
as it requires indirection through multiple implementations.

Since AugmentationFieldGetter is a package-internal implementation
detail, factor the check out into BindingReflections, where it can
execute directly. This not only improves locality, but also allows
us to remove one AugmentationFieldGetter implementation, resulting
in bimorphic invocation.

Change-Id: I15584dbe6151a70d13a766f27b927f598a5d21ba
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoGenerate DataObject codec implementation
Robert Varga [Mon, 15 Apr 2019 11:50:58 +0000 (13:50 +0200)]
Generate DataObject codec implementation

With the advent of CodecClassLoader we can safely instantiate
codec-specific implementations of binding interfaces instead
of relying on dynamic proxies.

This has several advantages:
- we do not generate a proxy class in public space, hence our mess
  will undergo normal GC rules
- generated code is a normal final class, hence we can inherit
  method implementations from interfaces and subclasses
- for each instance, we do not require a proxy and an invocation
  handler, so we instantiate only one object
- there is no reflection in the invocation path, hence JIT has
  full (and direct) visibility and can perform all of its magic

This patch DataObject support to use this approach, with
(Augmentable)CodecDataObject forming the base class.

The result is a bit more complex than the OpaqueObject case, but
also offers several advantages over the LazyDataObject approach
it replaces:
- nonnullFoo() methods are inherited from the binding interface,
  hence the presence of binding-dom-codec does not prevent CHA
  analysis from concluding there is only a single implementation
  -- thus allowing rapid devirtualization. This also means that
  DataContainerCodecContext no longer needs to track those methods
  or do anything.
- Augmentable interfaces are supported by a separate superclass,
  which implements AugmentationHolder, resulting in augmentations
  field being held only if the binding interface is augmentable
- getters and Identifiable.key() values are held in dedicated
  fields of the generated object. This leads to them being properly
  cached in all cases, hence invoking a getter after an
  equals/hashCode() operation will reuse the cached value if it
  was populated
- since we are using plain fields, data access does not involve
  walking a ConcurrentHashMap, further improving performance

The amount of generated code is kept at a minimum -- methods
just invoke CodecDataObject's method, passing it the ARFU
corresponding to the field as a constant -- and rely on the
compiler to inline the call, so that constants are propagated.

JIRA: MDSAL-442
Change-Id: I6acc34ab6b2cc62fd26dc34275259494ac4541fb
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoExpand class customization capabilities
Robert Varga [Tue, 23 Apr 2019 08:27:51 +0000 (10:27 +0200)]
Expand class customization capabilities

This expands CodecClassLoader.Customizer with the ability to
cross-reference generated classes, so a generated class can
depend on another generated class -- which can potentially live
in a different classloader. This capability is required to support
stream writers, as they delegate to each other.

JIRA: MDSAL-401
JIRA: MDSAL-443
Change-Id: I446dcfe10c742c670f2021123acab600a28c2514
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoSpeed up DataContainerCodecPrototype.get() a bit
Robert Varga [Tue, 23 Apr 2019 09:38:33 +0000 (11:38 +0200)]
Speed up DataContainerCodecPrototype.get() a bit

We can use less byte code to initialize both the local handle
and the cache field.

Change-Id: I362d0125836c6d962c4366c03ba76ae244fc54e5
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoGenerate OpaqueObject implementation
Robert Varga [Mon, 15 Apr 2019 08:02:03 +0000 (10:02 +0200)]
Generate OpaqueObject implementation

With the advent of CodecClassLoader we can safely instantiate
codec-specific implementations of binding interfaces instead
of relying on dynamic proxies.

This has several advantages:
- we do not generate a proxy class in public space, hence our mess
  will undergo normal GC rules
- generated code is a normal final class, hence we can inherit
  method implementations from interfaces and subclasses
- for each instance, we do not require a proxy and an invocation
  handler, so we instantiate only one object
- there is no reflection in the invocation path, hence JIT has
  full (and direct) visibility and can perform all of its magic

This patch does that for OpaqueObject, which results extremely
simple generated classes: they just subclass a ForeignOpaqueObject
and add the target binding interface.

JIRA: MDSAL-442
Change-Id: I2be5bb88f9557375f517415d6bec9f68e803628c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoAdd codec support for anyxml classes
Robert Varga [Sun, 14 Apr 2019 09:25:17 +0000 (11:25 +0200)]
Add codec support for anyxml classes

ForeignOpaqueData and ForeignOpaqueObject provide generalized
support for proxying over to yang.data.api.ForeignDataNode, hence
supporting anydata/anyxml in all possible object models.

The codec tree is extended with BindingOpaqueObjectCodecTreeNode,
which supports all OpaqueObjects, with the restriction that only
AnyXmlNodes (i.e. those with DOMSource object model) are supported
due to streaming restrictions in NormalizedNodeStreamWriter.

JIRA: MDSAL-285
Change-Id: I9192008ae169cf49a98f64a218a33d470d134eae
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoAdd support for anyxml node code generation
Robert Varga [Tue, 9 Apr 2019 21:43:40 +0000 (23:43 +0200)]
Add support for anyxml node code generation

This adds the support for generating OpaqueObject interfaces
based on anyxml nodes.

JIRA: MDSAL-437
Change-Id: Iee4f32449f73833b31444c7659047471758d0c88
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoAdd binding/dom codec class loader support
Robert Varga [Thu, 18 Apr 2019 11:07:22 +0000 (13:07 +0200)]
Add binding/dom codec class loader support

Our current codec implementation relies on creating classes in
classloaders holding compile-time-generated code, effectively
polluting them, in two distinct ways.

The first, less intrusive, is the instantiation of dynamic
proxies, which support LazyDataObject and ForeignOpaqueObject
instances. Since this is done via JVM interfaces, the JVM
takes care of reusing these classes, but still they cannot
be removed when the binding-dom-codec is unloaded -- fortunately
their nature of being derived from yang-binding and compile-time
generated interfaces allows them to be reused.

The second, more intrusive, is the instantiation of dynamic
streamers to support emitting NormalizedNode structures from
DataObject instances. While there are some provisions to reuse
them, they are inherently tied to how BindingRuntimeContext
interprets generated classes -- if the underlying SchemaContext
ends up interpreting them incompatibly (for example, by leaf
changing to anyxml), we end up between a rock and a hard place --
the classes do not match NormalizedNode world and they cannot
be reloaded to rectify the problem.

This patch adds the infrastructure for separating out compile-time
and run-time worlds by introducing StaticClassPool and
CodecClassLoader. StaticClassPool is used to bind Javassist code
generator to the classloader into which binding-dom-codec is loaded.

CodecClassLoader allows effective bridging of StaticClassPool and
whatever classloader is loading compile-time-generated classes,
and provides a place where new classes can be defined without
polluting either classloader.

Change-Id: I963c7bc6eefd5dd77a80e06442896265116664c0
JIRA: MDSAL-442
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoOptimize source generation
Robert Varga [Sun, 14 Apr 2019 14:22:50 +0000 (16:22 +0200)]
Optimize source generation

Since StringBuilder is fluent, we can optimize some of the source
generation utilities to have less bytecode. Also mark FIXMEs for
future improvement, as these would allow better devirtualization.

Furthermore we expose Class-based cast/assign operations, which
trim down code duplication a tiny bit.

Change-Id: I32d9d9321992effe0bec1423990208a92c1f780b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoDefine OpaqueData/OpaqueObject hashCode/equals
Robert Varga [Fri, 12 Apr 2019 02:09:33 +0000 (04:09 +0200)]
Define OpaqueData/OpaqueObject hashCode/equals

This adds baseline hashCode/equals specification, so that we do not
rely on identity for comparisons.

JIRA: MDSAL-439
Change-Id: I41291935a0402f6fce13b6e49531d85e2fc905d5
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoTag generated QNAME field with @NonNull
Robert Varga [Sun, 14 Apr 2019 07:33:15 +0000 (09:33 +0200)]
Tag generated QNAME field with @NonNull

Improve code generation, so that users can be sure QNAME is never
nullable, improving interactions with APIs which take a QName.

Change-Id: I0454ba448fb9edb605d04e97901381ae0f8a79d0
JIRA: MDSAL-441
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoTag InstanceIdentifier methods with @Nullable/@NonNull
Robert Varga [Sun, 14 Apr 2019 07:08:33 +0000 (09:08 +0200)]
Tag InstanceIdentifier methods with @Nullable/@NonNull

Most of these methods are guaranteed to return non-null, tag them
as such, improving user experience.

Change-Id: I6f581baf2a023b90274b9d89bf6475d9780449c8
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoBump version to 4.0.1-SNAPSHOT
Robert Varga [Thu, 11 Apr 2019 17:14:52 +0000 (19:14 +0200)]
Bump version to 4.0.1-SNAPSHOT

This starts the next release cycle.

Change-Id: Ic3462f2874e72597d6686ad25d16c607e44f7859
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoSpecialize LeafNodeCodecContext for TypeObjects
Robert Varga [Thu, 11 Apr 2019 14:43:09 +0000 (16:43 +0200)]
Specialize LeafNodeCodecContext for TypeObjects

This adds the gue between BindingTypeObjectCodecTreeNode and
LeafNodeCodecContext, which is necessary to correctly instantiate
leaves from caches.

JIRA: MDSAL-407
Change-Id: Ia636cf513e6581ad098e0887b37119476508063a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoSplit LeafNodeCodeContext and LeafSetNodeCodecContext
Robert Varga [Thu, 11 Apr 2019 14:07:41 +0000 (16:07 +0200)]
Split LeafNodeCodeContext and LeafSetNodeCodecContext

These are the two basic node contexts we are currently supporting,
split them from ValueNodeContext, properly separating deserializeObject()
implementations.

JIRA: MDSAL-436
Change-Id: Ieeb9c047f980631ab3861bb7e42ef87e52f9552e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoRename LeafNodeCodecContext to ValueNodeCodecContext
Robert Varga [Thu, 11 Apr 2019 13:36:58 +0000 (15:36 +0200)]
Rename LeafNodeCodecContext to ValueNodeCodecContext

'LeafNode' prefix has wrong implications, as it is reminiscent
of nodes from 'leaf' statement, when in fact it covers all nodes
considered 'leaf' values in the Binding Object tree. This covers leaf,
leaf-list, anyxml, anydata -- where leaf-list and leaf have actually
differnent handling.

This renames the class to ValueNodeCodecContext, to make a clear
distinction between the two groups.

JIRA: MDSAL-436
Change-Id: I02d60afc1650319efe6cbd90b12eeb47e5152a8f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoAllow BindingNormalizedNodeCachingCodec on any BindingObject
Robert Varga [Thu, 11 Apr 2019 11:58:40 +0000 (13:58 +0200)]
Allow BindingNormalizedNodeCachingCodec on any BindingObject

This lowers the requirements so we can have a caching codec for
any BindingObject.

JIRA: MDSAL-407
Change-Id: I1ae3659b277df29743028761e136457c2dfd1a0f
Signed-off-by: Jie Han <han.jie@zte.com.cn>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoAdd BindingTypeObjectCodecTreeNode
Robert Varga [Thu, 11 Apr 2019 10:14:26 +0000 (12:14 +0200)]
Add BindingTypeObjectCodecTreeNode

This interface supports TypeObject codecs, exposing the appropriate
codec interface.

JIRA: MDSAL-407
Change-Id: Ib45561039b85e051086934e72daa4fa701b600aa
Signed-off-by: Jie Han <han.jie@zte.com.cn>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoSplit BindingNormalizedNodeCache
Robert Varga [Wed, 10 Apr 2019 18:09:36 +0000 (20:09 +0200)]
Split BindingNormalizedNodeCache

We will end up caching various kinds of BindingObjects, this splits
up BindingNormalizedNodeCache into an abstract base class and a
concrete implementation for DataObjects.

JIRA: MDSAL-407
Change-Id: I7ae0338fa29124cfe4a5f0234fe9dd55e8bc389e
Signed-off-by: Jie Han <han.jie@zte.com.cn>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoRework BindingCodecTreeNode
Robert Varga [Wed, 10 Apr 2019 15:44:43 +0000 (17:44 +0200)]
Rework BindingCodecTreeNode

There is a strong tie-in between NodeCodecContext and
BindingCodecTreeNode, where the latter has massive oversubscription
of context.

This patch separates the semantics out, so that we end up with
cleaner interfaces and proper decomposition of concerns, so that
further binding concepts can be handled by the codec infrastructure.

This is a preparatory patch for both TypedObject caching and
Annotation/OpaqueObject translation.

JIRA: MDSAL-10
JIRA: MDSAL-285
JIRA: MDSAL-407
Change-Id: Ibc8d155b8a91b6081cd0eecd5d25fae56cb4699a
Signed-off-by: Jie Han <han.jie@zte.com.cn>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoRemove unneeded suppressions
Robert Varga [Wed, 10 Apr 2019 19:27:20 +0000 (21:27 +0200)]
Remove unneeded suppressions

Now that implementedInterface() is specialized by DataObject,
we can get rid of raw types and unchecked casts, as we know
the returned Class object is a subclass of DataObject.

Change-Id: I0d148a4437462e7d05384efbb79d935b5b00e9b7
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoClean up tryToUseCacheElse()
Robert Varga [Wed, 10 Apr 2019 12:51:00 +0000 (14:51 +0200)]
Clean up tryToUseCacheElse()

Generated code is a bit ugly for the case of accessing cache,
with missing newline and misplaced whitespace. Clean that up.

Change-Id: I13c754c808b9da19e3f5e4cfc216073aafb462db
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoDocument BindingCodec/Serializer/Deserializer
Robert Varga [Wed, 10 Apr 2019 11:10:57 +0000 (13:10 +0200)]
Document BindingCodec/Serializer/Deserializer

These interfaces are not documented at all, owing partly to the fact
they are are implementation of mdsal-binding-dom-codec, whose design
currently requires placing codecs into the same class loader as
generated code -- hence they leak to the common binding support
package.

Change-Id: Ib576b9aeddcc644d5b1f44a2047e775cc5266245
JIRA: MDSAL-401
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>