yangtools.git
4 years agoReduce use of getChildByName() 30/82930/2
Robert Varga [Mon, 8 Apr 2019 18:34:12 +0000 (20:34 +0200)]
Reduce use of getChildByName()

This reduces the number of warnings and also the number of required
assertions.

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

5 years agoSpecialize SchemaPath.create(boolean, QName) 24/82924/1
Robert Varga [Wed, 3 Jul 2019 22:30:16 +0000 (00:30 +0200)]
Specialize SchemaPath.create(boolean, QName)

As it turns out we use single-QName variant quite heavily, this
provides a specialized method, which does not have varargs.

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

5 years agoBump versions to 2.1.12-SNAPSHOT 08/82808/1
Robert Varga [Mon, 1 Jul 2019 04:10:50 +0000 (06:10 +0200)]
Bump versions to 2.1.12-SNAPSHOT

This starts the next development iteration.

Change-Id: I297ab5e11f604148963099bc295447b959325894
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoBump odlparent to 4.0.11 05/82805/1
Robert Varga [Sun, 30 Jun 2019 13:37:21 +0000 (15:37 +0200)]
Bump odlparent to 4.0.11

This bumps odlparent to 4.0.11, updating upstream dependencies.

Change-Id: I48392985915029e802b6eddcb160ae40d36b8881
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoAdd SharedSingletonMap.getEntry() 53/82653/1
Robert Varga [Thu, 20 Jun 2019 14:19:09 +0000 (16:19 +0200)]
Add SharedSingletonMap.getEntry()

This adds access to the single entry being present in the map,
without the need to encapsulate it via entrySet().

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

5 years agoDeduplicate concurrent SchemaContext loads 09/82509/1
Robert Varga [Tue, 11 Jun 2019 16:53:18 +0000 (18:53 +0200)]
Deduplicate concurrent SchemaContext loads

In case we are running concurrent SchemaContext computation, if
the result is not cached we will have multiple results. These
need to be reconciled with the cache, so that those results will
be squashed into a single instance.

JIRA: YANGTOOLS-1004
Change-Id: I82df2b32a534d0acc803548579fb8ad138853c68
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 6ee69cdac4289a3ef81c2ab989f40522149b89ce)

5 years agoExpose ReusableStreamReceiver 25/82425/1
Robert Varga [Thu, 6 Jun 2019 10:23:49 +0000 (12:23 +0200)]
Expose ReusableStreamReceiver

ReusableImmutableNormalizedNodeStreamWriter has two properties
which are not inherently tied to it being bound to immutable nodes:
- it can have its state reset
- it exposes a NormalizedNode result of a streaming session

Expose these traits as ReusableStreamReceiver, so that users
can use the API rather than the implementation.

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

5 years agoRemove AbstractPathArgument.hashCodeGuard 49/82349/1
Robert Varga [Thu, 30 May 2019 21:42:18 +0000 (23:42 +0200)]
Remove AbstractPathArgument.hashCodeGuard

This patch removes the explicit boolean guard around hashCode,
which guarantees disambiguation between 0 and uncomputed.

The single byte expended here has an actual cost of 7 bytes,
as it is forcing all subclasses to have a padding of 7 with
default settings in most environments.

This changes instance sizes as follows (32bit/64bit):

NodeIdentifier                24(3)/32(7) -> 24(4)/24(0)
NodeIdentifierWithPredicates  32(7)/40(7) -> 24(0)/32(0)
NodeWithValue                 32(7)/40(7) -> 24(0)/32(0)

Most notable here is the reduction of
NodeIdentifierWithPredicates, which cannot reasonably be
shared, as it depends on user data.

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

5 years agoAdd AugmentationIdentifier.create() methods 43/82343/1
Robert Varga [Thu, 30 May 2019 17:03:24 +0000 (19:03 +0200)]
Add AugmentationIdentifier.create() methods

This adds two flavors of AugmentationIdentifier.create(), which
use a global weak cache for normalizing AugmentationIdentifiers.

The cache is carefully populated, i.e. it makes a point of using
immutable keys only.

JIRA: YANGTOOLS-998
Change-Id: I1e7d65b995e50773ec2260c9fb01bc1c6bbaafbf
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 700dcb02f55c7172c61f16a8318901b276238242)

5 years agoAdd AugmentationIdentifier(ImmutableSet) 08/82308/1
Robert Varga [Wed, 29 May 2019 12:57:45 +0000 (14:57 +0200)]
Add AugmentationIdentifier(ImmutableSet)

There are situations where we know input is an ImmutableSet,
expose a constructor to wire such calls directly.

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

5 years agoAdd a missing annotation 32/82232/1
Robert Varga [Tue, 21 May 2019 18:07:04 +0000 (20:07 +0200)]
Add a missing annotation

QName.readFrom() is guaranteed to return non-null.

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

5 years agoTighten XmlParserStream.setValue() 91/82191/3
Robert Varga [Tue, 21 May 2019 09:54:47 +0000 (11:54 +0200)]
Tighten XmlParserStream.setValue()

The argument type to setValue() is required to be a
SimpleNodeDataWithSchema, make sure to express that in declaration
and have callers perform cast -- which is already guarded by
instanceof checks.

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

5 years agoCache translated XML attributes 90/82190/3
Robert Varga [Tue, 21 May 2019 09:46:54 +0000 (11:46 +0200)]
Cache translated XML attributes

Rather than parsing XML namespace strings over and over, use
two simple caches to speed the lookups.

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

5 years agoRepair accidental API breakage 25/82125/1
Robert Varga [Wed, 15 May 2019 14:32:16 +0000 (16:32 +0200)]
Repair accidental API breakage

NormalizedNodeResultBuilder is visible to subclasses of
ImmutableNormalizedNodeStreamWriter, hence it must not be moved.

Move it back to its original nested place, restoring visibility.

Change-Id: Ida0c6c2f63f7b3e2fd0b719d4a362112afc781de
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoAdd ReusableImmutableNormalizedNodeStreamWriter 77/82077/1
Robert Varga [Wed, 15 May 2019 08:44:01 +0000 (10:44 +0200)]
Add ReusableImmutableNormalizedNodeStreamWriter

In certain situations it can be beneficial to reuse the same
writer multiple times, resetting it between uses.

This patch adds a reusable version of
ImmutableNormalizedNodeStreamWriter, which provides this service.

JIRA: YANGTOOLS-988
Change-Id: Id74e8ddcaec0e730e805cf300d455c6bf5357156
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 52cb7f67625f434751983a2dcbdd47f8868dc939)

5 years agoAllow LeafSetEntryNodes to be added to result builder 29/82029/2
Robert Varga [Tue, 14 May 2019 11:23:28 +0000 (13:23 +0200)]
Allow LeafSetEntryNodes to be added to result builder

This amends the check of parent builders to account for
NormalizedNodeResultBuilder, so that individual entries may be
received. Also optimizes the checking a bit by caching the current
builder instead of fetching it from the stack.

JIRA: YANGTOOLS-987
Change-Id: I7b77bd17ffd4671b5d5c2fbe25dee8d95757a1f0
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoAllow builders to optionally use LinkedHashMap 20/81820/1
Jakub Toth [Tue, 23 Apr 2019 13:46:34 +0000 (06:46 -0700)]
Allow builders to optionally use LinkedHashMap

Some devices are unreasonably touchy about the order of children
we send them -- i.e. they expect to encounter direct container
children before seeing any augmented children. While we push them
to NormalizedNode builders in this order, the builders are using
plain HashMaps (and rightfully so) to track them, which means
they can get reordered.

This patch introduces a new system property,
org.opendaylight.yangtools.yang.data.impl.schema.builder.retain-child-order,
which when set to "true" will cause DataContainerBuilders to use
LinkedHashMaps to track children, sacrificing efficiency to retain
the original insertion order.

JIRA: YANGTOOLS-984
Change-Id: Ica1616c3fa93559c6458eba4030a5ceaac7be58a
Signed-off-by: Jakub Toth <jtoth@luminanetworks.com>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 6335bf3e7e821d7ec1c221ffb292000c90b0931a)

5 years agoUpdate RpcResultBuilder 86/81586/2
Robert Varga [Thu, 11 Apr 2019 19:43:14 +0000 (21:43 +0200)]
Update RpcResultBuilder

Annotation @NonNull returns and make sure we correctly propagate
out ImmutableList as the implementation.

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

5 years agoRevision should be Immutable 85/81585/2
Robert Varga [Thu, 11 Apr 2019 19:42:21 +0000 (21:42 +0200)]
Revision should be Immutable

This class has only a single member, which is immutable and is final,
which means it is Immutable. Reflect that in the class hierarchy.

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

5 years agoBump versions to 2.1.11-SNAPSHOT 60/81560/1
Robert Varga [Thu, 11 Apr 2019 10:27:16 +0000 (12:27 +0200)]
Bump versions to 2.1.11-SNAPSHOT

This starts the next development cycle.

Change-Id: Ibe9ab1f10edd558e5b6d60cb1ef781eadcb88839
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoBump odlparent to 4.0.10 42/81542/1
Robert Varga [Wed, 10 Apr 2019 22:44:33 +0000 (00:44 +0200)]
Bump odlparent to 4.0.10

This picks up the latest release for Neon.

Change-Id: If9bd1e2dd6acb8f9fd299df3ed22f4b9b5073f69
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoBump versions to 2.1.10-SNAPSHOT 41/81541/1
Robert Varga [Wed, 10 Apr 2019 22:43:45 +0000 (00:43 +0200)]
Bump versions to 2.1.10-SNAPSHOT

This starts the next development cycle.

Change-Id: Ife54f124f946cac5be6c01602ba8a0e55ac46931
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoExpand CollectionWrappers 07/81507/3
Robert Varga [Tue, 9 Apr 2019 21:08:32 +0000 (23:08 +0200)]
Expand CollectionWrappers

We recognize cross-wrapping between List and Set and unpeel
the backing collection, so reducing object retention chains.

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

5 years agoUse XMLStreamException for reporting parsing errors 98/81498/1
Robert Varga [Tue, 9 Apr 2019 17:16:37 +0000 (19:16 +0200)]
Use XMLStreamException for reporting parsing errors

Using IllegalStateException is pure evil, as users do not expect
a RuntimeException to be thrown from contexts which can clearly
report a checked exception.

Use a properly-formatted XMLStreamException instead.

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

5 years agoRemove misleading comment 37/81437/1
Robert Varga [Mon, 8 Apr 2019 07:32:09 +0000 (09:32 +0200)]
Remove misleading comment

The comment about .get() being safe is not relevant, remove it.

Change-Id: I92ed59e6ef72968ed7cfbdc1da0e22817431483c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoFix NONE operation node with automatic lifecycle 26/81426/2
Robert Varga [Mon, 8 Apr 2019 01:10:04 +0000 (03:10 +0200)]
Fix NONE operation node with automatic lifecycle

In case when previous operations fizzle into a NONE operation
on top of a non-present node, automatic lifecycle would fail
because there is no node to disappear.

Fix this case by not requiring the delegate operation to return
a present node.

JIRA: YANGTOOLS-938
Change-Id: I6b4a01af61e148efa0bae3953dd5aa80b2e63398
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 43f0b88599538edd48b971c8e99bbb758baef3e6)

5 years agoExpose QueuedNotificationManager statistics 27/81327/1
Robert Varga [Fri, 29 Mar 2019 09:51:31 +0000 (10:51 +0100)]
Expose QueuedNotificationManager statistics

This backports the MXBean defined in the controller project and makes
an implementation of it available through getMXBean().

JIRA: CONTROLLER-653
BUGZILLA: BUG-1446
Change-Id: Ica8dff7aef8989f2b23b1fc8c100a535998273b1
Signed-off-by: Tom Pantelis <tpanteli@brocade.com>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit e74ded11579d1413a8e8d89129660b81048d26bd)

5 years agoBackport YangInstanceIdentifier serialized form 85/81285/1
Robert Varga [Thu, 28 Mar 2019 16:21:53 +0000 (17:21 +0100)]
Backport YangInstanceIdentifier serialized form

This backports 3.0.0 serializable forms to allow 3.0.0->2.1.x
compatibility.

JIRA: YANGTOOLS-979
Change-Id: I6823c55c2cbd1abe9e05945a4fbb2de411fe0792
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 9f4a6257aceb0b81b037984da83189a6055b797f)

5 years agoBackport QNameModule externalizable proxy 55/81255/1
Robert Varga [Thu, 21 Mar 2019 09:00:07 +0000 (10:00 +0100)]
Backport QNameModule externalizable proxy

This is a backport of the proxy class only, so that yangtools-2.1.x
can understand data serialized by yangtools-3.0.x.

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

5 years agoBackport QName externalizable proxy 54/81254/1
Robert Varga [Thu, 21 Mar 2019 08:12:13 +0000 (09:12 +0100)]
Backport QName externalizable proxy

This is a backport of the proxy class only, so that yangtools-2.1.x
can understand data serialized by yangtools-3.0.x.

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

5 years agoBump yang-xpath-api/impl version to 0.3.9-SNAPSHOT 12/81212/2
Robert Varga [Tue, 26 Mar 2019 22:14:43 +0000 (23:14 +0100)]
Bump yang-xpath-api/impl version to 0.3.9-SNAPSHOT

XPath support underwent significant changes, so bump its version
by a 0.1.0 to make sure people do not get surprised.

Change-Id: Id0b7277292be62ce2c8cf84001a5b8c183c24282
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoYangNamespaceContext should not have a default namespace 11/81211/2
Robert Varga [Tue, 26 Mar 2019 09:00:52 +0000 (10:00 +0100)]
YangNamespaceContext should not have a default namespace

Default namespace is usually bound separately from prefix, hence
YangNamespaceContext should not contain it.

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

5 years agoFix YangXPathMathSupport serializability 10/81210/2
Robert Varga [Mon, 25 Mar 2019 20:27:52 +0000 (21:27 +0100)]
Fix YangXPathMathSupport serializability

Supports should always resolve to a singleton.

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

5 years agoDefine the concept of unresolved QName 09/81209/2
Robert Varga [Wed, 20 Mar 2019 17:37:20 +0000 (18:37 +0100)]
Define the concept of unresolved QName

YANG Xpaths have dynamic namespace resolution for the default
namespace: during parse time we can only bind qualified node
identifiers.

Unqualified node identifiers require an explicit default namespace
binding step, which happens between when the XPath is parsed and
when it is evaluated, when the context node is determined.

This is quite visible in the context of leafref path expressions:
- typedef expressions are bound to the leaf/leafset referencing them
- leaf expressions in groupings are bound only after they have been
  completely instantiated (i.e. 'uses' outside of grouping context)

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

5 years agoIntroduce UnqualifiedQName and QualifiedQName 13/81213/1
Robert Varga [Wed, 20 Mar 2019 22:15:16 +0000 (23:15 +0100)]
Introduce UnqualifiedQName and QualifiedQName

For the purposes of XPath expressions we need the concept of a future
node-identifier which is not bound to a concrete namespace (which
is already covered by QName).

This node identifier comes in two forms, qualified and unqualified,
each of which undergoes different namespace binding lifecycle.

This patch introduces AbstractQName, which serves as the base class
for all QName constructs and two separate classes UnqualifiedQName
and QualifiedQName, which have the ability to be be converted to
a full QName.

Note that due to Serializable contract, QName cannot be made a
subclass of AbstractQName. This fact is marked up for a future
API change.

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

5 years agoRemove YangXPathParserFactory @ThreadSafe annotation 08/81208/1
Robert Varga [Thu, 21 Mar 2019 16:46:28 +0000 (17:46 +0100)]
Remove YangXPathParserFactory @ThreadSafe annotation

Replace JSR305 with explicit documentation of the fact we expect
implementations to be thread-safe.

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

5 years agoRemove a stray FIXME 78/81178/2
Robert Varga [Tue, 26 Mar 2019 11:43:00 +0000 (12:43 +0100)]
Remove a stray FIXME

This FIXME was addressed already, remove it.

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

5 years agoStrings Ending in Backslash are Improperly Lexed 80/81180/1
Danielle Mustillo [Mon, 25 Mar 2019 18:27:45 +0000 (14:27 -0400)]
Strings Ending in Backslash are Improperly Lexed

Using greedy match for SUB_STRING fragment's forward lookahead
is troublesome because it will consume all non-double-quotes
until the final one -- including any escapes present.

This patch fixes the lexer to use non-greedy subrule, so that
escapes are properly accounted for.

JIRA: YANGTOOLS-971
Change-Id: Ic93c5c2bfa807001735125bd0367c29a1a25ea99
Signed-off-by: Danielle Mustillo <danielle.mustillo@ericsson.com>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit e307e3f6893f94bc0a6b3fac094270f3e206eef2)

5 years agoShorten QName.toString() 66/81066/1
Robert Varga [Thu, 21 Mar 2019 09:11:35 +0000 (10:11 +0100)]
Shorten QName.toString()

Take advantage of fluent StringBuilder, removing a bit of bytecode.

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

5 years agoSpeed up QName.intern() a bit 65/81065/1
Robert Varga [Wed, 20 Mar 2019 22:17:37 +0000 (23:17 +0100)]
Speed up QName.intern() a bit

In case we end up interning the localName, we should use the private
constructor to side-step re-validating localName.

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

5 years agoExpose Relative/Absolute YangLocationPath 47/81047/1
Robert Varga [Wed, 20 Mar 2019 12:20:38 +0000 (13:20 +0100)]
Expose Relative/Absolute YangLocationPath

This patch exposes the two concretizations of YangLocationPath,
so they can be used for constructing type-safe APIs.

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

5 years agoFix XPathExpr parsing 46/81046/1
Robert Varga [Wed, 20 Mar 2019 12:04:46 +0000 (13:04 +0100)]
Fix XPathExpr parsing

The parser mistakenly treated filter/path concatenation as a binary
expression, which lead to its inability to parse leafrefs, which
contain such a concatenation in predicates.

This fixes the parser to correctly use XPathExpr in this case.

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

5 years agoRefactor yang-xpath-impl error handling 40/81040/3
Robert Varga [Wed, 27 Feb 2019 14:38:10 +0000 (15:38 +0100)]
Refactor yang-xpath-impl error handling

Separate out CapturingErrorListener and make sure we install it
in InstanceIdentifierParser.

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

5 years agoRemove generics from YangNumberExpr 39/81039/3
Robert Varga [Wed, 27 Feb 2019 14:22:23 +0000 (15:22 +0100)]
Remove generics from YangNumberExpr

Generics are only getting in the way with the class and its support,
remove them from interface classes and move them to
AbstractYangXPathMathSupport.

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

5 years agoPropagate namespaceContext/mathSupport to FunctionSupport 38/81038/3
Robert Varga [Wed, 27 Feb 2019 12:50:00 +0000 (13:50 +0100)]
Propagate namespaceContext/mathSupport to FunctionSupport

A number of operations in Functions requires either mathSupport
or namespaceContext to work correctly. This patch makes sure it
is available.

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

5 years agoMerge location step shorthand handling 37/81037/3
Robert Varga [Wed, 20 Mar 2019 11:19:08 +0000 (12:19 +0100)]
Merge location step shorthand handling

This eliminates duplicate code by introducing parseStepShorthand()
and adjusting its two users to use it.

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

5 years agoUpdate yang-xpath-api design 36/81036/3
Robert Varga [Tue, 26 Feb 2019 21:14:28 +0000 (22:14 +0100)]
Update yang-xpath-api design

This is the first round of API design update, bringing the following
changes:
- MathMode is now a top-level enumeration
- YangXPathMathSupport is an API interface providing common functions
- Prefix resolution is done through YangNamespaceContext
- YangNaryExpr is final
- math-specific YangNumberExprs are hidden classes
- YangFunctionCallExpr.NoArgs is folded into YangFunctionCallExpr
- YangLiteralExpr is now final
- YangXPathExpression exposes MathMode
- Literal interpretation is lazy and works on subexpressions

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

5 years agoAdd ModuleNameNamespaceContext 44/81044/1
Robert Varga [Wed, 27 Feb 2019 11:17:48 +0000 (12:17 +0100)]
Add ModuleNameNamespaceContext

This adds a utility YangNamespaceContext, which maps QNameModules
to their corresponding module name as contained in a SchemaContext.

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

5 years agoAdd YangNamespaceContext 42/81042/1
Robert Varga [Wed, 27 Feb 2019 08:35:18 +0000 (09:35 +0100)]
Add YangNamespaceContext

We require prefix/QNameModule mapping in multiple contexts, some
of which are bound to a SchemaContext, some of which are bound to
a particular Module.

This patch adds a generalized YangNamespaceContext to serve in these
situations and provides a simple BiMap-based implementation.

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

5 years agoEliminate unneeded YangLocationPath subclasses 35/81035/1
Robert Varga [Wed, 20 Mar 2019 07:59:22 +0000 (08:59 +0100)]
Eliminate unneeded YangLocationPath subclasses

*WithSteps subclasses are not that helpful, as we only have single
onjects which do not have steps. Integrate steps into YangLocationPath,
making it bimorphic (and its getSteps() method monomorphic).

Also clean up arguments/returns, so that we propagate only Immutable
collections.

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

5 years agoCleanup LeafRefPath{Lexer,Parser} 34/81034/1
Robert Varga [Wed, 20 Mar 2019 09:20:26 +0000 (10:20 +0100)]
Cleanup LeafRefPath{Lexer,Parser}

Drop CRLFs and remove a trailing space.

JIRA: YANGTOOLS-969
Change-Id: I24fabf164db72164e07bc3ea149e11e028ba91a2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit a7773958b4f50c62ddc75d86e069683eb669488e)

5 years agoAdd YangXPathAxis.asStep() methods without predicates 33/81033/1
Robert Varga [Wed, 20 Mar 2019 07:40:02 +0000 (08:40 +0100)]
Add YangXPathAxis.asStep() methods without predicates

In some contexts we know we do not not have any predicates, add
convenience functions for instantiating such steps.

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

5 years agoFixup xpath resolution 03/81003/1
Robert Varga [Mon, 18 Mar 2019 16:53:20 +0000 (17:53 +0100)]
Fixup xpath resolution

Add basic handling for method invocations, namely deref() and
interrupted '..' chains.

JIRA: YANGTOOLS-968
Change-Id: I9b99a5aa84039749fb04f1dca8420d41b24ba6e2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit f5b7a9cf4d9cafe0e8b4c7c38168ab0fdb7719fc)

5 years agoFix HTML5 javadoc compliance 40/80940/2
Robert Varga [Sat, 16 Mar 2019 00:40:07 +0000 (01:40 +0100)]
Fix HTML5 javadoc compliance

We are using HTML4 tags for no good reason, migrate to better
concepts to improve compatibility.

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

5 years agoRemove object cache declaration 39/80939/2
Robert Varga [Sat, 16 Mar 2019 15:37:13 +0000 (16:37 +0100)]
Remove object cache declaration

object-cache has been removed in 2.1.0, remove its declaration.

Change-Id: I3aaad19fd21a306f32d4f2b661564df40ab3fa36
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoAdd YANG Schema Mount parser support 38/80938/1
Robert Varga [Thu, 7 Mar 2019 19:18:21 +0000 (20:18 +0100)]
Add YANG Schema Mount parser support

This adds the necessary bits and pieces to properly support
mount-point extension in the parser.

JIRA: YANGTOOLS-965
Change-Id: I7ca1b6c8c961e3033dc8023089d9169573dc3c4e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 18f08017dcdc114f5f7e22c171cac79b38ea0526)

5 years agoUpdate .gitreview 17/80917/1
Robert Varga [Sat, 16 Mar 2019 00:08:54 +0000 (01:08 +0100)]
Update .gitreview

Point to v2.1.x, not master.

Change-Id: I4c03bdd5b5073d0b200881612318b148854e4476
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoHook if-feature statements onto FeatureNamespace 50/80750/1
Robert Varga [Fri, 8 Mar 2019 17:10:07 +0000 (18:10 +0100)]
Hook if-feature statements onto FeatureNamespace

IfFeatureStatementSupport should perform a check against FeatureNamespace,
so that invalid feature references are properly caught and reported.

JIRA: YANGTOOLS-964
Change-Id: If9fe8da3235533a702a34ceac26d62d91acc03c3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 1e6da8dcec386c56a626d7982e20a67e35d8a4f7)

5 years agoDefine IfFeature via a specialized class 45/80745/1
Robert Varga [Fri, 8 Mar 2019 14:04:34 +0000 (15:04 +0100)]
Define IfFeature via a specialized class

This reworks the grammar to use less recursion, as we can use
wildcards to eagerly combine expressions like "foo || bar || baz"
into any(foo, bar, baz) rather than or(foo, or(bar, baz)).

In order to properly support this contract, we define IfFeatureExpr,
which we specialize, so that we do not need to lug an opaque
predicate tree.

JIRA: YANGTOOLS-964
Change-Id: I048c3ced9c074e340031ac53c1117ce881b0a78b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 5874f5da6ff34f70c5754f5a98dbd0a32820fba1)

5 years agoMake sure we populate features 44/80744/1
Robert Varga [Fri, 8 Mar 2019 17:38:04 +0000 (18:38 +0100)]
Make sure we populate features

The way features work with EffeciveModules means features are not
populated into FeatureNamespace. In fact that namespace is not
activated at all.

Fix this up, so features can be cross-referenced with if-feature.

Change-Id: I73cb4e8cf648e5f8ef72edce00556e4e69ee908c
JIRA: YANGTOOLS-964
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 33bc94f1abc68aebd26bc12ac1c085d6ba001eb9)

5 years agoMake getIfFeaturePredicate() a default method 40/80740/1
Robert Varga [Fri, 8 Mar 2019 16:38:03 +0000 (17:38 +0100)]
Make getIfFeaturePredicate() a default method

This is just a reference to the argument, there is no point in
forcing implementations to deal with this.

Change-Id: I40cb0c349694f9fe9e224e4458fea2b2c05fa870
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoAdd YangInstanceIdentifier.createReverse(Deque) 10/80710/1
Robert Varga [Wed, 6 Mar 2019 10:39:13 +0000 (11:39 +0100)]
Add YangInstanceIdentifier.createReverse(Deque)

There are use cases when we need to instantiate a YangInstanceIdentifier
and we have the components available in a stack (i.e. deque). We can
provide an optimized instantiator which will walk the stack in reverse
order, reducing the need for one invert operation.

This patch adds two methods, one operating on a Deque<PathArgument>
and one operating on Deque<Object> with an extractor function.

Change-Id: If2b05d62dcbfb5d37415a2ecb241c8265ceb1be6
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoAdd AnnotationSchemaNodeAware interface 84/80684/1
Robert Varga [Tue, 5 Mar 2019 09:32:15 +0000 (10:32 +0100)]
Add AnnotationSchemaNodeAware interface

It seems that having annotations indexed at the SchemaContext level.
To support that, add AnnotationSchemaNodeAware interface and make it
trivially implemented by SimpleSchemaContext.

Also retrofit AnnotationSchemaNode.find(SchemaContext) to recognize
AnnotationSchemaNodeAware and defer to the index if its available.

JIRA: YANGTOOLS-960
Change-Id: I1f3cd68a8356b20bceb2d0d620992ade10649e5b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 366d11917e78439aea6dfe0b1cb5aefc9978158d)

5 years agoUse ForwardingNormalizedNodeStreamWriter for QName tranformation 73/80673/1
Robert Varga [Mon, 4 Mar 2019 12:56:05 +0000 (13:56 +0100)]
Use ForwardingNormalizedNodeStreamWriter for QName tranformation

We have a utility forwarder, which can be used as a baseline, reducing
transformation complexity a bit. Also make sure we reuse identifiers
when they are not transformed.

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

5 years agoFix ForwardingNormalizedNodeStreamWriter 68/80668/1
Robert Varga [Mon, 4 Mar 2019 12:34:56 +0000 (13:34 +0100)]
Fix ForwardingNormalizedNodeStreamWriter

Forwarding objects should allow all methods to be overridden, fix
that.

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

5 years agoMake NormalizedNodeStreamWriter extensible 57/80657/1
Robert Varga [Thu, 28 Feb 2019 14:54:24 +0000 (15:54 +0100)]
Make NormalizedNodeStreamWriter extensible

NormalizedNodeStreamWriter needs to cater to at least one extension,
which is metadata emission. Introduce
NormalizedNodeStreamWriterExtension and add a getExtensions() method,
which returns no extensions by default.

JIRA: YANGTOOLS-497
Change-Id: Iebe11b80c3199f6b37b46c85bd7362a764de4ed6
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 61759f1441b7480bc5a2b46bb8f15a5837809b8f)

5 years agoAdd ExtensibleObject interface 49/80649/3
Robert Varga [Thu, 28 Feb 2019 15:10:14 +0000 (16:10 +0100)]
Add ExtensibleObject interface

This adds the basic ExtensibleObject and ObjectExtension interfaces,
which can be reused to define extensible objects.

Unlike a full-blown implementation, these interfaces provide only
access interface, not a mechanism to perform actual state attachment.

The attachment mechanism will be defined in future, when the need
for it actually arises.

JIRA: YANGTOOLS-497
Change-Id: Ie390b6174b8909c87595dddc0d467858f36ef8bf
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 33e06bd2f202c270f70b99091029cb18afeb792a)

5 years agoFix YangParserImpl streaming use 51/80651/1
Robert Varga [Thu, 28 Feb 2019 18:48:44 +0000 (19:48 +0100)]
Fix YangParserImpl streaming use

We should not be returning null, but "this", fix that.

Change-Id: I0683da43a4c1d0b30f8f7d0680be2aa17f4e05ec
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoRemove unneeded build-helper-plugin 95/80595/2
Robert Varga [Tue, 26 Feb 2019 09:51:53 +0000 (10:51 +0100)]
Remove unneeded build-helper-plugin

yang-parser-impl does not include any antlr sources, hence we do
not need to helper plugin anymore.

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

5 years agoAdd StatementMap.toString() 18/80418/1
Robert Varga [Tue, 19 Feb 2019 10:36:27 +0000 (11:36 +0100)]
Add StatementMap.toString()

This aids debugging by adding value content, making it easier
to read what is actually in the map.

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

5 years agoPrefer Immutable collections over Collections.emptyFoo() 40/80340/2
Robert Varga [Thu, 14 Feb 2019 16:47:37 +0000 (17:47 +0100)]
Prefer Immutable collections over Collections.emptyFoo()

Our immutable-checking logic works best on known classes, hence
we bias towards using ImmutableCollection-derived classes.

Change-Id: Ifdcfe3642f33b4ef050051b9cdbec74690740e37
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoFix ImmutableUnkeyedListNodeBuilder.valueEquals() 38/80338/2
Robert Varga [Thu, 14 Feb 2019 16:40:47 +0000 (17:40 +0100)]
Fix ImmutableUnkeyedListNodeBuilder.valueEquals()

Returning an empty Set from getValue() means that if we ever
encountered two instances of this class in comparison, their values
would fail to compare, as valueEquals() expects a List.

Fix this by returning ImmutableList.of() and codify that in the
return value.

Change-Id: I4301f4161648ea391f2e0a1e712e3f87c6dca33c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoDefang immutables.org 39/80339/1
Robert Varga [Thu, 14 Feb 2019 15:10:02 +0000 (16:10 +0100)]
Defang immutables.org

We do not want to leak annotations, so specify that in our style,
removing the need to suppress javax.annotation.

JIRA: YANGTOOLS-907
Change-Id: Ic363fc10e79336cd26274fb91d3791e3f8ba1334
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 6b0c1f975b558c3aef366e1e0c05a5abd2a4c946)

5 years agoRefactor checkTouchApplicable() 14/80314/1
Robert Varga [Wed, 13 Feb 2019 11:52:14 +0000 (12:52 +0100)]
Refactor checkTouchApplicable()

We can remove direct overrides of checkTouchApplicable() by making
the method smarter in its checking of preconditions. Notably we
do not check TreeNode presence multiple times, but rather perform
a step-wise unpacking of state.

This has the benefit of having a clean place where we check if
automatic lifecycle is in effect and that happens only if the node
does not exist.

JIRA: YANGTOOLS-943
Change-Id: I72f4316c77d8f36efaf95209c36e898c9b4873cd
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoAdd ModificationPath.toString() 09/80309/1
Robert Varga [Wed, 13 Feb 2019 11:32:37 +0000 (12:32 +0100)]
Add ModificationPath.toString()

While we use ModificationPath internally only, having a toString()
on it is useful for debugging.

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

5 years agoRemove checkApplicable() overrides 03/80303/1
Robert Varga [Tue, 12 Feb 2019 19:44:45 +0000 (20:44 +0100)]
Remove checkApplicable() overrides

The only time we are overriding checkApplicable() is in the TOUCH
case, which can more easily be handled through applyTouch().

Refactor AbstractNodeContainerModificationStrategy to include
the utility bits from AutomaticLifecycleMixin and move the override.
This reduces the number of implementations of checkApplicable()
from 7 to 2, while increasing the number of implementations of
checkTouchApplicable() from 3 to 7.

JIRA: YANGTOOLS-943
Change-Id: Iaf198ba852ff88d8e6b570b7c88b01f1064bb3a2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 136e34b09aa90ccbe5d20c0035fb3d573c45daeb)

5 years agoRemove DelegatingModificationApplyOperation 95/80295/1
Robert Varga [Tue, 12 Feb 2019 12:49:06 +0000 (13:49 +0100)]
Remove DelegatingModificationApplyOperation

MinMaxElementsValidation is the only subclass, hence merge the two
classes into one, making MinMaxElementsValidation type-safe through
use of the SchemaNode-generic of SchemaAwareApplyOperation.

Change-Id: I00700d2b45f4163072d8c4d4c364bd8047e5b430
JIRA: YANGTOOLS-955
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoRemove AlwaysFailOperation 85/80285/1
Robert Varga [Tue, 12 Feb 2019 12:39:25 +0000 (13:39 +0100)]
Remove AlwaysFailOperation

AlwaysFailOperation guards the case when we do not have a schema
context, which is exceeding rare and there is exactly one place
where we can check for null to detect non-presence of an operation.

Remove this implementation along with
NonApplyDelegatedModificationApplyOperation, making
MinMaxElementsValidation the only delegating implementation.

JIRA: YANGTOOLS-955
Change-Id: Id70814eced80dd80948a1a5601287977fa77cf12
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoRemove unneeded Iterator.remove() overrides 64/80264/1
Robert Varga [Mon, 11 Feb 2019 14:23:06 +0000 (15:23 +0100)]
Remove unneeded Iterator.remove() overrides

Java 8 has retrofitted remove() to be a default method which
throws UnsupportedOperationException. Take advantage of this and
remove some of our code.

Change-Id: Ie4e4ac4ef947d5d65a3f5b80c249c21c35909f92
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoCleanup yang-data-impl nullness annotations 59/80259/1
Robert Varga [Wed, 6 Feb 2019 15:55:16 +0000 (16:55 +0100)]
Cleanup yang-data-impl nullness annotations

This migrates yang-data-impl to use JDT nullness annotations, expanding
use of @NonNull in return types.

JIRA: YANGTOOLS-907
Change-Id: I16869db150ce28a94df5f6e5b55b5cf0fa07c34c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 5e2ee5120180b2cff62a6e8c2a2c172fbc625817)

5 years agoSchemaAwareApplyOperation has getSchema() 55/80255/2
Robert Varga [Wed, 6 Feb 2019 01:13:22 +0000 (02:13 +0100)]
SchemaAwareApplyOperation has getSchema()

Obviously, if an ModificationApplyOperation knows abouts its schema
it should expose it through getSchema(). This allows us to concentrate
fields a bit.

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

5 years agoCorrect mandatory leaf enforcement 56/80256/1
Robert Varga [Mon, 11 Feb 2019 10:46:17 +0000 (11:46 +0100)]
Correct mandatory leaf enforcement

Previous patch broke mandatory leaf enforcement on operational
data store. This patch fixes the logic to again apply this check.

Change-Id: I7b5d6ea05fea0b4df60c8cde9075168a3fa18e9c
JIRA: YANGTOOLS-947
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 875459db2abd73cbe5c9977c421e923e2c428de3)

5 years agoRemove MapModificationStrategy hack 59/80159/1
Robert Varga [Tue, 5 Feb 2019 02:07:37 +0000 (03:07 +0100)]
Remove MapModificationStrategy hack

MapModificationStrategy has special handling to deal with DataTrees
rooted at a MapEntryNode, which really papered over failure of
InMemoryDataTree to properly resolve its root strategy.

Fix up InMemoryDataTree to use ListEntryModificationStrategy instead
of MapModificationStrategy when it is rooted at a particular map
entry.

JIRA: YANGTOOLS-951
Change-Id: I2e0306d1bf88fcee517a32c5903dfa98c287eb2c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 39d6912a0df959abf070bcec53d2157f938eb7fc)

5 years agoRework DataNodeContainerModificationStrategy child tracking 54/80154/3
Robert Varga [Tue, 5 Feb 2019 11:11:05 +0000 (12:11 +0100)]
Rework DataNodeContainerModificationStrategy child tracking

Since we do not want to expand the entire modification tree, but
instantiate it lazily, we have used a Guava LoadingCache to load
children.

Unfortunately this has couple of disadvantanges, namely:
- memory overhead of the cache and its entries
- access through a ConcurrentHashMap
- synchronized entry loading

As it turns out, we can do much better by maintaining an immutable
map ourselves, with compare-and-swap locking. This results in
much lower memory overhead as well as fast access, as we perform
only a single volatile read in that case.

JIRA: YANGTOOLS-950
Change-Id: I7b8c6d6561d65373e54cf5a5dd9f0bc2537531ac
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoSquash value-based ModificationStrategies 53/80153/1
Robert Varga [Mon, 4 Feb 2019 17:15:15 +0000 (18:15 +0100)]
Squash value-based ModificationStrategies

LeafSetEntryModificationStrategy and LeafModificationStrategy
share all of their codebase, rendering them useless. Remove them
and promote AbstractValueNodeModificationStrategy to a full
class.

JIRA: YANGTOOLS-941
Change-Id: I95f6d5eb106a003dee85028bc8bb0251a25a6130
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit d3ea78c642c428f640ab29f8f197a65e4c4477e1)

5 years agoSeparate out ModificationApplyOperation.verifyStructure() 49/80149/1
Robert Varga [Thu, 31 Jan 2019 14:36:28 +0000 (15:36 +0100)]
Separate out ModificationApplyOperation.verifyStructure()

The boolean handling of this method makes it really two distinct
methods, quickVerifyStructure() and fullVerifyStructure().

Refactor them so that we have two separate invocation paths, which
meet in SchemaAwareApplyOperation and from there are properly
dispatched to subclasses.

This reduces the number of implementations and makes it much clearer
as to what the specific and shared logic is. Most notably it makes
fullVerifyStructure() have only three implementations and
quickVerifyStructure() becomes bimorphic.

JIRA: YANGTOOLS-947
Change-Id: Ife836c7b9011e97a421746efa575148b1e77f6e9
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 20df7021c844ccf06d1378f615c2988fff60edee)

5 years agoMove NormalizedNode-based DataTreeCandidateNodes into API 44/80144/2
Robert Varga [Mon, 28 Jan 2019 21:17:54 +0000 (22:17 +0100)]
Move NormalizedNode-based DataTreeCandidateNodes into API

These utility classes are useful for downstreams, and we have
an API point from where we can expose them in a relatively clean
fashion.

Move them to API package and expose them through DataTreeCandidateNodes
utility class.

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

5 years agoSeparate out RootModificationApplyOperation 36/80136/1
Robert Varga [Thu, 31 Jan 2019 08:17:31 +0000 (09:17 +0100)]
Separate out RootModificationApplyOperation

RootModificationApplyOperation is an operation holder, which has
particular lifecycle and can give access to the current
ModificationApplyOperation.

Rename it to RootApplyStrategy and have it *not* a subclass of
ModificationApplyOperation. This makes the flow more consistent
as well as making it obvious the three classes constituing its
associated logic cannot every come up in the context of traversing
a modification tree.

JIRA: YANGTOOLS-949
Change-Id: I01061db38c6d631f804eef1b241a93eaf11626e5
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoAdd utility wrappers for instantiating builders/nodes 30/80130/1
Robert Varga [Tue, 29 Jan 2019 23:38:13 +0000 (00:38 +0100)]
Add utility wrappers for instantiating builders/nodes

This removes the need for subclasses of
AbstractNodeContainerModificationStrategy to provide separate
methods, moving through a dispatch class instead. This lowers
the number of potential implementations down to one, with
the functionality being supported by 2 distinct classes.

As it turns out, this refactor actually has no additional overhead,
because the support instance reference can completely supplant
the Class reference we are holding.

JIRA: YANGTOOLS-941
Change-Id: I53a26981d41fb0cc6dd71dffd4e1bd71f9e9387d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit c91afd55c080cf25473767536b4509ae3b5e2603)

5 years agoEliminate no-op MandatoryLeafEnforcer 45/80045/1
Robert Varga [Wed, 30 Jan 2019 12:49:40 +0000 (13:49 +0100)]
Eliminate no-op MandatoryLeafEnforcer

Running through a no-op enforcer, while efficient, still requires
a bimorphic invocation, which results most of the time in a no-op.

Eliminate the no-op implementation and refactor its two users, so
that they provide dedicated subclasses which use enforcer. This has
the benefit of not overriding SchemaAwareApplyOperation just to
run a noop invocation.

JIRA: YANGTOOLS-945
Change-Id: Iff44eb6efa048bb86a71b0d7753d3e58425b5e4d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 8dbd4934c7ed38b62a36a27322c663c6ddb45159)

5 years agoAdd Abstract{LeafSet,Map}ModificationStrategy 39/80039/2
Robert Varga [Wed, 30 Jan 2019 13:54:51 +0000 (14:54 +0100)]
Add Abstract{LeafSet,Map}ModificationStrategy

This allows us to remove some code duplication in constructor,
but notably share the implementation of getChild().

Furthermore it allows us to make the rooted-at-MapEntry hack work
consistently for ordered map nodes too.

JIRA: YANGTOOLS-946
Change-Id: Id91529c31341afd46a693f24eb1ac4ea0dc4800d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoHide SchemaAwareApplyOperation.checkWriteApplicable() 41/80041/1
Robert Varga [Wed, 30 Jan 2019 17:20:39 +0000 (18:20 +0100)]
Hide SchemaAwareApplyOperation.checkWriteApplicable()

The refactor of MinMaxValidation allows us to optimize
checkWriteApplicable() by completely hiding it.

JIRA: YANGTOOLS-944
Change-Id: I804ddb5e4c8b7562bde11994be8b1a5615228d7c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoIntroduce DelegatingModificationApplyOperation 30/80030/2
Robert Varga [Wed, 30 Jan 2019 11:46:10 +0000 (12:46 +0100)]
Introduce DelegatingModificationApplyOperation

As it turns out implementations outside of SchemaAwareApplyOperation
can share implementations of most methods through delegation. Create
two new abstract classes, DelegatingModificationApplyOperation and
FullyDelegatedModificationApplyOperation which host partial and full
set of methods implemented as delegates.

FullyDelegatedModificationApplyOperation is used by AlwaysFailOperation
and RootModificationApplyOperation, as they the always-fail behaviour
is easily implemented through throwing ISE in delegate().

This eliminates 1-2 implementations of each ModificationApplyOperation
method.

Change-Id: I578769418baafb285593fefe8868e97e1d171157
JIRA: YANGTOOLS-944
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoCleanup AbstractValueNodeModificationStrategy 31/80031/1
Robert Varga [Wed, 30 Jan 2019 13:31:16 +0000 (14:31 +0100)]
Cleanup AbstractValueNodeModificationStrategy

The implementation did not log offending values and reused
verifyStructure() to perform validation, making analysis difficult.

Refactor the value check so that it is in a private method invoked
from the three codepaths which need to perform it, making code flow
clearer.

Change-Id: I315899982c0f304e0459d5ad33a19e56af0d2355
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoFix automatic lifecycle delete stacking 26/80026/1
Robert Varga [Mon, 28 Jan 2019 13:19:00 +0000 (14:19 +0100)]
Fix automatic lifecycle delete stacking

Nodes with automatic lifecycle have the strange property that their
delete operations may actually stack with other operations.

Unfortunately delete operation itself has no semantics of having
underlying modifications, as it has no baseline to which to apply
them.

In order to fix this, we need to turn deletes into empty writes
for these constructs and once we are performing disappearing, undo
this trick. This effectively means that both empty writes and deletes
result in a delete operation, if they ended up modifying the tree,
or into a no-op if they did not.

JIRA: YANGTOOLS-938
Change-Id: I68b9f304e76d6b1bdb707f411a87cd6085ed8bc7
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 75e30d2678989947221aef0fed94301faa785a9e)

5 years agoUpdate junit link 78/79978/1
Robert Varga [Mon, 28 Jan 2019 16:36:53 +0000 (17:36 +0100)]
Update junit link

javadoc.io breaks with JDK11, update the link.

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

5 years agoFix artifacts typo 04/79904/2
Robert Varga [Fri, 25 Jan 2019 11:14:28 +0000 (12:14 +0100)]
Fix artifacts typo

yangtools-docs is at the same version as yangtools, i.e. 2.1.9,
not 2.0.9.

Change-Id: I3d2473cee9d8b884931fc8a1960d992d2cd0d690
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoOptimize IMDT tests 56/79956/1
Robert Varga [Mon, 28 Jan 2019 12:55:19 +0000 (13:55 +0100)]
Optimize IMDT tests

These tests are sharing a SchemaContext, do not set it up multiple
times but reuse it across runs.

Change-Id: If9e27ace5e0e3af966102019d57ef074aa652c5b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoFix yangtools-docs 26/79826/1
Robert Varga [Tue, 22 Jan 2019 15:34:20 +0000 (16:34 +0100)]
Fix yangtools-docs

Current docs fail to correctly deploy, fix that up. Also group
packages to make them more readable.

Change-Id: Iebf8c785ca0fd7968724759a2b593ca559620057
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoRework aggregate javadocs 70/79770/7
Robert Varga [Sun, 20 Jan 2019 23:48:17 +0000 (00:48 +0100)]
Rework aggregate javadocs

Since javadoc:aggregate-jar is forcing a full re-generate and compile
of the project, let's take a different approach.

This patch overloads the purpose of the docs directory so that it
participates on maven build. It produces a pom file with attached
sources and javadocs. Later we can add more stuff to it, too.

Change-Id: I866e8405e73f297c552194a7caf10c1fd8b26731
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>