yangtools.git
5 years agoRemove ClassLoaderUtils.findFirstGenericArgumentTask() 06/72406/1
Robert Varga [Tue, 29 May 2018 12:13:06 +0000 (14:13 +0200)]
Remove ClassLoaderUtils.findFirstGenericArgumentTask()

This has a single caller, inline it there, eliminating a warning.

Change-Id: I8c472df53dec83547b074657343754ed3d75b56a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoFix YangModelDependencyInfo handling of arguments 73/72373/1
Robert Varga [Mon, 28 May 2018 16:49:34 +0000 (18:49 +0200)]
Fix YangModelDependencyInfo handling of arguments

Malformed YANG models could cause a NPE, let's be careful around
them and report IAE instead.

Change-Id: Idf31e2e383142e1283c978eccdf123faa7e40617
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoBump versions to next development cycle 47/72347/1
Robert Varga [Mon, 28 May 2018 07:43:15 +0000 (09:43 +0200)]
Bump versions to next development cycle

1.0.6-SNAPSHOT/2.0.6-SNAPSHOT.

Change-Id: Idb57c0481550a55630b8f401905e207404d9751f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoTrack current path in a stack 34/72134/10
Robert Varga [Mon, 21 May 2018 21:02:12 +0000 (23:02 +0200)]
Track current path in a stack

Rather than creating temporary InstanceIdentifiers, which eagerly
calculate hashCode and cost 32-64 bytes each, use a dedicated stack,
which costs 72-112 bytes without the need for hash code computations.

Since a DataTree may not start at YangInstanceIdentifier.EMPTY, we
need to have a dedicated subclass to properly report the full path.

The contents of the stack are converted to a YangInstanceIdentifier
when needed -- which is only in error paths.

Change-Id: Ifd77a79e6d7481a4355ecb052c9fc2d2c3c1f463
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoIntroduce RequiredElementCountException 49/72149/2
Robert Varga [Tue, 22 May 2018 09:07:47 +0000 (11:07 +0200)]
Introduce RequiredElementCountException

This exception captures min-elements/max-elements validation failure,
allowing users to recognize it.

Change-Id: Ia3a8a9a4f90978bac1cf7ced24980fc82cd8582c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoEliminate synthetic bridge methods in DataValidationException 48/72148/2
Robert Varga [Tue, 22 May 2018 09:03:46 +0000 (11:03 +0200)]
Eliminate synthetic bridge methods in DataValidationException

Having private constructors requires the compiler to create bridge
methods, relax constructor visibility.

Change-Id: Ibc584b8970d1f288794a45a8df7cf74412b47cac
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoCleanup yang-data-impl tests 21/72121/7
Robert Varga [Mon, 21 May 2018 17:07:23 +0000 (19:07 +0200)]
Cleanup yang-data-impl tests

- remove unneded throws
- do not store SchemaContext when not needed
- cache SchemaContext when it is used for multiple tests

Change-Id: I7a9ce0bcd08454409e371ca72957b1a4015dedbb
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoFix min/max validation inside written value 03/71803/16
Robert Varga [Fri, 4 May 2018 16:25:35 +0000 (18:25 +0200)]
Fix min/max validation inside written value

When the user is writing a complete tree min/max elements
validation needs to occur inside validateStructure(), as that
runs when the data is being introduced. If we fail to validate
it then, the parent will be committed with the assumption that
the written value actually conforms to the schema.

Fix MinMaxElementsValidation to check the number of elements
inside verifyStructure(), so we flat out reject invalid writes.

JIRA: YANGTOOLS-776
Change-Id: Ie804463612403c578f0f9230884ae53641ba76c6
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoClean up AbstractDataTreeTip 32/72132/6
Robert Varga [Mon, 21 May 2018 19:44:08 +0000 (21:44 +0200)]
Clean up AbstractDataTreeTip

Remove duplicate code and use static imports for checkArgument()
and checkState().

Change-Id: Ief1bc003e4bdca87188447e11cf3bd7d20c90fae
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoAdd cursor benchmarks 40/72140/2
Robert Varga [Tue, 22 May 2018 02:05:33 +0000 (04:05 +0200)]
Add cursor benchmarks

Cursor operations are supposedly more efficient as they do not need
to go through YangInstanceIdentifier. Add a microbenchmark to test
that theory.

Change-Id: Ic98b5219bfe5629b0edf6f4cbf8265695afa25f0
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoFix benchmarks 38/72138/4
Robert Varga [Mon, 21 May 2018 22:01:53 +0000 (00:01 +0200)]
Fix benchmarks

Benchmarks have been in a state of disarray, fix them up:
- use yang-test-utils
- properly ready modifications
- upgrade JMH to 1.21

Change-Id: I8fa90cdde3b56664935685ad62452bb7c272cf3d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoRemove checkstyle-logging 39/72139/1
Robert Varga [Tue, 22 May 2018 01:29:33 +0000 (03:29 +0200)]
Remove checkstyle-logging

Aggregator poms should not be doing checkstyle, remove it.

Change-Id: Ie4560db89d5f03f40a8b28ce1db911c8aec245b2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoExpose ImmutableNodes.mapNodeBuilder(NodeIdentifier) 37/72137/1
Robert Varga [Tue, 22 May 2018 00:42:04 +0000 (02:42 +0200)]
Expose ImmutableNodes.mapNodeBuilder(NodeIdentifier)

This utility is useful for users who have a NodeIdentifier handy,
bypassing NodeIdentifier.create().

Change-Id: I10f16ce5048ccb3b646761694b38f431447e09f2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoAdd a few 3.0.0 FIXMEs 33/72133/2
Robert Varga [Mon, 21 May 2018 20:09:42 +0000 (22:09 +0200)]
Add a few 3.0.0 FIXMEs

Clarify thrown exceptions and nullness, as well as the need to use
Optional.

Change-Id: I8a960b2593b87552f24d0de3d28cb75a1d4fb040
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoFix a raw type user 23/72123/2
Robert Varga [Mon, 21 May 2018 17:21:40 +0000 (19:21 +0200)]
Fix a raw type user

We don't really need to use raw types -- qualify the case and remove
corresponding @SuppressWarnings.

Change-Id: I0797b26bb40059654b718beeaf20095aebd9c3c0
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoFix AbstractValueNodeModificationStrategy message typos 24/72124/2
Robert Varga [Mon, 21 May 2018 17:32:41 +0000 (19:32 +0200)]
Fix AbstractValueNodeModificationStrategy message typos

We are missing a space in the message, fix that.

Change-Id: Iddc718ebd04d41fa6f994aa9310e9f8bf9b55e5c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoFix SchemaAwareApplyOperation whitespace 16/72116/1
Robert Varga [Mon, 21 May 2018 14:39:03 +0000 (16:39 +0200)]
Fix SchemaAwareApplyOperation whitespace

There should be only one space

Change-Id: I1fb3cb1427f356d4d51fc79ee2ffec236e296e5a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoFix a javadoc typo 15/72115/1
Robert Varga [Mon, 21 May 2018 14:38:48 +0000 (16:38 +0200)]
Fix a javadoc typo

writen -> written

Change-Id: I383996cd5b38de896dd1efe1a5ad2595ff4a5bf8
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoMake tests use UntrustedXML instead of XMLInputFactory 41/72041/1
Robert Varga [Wed, 16 May 2018 15:23:17 +0000 (17:23 +0200)]
Make tests use UntrustedXML instead of XMLInputFactory

We really do not want to instantiate factories in tests, as they
we do not configure them -- use a pre-configured factory in UntrustedXML.

Change-Id: I7b34a426a4fae9819d15053895b5a0aee5af335e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoYANGTOOLS-804: Netconf payload fails to render in JSON for anyxml 58/71058/8
Balaji Varadaraju [Tue, 17 Apr 2018 23:08:32 +0000 (18:08 -0500)]
YANGTOOLS-804: Netconf payload fails to render in JSON for anyxml

When a YANG model contains an anyxml element the output does not render correctly
in JSON in Restconf. XML output works however. Upon investigation we found issue
was with recognising and handling collections in XML. This patch addresses the
same and also enhanced and added more unit tests.

Change-Id: Icb238dd95a3b9af9c4d0f48ff673a7c285925364
Signed-off-by: Balaji Varadaraju <bvaradar@luminanetworks.com>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoAdd yang-data-api API evolution guidance 24/72024/1
Robert Varga [Tue, 15 May 2018 23:13:04 +0000 (01:13 +0200)]
Add yang-data-api API evolution guidance

This adds 3.0.0 and 4.0.0 evaluation FIXMEs. These need to be accounted
for in release planning and adopted, rejected or pushed out.

Change-Id: I50657a6bbb020189a4ac8662afb16bf1f7b7215f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoSimplify equals() implementation 94/71894/1
Robert Varga [Wed, 9 May 2018 12:41:34 +0000 (14:41 +0200)]
Simplify equals() implementation

We can use a simple return statement, do that to keep sonar happy.

Change-Id: I6b7ddbf7c9b7dd65c5595879a84c559b33818905
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoDo not declare URISyntaxException as thrown 93/71893/1
Robert Varga [Wed, 9 May 2018 12:37:07 +0000 (14:37 +0200)]
Do not declare URISyntaxException as thrown

This is not thrown from the body, hence we can simply remove it.

Change-Id: Ic5819ddbc25aea0bed7ed7da9ba79a8e40d98a88
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoMove trailing comments 92/71892/1
Robert Varga [Wed, 9 May 2018 12:33:10 +0000 (14:33 +0200)]
Move trailing comments

This is to make sonar happy.

Change-Id: Iadb582329c5774c6e302317a70d718869444d2f2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoDo not declare runtime exceptions 91/71891/1
Robert Varga [Wed, 9 May 2018 12:26:44 +0000 (14:26 +0200)]
Do not declare runtime exceptions

This is to keep sonar happy.

Change-Id: I306cbab1a471e6aec17e4abc76282766c72164d3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoFix yang-data-impl code smells 89/71889/1
Robert Varga [Wed, 9 May 2018 09:13:44 +0000 (11:13 +0200)]
Fix yang-data-impl code smells

This is a pass at addressing Sonar-reported issues.

Change-Id: I39a3aaf3369c6144cc9f03636242809a3de4f4d8
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoFix code smells in AlwaysFailOperation 84/71884/1
Robert Varga [Wed, 9 May 2018 09:07:31 +0000 (11:07 +0200)]
Fix code smells in AlwaysFailOperation

Concentrate IllegalStateException into a utility method.

Change-Id: I45fe9e20cc6c6facfdc4f468cd27d5a2f05719f2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoFix yang-data-jaxen code smell 83/71883/1
Robert Varga [Wed, 9 May 2018 09:06:56 +0000 (11:06 +0200)]
Fix yang-data-jaxen code smell

Using a semicolon confuses Sonar, let's not do that.

Change-Id: I51fee4642b90aa50865b0b1874bf9d81b88fbc77
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoFix code smell in RootModificationApplyOperation 82/71882/1
Robert Varga [Wed, 9 May 2018 09:06:25 +0000 (11:06 +0200)]
Fix code smell in RootModificationApplyOperation

Runtime exceptions should not be declared.

Change-Id: I04326273b3ed00a0e5f8f3787122ba1fd7360153
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoFix YangFunctionContext code smell 81/71881/1
Robert Varga [Wed, 9 May 2018 09:05:03 +0000 (11:05 +0200)]
Fix YangFunctionContext code smell

Trailing comments are discouraged, move the comment.

Change-Id: Idf7eb55464fe541f9f18095fc819332a786d7cb1
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoAdd yang-data-jaxen OSGi activator 30/71830/1
Robert Varga [Mon, 7 May 2018 11:24:56 +0000 (13:24 +0200)]
Add yang-data-jaxen OSGi activator

While we are providing a ServiceLoader definition, which can be
picked up by SPI Fly, provide an explicit OSGi activator, too.

Change-Id: Id7a221b34c10aeb4f492c9ab71b7af431840d718
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoRemove misleading TODO 24/71824/1
Robert Varga [Mon, 7 May 2018 09:41:46 +0000 (11:41 +0200)]
Remove misleading TODO

Write+Merge correctly result in both nodes being present, hence
the TODO is not really current.

Change-Id: I14a19ef4f31c665aae264a7a00c7cf41a1a75c6b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoDiscern exceptions when building LeafRefContext 98/71798/1
Robert Varga [Fri, 4 May 2018 13:03:33 +0000 (15:03 +0200)]
Discern exceptions when building LeafRefContext

IOExceptions are unexpected and result in an IllegalStateException,
while LeafRefYangSyntaxErrorException indicates an inconsistent
schema context, hence results in an IllegalArgumentException.

Change-Id: I5282dc964f64af7a46794e3a02e219358fd95285
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoThrow ISE when the thread is interrupted 97/71797/1
Robert Varga [Fri, 4 May 2018 13:00:10 +0000 (15:00 +0200)]
Throw ISE when the thread is interrupted

We really are failing, throw an IllegalStateException rather than
a RuntimeException.

Change-Id: I9a77ff1d537f4836eabbcebf364a070156848949
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoThrow ISE from SharedCodecCache 96/71796/1
Robert Varga [Fri, 4 May 2018 12:57:20 +0000 (14:57 +0200)]
Throw ISE from SharedCodecCache

When we fail to compute a cached value this amounts to an illegal
state -- throw IllegalStateException instead of RuntimeException.

Change-Id: Icafc0b9f054e7d2719f262b2ffac356fac49fa3c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoSpeed up XMLStreamNormalizedNodeStreamWriter.toString() 95/71795/1
Robert Varga [Fri, 4 May 2018 12:52:50 +0000 (14:52 +0200)]
Speed up XMLStreamNormalizedNodeStreamWriter.toString()

We already have a TransformerFactory, no need to create a new one,
which speeds up processing. Also change the thrown exception to
IllegalStateException, as we do not really expect this to fail.

Change-Id: I6710893ec7324a7cba26b13e8d7cdb9c2414167e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoFix code smells in checkstyle-logging 94/71794/2
Robert Varga [Fri, 4 May 2018 11:32:55 +0000 (13:32 +0200)]
Fix code smells in checkstyle-logging

Simple code structure changes, which will also slightly improve
performance.

Change-Id: I44f78506af8d3b0fb544080e2f6a1b25c9b5e0a8
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoFix code smells in yang-parser-spi 92/71792/2
Robert Varga [Fri, 4 May 2018 11:12:19 +0000 (13:12 +0200)]
Fix code smells in yang-parser-spi

These are simple Sonar violations, clear them up.

Change-Id: Ib8e71154ab29e87afff8a3696c8b8749bc2806ce
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoFix Sonar-reported code smells in yang-parser-reactor 91/71791/1
Robert Varga [Fri, 4 May 2018 10:55:03 +0000 (12:55 +0200)]
Fix Sonar-reported code smells in yang-parser-reactor

These are simple violations, fix them up.

Change-Id: I7a9b6a0b1276cb5d74967fb371ef2cdf7645cb84
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoBump versions for yangtools-2.0.5 development 88/71788/1
Robert Varga [Fri, 4 May 2018 09:15:05 +0000 (11:15 +0200)]
Bump versions for yangtools-2.0.5 development

This patch bumps to 2.0.5-SNAPSHOT/1.0.5-SNAPSHOT.

Change-Id: Ieb45bc56cad1fdeb2aad057d334b11233c76f365
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoMake Variant/CheckedValue subclassable 64/71664/1
Robert Varga [Wed, 2 May 2018 12:39:12 +0000 (14:39 +0200)]
Make Variant/CheckedValue subclassable

It is useful to specialized these two classes outside of concepts,
for example by providing alternative constructs on top of Variant
and providing a type-bound domain-specific CheckedValue.

Expose constructors and first()/second() to subclasses so that it
is feasible to perform these things.

Change-Id: I1253ba2b0ed115b0b3f6dc6f07138634f15091de
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoDo not use jaxen XPath 37/71537/2
Robert Varga [Sat, 28 Apr 2018 10:37:52 +0000 (12:37 +0200)]
Do not use jaxen XPath

We are really interested only in Expr and its evaluation, hence we
can skip the BaseXPath class, which is hiding things from us.

This also lowers the memory overhead of compiled expression very
slightly and improves performance, as the result is not needlessly
obfuscated via a singleton list.

Furthermore we no longer go through XPathReaderFactory, which incurs
reflection overhead, but rather instantiate
org.jaxen.saxpath.base.XPathReader directly.

Change-Id: I7fd315c17f4013f927e724226408ba12f8445606
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoStore XPath rather than BaseXPath 36/71536/1
Robert Varga [Sat, 28 Apr 2018 09:57:05 +0000 (11:57 +0200)]
Store XPath rather than BaseXPath

JaxenXPath should not really care how the XPath is implemented,
hence store just the interface. We still need BaseXPath for now.

Change-Id: I2a73cd51a02c0d99d9adf37801bccc83edce523c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoSpeed up YangFunctionContext.isDerivedFrom{OrSelf} 21/71521/2
Robert Varga [Fri, 27 Apr 2018 16:30:53 +0000 (18:30 +0200)]
Speed up YangFunctionContext.isDerivedFrom{OrSelf}

Rather than collecting a HashSet for the sole purpose or running
a single contains(), search for the target identity in ancestry.

Change-Id: I0d8c7b1d390c3f56b848c19b933cffa52a7bf9e3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoReorganize YangFunctionContext 20/71520/2
Robert Varga [Fri, 27 Apr 2018 16:15:00 +0000 (18:15 +0200)]
Reorganize YangFunctionContext

Sonar is not very happy about large lambdas, so reorganize this
class to use static methods and method handles as an alternative
to to constants.

Change-Id: I60a31091ed623eed001042574892d55cf9238c09
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoAdd DataSchemaContextTreeTest 15/71515/1
Robert Varga [Fri, 27 Apr 2018 14:59:41 +0000 (16:59 +0200)]
Add DataSchemaContextTreeTest

DataSchemaContextTree is completely untested, this patch adds some
unit tests.

Change-Id: I68b3c77080fa1b155ec28ca6ced4d15039437ec8
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoClean up DataSchemaContext{Node,Tree} 14/71514/1
Robert Varga [Fri, 27 Apr 2018 14:49:29 +0000 (16:49 +0200)]
Clean up DataSchemaContext{Node,Tree}

This patch fixes a potential NPE when a YangInstanceIdentifier does
not match the schema tree and adds alternative Optional-based methods
for finding children based on relative/absolute YangInstanceIdentifier.

Change-Id: Icdc08c02817ad9d59434a060b6da27dfe2b5ea67
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoExpose DataTreeSnapshot's SchemaContext 90/71390/1
Robert Varga [Thu, 26 Apr 2018 09:01:28 +0000 (11:01 +0200)]
Expose DataTreeSnapshot's SchemaContext

There are use cases where we need to acquire the SchemaContext
associated with a snapshot. Introduce a method to acquire it.

Change-Id: I16053e03068e7313d409b4d35353eb3c0328b76f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoExpose copy-based MapEntryNodeBuilder 18/71318/1
Juraj Kosmel [Fri, 9 Dec 2016 14:12:36 +0000 (06:12 -0800)]
Expose copy-based MapEntryNodeBuilder

This is a missing method needed for keyed lists.

Change-Id: Ie62be953c141f3c23cbd25eef261f21cbee1a018
Signed-off-by: Juraj Kosmel <juraj.kosmel@pantheon.tech>
6 years agoAdd CheckedValue future bridge methods 88/71188/1
Robert Varga [Sat, 21 Apr 2018 13:26:09 +0000 (15:26 +0200)]
Add CheckedValue future bridge methods

This patch adds convenience methods to convert a CheckedValue
into a immediately-complete {Completable,Fluent}Future as well
as bridge methods to complete existing {Completable,Settable}Futures
with the contained value.

Change-Id: I9abf3c76b62e591f83b5a219bea434429053164e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoFix checkstyle in yang-model-export 49/71049/3
Robert Varga [Tue, 17 Apr 2018 17:36:54 +0000 (19:36 +0200)]
Fix checkstyle in yang-model-export

Fix violations and enable enforcement.

Change-Id: I22ac0386510e001e09d3fd883876f92785e2f88f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoFix checkstyle in yang-parser-api 48/71048/1
Robert Varga [Tue, 17 Apr 2018 17:26:39 +0000 (19:26 +0200)]
Fix checkstyle in yang-parser-api

Fix the few violations and start enforcing checkstyle.

Change-Id: I04929e336d369265969989082e42db61c2a485ef
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoTag CanonicalValueSupport services 21/71021/1
Robert Varga [Tue, 17 Apr 2018 08:06:14 +0000 (10:06 +0200)]
Tag CanonicalValueSupport services

This generates ServiceLoader service entries, so that supports can
be loaded at runtime.

Change-Id: Ieed985d9db759f23962db9b4e145700ef08765e8
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoConvert CanonicalValue{Support,Validator} to use Variant 99/70999/8
Robert Varga [Mon, 16 Apr 2018 21:28:17 +0000 (23:28 +0200)]
Convert CanonicalValue{Support,Validator} to use Variant

Variant is useful here, as we can return either a CanonicalValue
or CanonicalValueViolation (which holds error details). This allows
us to side-step exception throws while retaining error information.

Change-Id: Ie3d1d6ff21611391a912b6ccfb208c0d58fa9ab5
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoAdd ModifyAction documentation 07/71007/4
Robert Varga [Tue, 17 Apr 2018 01:39:10 +0000 (03:39 +0200)]
Add ModifyAction documentation

Adds partial documentation and marks future evolution considerations.

Change-Id: I0eca13d8d9790435c77a3a9d3fd658f0c5cc8c75
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoAdd TreeType documentation 06/71006/4
Robert Varga [Tue, 17 Apr 2018 01:27:14 +0000 (03:27 +0200)]
Add TreeType documentation

Clarify TreeType's relationship with RFC6020, RFC7950 and RFC8342,
add 2.1.0/3.0.0 design considerations.

Change-Id: Ie74eba7244270015be87fdaf5e48d6d265f6e099
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoRemove unneeded scope 08/71008/1
Robert Varga [Tue, 17 Apr 2018 02:16:49 +0000 (04:16 +0200)]
Remove unneeded scope

odlparent has fixed the scope of metainf-services, remove
the now-unneeded declaration.

Change-Id: I8d29db2ef06e6b141adf876e19753c821469b7a7
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoConvert base types to implement CanonicalValue 90/70990/6
Robert Varga [Mon, 16 Apr 2018 16:27:54 +0000 (18:27 +0200)]
Convert base types to implement CanonicalValue

With CanonicalValue concept defined we can now retrofit into our
base support types for YANG. Aside from the canonical representation
which these classes provided, this allows them to communicate
value validation as needed.

Change-Id: I3ea24ecc2cbf3c2e23a3020b722b7a038f62b321
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoAdd generalized CanonicalValue YANG concept 89/70989/6
Robert Varga [Mon, 16 Apr 2018 15:54:17 +0000 (17:54 +0200)]
Add generalized CanonicalValue YANG concept

The parsing and validation concepts in DerivedString are really
useful in expressing that a particular value has been validated
to conform to some abstract contract.

This facility will allow us to side-step validation when moving
data between classes, especially when we can prove requried
validation has already been done.

This patch introduces CanonicalValue and support interfaces, so
it can be used more widely.

JIRA: YANGTOOLS-418
Change-Id: Ib3f8723facd60c6737351d863ad0f9cef6c4a5da
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoAdd yangtools.concepts.CheckedValue 65/70265/13
Robert Varga [Tue, 3 Apr 2018 07:42:21 +0000 (09:42 +0200)]
Add yangtools.concepts.CheckedValue

There are quite a few places where we would like to conditionally
create a value or report an error. These currently rely on thrown
exceptions, which has a performance penalty.

Introduce CheckedValue, which acts as a combined holder object
for either a value or an Exception. These objects can act as
intermediaries between callers and callees.

The underlying concept here is that of a variant value, which contains
either a value of type A or a value of type B. This patch adds
the concept as a utility Variant<T, U>.

Change-Id: Ibc6f562e22805b38402436cd9c0368dfcbb775fa
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoConsider submodule imports when sorting modules 74/70974/8
Robert Varga [Mon, 16 Apr 2018 10:24:39 +0000 (12:24 +0200)]
Consider submodule imports when sorting modules

YANGTOOLS-806 started skipping import statements, hence
a module's effective requirements are no longer expressed
in their imports.

Teach ModuleDependencySort about submodules and populate
the graph based on submodule's imports, too.

JIRA: YANGTOOLS-876
Change-Id: I1aed32de034cf2e602e130afcbeafb171fac514b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoAdd ModuleDependencyInfoTest 78/70878/9
Robert Varga [Thu, 12 Apr 2018 22:31:26 +0000 (00:31 +0200)]
Add ModuleDependencyInfoTest

We are missing an explicit test suite, start one.

Change-Id: I93e17df5c178d134a5d5a3bd586b398f93b0c4f3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoFix copyright year 82/70882/1
Robert Varga [Fri, 13 Apr 2018 00:11:16 +0000 (02:11 +0200)]
Fix copyright year

This is a fresh file, not a three-year-old one.

Change-Id: Id01a7249da3d100cf65256edb2bb741aa34a139a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoProvide some yangtools.yang.common javadoc 79/70879/2
Robert Varga [Thu, 12 Apr 2018 23:26:11 +0000 (01:26 +0200)]
Provide some yangtools.yang.common javadoc

This package deserves an introduction, provide one.

Change-Id: I9dfab88255d53915ed0df8ca9d59208a1030824c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoHarden yang-model-util test suite 77/70877/1
Robert Varga [Thu, 12 Apr 2018 22:05:00 +0000 (00:05 +0200)]
Harden yang-model-util test suite

Update the test suite to use yangtools mockito configuration, forcing
all mocking to be done.

Change-Id: Icbf0cd0bc6932b6b807bb6a5ac0fd3712543c99e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoMake yang.common base types non-final 75/70875/1
Robert Varga [Thu, 12 Apr 2018 19:34:42 +0000 (21:34 +0200)]
Make yang.common base types non-final

While final classes are useful, we will require the ability to mark
validation level of a particular piece of data in a vein similar to
DerivedString -- which requires subclassing to work memory-efficiently.

This patch prepares for that work by making the types non-final,
but does not allow their particulars to be overridden, so they still
form an effectively-final contract just like DerivedString
representations do.

Change-Id: Id7bde4b49d8b8aeb87c9b6e7317e5aa8f55e98eb
JIRA: YANGTOOLS-418
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoFixup DerivedStringValidator representation checking 89/70789/1
Robert Varga [Wed, 11 Apr 2018 15:32:35 +0000 (17:32 +0200)]
Fixup DerivedStringValidator representation checking

Validated DerviedStrings need to define compareTo() on the base
representation, disable the check for validators.

JIRA: YANGTOOLS-418
Change-Id: I8413674d15fc4caf7492402ddfb92e4de05d9c3f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoImprove ClassLoaderUtils.loadClassWithTCCL() 59/70659/2
Robert Varga [Mon, 9 Apr 2018 13:38:33 +0000 (15:38 +0200)]
Improve ClassLoaderUtils.loadClassWithTCCL()

There are scenarios when we do not have a Thread Context Class Loader,
such as when executing from Netty's GlobalEventExecutor. When we attempt
to load a class in that scenario, the method will throw a NPE, which
exposes users which can deal with the class not being able to load
to a RuntimeException -- preventing recovery.

Detect the case when TCCL is null and report a failure to load the class,
noting the reason for the failure.

Change-Id: Ia6837ba451d290a2070bc24e9e7088c60275cae0
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoAdd yang.common.DerivedString class 29/70229/18
Robert Varga [Sat, 31 Mar 2018 23:04:47 +0000 (01:04 +0200)]
Add yang.common.DerivedString class

DerivedString provides the baseline alternative for storing
String-equivalent information. The base class provides to prototype
using which interactions with Strings can be implemented.

Each such type is supported by a DerivedStringSupport, potentially
further validated via a DerivedStringValidator.

JIRA: YANGTOOLS-418
Change-Id: Ifa8c01723fdc43e71cc6ab48fca50963a131ccaa
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoUpdate yang-model-validator output 32/70432/1
Robert Varga [Fri, 6 Apr 2018 14:30:55 +0000 (16:30 +0200)]
Update yang-model-validator output

This cleans up argument handling, updates the commons-cli dependency
and adds -q and -d options for no and debug output.

Change-Id: I04b590019b27acf259830e69748c1d998121648e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoBump odlparent to 3.1.1 48/70348/1
Robert Varga [Thu, 5 Apr 2018 00:34:18 +0000 (02:34 +0200)]
Bump odlparent to 3.1.1

This is not really needed, as it has zero impact on the produced
artifacts.

Change-Id: Iae694bf5a41c5249bbab490723bf4120b9f4700a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoFix Decimal64 using Longs.hashCode() 59/70259/1
Robert Varga [Mon, 2 Apr 2018 23:48:19 +0000 (01:48 +0200)]
Fix Decimal64 using Longs.hashCode()

We are a Java 8 user, we should be using Long.hashCode() instead.

Change-Id: I3c18d40569a91341daa148d894c7bbab46cc175b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoFix leafref require-instance implementation 01/70201/1
Robert Varga [Thu, 29 Mar 2018 21:59:34 +0000 (23:59 +0200)]
Fix leafref require-instance implementation

Both identityref and leafref types default to require-instace=true,
hence we should be starting with that and also properly inherit
the property from the parent type.

Add RequireInstanceRestrictedTypeDefinition to capture the common
method and adjust RequireInstanceRestrictedTypeBuilder to check
for it and initialize the require-instance value appropriately.

JIRA: YANGTOOLS-872
Change-Id: I125d5687950af21694c4510ce64adb00f92ae4e6
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoBump versions to next development snapshot 72/70172/1
Robert Varga [Thu, 29 Mar 2018 00:07:40 +0000 (02:07 +0200)]
Bump versions to next development snapshot

This patch starts the 2.0.4 development cycle.

Change-Id: I975e631ebff9c86e083e2aed20ea4b40967a3335
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoRequire odl-guava-3.1.0+ 20/70020/1
Robert Varga [Fri, 23 Mar 2018 13:54:05 +0000 (14:54 +0100)]
Require odl-guava-3.1.0+

Guava is bumped incompatibly, hence we need to require it.

Change-Id: Ib2a48568c08fa0279d599d2bb10706ab6cce861d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoBump to odlparent 3.1.0 66/69866/2
Stephen Kitt [Thu, 22 Mar 2018 17:20:23 +0000 (18:20 +0100)]
Bump to odlparent 3.1.0

Change-Id: I6a556fedf84e256b64fd27507a1c98783dff8b7a
Signed-off-by: Stephen Kitt <skitt@redhat.com>
6 years agoAdd another 3.0.0 note 07/69807/1
Robert Varga [Thu, 22 Mar 2018 11:53:21 +0000 (12:53 +0100)]
Add another 3.0.0 note

Our use of Strings for YANG identifiers is confusing to the users
who need to map that string to other namespaces. Expressing the fact
that the string is composed of a limited set of characters would
be beneficial to, for example, mdsal's codegen components.

On the other hand, paying the cost of class encapsulation may not
be feasible and we should just be documenting contractual contents.

Change-Id: I3557bd180a63881b26848f087940ae62816e4214
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoRelax identity statement argument checks 35/69635/3
Robert Varga [Mon, 19 Mar 2018 18:45:48 +0000 (19:45 +0100)]
Relax identity statement argument checks

This patch relaxes identity statement checking, so that FD.io's
VLAN model continues to work. Emit a stern warning, but do not fail
if an strictly-invalid identity name is encountered.

Change-Id: If3b3ad3f16372b1d856406480606177ba7851336
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoAdd alternative ClassLoaderUtils methods 08/69608/4
Robert Varga [Mon, 19 Mar 2018 09:20:30 +0000 (10:20 +0100)]
Add alternative ClassLoaderUtils methods

ClassLoaderUtils uses method overloading on a FunctionalInterface,
which renders it not-completely-convenient to use with Java 8 lambdas.

Rather than method overloads, define dedicated methods for common
functional types, deprecating the old ones.

JIRA: YANGTOOLS-866
Change-Id: I40d5bdb5ef8845dccfc6ee0582acc0142e39cc09
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoIntroduce StmtContextUtils.parse(Node)Identifier 85/69485/8
Robert Varga [Wed, 14 Mar 2018 09:27:03 +0000 (10:27 +0100)]
Introduce StmtContextUtils.parse(Node)Identifier

These are an improvement over qnameFromArgument() as they follow
exact RFC7950 specification, performing validity checks and generally
performing better.

JIRA: YANGTOOLS-863
Change-Id: Ifc56cbb93ba0046f4e65f9bc89d0d46b27d74fd3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoAdd YangConstants.operation{Input,Output}QName() 84/69484/3
Robert Varga [Wed, 14 Mar 2018 02:25:51 +0000 (03:25 +0100)]
Add YangConstants.operation{Input,Output}QName()

Since we have QName.withModule(), we can optimize instantiation of
action/RPC input output statements by pre-validating the local name.

This is significantly faster than parsing the string via
StmtContextUtils.qnameFromArgument() and is useful for downstreams
which interaction with actions/RPCs.

Change-Id: If6da796df375f9785e05cb3cf901d64cccf2cfe5
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoBump versions to 2.0.3-SNAPSHOT 66/69366/1
Robert Varga [Mon, 12 Mar 2018 09:24:23 +0000 (10:24 +0100)]
Bump versions to 2.0.3-SNAPSHOT

This bumps versions for next release.

Change-Id: Ie9ce447f339d9b9de49b9eb1bd795ac06e381a5f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoCleanup Bug6887Test 58/69358/4
Robert Varga [Sun, 11 Mar 2018 21:08:48 +0000 (22:08 +0100)]
Cleanup Bug6887Test

Rather than using ImmutableList, use variadic arguments and their
array to construct the SchemaPath.

Change-Id: Ia3446e17e87981d2ad896d209a7b1f6ebf3f3b26
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoAdd QName.withModule(QNameModule) method 57/69357/4
Robert Varga [Sun, 11 Mar 2018 21:06:02 +0000 (22:06 +0100)]
Add QName.withModule(QNameModule) method

In situations when a companion QName with specified QNameModule needs
to be created, we can side-step localName checking and just directly
reuse it. QName.withModule() does precisely that and two callers
of QName.create() are updated to use it.

Change-Id: Ib1ca72210c0114610dafba0dfbbce15a2b8ddc03
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoAdd CollectionWrappers 74/68774/11
Robert Varga [Mon, 26 Feb 2018 15:27:17 +0000 (16:27 +0100)]
Add CollectionWrappers

SchemaNode/SchemaContext has some unfortunate method contracts
which require returning a Set, while they are represented as
java.util.Map.values() in EffectiveStatement world, where they
support keyed lookups, which is really what users require.

To bridge these two worlds without duplicating the same information
in two collections we need a memory-efficient proxy to act as an
adaptor, as we know the primary storage (Map.values()) is known
to be both immutable and conforming to Set interface requirements.

This patch such a class and provides a symmetric List wrapping
utility.

JIRA: YANGTOOLS-853
Change-Id: I052e4f9d58aa1f054450840c2216b0fd2109bc61
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoAdd default implementations of StatementDefinition methods 46/69246/4
Robert Varga [Thu, 8 Mar 2018 01:51:57 +0000 (02:51 +0100)]
Add default implementations of StatementDefinition methods

StatementSupport should be forwarding StatementDefinition methods
it is inheriting to the public view it is capturing.

This makes the API somewhat cleaner by making it explicit these
methods are related.

Change-Id: I3ec5d2bf182824225ebe7a1596cf60f5047848e0
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoIntroduce ImplicitParentAwareStatementSupport 44/69244/2
Robert Varga [Thu, 8 Mar 2018 01:35:15 +0000 (02:35 +0100)]
Introduce ImplicitParentAwareStatementSupport

Augment statement would like to know if it needs to adapt itself to
its target node -- which is based on whether the target node would
like to wrap any of its children.

Most of the statements do not want to do this, with the notable
excteption if choice statement. Separate getImplicitParentFor()
into a separate interface, so we can optimize this in future.

Change-Id: I1e1e2d8b1fd52d67b1c2f06838670af69e40f99e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoOptimize augment conflict checking 16/69216/2
Robert Varga [Wed, 7 Mar 2018 16:32:30 +0000 (17:32 +0100)]
Optimize augment conflict checking

When we are validating whether a node can be introduced, we end up
needlessly iterating when the source is not a DataDefinitionStatement
and also end up running comparison when a substatement is not a
DataDefinitionStatement,

Refactor the code to take these invariants into account.

Change-Id: Ie55c7dfebacfad1189de1929c23809fd284958b4
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoFix FeatureEffectiveStatementNamespace javadoc 08/69208/1
Robert Varga [Wed, 7 Mar 2018 12:21:47 +0000 (13:21 +0100)]
Fix FeatureEffectiveStatementNamespace javadoc

This namespace obviously contains features, not extensions.

Change-Id: I3aceaff8fd238cb346c53ec9caa9b94520a15d05
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoAdd YinXMLEventReaderFactory 92/67892/13
Robert Varga [Sat, 3 Feb 2018 15:29:45 +0000 (16:29 +0100)]
Add YinXMLEventReaderFactory

This is a proper way of exporting YIN models from parser output,
being more correct and much simpler than YinExportUtils.
YinExportUtils.writeModuleToOutputStream() methods are deprecated
in favor of writeModuleAsYinText() and writeSubmoduleAsYinText().

JIRA: YANGTOOLS-858
Change-Id: I9fda3ef3ccf2f3aa9e18d32da85e225d835151f9
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoFix format string 18/69118/1
Robert Varga [Tue, 6 Mar 2018 09:51:00 +0000 (10:51 +0100)]
Fix format string

checkArgument uses String.format() strings, not logger.

Change-Id: I723924bee6cafddda2cbc88362c3f5898e17da6a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoValidate parsed QName to identity 76/69076/1
Robert Varga [Mon, 5 Mar 2018 14:11:45 +0000 (15:11 +0100)]
Validate parsed QName to identity

We need to validate if parsed QName refers to an existing identity,
this fixes up unused AbstractModuleStringIdentityrefCodec to check
Module references.

Change-Id: Iebbb43681e9b384c43bd81607d169294373bdd72
JIRA: YANGTOOLS-846
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoValidate parsed QName to identity 43/68543/4
Robert Varga [Thu, 22 Feb 2018 14:01:52 +0000 (15:01 +0100)]
Validate parsed QName to identity

We need to validate if parsed QName refers to an existing identity
before allowing it in Identityref codecs. Introduce IdentityCodecUtil
along with a test suite and migrate users over.

JIRA: YANGTOOLS-846
Change-Id: I673ae6df4406110202b86329121a3ca9673fb0ed
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoCleanup resources allocated in @BeforeClass 42/68542/7
Robert Varga [Fri, 23 Feb 2018 12:27:02 +0000 (13:27 +0100)]
Cleanup resources allocated in @BeforeClass

This cleans up static fields after tests have been run.

Change-Id: Idf48234157b2196fadfdabcffd5628ad397639d5
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoIntern more arguments 04/69004/2
Robert Varga [Fri, 2 Mar 2018 14:37:12 +0000 (15:37 +0100)]
Intern more arguments

modifier, deviate and max-elements were missed in the original
interning patch, add them.

Change-Id: I9b14f4d84657b10f0fd0e56c0f6a867f5e6c8872
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoAdd timing information 48/68848/4
Robert Varga [Tue, 27 Feb 2018 23:54:51 +0000 (00:54 +0100)]
Add timing information

This adds timing information around code generation. It also exposes
the number of YANG modules processed, so we have some guidance
to interpret the time taken. Also lowers verbosity of dependency
scanning.

Change-Id: I7b202a388405e755964fe76d6b81bc42fd92b73b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoFix YangTextSnippetIterator with OpenConfig extensions 47/68847/2
Robert Varga [Tue, 27 Feb 2018 23:17:56 +0000 (00:17 +0100)]
Fix YangTextSnippetIterator with OpenConfig extensions

Since OC extensions are binding to all revisions, their
StatementSupport's QNameModule (without revision) is presented
by DeclaredStatement. Such a QNameModule does not match the imported
module (which obeys flexible rules) -- which means we cannot readily
look it up from ModuleEffectiveStatement.

Add a workaround to use a loose match until a proper fix is
implemented.

Change-Id: I9393fe7cef7b22014e3c68d69b09f9702dded303
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoOptimize QName.withoutRevision() 46/68846/1
Robert Varga [Tue, 27 Feb 2018 23:15:26 +0000 (00:15 +0100)]
Optimize QName.withoutRevision()

This method is used in a few users to implement loose matches. Optimize
it to not check localName, as that has already been checked. Also introduce
a mirror QNameModule method.

Change-Id: Id1045d79677fd4c0aeb5069f6b151530c545c20b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoCleanup AbstractEffectiveDocumentedDataNodeContainer a bit 37/68837/1
Robert Varga [Tue, 27 Feb 2018 20:00:40 +0000 (21:00 +0100)]
Cleanup AbstractEffectiveDocumentedDataNodeContainer a bit

Throw colision exception in a short block, allowing logic to be
better in-lined.

Change-Id: I87d056127869d3c2ea7cc2d240b6f6278b57c9c8
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoSkip duplicate classpath scanning 28/68828/1
Robert Varga [Tue, 27 Feb 2018 15:54:46 +0000 (16:54 +0100)]
Skip duplicate classpath scanning

Scanning the entire class path for jars is expensive. Do that
only once and capture dependencies so we can do the second pass
in a more direct manner.

JIRA: YANGTOOLS-855
Change-Id: I0763cbac3ea6781ebb400e014837b9f44375de63
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>