yangtools.git
2 weeks agoSimplify ModuleInfoSnapshotBuilder
Robert Varga [Sat, 3 Oct 2020 07:31:39 +0000 (09:31 +0200)]
Simplify ModuleInfoSnapshotBuilder

There is no need to allocate a full resolver, as the things we want
to achieve here are easily done through a simple parser.

Change-Id: I03a7255bc2b6f50171cc6b353ab15409e08ab747
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoEliminate SchemaPath references in codec infrastructure
Robert Varga [Thu, 1 Oct 2020 10:01:02 +0000 (12:01 +0200)]
Eliminate SchemaPath references in codec infrastructure

We have switched to SchemaNodeIdentifier across the board, this patch
makes the finishing touches.

JIRA: MDSAL-570
Change-Id: I8b54143e71ebbd4aef03cb00704e2b4f5311174f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoRemove unthrown exceptions
Robert Varga [Thu, 1 Oct 2020 09:48:55 +0000 (11:48 +0200)]
Remove unthrown exceptions

IOException is not thrown here, remove the declarations.

Change-Id: Ie112d79946b165283c900b420045aedf1b4d8673
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoClean DataContainerCodecPrototype methods
Robert Varga [Wed, 30 Sep 2020 18:28:40 +0000 (20:28 +0200)]
Clean DataContainerCodecPrototype methods

We have a number of suppressions and needlessly-public methods,
clean that up.

Change-Id: Id317f9392678f5c91c46ee42eff044d5aa8d31df
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoEliminate locking in DataObjectCodecContext
Robert Varga [Wed, 30 Sep 2020 18:14:32 +0000 (20:14 +0200)]
Eliminate locking in DataObjectCodecContext

Use normal getAcquire()/compareAndExchangeRelease() loading to
eliminate the use of locking when we are dealing with mismatched
augmentations. We also split processing into multiple staggered
method to help with inlining.

Change-Id: I2a35aea38c0ec502b27827af145cdad1a00312a4
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoRelax DataContainerCodecPrototype.instance locking
Robert Varga [Wed, 30 Sep 2020 15:55:36 +0000 (17:55 +0200)]
Relax DataContainerCodecPrototype.instance locking

All the objects we are creating in createInstance() do not have
unexpected side-effects nor should they require happens-before
semantics beyond what they can guarantee themselves.

Base on that we can make loadInstance() lockless and concurrent,
and reconcile purely via getAcquire()/compareAndExchangeRelease().

JIRA: MDSAL-579
Change-Id: I292024afafa41aecb65e547acc5c888ba7890ee1
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoDo not allocate HashMap for non-augmentations
Robert Varga [Wed, 30 Sep 2020 12:34:20 +0000 (14:34 +0200)]
Do not allocate HashMap for non-augmentations

Push state allocation into the conditional for better encapsulation.

Change-Id: Icf60a259634d263d920b60f3ab55bf162cf709d8
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoImprove BindingRuntimeContext.getAugmentationDefinition()
Robert Varga [Wed, 30 Sep 2020 12:24:13 +0000 (14:24 +0200)]
Improve BindingRuntimeContext.getAugmentationDefinition()

All callers are already guarding the call site with a check, hence
we can also require them to perform an explicit reinterpret. This
pushes safety checks to compile-time.

Also remove duplicate javadocs, so that we have one text defining
semantics.

Change-Id: I3ce23440c725441e663331e94a931ad09d71634a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoImprove ModuleInfoSnapshotBuilder API
Robert Varga [Wed, 30 Sep 2020 10:57:13 +0000 (12:57 +0200)]
Improve ModuleInfoSnapshotBuilder API

Add a fluent add(ModuleInfo) method and its siblings, so it is
much easier to use the builder. This also factors out
ModuleInfoSnapshotResolver which is a dynamic registry.

Change-Id: I886883d26f748e32f6d8c766926b4dbd00b75fa5
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoUse only BindingRuntimeContext for augmentation loading
Robert Varga [Wed, 30 Sep 2020 11:26:55 +0000 (13:26 +0200)]
Use only BindingRuntimeContext for augmentation loading

BindingRuntimeContext is the only proper way of loading binding
classes. Do not attempt to go behind its back, but rather trust
it can load everything it references -- it is a bug for if it
cannot.

Eliminate opportunistic augmentation class loading, which allows
is to make augmentation prototypes properly constant.

JIRA: MDSAL-578
Change-Id: Ie99e57b29b437a7fee52be4eb5006d3d122cb383
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoEliminate ClassLoadingStrategy
Robert Varga [Wed, 30 Sep 2020 10:43:56 +0000 (12:43 +0200)]
Eliminate ClassLoadingStrategy

ClassLoadingStrategy as a separate concept is very confusing. The
reality is that ModuleInfoSnapshot needs to be able to load classes
based on their FQCN and BindingRuntimeContext needs to do the same
based on they binding.model.api.Type.

Split ClassLoadingStrategy's two methods appropriately and remove
it. Also adjust all users to not rely on it.

JIRA: MDSAL-578
Change-Id: Id4606efcd67d8ea7c42e78c48c48aa915cb11a52
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoReduce use of getSchemaContext
Robert Varga [Wed, 30 Sep 2020 11:05:14 +0000 (13:05 +0200)]
Reduce use of getSchemaContext

We are moving towards to EffectiveModelContext usage across all
components. Make sure we propagate it to more places, fixing
related deprecation warnings.

Change-Id: If8da2a8c7037dbc1966351acc7c63b5f2cd1db85
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoCreate proper assertFileContains()
Robert Varga [Tue, 29 Sep 2020 22:45:37 +0000 (00:45 +0200)]
Create proper assertFileContains()

We want to have a proper assertion, not just assertTrue(). Change
findInFile() to assertFileContains().

Change-Id: I15d36db3423bc28df364dbed216adbdced8fc9a0
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoFix FileSearchUtil.getFiles()
Illia [Thu, 24 Sep 2020 11:18:25 +0000 (14:18 +0300)]
Fix FileSearchUtil.getFiles()

Do not skip files in the current folder after finding the first child
folder.

Change-Id: Ifba6071e431e18a0a4caa03c90d11b246ec2bc6b
Signed-off-by: Illia <illia.ihushev@pantheon.tech>
2 weeks agoMove common util methods to dedicated class
illia.ihushev [Tue, 11 Aug 2020 11:47:27 +0000 (14:47 +0300)]
Move common util methods to dedicated class

This will make it easier to reuse them.

Change-Id: I4ad75ba20da12936311bdb81c7b2e8e7a7a284d0
Signed-off-by: illia.ihushev <illia.ihushev@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoAdd BindingMap helper class
Robert Varga [Fri, 25 Sep 2020 16:20:22 +0000 (18:20 +0200)]
Add BindingMap helper class

Changing the mapping of keyed lists from List to Map made the baseline
generated builders hard to use, as there isn't an easy way to build
a map of entries in a fluent way.

BindingMap fills this role, providing both a direct way via
BindingMap.of(V...) as well as Builder-based interface via
BindingMap.Builder.

JIRA: MDSAL-553
Change-Id: Ieb3093c37b30f79666bffb50aa22a20922e41344
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Signed-off-by: Illia <illia.ihushev@pantheon.tech>
2 weeks agoBump to odlparent-8.0.0/yangtools-8.0.0-SNAPSHOT
Robert Varga [Tue, 29 Sep 2020 14:17:03 +0000 (16:17 +0200)]
Bump to odlparent-8.0.0/yangtools-8.0.0-SNAPSHOT

This patch starts integration for MRI window.

Change-Id: Ifa9780fbdfb411b4613df0ee18407d85e81bd517
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoUse QName.bindTo() instead of withModule()
Robert Varga [Tue, 29 Sep 2020 14:56:01 +0000 (16:56 +0200)]
Use QName.bindTo() instead of withModule()

QName.withModule() has been deprecated, migrate to using
AbstractQName.bindTo().

Change-Id: I95aa618ce0f8a0ad4844e99db03f373e9e4ea884
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks ago$YangModuleInfoImpl not generated for only extensions model
Michal Banik [Thu, 13 Aug 2020 18:09:04 +0000 (20:09 +0200)]
$YangModuleInfoImpl not generated for only extensions model

This adds a minimal test case, which flushes out the problem
in test harness, but production code is actually fine.

JIRA: MDSAL-589
Change-Id: I93404702551546585812f8d1b5be6690cc38e750
Signed-off-by: Michal Banik <michal.banik@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoBump odlparent/yangtools to 7.0.6/5.0.6
Robert Varga [Mon, 21 Sep 2020 12:17:50 +0000 (14:17 +0200)]
Bump odlparent/yangtools to 7.0.6/5.0.6

Pick up latest updates from upstream.

Change-Id: I22dae6f3cc21e115f349d568d6d3b9943a330027
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 69f8b01a7a376893461b68b1814510f1f8d856fd)

2 weeks agoFix wrong leafref path
illia.ihushev [Tue, 4 Aug 2020 19:22:13 +0000 (22:22 +0300)]
Fix wrong leafref path

leafref path points to nonexistent node, fix this path.

Change-Id: Ie6561743cf88d840598e3f2199fddff1c08029fa
Signed-off-by: illia.ihushev <illia.ihushev@pantheon.tech>
2 weeks agoEliminate AugmentationHolder
Robert Varga [Mon, 3 Aug 2020 12:02:14 +0000 (14:02 +0200)]
Eliminate AugmentationHolder

This makes interacting with Augmentables a lot simpler at the expense
of not supporting weird Reflection-based tricks like 'we will load
the interpretation behind your back'.

JIRA: MDSAL-577
Change-Id: Ib97ed323cf8fbec55a06188691610a31a1267bea
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoFix an Xtend warning
Robert Varga [Mon, 3 Aug 2020 11:59:12 +0000 (13:59 +0200)]
Fix an Xtend warning

There is a teensy warning, fix it up.

JIRA: MDSAL-491
Change-Id: I2a630ea42b27fd447e76a1ee567c61b21d74ace4
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoFix list Key data object nullness guarantees
illia.ihushev [Tue, 28 Jul 2020 12:20:58 +0000 (15:20 +0300)]
Fix list Key data object nullness guarantees

Verify is values nonnull in the constructors. Annotate getters return
types, constructor parameters with @NonNull.

JIRA: MDSAL-491
Change-Id: Idd8adacd9f8b2916b92a171df8d7e5001b1557d3
Signed-off-by: illia.ihushev <illia.ihushev@pantheon.tech>
2 weeks agoTeach BindingRuntimeContext how to lookup action paths
Robert Varga [Mon, 27 Jul 2020 11:19:41 +0000 (13:19 +0200)]
Teach BindingRuntimeContext how to lookup action paths

We do not want to rely on SchemaPath in binding-dom-adapter, so that
addressing is kept internal to BindingRuntimeTypes.

JIRA: MDSAL-581
Change-Id: I464582fa43b208de1ba347388cbde26161f3e304
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoReplace SchemaPath with SchemaNodeIdentifier.Absolute/QName
Robert Varga [Tue, 21 Jul 2020 11:42:54 +0000 (13:42 +0200)]
Replace SchemaPath with SchemaNodeIdentifier.Absolute/QName

SchemaNode.getPath() is going away, which also means we do not need
to tie ourselves down with SchemaPath.

RPCs embrace the fact they are really just a top-level construct
and use a plain QName.

Actions and notifications are required to use
SchemaNodeIdentifier.Absolute, which is the exact addressing
equivalent for them.

JIRA: MDSAL-569
Change-Id: I3a8f820c7b8f8a161881865bdac5a00d969cfc63
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoAdd @NonNull in DataObjects' default method signatures
illia.ihushev [Wed, 29 Jul 2020 10:41:34 +0000 (13:41 +0300)]
Add @NonNull in DataObjects' default method signatures

When specific DataObject is not Augmentable bindingToString parameter,
bindingEquals thisObj parameter, bindingHashCode parameter are not
annotated with @NonNull. Add these missing @NonNulls.

JIRA: MDSAL-582
Change-Id: I1ec4b500fd30cdf6b5006b8da2d91e035eff04ae
Signed-off-by: illia.ihushev <illia.ihushev@pantheon.tech>
2 weeks agoSkip bindingHashCode() generation on properties' absence
Ilya Igushev [Tue, 21 Jul 2020 08:02:32 +0000 (11:02 +0300)]
Skip bindingHashCode() generation on properties' absence

When DataObject implementation has no properties, augmentations, its
hashcode() wouldn't be overridden, so bindingHashcode() remains unused.

JIRA: MDSAL-471
Change-Id: If2f7bbb65f9dccf2353ba22b49d530f2a1ab4a71
Signed-off-by: illia.ihushev <illia.ihushev@pantheon.tech>
2 weeks agoAdd tests for generateBindingHashCode()
illia.ihushev [Mon, 20 Jul 2020 16:11:36 +0000 (19:11 +0300)]
Add tests for generateBindingHashCode()

Check bindingHashCode() declaration correctness.

JIRA: MDSAL-471
Change-Id: Iebf4963c1069b824ef97d07c9a81bff08cf3cabd
Signed-off-by: illia.ihushev <illia.ihushev@pantheon.tech>
2 weeks agoBump byte-buddy to 2.10.13
Robert Varga [Mon, 27 Jul 2020 15:07:25 +0000 (17:07 +0200)]
Bump byte-buddy to 2.10.13

https://github.com/raphw/byte-buddy/releases/tag/byte-buddy-1.10.12
https://github.com/raphw/byte-buddy/releases/tag/byte-buddy-1.10.13

Change-Id: I0966260bd0488abd08e9db0025bb1fd28d01f7e3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoBump odlparent/yangtools to 7.0.5/5.0.5
Robert Varga [Tue, 21 Jul 2020 19:40:36 +0000 (21:40 +0200)]
Bump odlparent/yangtools to 7.0.5/5.0.5

Pick up upgrades needed for netty and also further 7.0.0 development.

Change-Id: Ib80d5cfae5c5b93000ca3cf6fc907513d3901bdb
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoUse soft values in ValueTypeCodec
Robert Varga [Tue, 21 Jul 2020 08:39:32 +0000 (10:39 +0200)]
Use soft values in ValueTypeCodec

Using strong value references in STATIC_CODECS cache leads to target
classes being strongly reachable through the codec itself -- hence
they will never be weakly reachable, hence they will not be GC'd.

Use soft values, which allows the classes to be GC'd as soon as the
JVM decides they have not been used for a while -- which is what
will happen when a class becomes almost-eligible for unloading.

JIRA: MDSAL-580
Change-Id: I7956d564c46a9a1d52ba85fbe61f3a19c507a902
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoBinding DTOs: improve equals() implementation
Vladyslav Marchenko [Wed, 13 May 2020 10:09:03 +0000 (13:09 +0300)]
Binding DTOs: improve equals() implementation

DTO generator code recognize the types being compared and perform the following ordering:
1) numeric types (boolean, byte, short, int, long, biginteger, bigdecimal), identityrefs
2) string, binary, bits
3) instance identifier
4) all other (e.g. composite) types

JIRA: MDSAL-88
Change-Id: I8f64ad3cf234e4f0f16d608bd397b7f3fa96d785
Signed-off-by: Vladyslav Marchenko <vladyslav.marchenko@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoUse bindingEquals() generated for interfaces
illia.ihushev [Wed, 8 Jul 2020 09:58:08 +0000 (12:58 +0300)]
Use bindingEquals() generated for interfaces

As we are generating a default implementation of equals(), we
can defer to that implementation from runtime-generated proxies.

This results in:
- consistent results between compile-time and runtime implementations
- faster startup time, as there is only one dispatch implementation
- lower memory overhead, as runtime-generated classes are smaller
- more maintainable code, as the implementation can be examined at
  compile-time

Since this is the last method that references properties, we also
get to clean up some of the knowledge of how these need to be ordered.

JIRA: MDSAL-474
Change-Id: I1a0ca93755e670b7d8fa0834f87ee7a828843aa6
Signed-off-by: illia.ihushev <illia.ihushev@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoGenerate bindingEquals() and use it in generated implementations
Ilya Igushev [Fri, 3 Jul 2020 08:07:22 +0000 (08:07 +0000)]
Generate bindingEquals() and use it in generated implementations

As we are gearing towards generating default methods in interfaces,
we need the ability to completely analyze all a target type from
a template, not from a generator.

This ability was previously available to Builder*Template, now it
is part of JavaFileTemplate and hence can be picked up by
InterfaceTemplate as needed.

JIRA: MDSAL-473
Change-Id: Ife60dadb9b66dc01df04ebeba11d82c8806f2236
Signed-off-by: illia.ihushev <illia.ihushev@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoClean up AugmentationHolder's annotations
Robert Varga [Mon, 20 Jul 2020 12:41:17 +0000 (14:41 +0200)]
Clean up AugmentationHolder's annotations

We know AugmentationHolder must return a non-null, make sure we
have annotations documenting that.

Change-Id: Ie46791349c9ab0b3eb67fa8dd165d67702a993d2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoUse bindingHashCode() generated for interfaces
Robert Varga [Wed, 4 Sep 2019 17:16:09 +0000 (19:16 +0200)]
Use bindingHashCode() generated for interfaces

As we are generating a default implementation of hashCode(), we
can defer to that implementation from runtime-generated proxies.

This results in:
- consistent results between compile-time and runtime implementations
- faster startup time, as there is only one dispatch implementation
- lower memory overhead, as runtime-generated classes are smaller
- more maintainable code, as the implementation can be examined at
  compile-time

JIRA: MDSAL-472
Change-Id: Ifc4d3b71a1c63508e01491a4bf57bc4b163b5816
Signed-off-by: illia.ihushev <illia.ihushev@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoGenerate bindingHashCode() and use it in generated implementations
Robert Varga [Wed, 4 Sep 2019 15:44:12 +0000 (17:44 +0200)]
Generate bindingHashCode() and use it in generated implementations

As we are gearing towards generating default methods in interfaces,
we need the ability to completely analyze all a target type from
a template, not from a generator.

This ability was previously available to Builder*Template, now it
is part of JavaFileTemplate and hence can be picked up by
InterfaceTemplate as needed.

JIRA: MDSAL-471
Change-Id: I278c085da195df8b4153b62381203b8ddc7bd073
Signed-off-by: illia.ihushev <illia.ihushev@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoRemove ModuleInfoBackedContext
Robert Varga [Sun, 19 Jul 2020 22:01:39 +0000 (00:01 +0200)]
Remove ModuleInfoBackedContext

We have a replacement in ModuleInfoSnapshotBuilder, which is more
appropriate. Remove this badly leaking class and remove all the cruft
associated with its contract.

Change-Id: I185a57dc488a248bc8387e3f26603772116a48f2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoUse ModuleInfoSnapshot instead of ModuleInfoBackedContext
Robert Varga [Sun, 19 Jul 2020 21:52:36 +0000 (23:52 +0200)]
Use ModuleInfoSnapshot instead of ModuleInfoBackedContext

We do not need the entire dance around dynamic loading, use just
the bare minimum loader.

Change-Id: Ie04197083144fd24d11108edef013ec5941b2c90
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoRemove GeneratedClassLoadingStrategy
Robert Varga [Sun, 19 Jul 2020 16:30:42 +0000 (18:30 +0200)]
Remove GeneratedClassLoadingStrategy

We do not need this particular class anymore, remove it and migrate
its final set of users.

Change-Id: Ifce3d2803e2c3864377f174c468e83ee3a14b210
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoUse bindingToString() generated for interfaces
illia.ihushev [Tue, 14 Jul 2020 08:21:49 +0000 (11:21 +0300)]
Use bindingToString() generated for interfaces

As we are generating a default implementation of toString(), we
can defer to that implementation from runtime-generated proxies.

This results in:
- consistent results between compile-time and runtime implementations
- faster startup time, as there is only one dispatch implementation
- lower memory overhead, as runtime-generated classes are smaller
- more maintainable code, as the implementation can be examined at
  compile-time

JIRA: MDSAL-480
Change-Id: I56aceeb70461f6d35fcd6487e924fdd127a1ba1c
Signed-off-by: illia.ihushev <illia.ihushev@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoGenerate bindingToString() and use it in generated implementations
Ilya Igushev [Thu, 9 Jul 2020 09:52:02 +0000 (09:52 +0000)]
Generate bindingToString() and use it in generated implementations

As we are gearing towards generating default methods in interfaces,
we need the ability to completely analyze all a target type from
a template, not from a generator.

This ability was previously available to Builder*Template, now it
is part of JavaFileTemplate and hence can be picked up by
InterfaceTemplate as needed.

JIRA: MDSAL-479
Change-Id: I1e939aca15f2f77b82a83ca454503522c96bcabe
Signed-off-by: illia.ihushev <illia.ihushev@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoCorrect mdsal-binding-runtime-{api,spi} packages
Robert Varga [Sun, 19 Jul 2020 15:35:56 +0000 (17:35 +0200)]
Correct mdsal-binding-runtime-{api,spi} packages

Previous iteration left these new interface in the wrong package,
correct that mistake.

JIRA: MDSAL-548
Change-Id: I65c51ff2c1fc6c66684325c1022f6dca79a9b837
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoDeprecate binding.runtime.spi constructs
Robert Varga [Sun, 19 Jul 2020 15:23:37 +0000 (17:23 +0200)]
Deprecate binding.runtime.spi constructs

GeneratedClassLoadingStrategy is a relic, superseded by
ClassLoadingStrategy interface. Deprecate it for removal.

ModuleInfoBackedContext is an internal implementation detail, which
should not be used outside fo runtime-spi. Deprecate it for removal.

Change-Id: I520b7aa2bd60080e03c41f55087a5a9eca65ea8f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoRemove deprecated Builder.addAugmentation() variant
Robert Varga [Sun, 19 Jul 2020 11:53:46 +0000 (13:53 +0200)]
Remove deprecated Builder.addAugmentation() variant

We only support a single-argument variant, remove the deprecated
one.

JIRA: MDSAL-575
Change-Id: Ib2d256516f03a3e4be532378ac2dac6833acf489
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoRemove uses of deprecated Builder.addAugmentation()
Robert Varga [Sun, 19 Jul 2020 15:04:18 +0000 (17:04 +0200)]
Remove uses of deprecated Builder.addAugmentation()

We have a few tests which are using the deprecated addAugmentation()
method, remove them.

Change-Id: I3207588958610ee35eb1de2542ee31181467294f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoBump versions to 7.0.0-SNAPSHOT
Robert Varga [Fri, 17 Jul 2020 21:14:42 +0000 (23:14 +0200)]
Bump versions to 7.0.0-SNAPSHOT

Open the next major release.

Change-Id: I85ddea18470708fbb4d4346b4476ca32198d4f55
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoBump versions to 6.0.4-SNAPSHOT
Robert Varga [Fri, 17 Jul 2020 21:13:30 +0000 (23:13 +0200)]
Bump versions to 6.0.4-SNAPSHOT

This starts the next development iteration.

Change-Id: Ie2e139ddea855c81f765e1b9b4dff02810230000
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoBump odlparent/yangtools to 7.0.4/5.0.4
Robert Varga [Wed, 15 Jul 2020 10:32:22 +0000 (12:32 +0200)]
Bump odlparent/yangtools to 7.0.4/5.0.4

Pick up latest fixes from upstream.

Change-Id: Ic6d8e45955d77401b0bbdc4535b0a9a5e3ca9732
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoMake full type information accessible from InterfaceTemplate
illia.ihushev [Wed, 15 Jul 2020 11:35:26 +0000 (14:35 +0300)]
Make full type information accessible from InterfaceTemplate

As we are gearing towards generating default methods in interfaces,
we need the ability to completely analyze all a target type from
a template, not from a generator.

This ability was previously available to Builder*Template, now it
is part of JavaFileTemplate and hence can be picked up by
InterfaceTemplate as needed.

JIRA: MDSAL-470
Change-Id: I5a9b35ae31bfa7ecbffa2b555587d70a97fab93e
Signed-off-by: illia.ihushev <illia.ihushev@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoSpeed up BuilderGenerator matcher
Robert Varga [Wed, 15 Jul 2020 15:43:28 +0000 (17:43 +0200)]
Speed up BuilderGenerator matcher

We do not need to establish FQCN, as we can compare just JavaTypeNames,
which is faster.

Change-Id: I3c387e841fbf2d450195d864a928608bab8128ad
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoInline single-use locals
Robert Varga [Mon, 13 Jul 2020 20:11:22 +0000 (22:11 +0200)]
Inline single-use locals

We are storing instrumented type in a local, and use that local
only once. Just inline the getter to trim down some generator
bytecode.

Change-Id: Ibfac0c2dc1d294643cbe2619d14e1672314d8bdf
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoClean up CodecDataObjectGenerator documentation
Robert Varga [Mon, 13 Jul 2020 20:06:45 +0000 (22:06 +0200)]
Clean up CodecDataObjectGenerator documentation

We have a few typos and opportunities for cleanup.

Change-Id: Ibb9f5804ccc05c1b58c51d0ba1ac03fbaef7b223
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoRemove GeneratorUtil.getTopParentTransportObject()
Robert Varga [Mon, 13 Jul 2020 11:12:34 +0000 (13:12 +0200)]
Remove GeneratorUtil.getTopParentTransportObject()

This method is not used anywhere and is quite inefficient, remove
it.

Change-Id: I3d381793c6c20fb056d03118b942a2257756a4bc
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoEliminate use of addAugmentation(Class, DataObject)
Robert Varga [Mon, 15 Jun 2020 12:42:13 +0000 (14:42 +0200)]
Eliminate use of addAugmentation(Class, DataObject)

We have a replacement for this, migrate this user to remove
a warning.

Change-Id: Ib41c26cbd39766a8547edc88be03e3d8acf97265
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoBump versions to 6.0.3-SNAPSHOT
Robert Varga [Wed, 10 Jun 2020 20:19:00 +0000 (22:19 +0200)]
Bump versions to 6.0.3-SNAPSHOT

This starts the next development iteration.

Change-Id: Ice8a9c218fcc912a1e136b1063d83b13fcd50528
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoFix leafref-to-enum encoding
Peter Valka [Wed, 6 May 2020 07:54:18 +0000 (09:54 +0200)]
Fix leafref-to-enum encoding

When we have a leafref pointing to an enum via an absolute path,
in and RPC, we end up using a no-op codec, whereas we should be
extracting the name (from enum constant, or SchemaContext).

This ends up being a problem not in codec itself, as it is using
reflection to acquire the return type, defaulting to no-op.

The problem lies with AbstractTypeGenerator, which ends up not
being able to look up the generated type in case of RPC. The problem
here is the order in which types are generated, as the leaf being
referenced is generated after the RPC itself -- hence we cannot
find the definition.

While this is again highlighting the problem of single-pass code
generation, we can side-step the problem by moving RPC/notification
generation after the root data generation.

As a further complication, we need to record the enum/schema mapping,
as the codec needs to be able to find them via leafref types.

JIRA: MDSAL-552
Change-Id: Ifd92807029cdb7ba92dcad5655bb34d3ff4cef9d
Signed-off-by: Peter Valka <Peter.Valka@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoBump to odlparent-7.0.3/yangtools-5.0.3
Robert Varga [Tue, 9 Jun 2020 22:31:16 +0000 (00:31 +0200)]
Bump to odlparent-7.0.3/yangtools-5.0.3

Pick up latest updates from upstream.

Change-Id: I1f8ac05eecaeac0c7ba0d802543d82c3c7ea7548
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoBump byte-buddy to 1.10.11
Robert Varga [Mon, 8 Jun 2020 14:47:44 +0000 (16:47 +0200)]
Bump byte-buddy to 1.10.11

https://github.com/raphw/byte-buddy/blob/master/release-notes.md#4-june-2020-version-11011

Change-Id: I8538ecfa410bfc8fdbdbb87926914961ba2c6f1a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoBump versions to 6.0.2-SNAPSHOT
Robert Varga [Sat, 30 May 2020 13:30:08 +0000 (15:30 +0200)]
Bump versions to 6.0.2-SNAPSHOT

This starts next development iteration.

Change-Id: I6dd75c96d5e17bc6435539d44ecc4d0dcbe54daf
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoBump to odlparent-7.0.2/yangtools-5.0.2
Robert Varga [Sat, 30 May 2020 09:10:19 +0000 (11:10 +0200)]
Bump to odlparent-7.0.2/yangtools-5.0.2

Pick up latest updates from upstream.

Change-Id: Ibe48d3cc3f1ba0896ff582d285261ea287a0a87b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoBump byte-buddy to 1.10.10
Robert Varga [Fri, 29 May 2020 20:49:02 +0000 (22:49 +0200)]
Bump byte-buddy to 1.10.10

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

Change-Id: I536fc350302459e59245a87ab0d105d8df6ff3df
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoBackport controller's binding-broker tests
Robert Varga [Fri, 29 May 2020 11:11:04 +0000 (13:11 +0200)]
Backport controller's binding-broker tests

Pick up the class as it existed in controller as of
822e39fedebaf35ea9826067ad223dbfa98042ee.

JIRA: MDSAL-557
Change-Id: Ieaaeb594e33f8c5a4ac515d93c70db960cedb81c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoDo not use raw superclass for CodecDataObject instances
Robert Varga [Sat, 11 May 2019 09:47:38 +0000 (11:47 +0200)]
Do not use raw superclass for CodecDataObject instances

We can improve generated class accuracy by specifying generic type
argument of CodecDataObject, thus making generated classes look
not like raw subclasses.

JIRA: MDSAL-550
Change-Id: If0581ea7186793539c9bc149c5e62c6db906616b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoAdd lazily-instantiated maps
Robert Varga [Mon, 4 May 2020 12:34:27 +0000 (14:34 +0200)]
Add lazily-instantiated maps

Instantiating an ImmutableMap on each access is quite wasteful,
as there are a number of cases where we do not need the entire
mapping to be instantiated.

Typical uses touch the Map only once -- either to lookup a value
based on the key, or to iterate through the values. Others are
possible, but those two cover most of the patterns.

We add the prerequisite indirection and two implementations to
support each of the cases. The iterator part is optimized to
perform lazy object instantiation -- similar to LazyBindingList.

The lookup part works in a rather similar way, except it keeps
a lookup ConcurrentHashMap as the primary storage and values
are seen as expendable secondary storage. This makes iteration
order unstable, which might be seen as a violation of immutable
contract -- but our contract is a Map and mappings remain stable.

JIRA: MDSAL-539
Change-Id: I7c095065915f3c0d7b180d4aa1494e15d6374a11
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoAdd lazily-instantiated lists
Robert Varga [Tue, 5 May 2020 20:03:26 +0000 (22:03 +0200)]
Add lazily-instantiated lists

Lists are usually searched linearly. For large lists we can end
up instantiating a large number of items upfront, some of which is
wasteful.

The cutoff point can be configured via a JVM property, which is
interpreted as a dynamic constant.

JIRA: MDSAL-551
Change-Id: I9e7c987929481143b931e763f4ef0313745a5c89
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoGuarantee non-null in CodecDataObject.codecKey()
Robert Varga [Mon, 4 May 2020 13:49:50 +0000 (15:49 +0200)]
Guarantee non-null in CodecDataObject.codecKey()

The key loaded is guaranteed to be non-null, propagate that
annotation outwards.

Change-Id: If6bf3f4a7d5cabd760da603abb9038bb1e665b37
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoEliminate KeyedListNodeCodecContext.Unordered.getKey()
Robert Varga [Mon, 4 May 2020 12:40:40 +0000 (14:40 +0200)]
Eliminate KeyedListNodeCodecContext.Unordered.getKey()

This method and the methodhandle invoker are completely superfluous,
as we can directly access key() from the created object. While capturing
a MethodHandle lowers what method can be invoked, it does not really
buy us much, as the observed class will we always the same.

That property is visible enough (wired through an invokeExact() on the
constructor), hence JIT should be able to optimize without this help.

Change-Id: Id24eac8e74782f750576c90d60485b2dcbdcff9e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoTake advantage of MapNode.size()
Robert Varga [Mon, 4 May 2020 11:17:34 +0000 (13:17 +0200)]
Take advantage of MapNode.size()

Checking the size allows us to skip instantiating values, plus we
can pass it down to map construction, where a correct strategy
can be taken based on the size.

JIRA: MDSAL-539
Change-Id: Ib42e290571cf162150b6e94b24df4aca5a9762ff
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoRemove semicolons in comments
Robert Varga [Thu, 30 Apr 2020 07:31:29 +0000 (09:31 +0200)]
Remove semicolons in comments

sonarcloud insists this is commented-out code, which it is for
documentation purposes. Eliminating the trailing semicolon fools
it just enough to not notice.

Change-Id: I0546beb3b7584e426c2470c95bd4e8c177617bde
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoAdd InstanceIdentifier.verifyTarget()
Robert Varga [Sun, 3 May 2020 08:04:18 +0000 (10:04 +0200)]
Add InstanceIdentifier.verifyTarget()

There are a number of places where users are casting InstanceIdentifiers,
just to restore type-safety after a type-unsafe operation, such as
going through serialization. Add InstanceIdentifier.verifyTarget(),
which restores type safety.

Change-Id: I2bfa69eb938b4a6b86b88e4054369b3abadf7c7d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoBump versions to 6.0.1-SNAPSHOT
Robert Varga [Wed, 22 Apr 2020 18:34:49 +0000 (20:34 +0200)]
Bump versions to 6.0.1-SNAPSHOT

This starts the next development iteration.

Change-Id: I047dbba41739424eaeca008143fbe8ed7e466daf
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoRevert "Remove deprecated uint migration elements"
Robert Varga [Sun, 26 Apr 2020 13:06:09 +0000 (15:06 +0200)]
Revert "Remove deprecated uint migration elements"

This reverts commit 48af8df68d7abc7108e692eeefff3bf30c9c291d,
reinstating generation of compatibility elements.

JIRA: MDSAL-490
Change-Id: Ia59eb16f3f0e534ce7339c46c24fc4d0b22d6f05
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoBump to yangtools-5.0.1
Robert Varga [Thu, 23 Apr 2020 15:39:25 +0000 (17:39 +0200)]
Bump to yangtools-5.0.1

We need further changes to tie together netconf and us.

Change-Id: Ia3668c7a79221f060159696c5554ef1c21e38782
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoCleanup BindingRuntimeHelpers
Robert Varga [Thu, 23 Apr 2020 11:38:04 +0000 (13:38 +0200)]
Cleanup BindingRuntimeHelpers

We need to differentiate between testing (static context) and dynamic
contexts. This makes it possible to use these helpers in OSGi if we
inject the right set of services.

Change-Id: Ibc22b1597320956408217b98d44c9ea3fdd98c32
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoGenerate legacy List adaptation
Robert Varga [Thu, 23 Apr 2020 10:50:53 +0000 (12:50 +0200)]
Generate legacy List adaptation

In order to lower the pain of migration, generate legacy setFoo()
methods with List argument. These internally perform translation
to an ImmutableMap with unique index.

JIRA: MDSAL-434
Change-Id: If364c50a1f48d94b72520c674cbd033fe53646a8
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoFurther deprecate addAugmentation()
Robert Varga [Thu, 23 Apr 2020 10:31:54 +0000 (12:31 +0200)]
Further deprecate addAugmentation()

We want to remove this method in next major release. Make sure
its deprecated for removal.

JIRA: MDSAL-183
Change-Id: I8d76a1eeab07e9fd40f6d970be391dbf3b26f542
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoRemove AbstractBindingRuntimeContext.toString()
Robert Varga [Thu, 23 Apr 2020 09:08:31 +0000 (11:08 +0200)]
Remove AbstractBindingRuntimeContext.toString()

BindingRuntimeTypes can have a huge string representation, which
hurts when combined with a subclass of it being present in OSGi SR
and bundle-diag printing out services.

Change-Id: I38a95c6283454930674f5d6311829d7450559f0c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoUpdate BindingRuntime{Context,Generator,Types}
Robert Varga [Wed, 22 Apr 2020 22:13:54 +0000 (00:13 +0200)]
Update BindingRuntime{Context,Generator,Types}

These interfaces should be operating on EffectiveModelContext to
provide smooth transition to downstreams. Fix that, along with
implementation and tests.

JIRA: MDSAL-435
Change-Id: Idfb155984d1261203d225c8293189941d5d345e9
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoReduce use of BaseTemplate.getterMethodName()
Robert Varga [Wed, 22 Apr 2020 12:24:55 +0000 (14:24 +0200)]
Reduce use of BaseTemplate.getterMethodName()

We are using BuilderGeneratedProperty in Builder(Impl)Template,
and this class has access to the getter method. We therefore do
not need to construct the getter name, but rather can access it
directly.

Change-Id: I1b61c347d2919acf763d1f7d11ca9471b8a25f0f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoDeprecate misnamed FooBuilder.addAugmentation()
Robert Varga [Tue, 21 Apr 2020 09:26:47 +0000 (11:26 +0200)]
Deprecate misnamed FooBuilder.addAugmentation()

Add explicit documentation to generated methods and deprecate
the two-argument addAugmetation() variant. Steer users towards
the one-argument variant or removeAugmentation().

JIRA: MDSAL-183
Change-Id: I496cfa542cb1f35cec975cd8288ef79e2b38fba6
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoClean up GeneratedProperty use
Robert Varga [Wed, 22 Apr 2020 10:25:20 +0000 (12:25 +0200)]
Clean up GeneratedProperty use

Previous patch made a bit of a mess in GeneratedProperty. Clean this
up by creating a dedicated BuilderGeneratedProperty to hold the
properties created in java-api-generator.

Also add a few dedicated tests to ensure generated builders what
they are supposed to do.

JIRA: MDSAL-451
Change-Id: I594475019a997277560f77d4ef51144f2b281ffe
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoSquash empty lists/maps
Robert Varga [Tue, 21 Apr 2020 13:11:41 +0000 (15:11 +0200)]
Squash empty lists/maps

Dealing with lists requires us to interfere with what the user
is giving us in builders, effectively creating new mechanics.

This patch adds the model metadata to carry these around, exposing
just how badly broken some binding.model.api construcs are misused.
We do not fix the misuse, but make it slightly worse, but also mark
the mess for future cleanup.

JIRA: MDSAL-451
Change-Id: I43b3ddccff69bec9a4e98b3c8e73aac4679c1d1f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoCentralize non-key property copies
Robert Varga [Tue, 21 Apr 2020 12:44:25 +0000 (14:44 +0200)]
Centralize non-key property copies

AbstractBuilderTemplate can discern between a copied key property
and other properties. Make sure we split the second part into a
separte method, allowing it to be customized.

The immediate benefit here is that we do not end up copying properties
if there are no keys.

JIRA: MDSAL-451
Change-Id: Ic1ba59d12cd65e7e8991345d50dc80db3fc029bf
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoFixup DataObjectCodecContext.createBindingProxy() nullness
Robert Varga [Tue, 21 Apr 2020 09:50:35 +0000 (11:50 +0200)]
Fixup DataObjectCodecContext.createBindingProxy() nullness

This method cannot return a null, nor can anything which ultimately
uses it as its sole return.

Change-Id: Ia7bc32fa050777130a635d3929fbce6da705bb22
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoSquash empty MapNode/UnkeyedListNode objects to null
Robert Varga [Tue, 21 Apr 2020 09:43:55 +0000 (11:43 +0200)]
Squash empty MapNode/UnkeyedListNode objects to null

When we encounter an empty keyed/unkeyed list, we need to treat
it as it were not present. This adjusts the appropriate codecs
to ensure that is the case.

JIRA: MDSAL-452
Change-Id: Iba70207642e014d59a94cc09a69da988ee71c63f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoSimplify builder's addAugmentation() method
Robert Varga [Mon, 20 Apr 2020 23:15:06 +0000 (01:15 +0200)]
Simplify builder's addAugmentation() method

All augmentation already extend DataObject, which really is to say
that Augmentation should be doing the same. This has the benefit
of giving us access to DataContainer.implementedInterface(), which
we can use to add a simplified addAugmentation() method.

JIRA: MDSAL-183
Change-Id: I053a2d23e6bf95e07fa58e4078a37661e6e726a3
Signed-off-by: Michael Vorburger <vorburger@redhat.com>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoRemove explicit UOE throws
Robert Varga [Tue, 21 Apr 2020 05:50:55 +0000 (07:50 +0200)]
Remove explicit UOE throws

Private constructors do not really have to be that defensive.
Remove exception throws and related tests.

Change-Id: I245264a78607d136d92a4c18d68f5d5df17a4832
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoAdd CodeHelper.emptyToNull()
Robert Varga [Mon, 20 Apr 2020 22:30:16 +0000 (00:30 +0200)]
Add CodeHelper.emptyToNull()

We will need to be squashing empty collections to nulls, add
utility methods to do that.

JIRA: MDSAL-451
Change-Id: I28510efc2e10cef6181a9241d52f88c9cfd884e0
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoRemove CodeHelpers.nonNullValue()
Robert Varga [Mon, 20 Apr 2020 22:27:29 +0000 (00:27 +0200)]
Remove CodeHelpers.nonNullValue()

This method is used only with augmentations. Remove it and update
callers to use Objects.requireNonNull() instead.

This removes a source of IAEs in favor of more consistent NPE
as well as trims down a few bytes from builder classes.

Change-Id: I57ee77c19230f57b34bf85eb5e31863f17372437
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoAdd CodeHelper documentation
Robert Varga [Mon, 20 Apr 2020 22:19:33 +0000 (00:19 +0200)]
Add CodeHelper documentation

We are missing documentation for generic method types, add a few
words.

Change-Id: I3c3faa2836f4a6b55283028d04f5528728149bff
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoImprove often-used class imports
Robert Varga [Mon, 20 Apr 2020 18:28:29 +0000 (20:28 +0200)]
Improve often-used class imports

importedName(Class) is slightly slower than importName(JavaTypeName),
hence improve performance by creating a few more often-used constants.

Change-Id: I2af9ad97bc2122a83c26cd247faf15e136bdb768
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoReorder encapsulation checks
Robert Varga [Mon, 20 Apr 2020 18:03:04 +0000 (20:03 +0200)]
Reorder encapsulation checks

Reordering checks provides a small speed up due to fewer checks
being made on average, as we take care of most popular types first.

Change-Id: I0acc2e77007054c7c35ad159d98bb3be1cdabfee
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoCorrect ClassTemplate's check for types
Robert Varga [Mon, 20 Apr 2020 11:51:53 +0000 (13:51 +0200)]
Correct ClassTemplate's check for types

ClassTemplate's checks run against Java Types, which is fine, except
that we should be referencing them through BaseYangTypes, so that we
have the incidental alignment well covered.

Furthermore the checks rely on FQCN, which is potentially slow to
compute, while the new checks rely on plain type equality -- hence
potentially speeding up things and lowering the number of branches.

We also drop a FIXMEs to clarify situation around InstanceIdentifier.

Change-Id: I3328199a8ec56e28d58582c076f1344fb4459103
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoCorrect UnionTemplate's check for types
Robert Varga [Mon, 20 Apr 2020 11:35:50 +0000 (13:35 +0200)]
Correct UnionTemplate's check for types

UnionTemplate's checks run against Java Types, which is fine, except
that we should be referencing them through BaseYangTypes, so that we
have the incidental alignment well covered.

Change-Id: I5be3708d80ee5c376178df14dbc76333a01e06ff
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoMove BaseYangtypes to binding.model.util
Robert Varga [Mon, 20 Apr 2020 11:31:37 +0000 (13:31 +0200)]
Move BaseYangtypes to binding.model.util

These constants sit between Types and BindingTypes, hence they should
not be in a completely different package.

Change-Id: If9894102e27b8dd3568493ef615c40328d213ca9
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoSplit out BaseYangTypesProvider
Robert Varga [Mon, 20 Apr 2020 11:18:09 +0000 (13:18 +0200)]
Split out BaseYangTypesProvider

BaseYangTypes is related to binding.model.api, while the type provider
is related to binding.generator.api. Split out
BaseYangTypes.BASE_YANG_TYPES_PROVIDER as a BaseYangTypesProvider.INSTANCE,
separating these two concerns.

Change-Id: I61dc6ed7f39ba233017bb9938eaab151a7c41e3e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoCleanup java-api-generator Constants
Robert Varga [Mon, 20 Apr 2020 11:05:11 +0000 (13:05 +0200)]
Cleanup java-api-generator Constants

We have a number of useless constants here, remove them along with
the not-so-useful test.

Change-Id: I71ac7da20a035a7274d8e25017e2e937c1fefcf1
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoTag TypeObjects which wrap a value with ScalarTypeObject
Robert Varga [Tue, 24 Mar 2020 15:58:29 +0000 (16:58 +0100)]
Tag TypeObjects which wrap a value with ScalarTypeObject

Capturing this type of objects has a nice side-effect of being
able to specialize code generation. It is furthermore useful
for providing a common definition of getValue() method.

This is an unfortunate side-effect of changing the API
mapping for boolean typedefs: the accessor changes from isValue()
to getValue().

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