yangtools.git
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>
5 years agoRemove unneded artifacts entries 69/79769/1
Robert Varga [Sun, 20 Jan 2019 23:30:35 +0000 (00:30 +0100)]
Remove unneded artifacts entries

object cahce is a thing of the past, remove these stale
entries.

Change-Id: I3d81196819c291364b7dad2d53431b8f0024516c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoAllow {Json,Xml}ParserStream to handle actions 64/79764/2
Robert Varga [Sun, 20 Jan 2019 18:25:12 +0000 (19:25 +0100)]
Allow {Json,Xml}ParserStream to handle actions

Generalize the support for RPCs to include actions, so that we can
use both. Also fix null handling to comply with javadoc.

Change-Id: Id84052c1d1f20aa9d0371015f01b0c8845152de2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoAllow JSON/XML writers to be instantiated with root node 65/79765/2
Robert Varga [Sun, 20 Jan 2019 18:43:42 +0000 (19:43 +0100)]
Allow JSON/XML writers to be instantiated with root node

Rather than requiring a SchemaContext/SchemaPath combination, allow
writers to be instantiated by specifying a DataNodeContainer.

Change-Id: I9eb470587cad2af9b3390d134dcc03abc95e8645
JIRA: YANGTOOLS-935
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoBump version to 9-SNAPSHOT 59/79659/2
Robert Varga [Fri, 18 Jan 2019 14:42:20 +0000 (15:42 +0100)]
Bump version to 9-SNAPSHOT

This starts the next development cycle.

Change-Id: I0be6ec1cb52f2603c2d2d6077df26f9892d69495
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoBump to odlparent 4.0.9 58/79658/2
Stephen Kitt [Fri, 18 Jan 2019 13:50:35 +0000 (14:50 +0100)]
Bump to odlparent 4.0.9

Change-Id: Ie33ea4ef73069041ec5883c461f08ea31740d8c0
Signed-off-by: Stephen Kitt <skitt@redhat.com>
5 years agoRemove writeValue()'s IOException throws 55/79655/1
Robert Varga [Fri, 18 Jan 2019 12:08:07 +0000 (13:08 +0100)]
Remove writeValue()'s IOException throws

Neither implementation can throw an IOException, hence tighten
internal API contract.

Change-Id: I7e3fe5bebfae87f5130f85cd4f40c87061d528d1
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoClean up XMLStreamWriterUtils 87/79587/5
Robert Varga [Wed, 16 Jan 2019 21:27:05 +0000 (22:27 +0100)]
Clean up XMLStreamWriterUtils

This is slight refactor propagating @NonNull annotations and
acting on them:
- we do not need to use String.valueOf()
- we do not need guard against null values
- ValueWriter is a nice place to have a utility for doing
  writeCharacters(obj.toString())

Change-Id: Idcbc24036c2ae07cf93481cba1a2e311db7def6f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoDelay calling writeStartElement() 82/79582/7
Robert Varga [Wed, 16 Jan 2019 16:29:52 +0000 (17:29 +0100)]
Delay calling writeStartElement()

Java's default XMLStreamWriter is rather bad at emitting self-closing
tags, in that it will not do that unless we explicitly call
writeEmptyElement().

This is rather unfortunate, as there is plenty of cases, where it's
the writer's job to realize the element should be self-closing, for
example in case it carries only attributes -- which we simply have
no way of driving through XMLStreamWriter.

In order to make this work, we need to delay the call to
writeStartElement() until we see the next event, which can end up
being writeEndElement() -- which is where when we need to use
writeEmptyElement() instead.

Since value serializers can end up emitting namespace declarations
and characters into the stream, we hide the writer behind two classes:

- ValueWriter, which is abstract class strictly for use by serializers
  and exposes minimal methods required for them
- StreamWriterFacade, which is the sole implementation of ValueWriter,
  which holds methods required by XMLStreamNormalizedNodeStreamWriter

StreamWriterFacade thus has visibility into activity of both call
sites and can make appropriate decisions.

JIRA: YANGTOOLS-927
Change-Id: Ib42d7662d0b9b648132e93bc4ea9fbe012104deb
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoDeprecate XMLStreamNormalizedNodeStreamWriter.toString(Element) 88/79588/4
Robert Varga [Wed, 16 Jan 2019 22:16:33 +0000 (23:16 +0100)]
Deprecate XMLStreamNormalizedNodeStreamWriter.toString(Element)

This is an unused method, deprecate it for removal.

Change-Id: I6c0706d9d74ee7cae983b767c1b98e7899e04916
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoDo not write empty string in EmptyXmlCodec 83/79583/5
Robert Varga [Wed, 16 Jan 2019 21:38:04 +0000 (22:38 +0100)]
Do not write empty string in EmptyXmlCodec

Emitting an empty string does nothing but churn writer state,
so speed up EmptyXmlCodec by not touching the writer.

Change-Id: Iab7db37089b84ec1a3c2e3c9381265025e21fdca
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoRefactor implementations to hide XMLStreamWriter 81/79581/4
Robert Varga [Wed, 16 Jan 2019 15:23:21 +0000 (16:23 +0100)]
Refactor implementations to hide XMLStreamWriter

In order to have control over when we output an element, we need
to make sure we know how the writer is being used.

Refactor XMLStreamNormalizedNodeStreamWriter interaction with its
subclasses so we know when we are leaking the writer -- which
happens only in writeValue().

JIRA: YANGTOOLS-927
Change-Id: I7e7bd62016e994a31fe6d69995e9d088746359da
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoRework anyxml encoding 24/79524/8
Robert Varga [Mon, 14 Jan 2019 19:55:36 +0000 (20:55 +0100)]
Rework anyxml encoding

It seems JRE's Transformers are broken in the DOM->StAX direction,
such they do not work with external StAX implementations like
woodstox-core.

As it turns out, this is quite unnecessary complexity because
stax2-api gives us XMLStreamReader wrapping a DOM Element, which
we are already using in the parser side.

This patch removes the the use the transformer in favor of rather
simpler forwarding of XMLStreamReader events to the underlying
XMLStreamWriter.

Also move StAX-based transformer to XmlParserStream, as it is now
the only user of StAX->DOM, updating required feature to StAXSource.

Performs plain old DOM->stream translation, hence it can use any
old transformer.

JIRA: YANGTOOLS-926
Change-Id: I25d0210a6b76f7cbbd5956814773d26776cbace6
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoRemove unused XMLStreamWriterUtils.writeAttribute() method 84/79584/1
Robert Varga [Wed, 16 Jan 2019 18:38:52 +0000 (19:38 +0100)]
Remove unused XMLStreamWriterUtils.writeAttribute() method

This method is completely unused, remove it.

Change-Id: I74c5eb42a1d20464270a41329bb849dd0e5b0b0e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoFix default namespace emission 46/79546/3
Robert Varga [Tue, 15 Jan 2019 18:19:08 +0000 (19:19 +0100)]
Fix default namespace emission

When we are emitting opening a new element, we need to consult
XMLStreamWriter before we emit the element, otherwise its state
already reflects the newly-started element.

In non-repairing mode the JDK writer will accept our invocation
and update the namespace mapping, which will lead us to erroneously
assume we do not need to emit the declaration.

Since it is non-repairing, it will not emit the declaration itself,
leading to a blank document -- something for which we are actually
testing in one of our tests.

In order to improve the confidence in results, also update tests
which used only repairing factories to use both repairing and
non-repairing ones.

JIRA: YANGTOOLS-801
Change-Id: I6975cf21121f7a8f92056b5b49b31d53b685dc0f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoImprove JAXP implementation compatibility 44/79544/2
Robert Varga [Tue, 15 Jan 2019 16:50:03 +0000 (17:50 +0100)]
Improve JAXP implementation compatibility

Testing with woodstox-core shows a couple of UT failures that
are really assumptions on the implementation. Address them so we
do not get failures when implementation changes (too much).

While we are at it, improve startsWith/contains string checks
by using hamcrest.

Change-Id: I4af0c9cc370e5699255725f049ee7bb9b5c171ac
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoAdd javadoc.io badge 12/79412/1
Robert Varga [Thu, 10 Jan 2019 11:45:59 +0000 (12:45 +0100)]
Add javadoc.io badge

With aggregated javadocs out there, add a badge pointing to
javadoc.io.

Change-Id: I4fe75f7df39e56b01e6f33603f622577b90bdc9b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoStart 2.1.8 release development 03/79403/1
Robert Varga [Thu, 10 Jan 2019 10:15:52 +0000 (11:15 +0100)]
Start 2.1.8 release development

This bumps artifacts to .8-SNAPSHOT version.

Change-Id: I023530bb8d3599149e74607ab97f0c92f96edd9c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoBump to odlparent 4.0.8 52/79352/1
Stephen Kitt [Wed, 9 Jan 2019 14:01:54 +0000 (15:01 +0100)]
Bump to odlparent 4.0.8

Change-Id: Iee91b1e015ee6c8a122b427860d5e96fd9f8cd42
Signed-off-by: Stephen Kitt <skitt@redhat.com>
5 years agoRemove JSR305 annotations from yang-data-codec-gson 66/79266/2
Robert Varga [Mon, 7 Jan 2019 09:30:49 +0000 (10:30 +0100)]
Remove JSR305 annotations from yang-data-codec-gson

Ditch JSR305 annotations in favor of JDT annotations.

JIRA: YANGTOOLS-907
Change-Id: I9b5a19f88f54ca92e07ce8404b469cc76a7858a5
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoRemove JSR305 annotations from yang-data-codec-xml 67/79267/1
Robert Varga [Mon, 7 Jan 2019 10:06:53 +0000 (11:06 +0100)]
Remove JSR305 annotations from yang-data-codec-xml

Ditch JSR305 annotations in favor of JDT annotations.

JIRA: YANGTOOLS-907
Change-Id: Ife00f06b20b562f62514f8fbd2e36e3179223857
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoRemove JSR305 annotations from yang-data-util 65/79265/2
Robert Varga [Mon, 7 Jan 2019 09:39:47 +0000 (10:39 +0100)]
Remove JSR305 annotations from yang-data-util

Ditch JSR305 annotations in favor of JDT annotations.

JIRA: YANGTOOLS-907
Change-Id: Ia183995a947277ea78cb9e37e2aa1494f937c43e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoAlign createQName @Nonnull declarations 61/79261/1
Stephen Kitt [Mon, 7 Jan 2019 08:42:09 +0000 (09:42 +0100)]
Align createQName @Nonnull declarations

RFC7951JSONInstanceIdentifierCodec overrides createQName with a
mismatched lastModule annotations; this patch aligns the annotations
(@Nonnull) without changing the implementation (which throws an
IllegalArgumentException if lastModule is null).

(Caught by SpotBugs.)

Change-Id: I9e08241a5ec1c58554a0cd178e46ad4aeb061a77
Signed-off-by: Stephen Kitt <skitt@redhat.com>
5 years agoRemove unneeded jaxb-api workarounds 36/79136/1
Robert Varga [Wed, 2 Jan 2019 12:53:46 +0000 (13:53 +0100)]
Remove unneeded jaxb-api workarounds

odlparent-4.0.5 provides a correct declaration of jaxb-api
and exclusions, hence we can remove them.

Change-Id: I91bd84fc7c8bd566d178a875df0d07addf08893b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoAdd Codec/Deserializer/Serializer FIXMEs 95/79095/1
Robert Varga [Tue, 1 Jan 2019 16:28:57 +0000 (17:28 +0100)]
Add Codec/Deserializer/Serializer FIXMEs

The general design of Codec/Serializer/Deserializer allows for
nulls and does not allow for error reporting. This should be
fixed in next API design review.

Change-Id: Ib553d17f2ea570589b9c0094d1be6a0bcf598072
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoMigrate parser to JDT annotations 04/76704/10
Robert Varga [Tue, 1 Jan 2019 15:28:38 +0000 (16:28 +0100)]
Migrate parser to JDT annotations

This gets rid of unneeded nullness annotations and migrates
the remaining ones to JDT.

JIRA: YANGTOOLS-907
Change-Id: I601df58c7270bcc7e78d661a4a0b0eb430d53631
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoAttach aggragate javadocs to aggragator 36/79036/3
Robert Varga [Mon, 24 Dec 2018 21:23:13 +0000 (22:23 +0100)]
Attach aggragate javadocs to aggragator

This allows us to point users to our aggregated javadocs, hence
they do not fish for them.

Change-Id: If191cdfd45c2732a96d4a62deb183f6add155a65
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoBump odlparent to 4.0.7 81/79081/4
Robert Varga [Thu, 27 Dec 2018 15:56:56 +0000 (16:56 +0100)]
Bump odlparent to 4.0.7

This fixes Java11 SFT compatiblity and removes the need to
declare triemap import.

Change-Id: Ia7c3f448cfceedd4cc6acd65b469438b328386c2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoEnable spotbugs in yang-parser-reactor 16/76016/9
Robert Varga [Wed, 12 Sep 2018 00:51:26 +0000 (02:51 +0200)]
Enable spotbugs in yang-parser-reactor

Fix reported issues and flip the switch.

Change-Id: I3c496143e8c666dd103a429bcce2c586a313915b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoShorten StatementMap$Regular.get(int) 54/79054/2
Robert Varga [Wed, 26 Dec 2018 02:36:03 +0000 (03:36 +0100)]
Shorten StatementMap$Regular.get(int)

We can use a trigraph instead of a if/return combo, saving an
instruction.

Change-Id: If1482da5a4cf83f87b4d995333d757d2fa2d7e12
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoFix StatementMap$RegularAsCollection's size 24/76024/6
Robert Varga [Wed, 12 Sep 2018 09:29:40 +0000 (11:29 +0200)]
Fix StatementMap$RegularAsCollection's size

We are not initializing the size field, hence the class does not
operate correctly. Fix that and remove isEmpty(), which is a useless
override.

Change-Id: I1543e617f14f0a88c6b59afe93364cace151ee5c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoMass-migrate to Objects.requireNonNull() 40/79040/4
Robert Varga [Tue, 25 Dec 2018 21:58:19 +0000 (22:58 +0100)]
Mass-migrate to Objects.requireNonNull()

Rather than using Guava's version of this method, use JDK8-native
one.

Change-Id: I43f229fecb0490103b4a02d9d8242e91797ae177
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoSpeed up StatementContextVisitor.getValidStatementDefinition() 42/79042/6
Robert Varga [Tue, 25 Dec 2018 22:18:49 +0000 (23:18 +0100)]
Speed up StatementContextVisitor.getValidStatementDefinition()

Unprefixed statements are most common and we end up creating
a QNameModule each time we encounter them, while we have a common
constant which we can use.

Use the constant, allowing us to allocate fewer objects while
also allowing making interning work.

Change-Id: I9e8847f8bd39fb9bcf6f8d0e8b86d196aeb5e2cd
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoFix noRev map efficiency 46/79046/3
Robert Varga [Tue, 25 Dec 2018 23:07:24 +0000 (00:07 +0100)]
Fix noRev map efficiency

QName.getRevision() always returns non-null, which means we are
always taking the slow version of this branch, as correctly flagged
by Eclipse.

Furthermore we can use QName.withoutRevision() to side-step QName's
localName validation, as the local name is known to have already
been checked.

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