yangtools.git
2 weeks agoDefine getImplementedInterface name in BindingMapping
Robert Varga [Fri, 16 Nov 2018 06:34:37 +0000 (07:34 +0100)]
Define getImplementedInterface name in BindingMapping

This moves the definition from LazyDataObject to a common place,
so we have one place which defines it. Also remove unused Throwable
declaration.

Change-Id: Icfbc861419fca3b207e9aebfc2b00ddf8a1fc38f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoCache mismatched augmentations
Robert Varga [Tue, 13 Nov 2018 14:13:41 +0000 (15:13 +0100)]
Cache mismatched augmentations

Address a FIXME around caching of mismatched augmentations, as it
seems openflowplugin is doing this on purpose.

The cache is expected to be needed infrequently in terms of associated
objects as well as modified infrequently, hence we use a space-efficient
ImmutableMap.

JIRA: MDSAL-388
Change-Id: Id86d8c713ee1014d9d4867558032ba3ccd51fc45
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoGenerate nonnull default wrappers for list getters
Robert Varga [Thu, 8 Nov 2018 15:27:49 +0000 (16:27 +0100)]
Generate nonnull default wrappers for list getters

This adds the knowledge about default methods to BindingMapping,
templates and CodeHelpers, so that whenever we emit a List accessor
(getFoo) we also emit a corresponding nonnull accessor (nonnullFoo).

The nonnull accessor is a default method, which takes invokes
getFoo() and runs it through CodeHelper.nonnull(), which turns
nulls into empty lists.

JIRA: MDSAL-18
Change-Id: Ic4fc80aa071b7d5b93bf49d1de44855f4bd820f2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoMove getter method naming to BindingMapping
Robert Varga [Thu, 8 Nov 2018 11:18:17 +0000 (12:18 +0100)]
Move getter method naming to BindingMapping

Both BaseTemplate.isAccessor() and a chunk of
AbstractTypeGenerator.getterMethodName() should actually be held
in BindingMapping, so we retain consistent naming of things.

This patch introduces the constants necessary for this to work
and migrates the code there. This cascades to various other places,
like mdsal-binding-dom-codec, where we extract copy&pasted code
to a common utility class.

JIRA: MDSAL-18
Change-Id: I5fb285f00658ce81f60890d03844b51e19bd4a40
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoRevert "Add DataObjectUtils"
Robert Varga [Thu, 8 Nov 2018 09:49:32 +0000 (10:49 +0100)]
Revert "Add DataObjectUtils"

This reverts commit 865a75b8201cd92346e60a48b22c13fd09eb2ab0 in
preparation for a more proper solution.

JIRA: MDSAL-18
Change-Id: I96b89867e5a324327eb77cdde018700456fc4bbc
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoPrevent NPE from being propagated from LazyDataObject
Robert Varga [Thu, 8 Nov 2018 14:09:49 +0000 (15:09 +0100)]
Prevent NPE from being propagated from LazyDataObject

Rather than incurring a NPE when we fail to find proper
NodeContextSupplier, add an explicit verifyNotNull() check to
throw a more explanatory VerifyException.

Change-Id: Ieed6d050bccfe482f69152b33a9a84bbe20037c2
JIRA: MDSAL-18
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoRefactor DataObjectCodecContext.getBindingChildValue()
Robert Varga [Thu, 8 Nov 2018 14:01:07 +0000 (15:01 +0100)]
Refactor DataObjectCodecContext.getBindingChildValue()

Using instanceof checks is an OOP anti-pattern, which we do not
want here anyways. Generalize NodeCodecContext.defaultObject()
to return null by default and refactor decoding to rely on it,
with LeafNodeCodecContext returning whatever it has as a default
value.

Change-Id: I2b58bc7f1a16496cf6bc93fd7a33aec38f864597
JIRA: MDSAL-18
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoBump yangtools to 2.1.3
Robert Varga [Wed, 7 Nov 2018 20:48:17 +0000 (21:48 +0100)]
Bump yangtools to 2.1.3

This adopts yangtools-2.1.3.

Change-Id: I6c67a060fa24d06553c6b6076acfa85f6f35718e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoRework lookup to eliminate the need for checkArgument()
Robert Varga [Wed, 7 Nov 2018 22:03:40 +0000 (23:03 +0100)]
Rework lookup to eliminate the need for checkArgument()

SpotBugs is twitchy around this, let's rework it to make
the precondition unnecessary.

Change-Id: I2083877c1c6b263b6c9d8368cd8f3fb746bbc6d0
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoAdd DataObjectUtils
Robert Varga [Fri, 19 Oct 2018 12:42:06 +0000 (14:42 +0200)]
Add DataObjectUtils

Add DataObjectUtils.nullToEmpty(List), which is useful when dealing
with nullable lists being returned from binding DTOs. This also moves
mdsal.binding.spec.util to yang-binding, so the utilities are
available to all model users.

Change-Id: I681c49141b4e880448747a53d749065208f9aca1
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoReduce use of javax.annotation annotations
Robert Varga [Mon, 8 Oct 2018 09:12:50 +0000 (11:12 +0200)]
Reduce use of javax.annotation annotations

The annotations in use have runtime retention, which triggers
generation of import-package for javax.annotation, which is no longer
satisfied with newer JDKs.

Use JDT @Nullable annotation instead. Since @Nullable is TYPE_USE
annotation, this also requires a bit of juggling in JavaFileTemplate
to make it work correctly with types which end up being referenced
via their FQCN.

This still retains javax.annotation.CheckReturnValue, but marks it
for replacement once we decide where to go annotation-wise.

JIRA: MDSAL-372
Change-Id: I792094d3c07162a5f8e6ca82ceea3a75b48c7b6e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoTry harder to acquire class mapping
Robert Varga [Mon, 15 Oct 2018 12:44:48 +0000 (14:44 +0200)]
Try harder to acquire class mapping

We can perform a third try when we failed to load an augmentation
using TCCL by installing the candidate class classloader as the TCCL.

This can help in situations where we are invoked from a context where
the TCCL is not set up to actually see binding classes properly.

JIRA: MDSAL-379
Change-Id: I56d65494cbce32aee0592e3f0799a2bf283e6d17
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoRelax LazyDataObject.augmentations() implementation
Robert Varga [Sat, 13 Oct 2018 09:35:56 +0000 (11:35 +0200)]
Relax LazyDataObject.augmentations() implementation

We use double-checked locking to guard against concurrent
initialization of cachedAugmentations. While this ensures we do
not do the same work twice, it is a bit costly for the typical
case when the augmentations field is accessed once.

During the first call, we perform:
- a volatile read
- a lock acquire
- a volatile read
- compute the value (exclusive)
- a volatile write
- a lock release

Rather than doing that, allow the value to be computed concurrently
and use compare-and-swap to initialize it. Hence for the first call
we perform:
- a volatile read
- compute the value (concurrent)
- a compare-and-set

In case of concurrent initialization, all threads will compute
the value, but all except the first one will issue another volatile
read and throw their work away.

JIRA: MDSAL-377
Change-Id: I1dbf9c4e60cf9800720eea31bd9de936b1dae5aa
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoSpeed up DataObjectCodecContext instantiation
Robert Varga [Mon, 15 Oct 2018 10:22:09 +0000 (12:22 +0200)]
Speed up DataObjectCodecContext instantiation

Do not bounce multiple times to bindingClass(), but rather store
it in a local variable. Since we are here, also update other callers
of bindingClass().

Change-Id: Ia093d5dbdff16f6ec17f96c71895cb292eb12862
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoDo not instantiate entrySet when not needed
Robert Varga [Mon, 15 Oct 2018 09:00:12 +0000 (11:00 +0200)]
Do not instantiate entrySet when not needed

reloadAllAugmentations() does not need the key, hence we do not
need to instantiate entrySet(), values() is sufficient.

Change-Id: Ib58b5fac547370709ab916ca5f700bc4b841efb8
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoShorten java.util.Optional reference
Robert Varga [Sun, 14 Oct 2018 00:07:07 +0000 (02:07 +0200)]
Shorten java.util.Optional reference

All of our codebase is using JDK Optionals, hence we need not use
a FQCN.

Change-Id: Ib6b4fba3e8021fce4d238f8db84db32ac5bf746c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoBump versions for 3.0.2-SNAPSHOT
Robert Varga [Sat, 13 Oct 2018 12:55:53 +0000 (14:55 +0200)]
Bump versions for 3.0.2-SNAPSHOT

This starts the next version development.

Change-Id: Ia3e479b1d364d6f92e7ff8405ada398c342227a6
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoBump yangtools to 2.1.2
Robert Varga [Sat, 13 Oct 2018 12:52:30 +0000 (14:52 +0200)]
Bump yangtools to 2.1.2

This propagates the released version.

Change-Id: I404e82dcb0aa6102ef00fb1ee65cbbf7aa8f821a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoOptimize AbstractBuilderTemplate key property sort
Robert Varga [Sat, 13 Oct 2018 08:54:39 +0000 (10:54 +0200)]
Optimize AbstractBuilderTemplate key property sort

Rather than using a lambda for each comparison, create a constant
Comparator and reuse it.

Change-Id: I0b5af97b485f65924adb2de369a69e03027af887
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoOptimize AbstractBuilderTemplate.generateAugmentField()
Robert Varga [Sat, 13 Oct 2018 08:08:42 +0000 (10:08 +0200)]
Optimize AbstractBuilderTemplate.generateAugmentField()

This moves the "private" field to its sole caller, eliminating
the need for a redundant IF. Also cache the importedName result
so we do not make multiple round-trips to cache.

Change-Id: I31bd9ffe51e6820d6b4b22f489ed0fbaf9dd1192
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoUse ArrayList.sort() instead of Collections.sort()
Robert Varga [Sat, 13 Oct 2018 08:38:32 +0000 (10:38 +0200)]
Use ArrayList.sort() instead of Collections.sort()

We do not need Collections, as we have Java 8 and hence can
directly use List.sort(). This has the side-effect of
short-circuiting to ArrayList's implementation.

Change-Id: If978265242275014c586fcf92d96d5ba09bb7bca
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoBuilder should acquire augmentations only once
Robert Varga [Sat, 13 Oct 2018 08:28:34 +0000 (10:28 +0200)]
Builder should acquire augmentations only once

While generated DataObjects have this method simple, LazyDataObject
constructs the map lazily and caches it -- hence additional access
is forcing an additional volatile read.

Therefore instead of invoking augmentations() twice, store its
result in a local variable and reuse that.

Change-Id: Ifbe2002bb7edbd253d65b5bdc1e53c4d687bed32
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoBump yangtools to 2.1.2-SNAPSHOT
Robert Varga [Fri, 12 Oct 2018 12:31:54 +0000 (14:31 +0200)]
Bump yangtools to 2.1.2-SNAPSHOT

Preparatory patch to get validation of upcoming yangtools release.

Change-Id: Iaf6f4371216a85639d8f12089d69ca7c94b8822a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoEnable spotbugs in mdsal-binding-dom-codec
Robert Varga [Thu, 11 Oct 2018 19:13:53 +0000 (21:13 +0200)]
Enable spotbugs in mdsal-binding-dom-codec

This fixes up the issues reported and flips enforcement to on.

Change-Id: I7e5b5c20a8b9f1ce3de42aac512ac3b31779821f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoEnable spotbugs in mdsal-binding-dom-codec-osgi
Robert Varga [Thu, 11 Oct 2018 18:57:37 +0000 (20:57 +0200)]
Enable spotbugs in mdsal-binding-dom-codec-osgi

This fixes up the issues reported and flips enforcement to on.

Change-Id: Ia58b4f08fb1b594446cec458268586db8df8d62c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoEnable spotbugs in yang-binding
Robert Varga [Thu, 11 Oct 2018 18:49:01 +0000 (20:49 +0200)]
Enable spotbugs in yang-binding

This fixes up the issues reported and flips enforcement to on.

Change-Id: I2e9b0c82af063d322428216be40e7562959f0824
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoEnable spotbugs in mdsal-binding-spec-util
Robert Varga [Thu, 11 Oct 2018 18:31:02 +0000 (20:31 +0200)]
Enable spotbugs in mdsal-binding-spec-util

This fixes up the issues reported and flips enforcement to on.

Change-Id: I24d7722143253cc4c16cfac6f6d38976741ee6b2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoFix checkstyle in mdsal-binding-java-api-generator
Robert Varga [Thu, 11 Oct 2018 15:38:26 +0000 (17:38 +0200)]
Fix checkstyle in mdsal-binding-java-api-generator

This fixes violations and flips enforcement on.

Change-Id: I08d96c67c0d072655529ed9890b85ca1c4e7059f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoEnable checkstyle in mdsal-binding-spec-util
Robert Varga [Thu, 11 Oct 2018 12:13:39 +0000 (14:13 +0200)]
Enable checkstyle in mdsal-binding-spec-util

This flips enforcement on.

Change-Id: I8e3db62a29d21fe727b1c31b0c3982b42eb58444
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoRemove redundant string operations
Stephen Kitt [Thu, 11 Oct 2018 09:58:14 +0000 (11:58 +0200)]
Remove redundant string operations

* use StringBuilder::append to extract substrings directly;
* split combined append/concatenation into multiple append calls;
* use "" instead of new String();
* remove a couple of unnecessary toString() calls.

Change-Id: If09efe90d756c3b1faf30c27eb94d514593a4861
Signed-off-by: Stephen Kitt <skitt@redhat.com>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoSeparate out builder/impl copy generators
Robert Varga [Wed, 10 Oct 2018 17:43:41 +0000 (19:43 +0200)]
Separate out builder/impl copy generators

Builders are taking an immutable implementation of target type,
hence for list entries they can rely on the key to be present and
do not have to check it. Implementations need to account
for the builder key being set to null, hence they need to
instantiate the key themselves.

This patch separates the two code paths, so both cases are properly
expressed in the object hierarchy. This allows us to simplify
the abstract template, removing weird boolean-based decisions.

We also promote implementation constructor to package-visible, which
allows javac to skip generation of synthetic accessor.

We further optimize the template output by capturing importedNames
when they are reused -- leading to xtend generating cleaner Java code.

JIRA: MDSAL-374
Change-Id: I3274e35780b8e6a56d470caf80459e9e115a5374
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoSort out BindingCodecTreeNode.streamChild() nullness
Robert Varga [Mon, 8 Oct 2018 17:52:21 +0000 (19:52 +0200)]
Sort out BindingCodecTreeNode.streamChild() nullness

This method really cannot return null, which means there is some
dead code in DataContainerCodecContext. Remove the FIXME and kill
the superfluous code.

Change-Id: I7ee3e86b10e1ad2ccc5cfaa4aad228654b1445c5
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoFixup null warnings reported by eclipse
Robert Varga [Mon, 8 Oct 2018 17:29:20 +0000 (19:29 +0200)]
Fixup null warnings reported by eclipse

JDT annotations are flushing out some lazyness in tests, fix that
up by throwing UnsupportedOperationExceptions and proper mocking
in most places.

Change-Id: I2374a368e4a361c0e58d61e4b563f98036b4c540
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoMigrate mdsal-binding-dom-codec to JDT annotations
Robert Varga [Mon, 8 Oct 2018 13:12:08 +0000 (15:12 +0200)]
Migrate mdsal-binding-dom-codec to JDT annotations

This removes the use of javax.annotation nullable annotations
to remove import-package.

Change-Id: I436b9f0d0b3c835fce9da9e4c99e4dad273f9bbe
JIRA: MDSAL-373
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoRemove unneeded dependencies
Robert Varga [Tue, 9 Oct 2018 14:49:10 +0000 (16:49 +0200)]
Remove unneeded dependencies

odlparent is declaring test dependencies for us, and also
declares osg.core correctly. yangtools also declares test utils
with proper scope, hence we can remove those overrides, too.

Change-Id: I7c4f18313b32123043242b36b573263afde40962
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoUse dom-parent internally
Robert Varga [Tue, 9 Oct 2018 14:27:25 +0000 (16:27 +0200)]
Use dom-parent internally

dom-parent is essentially an mdsal-level bundle-parent, as it
inherits from bundle-parent and brings in dependencyManagement
we (and our downstreams) need.

Reuse this parent pom across the project, so that we do not have
to repeat dependencyManagement over and over again.

Change-Id: I0575ef37d2eedcd7cda0c69d6dcec3a65af64cf3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoRemove use of Class.newInstance()
Robert Varga [Tue, 9 Oct 2018 13:12:34 +0000 (15:12 +0200)]
Remove use of Class.newInstance()

This method has been deprecated in JDK9+, use its simple replacement
instead.

Change-Id: I1f7ed3babd4b339d1b1a9cc396b901e7886c985a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoMigrate mdsal-binding-dom-adapter to JDT annotations
Robert Varga [Mon, 8 Oct 2018 13:29:40 +0000 (15:29 +0200)]
Migrate mdsal-binding-dom-adapter to JDT annotations

This removes the use of javax.annotation nullable annotations
to remove import-package.

Change-Id: I220ed55636d3a4a4bc3e4c39a6169541f89cf283
JIRA: MDSAL-373
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoSuppress javax.annotation imports in yang-binding
Robert Varga [Mon, 8 Oct 2018 16:24:54 +0000 (18:24 +0200)]
Suppress javax.annotation imports in yang-binding

We do not want to generate references to javax.annotation, remove
it from imports.

Change-Id: I2edffd282db530c6052b3541a553d52e33c3fd78
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoMake sure we compare key members via their property name
Robert Varga [Thu, 4 Oct 2018 15:17:42 +0000 (17:17 +0200)]
Make sure we compare key members via their property name

As it turns out, simple comparison ignoring cases does not correctly
work if the schema is using CamelCase. We need to do the hard work of
deriving Binding property name and sort on that to be consistent with
what the codegen does.

JIRA: MDSAL-355
Change-Id: I34cdb032fbdeb093e2973b91c5011e302e6280bc
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoBump versions to 3.0.1-SNAPSHOT
Robert Varga [Fri, 5 Oct 2018 06:31:53 +0000 (08:31 +0200)]
Bump versions to 3.0.1-SNAPSHOT

This starts the next development cycle.

Change-Id: I1f1e0381f1abf9ae89c2c17ca3eb6ead58ce201a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoDrop Xtend Equinox Common overrides
Stephen Kitt [Thu, 4 Oct 2018 14:52:06 +0000 (16:52 +0200)]
Drop Xtend Equinox Common overrides

These are no longer necessary and make it harder than it should be to
upgrade Xtend in odlparent.

Change-Id: I3196ad374895e8e96f71f79529dde578913589ab
Signed-off-by: Stephen Kitt <skitt@redhat.com>
2 weeks agoBump 2.7.0-SNAPSHOT to 3.0.0-SNAPSHOT
Robert Varga [Thu, 4 Oct 2018 09:39:28 +0000 (11:39 +0200)]
Bump 2.7.0-SNAPSHOT to 3.0.0-SNAPSHOT

We are just about ready for release, with all significant external
versions harmonized to 2.7.0-SNAPSHOT. Switch this to 3.0.0-SNAPSHOT
in preparation for mdsal-3.0.0.

Change-Id: Ia9a6e8e9714e6a75eba479a4e5daf56ab5520a89
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoCleanup binding spec artifact versions
Robert Varga [Thu, 4 Oct 2018 09:26:30 +0000 (11:26 +0200)]
Cleanup binding spec artifact versions

This bumps binding specification and related artifacts to version
1.0.0-SNAPSHOT.

Change-Id: Ia9fa86179e13eb5ec4a00a519ebba56311722a64
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoHarmonize parent versions with MD-SAL version
Robert Varga [Thu, 4 Oct 2018 08:38:58 +0000 (10:38 +0200)]
Harmonize parent versions with MD-SAL version

We want to keep entrypoints at the same versions -- i.e.
mdsal-artifacts and all parents, so users have an easier time
figuring out inconsistencies.

Change-Id: I014ef6db9649a9f8b42a2bf5ab76776a8816c467
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoBump yangtools to 2.1.1
Robert Varga [Wed, 3 Oct 2018 12:50:37 +0000 (14:50 +0200)]
Bump yangtools to 2.1.1

This bumps yangtools to 2.1.1 to version-converge with odlparent-4.0.2

Change-Id: I6cbbb0bfe9029551d3ac69e6f56283e02694aae0
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoRemove unused import
Robert Varga [Mon, 1 Oct 2018 06:01:21 +0000 (08:01 +0200)]
Remove unused import

BaseTemplate no longer uses GTO, remove the import.

Change-Id: I43259e05f251ea87083abd382f7e727d4ffd9624
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoFix KeyedListAction serialization
Jakub Tóth [Fri, 14 Sep 2018 08:44:14 +0000 (10:44 +0200)]
Fix KeyedListAction serialization

SchemaRootCodecContext needs to understand both Action and
KeyedListAction, as their parameterizations differ.

JIRA: MDSAL-371
Change-Id: I405a73b1a8ca8801ae1786be704cefe674c5fb72
Signed-off-by: Jakub Tóth <jakub.toth@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoBump odlparent to 4.0.2
Robert Varga [Sat, 29 Sep 2018 07:49:20 +0000 (09:49 +0200)]
Bump odlparent to 4.0.2

This bumps the versions to receive updates of plugins.

Change-Id: If5c9346d221d5c4af6e4357b0c0847bc88465dbe
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoBump to yangtools-2.1.0
Robert Varga [Wed, 19 Sep 2018 12:15:10 +0000 (14:15 +0200)]
Bump to yangtools-2.1.0

This bumps from snapshot versions to release versions, bringing
us closer to mdsal-3.0.0.

Change-Id: I7cbc43f8814386fd5570ce37c3b96faf2c1f9a91
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoSwitch to odlparent-4.0.0
Robert Varga [Thu, 13 Sep 2018 17:35:42 +0000 (19:35 +0200)]
Switch to odlparent-4.0.0

Now that odlparent-4.0.0 has been released, we can nail down that
version, getting us closer to our release.

Change-Id: I4669b27c013bd30101db0f45e0ba866da1dbb26e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoChange InstanceIdentifier serialization format
Robert Varga [Sat, 11 Aug 2018 15:52:07 +0000 (17:52 +0200)]
Change InstanceIdentifier serialization format

This patch uses serialization proxy in order to get rid of use
of reflection in InstanceIdentifier serialization.

Change-Id: Ic146a80cba0e6e3aeaab75e805c6ca243fe047f4
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoRemove deprecated InstanceIdentifier methods
Robert Varga [Sat, 11 Aug 2018 15:00:31 +0000 (17:00 +0200)]
Remove deprecated InstanceIdentifier methods

This removes all deprecated methods in InstanceIdentifier,
slimming each instance down a bit.

Change-Id: I62cfaa9d4ce8f9672355822c3fb5d92f5c833249
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoRemove deprecated BindingReflections methods
Robert Varga [Sat, 11 Aug 2018 14:54:35 +0000 (16:54 +0200)]
Remove deprecated BindingReflections methods

These methods have their replacements directly in YangModuleInfo,
remove them.

Change-Id: Ic38166ec0b94a74e78d6cedcde9358adae7b1fe0
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoMigrate to java.util.function.Function
Robert Varga [Wed, 8 Aug 2018 21:09:27 +0000 (23:09 +0200)]
Migrate to java.util.function.Function

Migrate to use of Java Function instead of Guava.

Change-Id: I11245ef7eec9df00141f5af0fc6e91f510e5b281
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoMass-migrate to java.util.Optional
Robert Varga [Wed, 8 Aug 2018 20:44:26 +0000 (22:44 +0200)]
Mass-migrate to java.util.Optional

This patch migrates from Guava's Optional to Java Optional, no questions
asked.

Change-Id: If91efb662af08434c584549d86ced61d9a72870a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoBump odlparent/yangtools versions to 4.0.0/2.1.0-SNAPSHOT
Robert Varga [Mon, 6 Aug 2018 13:25:02 +0000 (15:25 +0200)]
Bump odlparent/yangtools versions to 4.0.0/2.1.0-SNAPSHOT

This patch snapshot-integrates odlparent/yangtools until
so we can test downstreams more easily.

Change-Id: I0f85ce833bab648ebdfa1969fa016d4880bd8287
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoFixup javassist class use
Robert Varga [Fri, 10 Aug 2018 08:51:45 +0000 (10:51 +0200)]
Fixup javassist class use

We need to cast the returned class, as the Javassist API no longer
does so.

Change-Id: Ib19477ece9e76b735285df3b553ca9504579f8c9
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoBump versions by x.(y+1).z for next dev cycle
Anil Belur [Thu, 9 Aug 2018 14:16:56 +0000 (19:46 +0530)]
Bump versions by x.(y+1).z for next dev cycle

Change-Id: I81629ad260fcf40f4b1a054c6bbc7891b4546b2a
Signed-off-by: Anil Belur <abelur@linuxfoundation.org>
2 weeks agoBump versions by x.(y+1).z for next dev cycle
Anil Belur [Thu, 9 Aug 2018 12:40:15 +0000 (18:10 +0530)]
Bump versions by x.(y+1).z for next dev cycle

Change-Id: I783427aabbf6d3e421f14912e4bdfd971064f7d7
Signed-off-by: Anil Belur <abelur@linuxfoundation.org>
2 weeks agoBump yangtools to 2.0.10
Robert Varga [Mon, 6 Aug 2018 15:49:05 +0000 (17:49 +0200)]
Bump yangtools to 2.0.10

This fixes an issue with actions, hence we need it in Fluorine.

Change-Id: I557bc824fdbe3d957a36caada17428e10fd2ab24
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoClean up BaseTemplate
Robert Varga [Fri, 27 Jul 2018 22:08:51 +0000 (00:08 +0200)]
Clean up BaseTemplate

Move logic dispatch methods into JavaFileTemplate, where we can
write the same thing in Java. Also makes a few methods static.

Change-Id: I3ac8c16b5378d0420dcb37c31265f06a5f7770a2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoRework inlined union generation
Robert Varga [Fri, 27 Jul 2018 19:32:04 +0000 (21:32 +0200)]
Rework inlined union generation

Unions internal to a leaf union end up being incompletely generated,
as they lack stringValue(), hashCode(), equals() and do not correctly
bind to its enclosing builder -- leading to a generated code not being
compilable.

There are multiple issues here, all of which are addressed in this patch:
- hashCode/equals properties are created in the wrong place
- property return type is set to the builder, not its product
- union builder type is not set as a union
- builders for nested types are not correctly emitted
- Class/InterfaceTemplate use different logic to emit the inner classes

JIRA: MDSAL-320
Change-Id: I626fb4ac42ae6528bc98b809bc33756e8daa08b9
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoSimplify code using Java 8 features
Stephen Kitt [Fri, 27 Jul 2018 15:26:11 +0000 (17:26 +0200)]
Simplify code using Java 8 features

* lambda expressions
* method references
* ThreadLocal::withInitial
* Comparator::comparing
* List::sort
* Map::computeIfAbsent

Change-Id: Ia1eee88a49fe3cb7f07bd90cdaa481ecd5c10003
Signed-off-by: Stephen Kitt <skitt@redhat.com>
2 weeks agoBump yangtools to 2.0.9
Robert Varga [Fri, 27 Jul 2018 12:10:13 +0000 (14:10 +0200)]
Bump yangtools to 2.0.9

This patch bumps yangtools to latest release.

Change-Id: I61e0f6549cf21b56bfc5b9c96860b5492c719311
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoFix actions in keyed lists
Robert Varga [Fri, 27 Jul 2018 01:10:33 +0000 (03:10 +0200)]
Fix actions in keyed lists

When we encounter a keyed list we end up generating an action for
the key, not for the list, which leads to a compilation error.

Change-Id: Iad9a5b449778704a3209d43011060f4a7942b9a6
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoDo not confuse nested type with available types
Robert Varga [Thu, 26 Jul 2018 18:42:56 +0000 (20:42 +0200)]
Do not confuse nested type with available types

Nested types imply the same package, which is not acurate in this
context. Fix this by populating conflictingNames and mark it for
possible future improvement.

Change-Id: Icca087257eaf0c63b9a44204368dd48552da01a4
JIRA: MDSAL-365
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoFixup BuilderTemplate decomposition
Robert Varga [Thu, 26 Jul 2018 09:34:33 +0000 (11:34 +0200)]
Fixup BuilderTemplate decomposition

This patch reworks BuilderTemplate to correctly represent its
generated class layout into GeneratedType hierarchy. This eliminates
a special-case hack in AbstractJavaGeneratedType and fixes overlap
between inherited and imported classes.

JIRA: MDSAL-365
Change-Id: I10affa8fc6e6b6447024744473e95ac1e600cd6b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoBump to odlparent 3.1.3
Stephen Kitt [Wed, 18 Jul 2018 16:06:40 +0000 (18:06 +0200)]
Bump to odlparent 3.1.3

Change-Id: I032f846fcd8fb037dde7931caa712b3a24eb41b7
Signed-off-by: Stephen Kitt <skitt@redhat.com>
2 weeks agoChange DOM invokeRpc to FluentFuture
Tom Pantelis [Tue, 24 Jul 2018 00:05:19 +0000 (20:05 -0400)]
Change DOM invokeRpc to FluentFuture

CheckedFuture is deprecated.

This breaks the controller - corresppnding patch is
https://git.opendaylight.org/gerrit/#/c/74366/

Change-Id: I08f396b872699512171a24732d9473ca96b89778
Signed-off-by: Tom Pantelis <tompantelis@gmail.com>
2 weeks agoMove BindingMapping
Robert Varga [Mon, 23 Jul 2018 22:13:00 +0000 (00:13 +0200)]
Move BindingMapping

This class is used only internally in md-sal, move it
mdsal-binding-spec-util, as it is not part of the spec (as viewed
by users).

This requires creating of RegexPatterns, which is a shared component
to ensure consistency.

Change-Id: If572bb97643f28354ba5c69f0addaf0ee02388d4
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoRemove BindingReflections from yang-binding
Robert Varga [Mon, 23 Jul 2018 15:41:19 +0000 (17:41 +0200)]
Remove BindingReflections from yang-binding

This is a utility reflection class, it should not be present in
yang-binding itself. It resides now in mdsal-binding-spec-util.

Change-Id: Ic5ecfb9f94f0199c4fe4be9f50a7f7f2977384da
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoEliminate Union char[] constructor
Robert Varga [Wed, 11 Jul 2018 16:24:41 +0000 (18:24 +0200)]
Eliminate Union char[] constructor

This is a JMX-specific hack, which we no longer need to support,
remove it. This also removes getValue(), which could conflict with
user-specified type.

JIRA: MDSAL-364
Change-Id: If6e97c453beda1499722359080155720c2da1aaa
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoMove BindingReflections to mdsal-binding-spec-util
Robert Varga [Mon, 23 Jul 2018 15:25:34 +0000 (17:25 +0200)]
Move BindingReflections to mdsal-binding-spec-util

This is the first stage of movement: create a copy of the class
and migrate the test suite.

Change-Id: I0d229ccd4277b917c99414dd8ba698f497629ec3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoMove StringValueObjectFactory to mdsal-binding-spec-util
Robert Varga [Mon, 23 Jul 2018 11:18:50 +0000 (13:18 +0200)]
Move StringValueObjectFactory to mdsal-binding-spec-util

This class does not need to reside in yang-binding, move it out
into mdsal-binding-spec-util.

Change-Id: Ib2f178e579ab814cb8c8977d5740d6077d5fa9e5
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoMove DataObjectReadingUtil to mdsal-binding-spec-util
Robert Varga [Mon, 23 Jul 2018 12:32:52 +0000 (14:32 +0200)]
Move DataObjectReadingUtil to mdsal-binding-spec-util

This moves access utility from yang-binding to mdsal-binding-spec-util,
as it has no place in yang-binding.

Change-Id: Ieda67f69da45183dfcd75d7828cc244839b25cde
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoMove NotificationListenerInvoker to mdsal-dom-adapter
Robert Varga [Mon, 23 Jul 2018 12:16:39 +0000 (14:16 +0200)]
Move NotificationListenerInvoker to mdsal-dom-adapter

These classes should not be in yang-binding, as their concern lies
in runtime API realization. Move them to mdsal-dom-adapter.

Change-Id: I5fd470796e9251f6c69a8ca3568bb17ddc0ce5a2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoMove RpcServiceInvoker to mdsal-dom-adapter
Robert Varga [Mon, 23 Jul 2018 10:43:42 +0000 (12:43 +0200)]
Move RpcServiceInvoker to mdsal-dom-adapter

These classes should not be in yang-binding, as their concern lies
in runtime API realization. Move them to mdsal-dom-adapter.

Change-Id: I5640c2f169b6569dcdbc306580768751791fd415
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoAdd NotificationListenerInvoker bridge class
Robert Varga [Mon, 23 Jul 2018 12:13:16 +0000 (14:13 +0200)]
Add NotificationListenerInvoker bridge class

This adds a migration bridge for controller, so we can safely
move NotificationListenerInvoker from yang-binding.

Change-Id: I0ec360a324fb9cb44a886efb99b85916554b437e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoAdd RpcServiceInvoker bridge class
Robert Varga [Mon, 23 Jul 2018 10:35:15 +0000 (12:35 +0200)]
Add RpcServiceInvoker bridge class

This adds a migration bridge for controller, so we can safely
move RpcServiceInvoker from yang-binding.

Change-Id: I6b191fc8cb331d6ceff975e9d5b401b059d02709
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoConvert binding read to java.util.Optional
Tom Pantelis [Thu, 19 Jul 2018 13:32:12 +0000 (09:32 -0400)]
Convert binding read to java.util.Optional

Change-Id: I37e56ae9ea86d7742b0510453163e63ff8f660df
Signed-off-by: Tom Pantelis <tompantelis@gmail.com>
2 weeks agoGenerate stringValue() in union types
Robert Varga [Sun, 15 Jul 2018 22:00:53 +0000 (00:00 +0200)]
Generate stringValue() in union types

We need to vacate getValue() method name, as that may be specified
by user. Create a new stringValue() method, which additionally
contains a String rather a char[].

Change-Id: I43ff685f941c2eb1e05ad47858bebd2caf1db8bd
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoTeach binding-dom-codec about actions
Robert Varga [Thu, 12 Jul 2018 17:32:20 +0000 (19:32 +0200)]
Teach binding-dom-codec about actions

Serialization of actions is slightly different than serialization
of RPCs or notifications. Teach BindingCodecContext how to deal
with them.

Change-Id: Id763d4034af394cf97d5497635f7188d8743fdeb
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoAdd BindingLazyContainerNode
Robert Varga [Fri, 13 Jul 2018 11:16:08 +0000 (13:16 +0200)]
Add BindingLazyContainerNode

In order to cleanly migrate LazySerializedContainerNode from
binding-dom-adapter to codec, we need a baseline in codec.api.

BindingLazyContainerNode provides this baseline interface,
and AbstractBindingLazyContainerNode provides a reference
implementation.

We also improve type safety by requiring ContainerNode instead
of a raw NormalizedNode.

Change-Id: Ic1b7c975c55fb0f06ce094a9d27b767d0a1f3b89
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoLog a message when we are falling back in QName search
Robert Varga [Fri, 13 Jul 2018 12:40:35 +0000 (14:40 +0200)]
Log a message when we are falling back in QName search

Computing the QName should be mostly unneeded, log at debug
reasons for us having to fall back.

Change-Id: Ia0169665612fc2ae8eb31f0d59d93d3ed2261f3f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoSpeed up Action QName/QNameModule getter
Robert Varga [Fri, 13 Jul 2018 12:30:34 +0000 (14:30 +0200)]
Speed up Action QName/QNameModule getter

Action has a QNAME field, hence we can access it directly.

Change-Id: Idcd81f6750cbdce5fd91572c4d29789eafaab2c2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoDeprecate yang.binding.RpcImplementation
Robert Varga [Fri, 13 Jul 2018 10:21:08 +0000 (12:21 +0200)]
Deprecate yang.binding.RpcImplementation

This is an old tagging interface, which is not used anywhere,
probably since we have started running binding RPCs on top
of DOM infrastructure.

Mark it deprecated for now, we will either remove it if it is not
useful or un-deprecate and documented it if we find a use for it.

Change-Id: If4f69c3202113d521a0992b1478247e2614ae523
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoRpcInput/RpcOutput should be DataObjects
Robert Varga [Fri, 13 Jul 2018 09:11:28 +0000 (11:11 +0200)]
RpcInput/RpcOutput should be DataObjects

RPC code already adds DataObject (instead of RpcInput) here, let's
make sure this is captured in the API contract.

Change-Id: Ibd62a28ecda1f598f34ccf085185475a3a16dd58
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoSpeed up dom-codec tests
Robert Varga [Thu, 12 Jul 2018 22:34:33 +0000 (00:34 +0200)]
Speed up dom-codec tests

SchemaContext and BindingRuntimeContext are classloader-invariants,
so we can safely cache them for all tests -- an improvement from
9 to 6 seconds.

Change-Id: Ic0036b4a4c16b6ed7fdbad37b67daeb7833fc962
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoSpeed up RPC prototype lookup
Robert Varga [Wed, 11 Jul 2018 23:32:37 +0000 (01:32 +0200)]
Speed up RPC prototype lookup

Instead of mashing all the RPCs together, lookup the corresponding
module first and only look at that modules' RPCs.

Change-Id: I852931991b2fa5f64ef07ad5bae3808202a24b49
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoAction should not be @NonNullByDefault
Robert Varga [Thu, 12 Jul 2018 16:21:50 +0000 (18:21 +0200)]
Action should not be @NonNullByDefault

Since the codegen does not have the concept of annotation use,
hence we cannot use @NonNullByDefault and generate appropriate
annotations in generated code.

Change-Id: Iacb441208484609e7551ba55de37154a40061424
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoAdd action tests
Robert Varga [Thu, 12 Jul 2018 14:56:51 +0000 (16:56 +0200)]
Add action tests

This adds a very basic test, which uncovered a failure to deal
with actions being multiply-inherited -- and fixes that issue.

Also a test model is added, so higher-layer components can be
tested.

Change-Id: I775341e2860e06f360fd4c6c6f6449e96ed92c64
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoAdd dom-parent
Robert Varga [Mon, 2 Jul 2018 21:45:57 +0000 (23:45 +0200)]
Add dom-parent

Adding yangtools/mdsal declarations without running the plugin
is quite useful across our project and in downstreams.

Create dom-parent to hold exactly that.

Change-Id: I837600ff7ab0b432fd68d86784bab85da01a9ef5
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoGenerate checkers for union member types
Robert Varga [Tue, 3 Jul 2018 16:28:20 +0000 (18:28 +0200)]
Generate checkers for union member types

Update AbstractTypeProvider to propagate restrictions and update
UnionTemplate to take advantage of common methods already present
in BuilderTemplate.

Change-Id: I7e34c3fcb3859db270647ca434ac02658e2b1316
JIRA: MDSAL-360
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoOptimize single-value range checks
Robert Varga [Wed, 4 Jul 2018 13:54:06 +0000 (15:54 +0200)]
Optimize single-value range checks

For 'length 0' we generate a 'length >= 0 && length <= 0' check,
where we can simply use 'length == 0'. Fix that by teaching
the generator that min and max can be equal.

Change-Id: I1334bfcd590db59b18665f6609ee71c48e4646ba
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoFix xtend warnings
Robert Varga [Tue, 3 Jul 2018 15:40:46 +0000 (17:40 +0200)]
Fix xtend warnings

xtend-maven-plugin-2.14.0 flushes out a few more warnings, fix them.

Change-Id: I07bfb4da699ec2c176bebd5b6b92289c0e65b002
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoAllow ipv4-address-no-zone to be parsed
Robert Varga [Thu, 7 Jun 2018 11:50:35 +0000 (13:50 +0200)]
Allow ipv4-address-no-zone to be parsed

Add methods which allow no-zone addresses to be parsed equally
efficiently as ip addresses.

JIRA: BGPCEP-790
Change-Id: Ic119430e3398777addeec2b41ca8e83eaead363b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoRemove maven site configuration
Robert Varga [Mon, 2 Jul 2018 22:16:40 +0000 (00:16 +0200)]
Remove maven site configuration

We are not using maven site, remove its leftovers.

Change-Id: I3321b1564516c9097a9790e9d11bf9edcf619aa5
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoRefactor GeneratorJavaFile
Robert Varga [Wed, 27 Jun 2018 17:06:08 +0000 (19:06 +0200)]
Refactor GeneratorJavaFile

This patch reworks GeneratorJavaFile so that it performs two-step
code generation. This allows us to understand what files are going
to be generated before actually generating them.

For bonus points we have removed a dependency on the ancient
plexus-container-default and made mdsal-binding-java-api-generator
maven-agnostic.

JIRA: MDSAL-350
Change-Id: Ie29865d93cce751a5ca265105a24a24049f4ccdb
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoBump to yangtools 2.0.7
Stephen Kitt [Tue, 26 Jun 2018 16:01:36 +0000 (18:01 +0200)]
Bump to yangtools 2.0.7

Change-Id: Ibf88882e8f5611444e952a73fc2bbcf7e2e1709a
Signed-off-by: Stephen Kitt <skitt@redhat.com>