mdsal.git
3 years agoAbstractConcurrentDataBrokerTest @deprecate-s the AbstractDataBrokerTest 81/90081/1
Michael Vorburger [Mon, 6 Feb 2017 23:23:31 +0000 (00:23 +0100)]
AbstractConcurrentDataBrokerTest @deprecate-s the AbstractDataBrokerTest

This is take #2 on a similar earlier attempt which made the same change
directly in AbstractDataBrokerTest, which broke some downstrean tests,
which were BADLY WRITTEN (!) because the assumed single threaded direct
execution (which DataBroker does not guarantee).

https://bugs.opendaylight.org/show_bug.cgi?id=7538 has full background

JIRA: MDSAL-556
Change-Id: I05ac3525bdcf1ab9c99dfa15b98e090848d0fddc
Signed-off-by: Michael Vorburger <vorburger@redhat.com>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 3282f1989aba438817739bbf611fd133c381a5e7)

3 years agoAbstractDataBrokerTestTest which actually does something 80/90080/1
Michael Vorburger [Wed, 5 Oct 2016 16:22:25 +0000 (18:22 +0200)]
AbstractDataBrokerTestTest which actually does something

Incl. verification that each @Test cleans up after itself.  We had a
suspicion that this didn't work; it turns out that it actually does and
we had another problem somewhere else.  Contributing this test still
seems useful for future non-regression.

JIRA: MDSAL-556
Change-Id: I295ebde45a0c030ab74852788b45203cdf6639e0
Signed-off-by: Michael Vorburger <vorburger@redhat.com>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 4a461d624f03984047b593c823112feac729aceb)

3 years agoDataBrokerTestModule: use AbstractDataBrokerTest without inheritance 79/90079/1
Michael Vorburger [Wed, 10 Aug 2016 15:22:30 +0000 (17:22 +0200)]
DataBrokerTestModule: use AbstractDataBrokerTest without inheritance

While starting to write JUnit tests (for functional components) with the
AbstractDataBrokerTest, I found myself not liking its design which
forces one to use a class SomeTest extends AbstractDataBrokerTest...

Modern JUnit tests should be written by composition, not enforced
inheritance.  Thus this new DataBrokerTestModule allows one to obtain a
DataBroker suitable for Tests from anywhere.

The *(Test)Module naming convention is obviously inspired by a DI point
of view (think Spring Framework's @Configuration classes, or Google
Guice or Dagger (yay!) *Module classes - which is exactly what this
really is - a particular way to obtain an instance of an
implementationof some service (here a DataBroker) in a certain
environment (here for tests).

The internal implementation of DataBrokerTestModule could be changed
later; I guess ideally what's in AbstractDataBrokerTest could go into
DataBrokerTestModule and AbstractDataBrokerTest could use it, but for
now I'm too lazy to change that, as this does the trick nicely.  Later
implementation changes would be transparent to users of
DataBrokerTestModule.

JIRA: MDSAL-556
Change-Id: I9641f527bbc0cb92732f2e513cdd64cc6a837200
Signed-off-by: Michael Vorburger <vorburger@redhat.com>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit e94d340da0d1b19e506fe2ad7e4e19c79959e241)

3 years agoFix SnapshotBackedWriteTransaction error message 87/89987/1
Robert Varga [Tue, 26 May 2020 11:15:42 +0000 (13:15 +0200)]
Fix SnapshotBackedWriteTransaction error message

The message is misleading, as we are not performing a write, but
a merge operation.

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

3 years agoBump versions to 4.0.15-SNAPSHOT 74/89774/1
Robert Varga [Thu, 14 May 2020 16:31:01 +0000 (18:31 +0200)]
Bump versions to 4.0.15-SNAPSHOT

This starts the next development iteration.

Change-Id: Ie328cd001fb3bf9f45f174ef6c22fd6765fd7802
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoBump to odlparent-5.0.7/yangtools-3.0.11 73/89773/2
Robert Varga [Thu, 14 May 2020 13:56:18 +0000 (15:56 +0200)]
Bump to odlparent-5.0.7/yangtools-3.0.11

Adopt latest releases of upstream in preparation for next release.

Change-Id: I3c57861bc567da22240678bb7877f071d0cc8123
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoAdd test-sources for mdsal-binding-dom-adapter 66/89666/1
Robert Varga [Mon, 11 May 2020 15:58:41 +0000 (17:58 +0200)]
Add test-sources for mdsal-binding-dom-adapter

We are (unwisely) constructing a test-jar here, hence we should
also be publishing the corresponding sources.

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

4 years agoImprove notification delivery defensiveness 88/89488/1
Robert Varga [Mon, 27 Apr 2020 11:45:28 +0000 (13:45 +0200)]
Improve notification delivery defensiveness

If a listener throws an exception, make sure to log it and proceed
as if nothing happened.

JIRA: MDSAL-544
Change-Id: I0ca54bb5c517115b840ad03ea24d442c7762ff05
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit bc58fd6b46acb6f94d6b9395a67f7112d134f0c1)

4 years agoFix unsubscribe checks in DOMNotificationRouterEvent 87/89487/1
Robert Varga [Mon, 27 Apr 2020 11:42:12 +0000 (13:42 +0200)]
Fix unsubscribe checks in DOMNotificationRouterEvent

The checks here are based on old assumption that the listener
would be set to null, which does not hold true for quite some
time. Update the check to close a simple race.

JIRA: MDSAL-545
Change-Id: I950ffcbcf732d4c24dcad675b81c2889465d9045
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 91749a5a5fb089e74306f288d786acb8d3c450ae)

4 years agoImprove grouping sort allocation 47/88947/2
Robert Varga [Fri, 17 Apr 2020 19:37:28 +0000 (21:37 +0200)]
Improve grouping sort allocation

Pre-allocating the result list saves us the common case when
the input is actually empty.

Change-Id: I237a75db38e8e0c160b204875bc5824433e9c3dc
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoImprove grouping error reporting 09/89109/2
Robert Varga [Fri, 17 Apr 2020 19:54:00 +0000 (21:54 +0200)]
Improve grouping error reporting

Reporting FQCN here is useful, as it is giving us crucial information
as to what class is being generated -- including the namespace.

Change-Id: I1ad5f6a0a568a71656e338ae0d5d9e3f863103a4
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoCache YangModuleInfo type name 17/89017/1
Robert Varga [Wed, 18 Dec 2019 09:05:15 +0000 (10:05 +0100)]
Cache YangModuleInfo type name

Analysis of a heap dump shows we are creating a number of instances
pointing to the same type for the purposes of having the QNAME constant.

As we have the context in which we are creating YangModuleInfo,
instantiate a primitive cache to de-duplicate these definitions.

JIRA: MDSAL-515
Change-Id: I9bb52d04627e91eac3adff672b06f6340cac157f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoFix logic ensuring parent presence 84/88984/1
Robert Varga [Wed, 8 Apr 2020 13:01:59 +0000 (15:01 +0200)]
Fix logic ensuring parent presence

When we are asked to create intermediate nodes for a path, whose
parent is the conceptual root (i.e. its parent is empty), we should
not attempt to merge it, as it just does not make sense.

JIRA: MDSAL-534
Change-Id: Ia5f6ef2857903d8e88030f4c1f3867b8ed8f5a0e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit ed271c6322092bccf8ff9500b1bbb0fb62683419)

4 years agoRemove superfluous @NonNull annotations 83/88983/1
Robert Varga [Wed, 8 Apr 2020 12:31:02 +0000 (14:31 +0200)]
Remove superfluous @NonNull annotations

These annotations are inherited from interface contract, there is
no point in specifying them again.

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

4 years agoMigrate test to use mergeParentStructure{Merge,Put} 82/88982/1
Robert Varga [Wed, 8 Apr 2020 12:22:51 +0000 (14:22 +0200)]
Migrate test to use mergeParentStructure{Merge,Put}

We have deprecated these methods, make sure we migrate the test
so that it does not add false warnings.

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

4 years agoBump versions to 4.0.14-SNAPSHOT 55/88355/1
Robert Varga [Sat, 7 Mar 2020 09:22:33 +0000 (10:22 +0100)]
Bump versions to 4.0.14-SNAPSHOT

This starts the next development development iteration.

Change-Id: I5289dc3331cc03eb66676e732b845d4fe351abff
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoFix yangtools mis-bump 54/88354/1
Robert Varga [Sat, 7 Mar 2020 08:57:48 +0000 (09:57 +0100)]
Fix yangtools mis-bump

I7e374903ca22059f5e31377a9b91971a2d82e196 actually failed to pick
up yangtools-3.0.10, fix that up.

Change-Id: Iece7d3a7bf15db6e3f287e86bbb35f9f8749482b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoBump versions to 4.0.13-SNAPSHOT 44/88344/1
Robert Varga [Sat, 7 Mar 2020 02:12:54 +0000 (03:12 +0100)]
Bump versions to 4.0.13-SNAPSHOT

This starts the next development development iteration.

Change-Id: If3b2159f6e106064d0deee1acb13bf30bdc93d6a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoFix YANG snippet escaping 38/88338/2
Robert Varga [Mon, 2 Mar 2020 12:58:50 +0000 (13:58 +0100)]
Fix YANG snippet escaping

This is the non-javadoc path for module generation, where we are
failing to escape potential unicode references. Add the proper
callout and also optimize it to be a faster no-op when not
applicable, properly documenting what is going on.

JIRA: MDSAL-529
Change-Id: Ib21ed4f15555d49aaa7eb3dac61043c4b2e90451
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoBump to odlparent-5.0.6/yangtools-3.0.10 33/88333/3
Robert Varga [Fri, 6 Mar 2020 15:02:37 +0000 (16:02 +0100)]
Bump to odlparent-5.0.6/yangtools-3.0.10

This picks up latest fixes from both upstreams.

Change-Id: I7e374903ca22059f5e31377a9b91971a2d82e196
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoPropagate grouping inference flag 32/88332/2
Samuel Kontris [Fri, 28 Feb 2020 13:33:02 +0000 (14:33 +0100)]
Propagate grouping inference flag

The test case ends up looking through the magic code flagged
for refactoring -- which is losing knowledge that the parent
node is actually a grouping. Fix this up by propagating the
flag correctly.

JIRA: MDSAL-519
Change-Id: I8fe04e688adfcc068ff29e90a039530bcd56b3c3
Signed-off-by: Samuel Kontris <samuel.kontris@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoExpand test suite to cover uses-augment of actions 46/88146/1
Robert Varga [Fri, 28 Feb 2020 17:39:51 +0000 (18:39 +0100)]
Expand test suite to cover uses-augment of actions

Augment can also target a relative path from uses context, this
expands the testing model to cover that case, too.

The test case flushes out the problem of not handling
action/notification nodes when targeted in this manner, leading
to an obvious hiccup.

JIRA: MDSAL-517
Change-Id: If389440622c31f544917b04e3825fe6e08e08244
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoUpdate Mdsal517Test a bit 45/88145/1
Robert Varga [Fri, 28 Feb 2020 17:36:28 +0000 (18:36 +0100)]
Update Mdsal517Test a bit

This just cleans up naming to prevent confusion.

JIRA: MDSAL-617
Change-Id: I75d2e95d2396f63d05cd533f16057f556850763c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoFix augmentation pointing to a grouping action's input 28/88128/2
miroslav.kovac [Thu, 27 Feb 2020 16:51:37 +0000 (17:51 +0100)]
Fix augmentation pointing to a grouping action's input

When augmentation targets an action input which itself is defined
in a grouping, we need to actually lookup the original definition.

Add a type aliasing information, which should be consulted when
making a simple reference to a type -- and use it in
augmentationToGenTypes().

JIRA: MDSAL-517
Change-Id: I1ef383e8777a7c09a979cbdd84f71be3a0f9b021
Signed-off-by: miroslav.kovac <miroslav.kovac@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoSwitch from NPE to ISE 27/88127/1
Robert Varga [Fri, 28 Feb 2020 05:55:29 +0000 (06:55 +0100)]
Switch from NPE to ISE

When we fail to locate a type it constitutes an IllegalState, not
a plain NPE.

Change-Id: I46eaa470342a5e72ad6a92aefed97e458a2ca398
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoFix action/grouping lookup mechanics 93/88093/2
Robert Varga [Thu, 27 Feb 2020 09:38:33 +0000 (10:38 +0100)]
Fix action/grouping lookup mechanics

When we are following references towards the original definitions
we need to mind the fact that 'uses' statement may point to a grouping
in a different module and hence we need to adjust namespace accordingly.

The same thing applies when we want to find generated types for such
actions' input/output -- here we need to acquire the correct
ModuleContext.

JIRA: MDSAL-516
Change-Id: I1931279beb8e663e6d8558d50c5d7d274e248cf3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoUse osgi-core constants 63/87963/1
Robert Varga [Wed, 26 Feb 2020 10:38:07 +0000 (11:38 +0100)]
Use osgi-core constants

Just to keep things consistent, use OSGi's Constants class to get
the bundle id for framework (i.e. SYSTEM_BUNDLE_ID).

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

4 years agoDeprecate BindingRuntimeContext.getEnumMapping() 03/87903/1
Robert Varga [Mon, 17 Feb 2020 22:36:15 +0000 (23:36 +0100)]
Deprecate BindingRuntimeContext.getEnumMapping()

Generated enumerations capture their YANG-declared name and expose
it as their method.

JIRA: MDSAL-392
Change-Id: Iac16b6b3599565f059332ed079c432c0603ac500
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoRefactor GeneratedClassLoadingStrategy 02/87902/1
Robert Varga [Tue, 18 Feb 2020 08:58:07 +0000 (09:58 +0100)]
Refactor GeneratedClassLoadingStrategy

This class holds two implementations, each of which is a singleton.
Make sure we lazy-load implementation classes so that the CHA can
be more effective.

JIRA: MDSAL-392
Change-Id: Ia31f63d877ec1025e1a06bf8676d918857e6fd1e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoFix checkstyle a bit 35/87835/1
Robert Varga [Mon, 17 Feb 2020 16:55:45 +0000 (17:55 +0100)]
Fix checkstyle a bit

We have a misaligned method here, fix that up.

Change-Id: Iff4ad3e9a5c2da1e64f73f8b3dfaf78d77b1db85
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoBump versions to 4.0.12-SNAPSHOT 25/87025/1
Robert Varga [Fri, 17 Jan 2020 11:02:49 +0000 (12:02 +0100)]
Bump versions to 4.0.12-SNAPSHOT

This starts the next development iteration.

Change-Id: I9a389d9c99840de5d0cf8766793a5f2bbaab7836
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoFix path namespace resolution 22/87022/1
miroslav.kovac [Mon, 16 Dec 2019 15:57:22 +0000 (16:57 +0100)]
Fix path namespace resolution

If a path is defined in terms of a submodule-local import,
SchemaContextUtil.findDataSchemaNode() breaks down because
it's reparse attempt fails to find the import in the actual
module.

SchemaContextUtil is providing findDataTreeSchemaNode() which
works properly on parsed PathExpression, use that instead.

JIRA: MDSAL-499
Change-Id: Ifa8a8958d7118d851d27fcc2c70c6d8382e3e3c0
Signed-off-by: miroslav.kovac <miroslav.kovac@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoBump versions to 4.0.11-SNAPSHOT 86/86986/1
Robert Varga [Thu, 16 Jan 2020 15:49:37 +0000 (16:49 +0100)]
Bump versions to 4.0.11-SNAPSHOT

This starts the next development iteration.

Change-Id: I4017bdc625b2e70308995f023c4e8e569a96d4a8
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoBump to odlparent-5.0.5 and yangtools-3.0.9 82/86982/1
Robert Varga [Thu, 16 Jan 2020 14:38:08 +0000 (15:38 +0100)]
Bump to odlparent-5.0.5 and yangtools-3.0.9

Pick up latest updates and fix for SFT.

Change-Id: Ie547285ce14a943107646585d9a24666f6433025
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoBump versions to 4.0.10-SNAPSHOT 17/86917/1
Robert Varga [Wed, 15 Jan 2020 08:41:33 +0000 (09:41 +0100)]
Bump versions to 4.0.10-SNAPSHOT

This starts the next development iteration.

Change-Id: Ic1b4b1949741087893ae3f23e62a320f07a9231f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoMigrate away from DataNodeIterator 16/86916/1
Robert Varga [Tue, 14 Jan 2020 16:09:05 +0000 (17:09 +0100)]
Migrate away from DataNodeIterator

We do not need to collect the entire analysis, just typedefs
(and containers in a test). Migrate to new SchemaUtils methods which
provide exactly that functionality more efficiently.

Change-Id: Idfbe19c785351f3280eae33c476d533055cb16e6
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoBump yangtools to 3.0.8 07/86907/3
Robert Varga [Wed, 15 Jan 2020 00:03:28 +0000 (01:03 +0100)]
Bump yangtools to 3.0.8

Pick up latest fixes and improvements.

Change-Id: I9e7e6d236c8059ca42220117aa49c88c7f894b79
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoUse parallelStream() to generate files 06/86906/1
Robert Varga [Tue, 7 Jan 2020 20:35:22 +0000 (21:35 +0100)]
Use parallelStream() to generate files

This is a follow-up cleanup, reducing complexity of parallel dispatch
by taking advantage of parallel streams.

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

4 years agoGenerate binding files in parallel 05/86905/1
Robert Varga [Tue, 7 Jan 2020 20:35:22 +0000 (21:35 +0100)]
Generate binding files in parallel

Binding-generated files are standalone in that the process of
generating its source does not have any other side effects.

Improve the performance by generating these files in parallel
using the common ForkJoin pool -- thus taking advantage of all
available cores.

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

4 years agoAdd utility methods to strip zone from Ipv{4,6}Address 91/86791/1
Robert Varga [Tue, 7 Jan 2020 11:25:33 +0000 (12:25 +0100)]
Add utility methods to strip zone from Ipv{4,6}Address

Most callers really want to operate of Ipv4AddressNoZone, as a zone
does not make sense. Some amount of translation may be needed when
dealing with models which we have no control over, hence ensuring
no zone is present needs to be done quickly.

This adds ipv4AddressNoZoneFor(Ipv4Address), which does an efficient
check (for the case where the source is already a NoZone) and strips
the zone.

Change-Id: Ieada4625637d0216983b515324bb5d33f5d33a99
JIRA: MDSAL-510
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 6c02ae5ce070dfeeeaae878dc5436c601d305886)

4 years agoParse IPv4-mapped IPv6 address as an IPv6 address 84/86784/1
Ajay Lele [Mon, 6 Jan 2020 18:49:50 +0000 (10:49 -0800)]
Parse IPv4-mapped IPv6 address as an IPv6 address

Inet6Address.getByAddress(byte[]) does not explicitly exist, and is
really InetAddress.getByAddress(byte[]). That method ends up returning
an Inet4Address for IPv4-mapped IPv6 addresses.

This in turn causes addressStringV6() to do the wrong thing and format
the address as an Ipv4. This is not caught by validation, as we are
skipping it by default -- and ends up causing problems way later when
such an address meets an enforcement point -- such as DOM->Binding
translation.

Fix this by using Inet6Address.getByAddress(String. byte[], NetworkInterface),
which is guaranteed to result in an Inet6Address.

Also add proper defences to addressStringV6(InetAddress), so that any
attempt to mis-use it is caught.

JIRA: BGPCEP-891
Signed-off-by: Ajay Lele <ajayslele@gmail.com>
Change-Id: Ife4cc9e57bd49b45f2beb73462a865ad84483d8f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 1d8897caf5cec5f044f870f949a15fa57de54d71)

4 years agoEliminate shift variable 67/86767/1
Robert Varga [Mon, 6 Jan 2020 22:36:21 +0000 (23:36 +0100)]
Eliminate shift variable

We do not need to track shift amount, as we can can just shift
the entire previous result, leading to more invariants in the loop.

JIRA: MDSAL-509
Change-Id: I13a108be27cac2fe4498952f3f05437927c999c0
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 4b26656c945b9af5e67d28d10b014b0ed37cc510)

4 years agoAdd DottedQuad/int interface 64/86764/1
Robert Varga [Mon, 6 Jan 2020 22:17:05 +0000 (23:17 +0100)]
Add DottedQuad/int interface

DottedQuad is essentially an Ipv4Address, hence we should have
the same level of support. Add interface to create DottedQuad from
bits and serialize it to bits.

JIRA: MDSAL-509
Change-Id: I9cee4afa1993a0090f10b3969152344e03e9adc0
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 4e1311cbb83dd15f2da7936385dd9384b6dc0229)

4 years agoAdd IPv4 address bridges to primitive int 54/86754/1
Robert Varga [Mon, 6 Jan 2020 17:41:24 +0000 (18:41 +0100)]
Add IPv4 address bridges to primitive int

Interfacing Ipv4Address(NoZone) with plain int is useful when
we we want to interface with byte streams, such as DataInput
or Netty's ByteBuf. This adds the methods to do so.

JIRA: MDSAL-509
Change-Id: Icce95e4a94ae41be4fc2aee352f83655ea55e89f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 98143cfc18f95eb4057587c1bdb4aa3b5e3b2e20)

4 years agoAdd HexString/DottedQuad/Uuid support to IetfYangUtil 18/86718/1
Robert Varga [Sun, 5 Jan 2020 12:33:34 +0000 (13:33 +0100)]
Add HexString/DottedQuad/Uuid support to IetfYangUtil

HexString is similar to a MacAddress and PhysAddress, hence it is
very simple to support it.

DottedQuad is essentially an Ipv4Address, hence it is almost as
simple to support it, too.

Uuid can be created from java.util.UUID, so that is the input
we are expecting.

JIRA: MDSAL-508
Change-Id: I82abd68b23bf857deeb9a64eefb69164fe6c8b24
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 7cbd12d8894b1703b19e70b07436a937a7b8d0bf)

4 years agoCleanup AbstractTypeProvider.isLeafRefSelfReference() 50/86650/1
Robert Varga [Mon, 30 Dec 2019 12:45:01 +0000 (13:45 +0100)]
Cleanup AbstractTypeProvider.isLeafRefSelfReference()

This method's logic eagerly strips the xpath, even when we may
end up not needing it. Refactor implementation to initialize
later (and bail quicker).

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

4 years agoDTOs for anydata/anyxml are not generated within a list 05/86605/3
wusandi [Wed, 25 Dec 2019 12:04:16 +0000 (20:04 +0800)]
DTOs for anydata/anyxml are not generated within a list

Code generation for container and list statements follows different
code paths and we have missed a hook in the latter to generate
opaque objects.

JIRA: MDSAL-506
Change-Id: I25a54362ceb09937ffe796081660afe7fa1d6bb2
Signed-off-by: wusandi <wusandi@163.com>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit e905b3d4792076251ddc276fa248e441bba157b2)

4 years agoSpeed up AbstractBuilderTemplate.removeProperty() 07/86607/2
Robert Varga [Thu, 19 Dec 2019 14:51:20 +0000 (15:51 +0100)]
Speed up AbstractBuilderTemplate.removeProperty()

Rather than performing a linear unbounded search followed by a
conditional remove, use an interator and remove the first matching
property, bailing out.

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

4 years agoUse BindingTypes.identifiable() 05/86505/1
Robert Varga [Thu, 19 Dec 2019 12:51:04 +0000 (13:51 +0100)]
Use BindingTypes.identifiable()

Instead of looking up Identifiable type each time we use it, use
the convenience method exposed through BindingTypes, improving
efficiency a bit.

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

4 years agoAdd BindingTypes.augmentation() 78/86478/1
Robert Varga [Wed, 18 Dec 2019 10:23:33 +0000 (11:23 +0100)]
Add BindingTypes.augmentation()

This migrates Types.augmentationTypeFor() into BindingTypes, so we
have proper separation.

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

4 years agoDeprecate Types.augmentableTypeFor() 74/86474/1
Robert Varga [Wed, 18 Dec 2019 08:48:31 +0000 (09:48 +0100)]
Deprecate Types.augmentableTypeFor()

This method has a mirror in BindingTypes, which is a more appropriate
place for the definition. Deprecate the method for removal and
redirect it to BindingTypes.augmentation().

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

4 years agoAdd BindingTypes.QNAME 73/86473/1
Robert Varga [Wed, 18 Dec 2019 08:52:20 +0000 (09:52 +0100)]
Add BindingTypes.QNAME

We are looking this type for each constant, which is not entirely
efficient. Add a constant to BindingTypes and use it directly, providing
a slight performance benefit.

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

4 years agoFix RPC method name conflict with JLS 66/86466/1
miroslav.kovac [Mon, 16 Dec 2019 16:28:41 +0000 (17:28 +0100)]
Fix RPC method name conflict with JLS

When we are constructing the method name for use with the RPC
provider interface we need to pay attention to conflicts with
JLS reserved words.

If such a conflict occurs, append a single '$' to the name, so
that we have a valid method name.

JIRA: MDSAL-500
Change-Id: Ifb533e2daa71bc9d1780a5d8eb48da6ce3b2d209
Signed-off-by: miroslav.kovac <miroslav.kovac@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 6e6ebc43866204667658f8bbf7cfb6233caffdc7)

4 years agoBump versions to 3.0.9-SNAPSHOT 59/86359/1
Robert Varga [Wed, 11 Dec 2019 21:46:30 +0000 (22:46 +0100)]
Bump versions to 3.0.9-SNAPSHOT

This starts the next development iteration.

Change-Id: Ic3476c2c1b8e06f8034790a9b2c695504e53ff51
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoBump odlparent/yangtools to 5.0.4/3.0.7 58/86358/1
Robert Varga [Wed, 11 Dec 2019 21:44:53 +0000 (22:44 +0100)]
Bump odlparent/yangtools to 5.0.4/3.0.7

This picks up the latest upgrades.

Change-Id: Ib02e30c7dcfa4ded9fa3b2e13015cde0b271b2c9
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoAdd codegen support for nested notifications 24/86324/1
Robert Varga [Mon, 9 Dec 2019 15:44:30 +0000 (16:44 +0100)]
Add codegen support for nested notifications

We do not have a concept of instance notification, which is similar
in many respects to an action. Add the baseline interface marker
and teach mdsal-binding-generator-impl to emit interface definitions
for them.

JIRA: MDSAL-493
Change-Id: I6af84b50f3083a8e1046ee0521b126aae1ffafe5
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 480afab4e0a0eb8d64367c0bd12fa3ec892a3383)

4 years agoCorrect @NonNull CodeHelpers.compilePatterns() 36/85936/1
Robert Varga [Thu, 21 Nov 2019 13:27:12 +0000 (14:27 +0100)]
Correct @NonNull CodeHelpers.compilePatterns()

Arrays and type-use annotations have weird way of being written,
this adds the correct form.

JIRA: MDSAL-487
Change-Id: I2e31c90eca5b59250f0a9e33444fa8b3b8ae5e4c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit c03c60cc068b342582a2d54861719718c750a880)

4 years agoFix CodeHelper.nonnull() nullness annotation 35/85935/1
Robert Varga [Thu, 21 Nov 2019 13:25:53 +0000 (14:25 +0100)]
Fix CodeHelper.nonnull() nullness annotation

We do not correctly propagate the fact the return is @NonNull,
leading to Eclipse issuing warnings. Fix that.

JIRA: MDSAL-487
Change-Id: I24360192d105423a19165855521bb24bb0bd0678
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 8fc4a97304080fafab158ef877e6fc180c030ac0)

4 years agoCorrect YangModuleInfo.getInstance() nullness warning 34/85934/1
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>
(cherry picked from commit 1144f464d67c5371b30463be5e4e144edaddd05b)

4 years agoFix onDataTreeChanged() references 82/85882/2
Robert Varga [Wed, 20 Nov 2019 08:11:28 +0000 (09:11 +0100)]
Fix onDataTreeChanged() references

Use a link to specific method, not just any matching.

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

4 years agoAdd yangtools javadoc link 85/85885/1
Robert Varga [Wed, 20 Nov 2019 08:12:09 +0000 (09:12 +0100)]
Add yangtools javadoc link

Cross-references mdsal-docs with yangtools-docs.

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

4 years agoResync javadoc links 84/85884/1
Robert Varga [Wed, 20 Nov 2019 08:13:07 +0000 (09:13 +0100)]
Resync javadoc links

This re-synchronizes links to upstreams to match odlparent.

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

4 years agoRemove use of xbase-lib in tests 59/85859/1
Robert Varga [Tue, 19 Nov 2019 15:09:49 +0000 (16:09 +0100)]
Remove use of xbase-lib in tests

The way the expected object is constructed is horrible, just use
plain fluent builder without the extensions. This makes it more
clear and much more concise.

Change-Id: I042dfda9fadcc2b3764a449dfc34300f0928370b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoImport types being checked 50/85850/1
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>
(cherry picked from commit b76fcb3bb19ecffdfbb47d7840a51e335bead392)

4 years agoAdd Types.isListType(ParameterizedType) 49/85849/1
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>
(cherry picked from commit c7da6941c5e7f46e189cc85a8b4eb66ba8551f70)

4 years agoSpeed up ListsBindingUtils 48/85848/1
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>
(cherry picked from commit 9e4b1ee522aa173efe114e315b017f77716cdb79)

4 years agoInline AbstractTypeGenerator.resolveListKeyTOBuilder() 47/85847/1
Robert Varga [Mon, 18 Nov 2019 11:52:47 +0000 (12:52 +0100)]
Inline AbstractTypeGenerator.resolveListKeyTOBuilder()

This method is only called once in a context which can already
know whether it needs to actually call it. Inline the definition,
so that we have a more efficient code flow.

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

4 years agoOptimize AbstractTypeGenerator.listKeys() 46/85846/1
Robert Varga [Mon, 18 Nov 2019 11:36:45 +0000 (12:36 +0100)]
Optimize AbstractTypeGenerator.listKeys()

In case of an empty key definition we end up allocating
short-lived empty ArrayLists, which is not efficient. Also lists
typically have a few elements, so we end up over-allocating them.

This fixes both cases, by checking the definition first and
returning an empty list in case the definition is empty, as well
as properly allocating efficient implementation where needed.

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

4 years agoRemove unneeded checkstyle supressions 45/85845/1
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>
(cherry picked from commit 6087dda3aa2e148c5046fb2d8e7b0f75a5eee844)

4 years agoParse docs version of pom.xml 46/85746/1
Thanh Ha [Mon, 4 Nov 2019 16:11:50 +0000 (11:11 -0500)]
Parse docs version of pom.xml

Issue: MDSAL-489
Signed-off-by: Thanh Ha <zxiiro@gmail.com>
Change-Id: Ie32ef32b3d89e98b9ea432bd8e2ac5ea91bf13b9
(cherry picked from commit da3cf4cd9f78d66a7edac29d6efa74a7b8a867b6)

4 years agoSpecialize JavaFileTemplate.importedName(Type) 17/85317/1
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>
(cherry picked from commit dbaae85acd37ba622f4f53a7335af14e768fb180)

4 years agoUse SUPPRESS_WARNINGS reference 16/85316/1
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>
(cherry picked from commit b5a4b1eb66e208a957cef4ff43fe58a68af4c928)

4 years agoAdd @NonNull annotation to $YangModuleInfoImpl.qnameOf() 08/85308/3
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>
(cherry picked from commit b0ea6f0f70fbc597779703a4c65dd85b69355de3)

4 years agoCleanup YangModuleInfoTemplate 05/85305/1
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>
(cherry picked from commit d8bc8182155d7ee25ab056c487a4e09b5b2e8df6)

4 years agoFix spotbugs complaints around logging 97/85297/1
Robert Varga [Mon, 21 Oct 2019 16:52:35 +0000 (18:52 +0200)]
Fix spotbugs complaints around logging

Spotbugs is very much correct about warning about non-constant
format strings. This patch fixes that up.

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

4 years agoUse ImmutableSet in YangModuleInfo 96/85296/1
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>
(cherry picked from commit e25127d59b38c6e12e2a3807f1c752f37f29c045)

4 years agoBump versions to 4.0.8-SNAPSHOT 48/85248/1
Robert Varga [Sat, 19 Oct 2019 17:25:11 +0000 (19:25 +0200)]
Bump versions to 4.0.8-SNAPSHOT

This starts the next development iteration.

Change-Id: I9589b20f0349b7fad8eb0d86a35af81038b07e8c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoBump to odlparent-5.0.3/yangtools-3.0.6 33/85233/4
Robert Varga [Sat, 19 Oct 2019 09:45:08 +0000 (11:45 +0200)]
Bump to odlparent-5.0.3/yangtools-3.0.6

This ugprades both upstreams to latest versions.

Change-Id: I020a3bf0d107fbb105645ebf3a598c11ee7d972f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoAdd IetfYangUtil.physAddressBytes() 39/85239/2
Robert Varga [Sat, 19 Oct 2019 10:45:29 +0000 (12:45 +0200)]
Add IetfYangUtil.physAddressBytes()

This adds {mac,phys}AddressBytes() to extract these from well-known
objects.

JIRA: MDSAL-486
Change-Id: Id4a9825be476e4a83bf39c4372340b479dd76164
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit b6b5ca2897c00acb04367d009fa698235ba6de06)

4 years agoFix invalid augmentations 41/85241/1
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>
4 years agoFix bug5882 test case 37/85237/1
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>
4 years agoAdd @Deprecated to obsolete elements 04/85204/1
Robert Varga [Sat, 12 Oct 2019 14:06:19 +0000 (16:06 +0200)]
Add @Deprecated to obsolete elements

This adds the functionality to add @Deprecated to obsolete components,
unlike the Java 9 counterpart, we are not marking the result for removal.

JIRA: MDSAL-481
Change-Id: I2e23e37e65b799b363a518fc5d737b40e5a64a3c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 510bf99c58b9b76611901d068ce23f32ca9a46a9)

4 years agoMake Builders sensitive to @Deprecated annotations 03/85203/1
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>
(cherry picked from commit e4ccdeadb4ffddae62860f8d080cb2a391a02f1f)

4 years agoFix space stripping 02/85202/1
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>
(cherry picked from commit 41cf4c3d41e7779ab42d6fae87fd44f7c8b69dcf)

4 years agoAdd factory method for malformed messages 28/84828/2
Robert Varga [Mon, 30 Sep 2019 21:15:56 +0000 (23:15 +0200)]
Add factory method for malformed messages

This is a utility method to make it easier for users to create nice
messages when they cannot make sense of a message.

JIRA: MDSAL-455
Change-Id: Ic8292b3d766d53b17a5e3e3dd7fd5a625e7618bc
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 8ca1742fc91ac9f21772c9b69879df134ecaf689)

4 years agoBump versions to 4.0.7-SNAPSHOT 74/84574/1
Robert Varga [Sun, 22 Sep 2019 16:02:18 +0000 (18:02 +0200)]
Bump versions to 4.0.7-SNAPSHOT

This starts the next development iteration.

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

This reverts commit cbe6a8cafaec862f2a918ecc9af99720090d3c8a,
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>
(cherry picked from commit f4f93bf1189e44a7e62a6c8396d7aa4fea03e5ca)

4 years agoRemove superfluous @NonNull annotation 80/84480/1
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>
(cherry picked from commit 8123a3db8da09c4773e64829225274e5f973c05d)

4 years agoBump versions to 4.0.6-SNAPSHOT 15/84415/3
Robert Varga [Fri, 13 Sep 2019 17:49:53 +0000 (19:49 +0200)]
Bump versions to 4.0.6-SNAPSHOT

This starts the next development iterator.

Change-Id: Id55e5d8dacc938e238d4dc5ae548849e78383164
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
4 years agoMake BaseTemplate.asArguments() take a Collection 84/84384/1
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>
(cherry picked from commit 238b755b457a5e1fd9b85cd2fe8a9aea1db82322)

4 years agoRemove use of new Integer(String) 83/84383/1
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>
(cherry picked from commit 9e2bced0e7e2945fed1b2981424f4fa5232c3ae5)

4 years agoOptimize array checks 82/84382/1
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>
(cherry picked from commit 35400adb8f5c7db3320fdf6fbcbadf377569c2e0)

4 years agoCache computed fieldName in templates 81/84381/1
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>
(cherry picked from commit 72585e1dff2c81af33f547b49694f7c976033bed)

4 years agoFix ClassTemplate.genConstructor() declaration 80/84380/1
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>
(cherry picked from commit 44e0faeba93e1ac992130b3b282c46186b13a076)

4 years agoAcquire first value manually in ClassTemplate 79/84379/1
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>
(cherry picked from commit 878c3a64f17c7771bb6fac0d42f8e9c1307d6096)

4 years agoAcquire first entry of type constants in BuilderTemplate 78/84378/1
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>
(cherry picked from commit a27fbe05be80601723f60371ff4130bca16ca568)

4 years agoOptimize allProperties sorting 77/84377/1
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>
(cherry picked from commit ff8b2d05432e6e35f005b9ab7974985b5b4e01d7)

4 years agoOptimize ClassTemplate.allProperties 76/84376/1
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>
(cherry picked from commit 425d13761fd76b0ca9691a4735977519e96adf45)

4 years agoOptimize BuilderTemplate string references 75/84375/1
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>
(cherry picked from commit 55f2409e9afd9eb7b82213bdd9e710b4e206495a)

4 years agoImprove generated builder documentation 74/84374/1
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>
(cherry picked from commit 1c11427fc685e19c6fa666e5d97462113060bd03)