yangtools.git
3 months agoCorrect YangModuleInfo.getInstance() nullness warning
Robert Varga [Thu, 21 Nov 2019 13:25:04 +0000 (14:25 +0100)]
Correct YangModuleInfo.getInstance() nullness warning

This method is missing a @NonNull, which means we end up issuing
a warning. Fix that up.

JIRA: MDSAL-487
Change-Id: I0870880bceb727b6a820bcdc0fd4177002fb4119
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoImport types being checked
Robert Varga [Mon, 18 Nov 2019 12:44:39 +0000 (13:44 +0100)]
Import types being checked

When we are checking individual component types, we should not
be needing to reference them via the full name. Use imported name
instead.

Change-Id: I728d4790929cb548ef022c3b3b34e6cddc2f5aa3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoAdd Types.isListType(ParameterizedType)
Robert Varga [Mon, 18 Nov 2019 12:16:37 +0000 (13:16 +0100)]
Add Types.isListType(ParameterizedType)

Performing duplicate checks is not efficient, if the caller already
knows the type is parameterized.

Change-Id: I164291490602959d1f5bdd83eb35be7f2b0d0428
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoSpeed up ListsBindingUtils
Robert Varga [Mon, 18 Nov 2019 12:54:42 +0000 (13:54 +0100)]
Speed up ListsBindingUtils

This just uses proper fluent builder pattern instead of a
temporary variable.

Change-Id: I8cdf2cff7c910f5518eb999949f315740fe7c1ca
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoRemove unneeded checkstyle supressions
Robert Varga [Mon, 18 Nov 2019 10:44:11 +0000 (11:44 +0100)]
Remove unneeded checkstyle supressions

Treading carefully and using Class.asSubclass() allows us to
remove raw types/unchecked casts.

Change-Id: Ib7554cc40f0b4f41495405db3b7715e0f4e21cc7
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoBump versions to 5.0.5-SNAPSHOT
Robert Varga [Mon, 4 Nov 2019 09:57:52 +0000 (10:57 +0100)]
Bump versions to 5.0.5-SNAPSHOT

This starts the next development iteration.

Change-Id: Ie74fd03ed815844bf0e74b693f101b6884973172
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoPropagate @NonNull around JavaFileTemplate
Robert Varga [Mon, 21 Oct 2019 20:55:03 +0000 (22:55 +0200)]
Propagate @NonNull around JavaFileTemplate

We really do not tolerate nulls here, add appropriate annotations
to silence Eclipse warnings.

Change-Id: If48ba86523e61ea30874a979a03874f17dc877e7
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoRemove JavaFileTemplate.addImport()
Robert Varga [Mon, 21 Oct 2019 20:49:56 +0000 (22:49 +0200)]
Remove JavaFileTemplate.addImport()

This method is unused, remove it.

Change-Id: Ib8192127845e607a29ed68d8cbc8d9da68757897
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoRemove support for multiple annotations
Robert Varga [Mon, 21 Oct 2019 20:43:43 +0000 (22:43 +0200)]
Remove support for multiple annotations

We are only using a single annotation, hence we can collapse
a for loop into a straight append. Also reduces the need to allocate
arrays (even if JIT will handle that).

Change-Id: I5d226b115c16a91636045031c1ae3870a119e81a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoCache most common importedName(Class) references
Robert Varga [Mon, 21 Oct 2019 18:44:10 +0000 (20:44 +0200)]
Cache most common importedName(Class) references

Going through importedName(Class) incurs some cost to look up
the JavaTypeName in the global cache. There is a number of common
classes we end up using very frequently.

We express these references as JavaTypeName constants, hence
reducing the need for cache lookups in the hot path.

Change-Id: I7f0430f529e82a7d4838ebe2200520d20a5a44a0
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoUse SUPPRESS_WARNINGS reference
Robert Varga [Mon, 21 Oct 2019 19:15:07 +0000 (21:15 +0200)]
Use SUPPRESS_WARNINGS reference

When suppressing warnings, we should use the JavaTypeName constant
available in JavaFileTemplate.

Change-Id: I9b6a46403b67f4411356e2aaf16c758b15430273
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoSpecialize JavaFileTemplate.importedName(Type)
Robert Varga [Mon, 21 Oct 2019 18:46:29 +0000 (20:46 +0200)]
Specialize JavaFileTemplate.importedName(Type)

95% of call sites do not use annotations, hence we specialize
this method and support it through specialized
AbstractJavaGeneratedType.getReferenceString(Type).

This clearly separates the two codepaths and removes superfluous
checks and indirections in both paths.

Change-Id: I17bfef631d446d71147b17146d5b2cf71a8be623
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoRemove an unused import
Robert Varga [Mon, 21 Oct 2019 18:27:24 +0000 (20:27 +0200)]
Remove an unused import

This import was left unused after the previous patch, remove it.

JIRA: MDSAL-487
Change-Id: Ie3fe896c64a1cae5c86095dd98386111dcf17959
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoAdd @NonNull annotation to $YangModuleInfoImpl.qnameOf()
Robert Varga [Mon, 21 Oct 2019 12:44:33 +0000 (14:44 +0200)]
Add @NonNull annotation to $YangModuleInfoImpl.qnameOf()

YangModuleInfoTemplate has a lot of ceremony when we statically
know the types being used by the template. Concentrate imports
into two sets, instantiate them as strings and be done with it.

Since this takes care of most dynamics, making things much easier
and predictable, we can easily add @NonNull annotations as needed.

JIRA: MDSAL-487
Change-Id: Ic9cd4da1002f3edea6f3fb18f9d49e4a377e145b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoUse ImmutableSet in YangModuleInfo
Robert Varga [Mon, 21 Oct 2019 15:23:01 +0000 (17:23 +0200)]
Use ImmutableSet in YangModuleInfo

This allows us to bind to a concrete implementation, improving
performance very slightly.

Change-Id: I2ed60f86ae64895685047d772f31b429aac79d22
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoBump to odlparent-6.0.1/yangtools-4.0.2
Robert Varga [Sun, 20 Oct 2019 08:53:38 +0000 (10:53 +0200)]
Bump to odlparent-6.0.1/yangtools-4.0.2

This picks up latest upgrades and fixes.

Change-Id: Ib6970d280f73b149e993dbefee29386ccca9ad0a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoFix bug5882 test case
Robert Varga [Sat, 19 Oct 2019 10:18:54 +0000 (12:18 +0200)]
Fix bug5882 test case

This test case uses illegal duplicate leaves, fix that up.

Change-Id: I3330fafb11b798ab74f9a64b04f4bff8d82b2ce6
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoFix invalid augmentations
Robert Varga [Sat, 19 Oct 2019 12:43:00 +0000 (14:43 +0200)]
Fix invalid augmentations

choice/case structures are collapsed to their parent data tree
node, hence it is invalid to define (in same namespace) the equivalent
of:

container {
  leaf foo { type string; }
  choice some {
    case foo {
      leaf foo { type string; }
    }
  }
}

Fix up the testing model.

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

3 months agoAdd JavaTypeNames for annotation types
Robert Varga [Fri, 18 Oct 2019 11:37:00 +0000 (13:37 +0200)]
Add JavaTypeNames for annotation types

We tend to use these quite heavily and each access goes through
the type cache to acquire the JavaTypeName. We can speed things up
a bit by having constants for these annotations.

Change-Id: Id78c92e6f7cca6ecfde85cbe9b986a988acfc9e1
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoMore nullable annotations
Robert Varga [Tue, 15 Oct 2019 15:28:02 +0000 (17:28 +0200)]
More nullable annotations

This adds a few nullable annotations so eclipse is happier.

Change-Id: I7ce1bb366724413243bdeebc915e5f6978989e9f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoMake Builders sensitive to @Deprecated annotations
Robert Varga [Sat, 12 Oct 2019 13:54:37 +0000 (15:54 +0200)]
Make Builders sensitive to @Deprecated annotations

When we are generating a builder for a deprecated type, we need to
consider how it deals with deprecated elements.

There are two scenarios here:

1) status=deprecated -> @Deprecated
In this case it is fair game to produce data, hence the builder
is not deprecated and therefore has @SuppressWarnings("deprecation")

2) status=obsolete -> @Deprecated(forRemoval = true)
In this case the data should not be produced at all, hence
the builder needs to be @Deprecated(forRemoval), too.

We recognize both these conditions and act accordingly. We misue
bug-586 test case to hijack compilation testing.

JIRA: MDSAL-485
Change-Id: I9d08116615cf8c5bdb6a8f4977c9810686618cda
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoCleanup YangModuleInfoTemplate
Robert Varga [Tue, 15 Oct 2019 10:32:16 +0000 (12:32 +0200)]
Cleanup YangModuleInfoTemplate

generateModelProvider() returns a string, use the appropriate
template syntax. Also use Map.putIfAbsent() instead of
containsKey()/put() checks.

Change-Id: I48faccd7c87f2ffff51b30d9df04c5cb613df184
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoFix boxing warnings
Robert Varga [Mon, 14 Oct 2019 10:52:01 +0000 (12:52 +0200)]
Fix boxing warnings

Use Boolean.TRUE to fix a warning.

Change-Id: Iff20fe6af6d53351a560f54bed7d0fb426a29fd6
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoRemove unused field from BuilderGeneratorTest
Robert Varga [Mon, 14 Oct 2019 10:50:39 +0000 (12:50 +0200)]
Remove unused field from BuilderGeneratorTest

We're not using properties, remove the string constant.

Change-Id: If77cac4f65d4e1df54dca30f8ce7e26be6108260
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoFix nullness warnings in GeneratorJavaFileTest
Robert Varga [Mon, 14 Oct 2019 10:49:20 +0000 (12:49 +0200)]
Fix nullness warnings in GeneratorJavaFileTest

Add a simple @NonNullByDefault annotation to utility method to
eliminate some nullness noise.

Change-Id: I41d32f5cf2bbae06c6c82127590c08c5536dc86a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoBump versions to 5.0.4-SNAPSHOT
Robert Varga [Fri, 11 Oct 2019 12:57:55 +0000 (14:57 +0200)]
Bump versions to 5.0.4-SNAPSHOT

This starts the next development iteration.

Change-Id: I1359a57ac5409b62d3c1b61d2b166b338be01c62
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoMake yang-binding an automatic module
Robert Varga [Thu, 10 Oct 2019 07:37:09 +0000 (09:37 +0200)]
Make yang-binding an automatic module

This is an API component and while it will need to see some
further movement, we should make it an automatic module. As a
side-effect, this fixes javadoc lookup errors we were seeing
in downstream automatic modules.

Change-Id: I3448918da8673f6ee98511265bda7f3b6659c2a1
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoBump versions to 5.0.3-SNAPSHOT
Robert Varga [Wed, 9 Oct 2019 07:58:29 +0000 (09:58 +0200)]
Bump versions to 5.0.3-SNAPSHOT

This starts the next development iteration.

Change-Id: I8216eb6e8172171ba64f85082c2c1a76ed2dc212
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoSquash Parameterized types in javadoc references
Robert Varga [Wed, 9 Oct 2019 05:50:42 +0000 (07:50 +0200)]
Squash Parameterized types in javadoc references

When we are making a reference to a method, any arguments that
are parameterized (such as Class<?>) need to be squashed to their
raw type (such as Class).

JIRA: MDSAL-483
Change-Id: I0d8b596e17ec594a67fdde6f5fc17219aac99a3d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoBump versions to 5.0.2-SNAPSHOT
Robert Varga [Wed, 2 Oct 2019 13:01:17 +0000 (15:01 +0200)]
Bump versions to 5.0.2-SNAPSHOT

This starts the next development iteration.

Change-Id: Ib38d9891d20f92db893372bd78e8c491123ae98e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoBump yangtools to 4.0.1
Robert Varga [Wed, 2 Oct 2019 11:22:45 +0000 (13:22 +0200)]
Bump yangtools to 4.0.1

This bumps yangtools to 4.0.1 to pick up Uint64 fix. Also fixes
AbstractDOMStoreTreeChangePublisherTest to not muck in
AbstractRegistration internals.

Change-Id: I2d59eb48a42f2b9d1818c8403f6f443fc47d6e1a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoBump versions to 4.0.1-SNAPSHOT
Robert Varga [Tue, 1 Oct 2019 19:27:08 +0000 (21:27 +0200)]
Bump versions to 4.0.1-SNAPSHOT

This starts the next development iteration.

Change-Id: I1cd1f5d811fd4ceab6b659d5a6aa27f11bd63e40
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoBump yangtools to 4.0.0
Robert Varga [Tue, 1 Oct 2019 12:17:43 +0000 (14:17 +0200)]
Bump yangtools to 4.0.0

yangtools-4.0.0 has been released, this patch adopts that version,
ending the period when we were snapshot-integrated.

Change-Id: I724f264c434ef2efd797ae56e61db9f3e374e425
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoRemove unneeded javax.annotation suppressions
Robert Varga [Tue, 1 Oct 2019 11:06:12 +0000 (13:06 +0200)]
Remove unneeded javax.annotation suppressions

We do not have javax.annotation dependencies in these components,
remove supressions.

Change-Id: Ie08b1fffb923afb2f5579abc01577b9b786204df
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoTerminally deprecate yang.binding.RpcImplementation
Robert Varga [Tue, 1 Oct 2019 10:30:04 +0000 (12:30 +0200)]
Terminally deprecate yang.binding.RpcImplementation

We do not seem to have any use for this interface, let's just
schedule it for removal.

Change-Id: Iae2b36320411f89486d0f7def0b144b03ed015c1
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoRemove dom.codec.gen.spi remnants
Robert Varga [Tue, 1 Oct 2019 10:21:41 +0000 (12:21 +0200)]
Remove dom.codec.gen.spi remnants

This removes the last remnants of the binding-dom-codec SPI contract,
keeping all implementation details internal.

Change-Id: I7f5c71b3abb17737ef0fd8c580260c01bc777c9a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoAdjust for NormalizedNodeStreamWriter.startAnyxmlNode() changing
Robert Varga [Mon, 30 Sep 2019 15:29:13 +0000 (17:29 +0200)]
Adjust for NormalizedNodeStreamWriter.startAnyxmlNode() changing

The baseline interface now propagates the intended object model,
handle it accordingly.

Change-Id: I9b68801a2a1ee20d86599432fe6b593007836807
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoAdjust for AnydataExtension being integrated
Robert Varga [Mon, 30 Sep 2019 11:31:50 +0000 (13:31 +0200)]
Adjust for AnydataExtension being integrated

This updates serialization code to match changes made to
NormalizedNodeStreamWriter -- i.e. AnydataExtension being an
integral part of it.

Change-Id: Id09cec7ba7f7d4359379e9bd74baae4d008b1e63
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoFix references to Any{Data,Xml}SchemaNode
Robert Varga [Fri, 27 Sep 2019 14:09:20 +0000 (16:09 +0200)]
Fix references to Any{Data,Xml}SchemaNode

This is a follow-up for renames of AnyXmlSchemaNode and
AnyDataSchemaNode.

Change-Id: I63f9ae94b1bc3fc72385b4ad947a16803d959d0c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoAdjust for AnyXmlNode changing its name
Robert Varga [Fri, 27 Sep 2019 14:05:20 +0000 (16:05 +0200)]
Adjust for AnyXmlNode changing its name

This is a follow-up patch to adjust uses of AnyXmlNode to either
AnyxmlNode or DOMSourceAnyxmlNode.

Change-Id: I98be4147b6515ab939dc9113d4b80c0a589786d0
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoRevert "Do not emit empty lists to NormalizedNodes"
Robert Varga [Sun, 22 Sep 2019 02:12:42 +0000 (04:12 +0200)]
Revert "Do not emit empty lists to NormalizedNodes"

This reverts commit 672a3adc4378ec5228b15bcdafc4dec2ea066dbd,
as it is breaing DTO behavior applications explicitly depend on.

The issue cannot be fixed without touching templates, i.e. requires
complete implementation of MDSAL-449.

JIRA: MDSAL-456
Change-Id: I07baf3a7be3867c6bee1b66a05b013ee0ba5171f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoFix space stripping
Robert Varga [Tue, 6 Aug 2019 15:48:56 +0000 (17:48 +0200)]
Fix space stripping

This fixes the coded intended to strip leading/trailing spaces
from the line builder. This was ineffective due to how xtend
compares char-to-String and would not work anyway, as the stripping
was done in wrong order.

Change-Id: I119ed55492da17355e3f3137dcbb8862259dc44f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoRemove superfluous @NonNull annotation
Robert Varga [Sun, 15 Sep 2019 10:11:14 +0000 (12:11 +0200)]
Remove superfluous @NonNull annotation

MoreObjects.toStringHelper() is not tagged properly, hence generated
toString() methods generate a ton of nullness warnings. Fix that up
by removing the annotation (to mirror what we are otherwise doing
in other methods).

Change-Id: Ib4fc3d3fdd3fab1e5fb257f3e85c344999d6eb1a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoForce BindingNormalizedNodeSerializers to deal with event instant
Robert Varga [Fri, 13 Sep 2019 15:56:18 +0000 (17:56 +0200)]
Force BindingNormalizedNodeSerializers to deal with event instant

This is a bit of public API, which was retrofitted. Now make the
eventInstant-aware method mandatory-to-implement.

Change-Id: I9b9287bd62dc2c1ca789e0bc112a92e499ffd246
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoMake BindingCodecTree.getIdentityCodec() non-default
Robert Varga [Fri, 13 Sep 2019 15:52:22 +0000 (17:52 +0200)]
Make BindingCodecTree.getIdentityCodec() non-default

We want this method implemented, hence make it non-default.

Change-Id: I5fbd6a0685eb508c42d63dce69d716e5efaa4912
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoRemove yang.binding.annotations.(Module)QName
Robert Varga [Wed, 4 Sep 2019 20:03:17 +0000 (22:03 +0200)]
Remove yang.binding.annotations.(Module)QName

These annotations are scope=runtime and are not used anywhere.
Furthermore they require refection access to classses, so just don't
bother.

Change-Id: Icb23fd1ffbd6ebc18e722ba6f0bff9109db5f356
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoGenerate legacy value contructors for all classes
Robert Varga [Thu, 5 Sep 2019 13:11:38 +0000 (15:11 +0200)]
Generate legacy value contructors for all classes

This expands legacy constructor compatibility to also include
Key classes, not only value wrappers. The codegen parts is relatively
straightforward.

IdentitiableItemCodec is coded on the assumption there are only
two constructors -- one copy and one all-value, which is now violated.

Hence we update IdentifiableItemCodec to also ignore any constructors
which are marked as deprecated.

JIRA: MDSAL-330
Change-Id: Ie23ba8b3788b320b2d11e263c9af228b4c2e41a9
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoMake BaseTemplate.asArguments() take a Collection
Robert Varga [Thu, 5 Sep 2019 12:25:28 +0000 (14:25 +0200)]
Make BaseTemplate.asArguments() take a Collection

This side-steps the need for IterableExtensions, make the code
a tad faster.

Change-Id: I210d4da343bdae82b81dbb0fd30c6d8ed7d6c13e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoRemove use of new Integer(String)
Robert Varga [Thu, 5 Sep 2019 10:05:57 +0000 (12:05 +0200)]
Remove use of new Integer(String)

This constructor has been deprecated in Java 9, migrate to
Integer.valueOf(String) instead.

Change-Id: I5b6dfe27502408bab9ae2f2453dd1a713c00b6bd
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoMake BaseTemplate.fieldName() return String
Robert Varga [Thu, 5 Sep 2019 10:00:15 +0000 (12:00 +0200)]
Make BaseTemplate.fieldName() return String

Java 9+ has very efficient string concatenations, hence we can
use them. This allows us to better bind to to StringConcatenation,
as we'll end up wired to .append(String) rather than .append(Object),
as would be the case with CharSequences.

Change-Id: I2a93139c1b1af8b4c335aa4a4cb8a68bd76acb95
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoAdd migration setter @return javadoc
Robert Varga [Thu, 5 Sep 2019 09:38:22 +0000 (11:38 +0200)]
Add migration setter @return javadoc

This mitigates a warning emitted by javadoc.

JIRA: MDSAL-330
Change-Id: Ic3aa1cc517d7a5d0f3e460d9c1ca353450ae4c66
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoGenerate compatibility constructors for Uint wrapped types
Robert Varga [Wed, 4 Sep 2019 14:57:10 +0000 (16:57 +0200)]
Generate compatibility constructors for Uint wrapped types

We already are generating compatibility setters, this extends this
capability to wrapper classes (i.e. their constructors). As usual
the compatibility code is marked as deprecated for removal.

Also fixes some code formatting issues introduces in previous
patches.

JIRA: MDSAL-330
Change-Id: I0b2db136c27c26de33f8a756292dde4cdf53bebb
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoSeparate all-values constructor from typedef constructor
Robert Varga [Wed, 4 Sep 2019 14:03:48 +0000 (16:03 +0200)]
Separate all-values constructor from typedef constructor

ClassTemplate.allValuesContructor() is actually two separate
templates, which is obfuscated by a number of checks. This patch
splits them out, eliminating the need for multiple checks for
the same thing.

JIRA: MDSAL-330
Change-Id: I298299ffe126fe5f51dc9c2776f46245eb0ce563
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoOptimize array checks
Robert Varga [Wed, 4 Sep 2019 14:24:01 +0000 (16:24 +0200)]
Optimize array checks

Rather than bouncing through .importedName().contains("[]"), we
can make this check through .name().endsWith("[]"), which prevents
a round-trip to import mechanics and is potentially faster.

Change-Id: I4a939333c294ffa94ac1c013a8e3cee466e32cb9
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoCache computed fieldName in templates
Robert Varga [Wed, 4 Sep 2019 14:17:32 +0000 (16:17 +0200)]
Cache computed fieldName in templates

We end up using the same name multiple times, which really is an
invariant. Cache and reuse the constant, so that we end up with
more efficient code.

Change-Id: I6ee5cc162c43c542a08ba84250f42d9a30ba3f0d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoFix ClassTemplate.genConstructor() declaration
Robert Varga [Wed, 4 Sep 2019 12:44:47 +0000 (14:44 +0200)]
Fix ClassTemplate.genConstructor() declaration

Using an array here is forcing us to needlessly unwrap the arraylist
(a perfectly iterable thing) to an array, which is only iterater over.

Fix this by passing down an iterable, which means the list can be
passed down as is.

Change-Id: I1572729d554c3ce8ae6ab94c1ba3d5547399e7ab
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoAcquire first value manually in ClassTemplate
Robert Varga [Wed, 4 Sep 2019 12:40:35 +0000 (14:40 +0200)]
Acquire first value manually in ClassTemplate

xtend's get(0) extension ends up creating a temporary list
holding a copy of the (single) value. This is not entirely
efficient, as we can get the same result from plain iterator.

Change-Id: I0f4398a47cb771e8ab7a212a67c5e402d49ffbf2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoAcquire first entry of type constants in BuilderTemplate
Robert Varga [Wed, 4 Sep 2019 12:30:47 +0000 (14:30 +0200)]
Acquire first entry of type constants in BuilderTemplate

Current code is relying on xtend Conversions to get first entry
from keySet/values separately. That code ends up copying the entire
collection into an array before picking the first element, which
is ... far from optimal.

Peel the first entrySet item using iterator().next() and then
reference key/value from there, which removes a dependency on
Conversions and is way more efficient.

Change-Id: I9cf16c416e65e538697aab26ebb5b9a81965e871
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoOptimize allProperties sorting
Robert Varga [Wed, 4 Sep 2019 11:55:25 +0000 (13:55 +0200)]
Optimize allProperties sorting

Java 8 has list.sort(), which we can easily short-circuit to
ArrayList's implementation by using 'val' declaration. We can
also make the comparator a constant, so that it is widely reused.

Change-Id: Ib8ce132a806d4e1ab58746ce85e732d451d82845
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoOptimize ClassTemplate.allProperties
Robert Varga [Wed, 4 Sep 2019 11:46:14 +0000 (13:46 +0200)]
Optimize ClassTemplate.allProperties

This variable is guaranteed to be a List, declare it as such,
adding following benefits:
- eliminates ClassTemplate's reliance on IterableExtensions
- a few isEmpty() checks get be eliminated, as size() is now
  handled through List.size()

Change-Id: I14354dfef3a6b663c9a027353704127437d4344d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoOptimize BuilderTemplate string references
Robert Varga [Wed, 4 Sep 2019 11:34:38 +0000 (13:34 +0200)]
Optimize BuilderTemplate string references

AUGMENTATION_FIELD.toFirstUpper is a true constant, make sure we
compute it only once.

Also, in case of augmentable, the augmentable imported name is an
invariant, hence precompute the string and use it multiple times
in the template.

Change-Id: I9607ac2e18e587118659545205323037db176fda
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoBackport code generation test
Robert Varga [Wed, 4 Sep 2019 11:15:12 +0000 (13:15 +0200)]
Backport code generation test

This backports the model used in binding2 testing.

JIRA: MDSAL-330
Change-Id: I8d2e3998523b78ceccf627134ed92496169a0ca8
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoImprove generated builder documentation
Robert Varga [Tue, 3 Sep 2019 20:01:24 +0000 (22:01 +0200)]
Improve generated builder documentation

This adds some sorely-needed guidelines as to how to use generated
builders.

Change-Id: I786a7e2f249f336363d4ddc107919edb861e0422
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoRemove BigIntegerRangeGenerator
Robert Varga [Mon, 2 Sep 2019 14:28:48 +0000 (16:28 +0200)]
Remove BigIntegerRangeGenerator

We do not generate BigIntegers anymore, this removes related
generator.

JIRA: MDSAL-330
Change-Id: I29be15b970e8392f474136c8dd6a948fcbd4054c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoFix Builder javadoc mis-reference
Robert Varga [Tue, 3 Sep 2019 19:24:17 +0000 (21:24 +0200)]
Fix Builder javadoc mis-reference

Builders should reference target type in their documentation.

Change-Id: I3ba9c31c77be9d86bc4e2d854360b6f8cf0fb86b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoChange mapping of uint{8,16,32,64}
Robert Varga [Mon, 2 Sep 2019 08:34:32 +0000 (10:34 +0200)]
Change mapping of uint{8,16,32,64}

This changes the mapping of uint types to non-widening yang.common
classes and deals with them being used by yang.{data,model}.api:

YANG type  Old Java type         New Java Type
uint8      java.lang.Short       org.opendaylight.yangtools.yang.common.Uint8
uint16     java.lang.Integer     org.opendaylight.yangtools.yang.common.Uint16
uint32     java.lang.Long        org.opendaylight.yangtools.yang.common.Uint32
uint64     java.math.BigInteger  org.opendaylight.yangtools.yang.common.Uint64

This affects all getters, setters and value wrapper classes. For
setters, code generator emits a deprecated setter, which performs
the conversion internally.

JIRA: MDSAL-330
JIRA: YANGTOOLS-1018
Change-Id: Ic3913adc4a5d707b01671a982c58221cb028f6d9
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoImprove BindingMapping lookup
Robert Varga [Mon, 2 Sep 2019 15:57:36 +0000 (17:57 +0200)]
Improve BindingMapping lookup

Expose the fact that JAVA_RESERVED_WORDS is an ImmutableSet,
allowing callers to better bind to it.

Change-Id: I8131aa8d2be9a2b8b1e13f7c5d6231b9ccb5fd2d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoFixup leaf caching test in face of lazy leaf nodes
Robert Varga [Fri, 30 Aug 2019 11:18:02 +0000 (13:18 +0200)]
Fixup leaf caching test in face of lazy leaf nodes

In case we are doing lazy leaves, we end up not retaining them
and hence the test needs to do something different.

Change-Id: I68fded3a799d3c6c023eaa63336b7002ea4594c7
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoAdd @ConstructorParameters to generated classes
Robert Varga [Wed, 28 Aug 2019 15:09:12 +0000 (17:09 +0200)]
Add @ConstructorParameters to generated classes

This allows generated classes to be used with both java.beans
and javax.management even either of java.desktop or java.management
module is missing.

JIRA: MDSAL-468
Change-Id: I9903558102d094efeb60201673980685e2b5a253
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 months agoSwitch to using VarHandles
Robert Varga [Wed, 1 May 2019 12:23:15 +0000 (14:23 +0200)]
Switch to using VarHandles

VarHandles allow us to relax the memory ordering when accessing
cached CodecDataObject fields. Use them instead of
AtomicReferenceFieldUpdaters.

Change-Id: If95e4e058491cee4babfcbb49bb7cf47e62f9444
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
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>