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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
Robert Varga [Tue, 27 Feb 2018 10:20:50 +0000 (11:20 +0100)]
Allow StatementMap to be resized to correct size
StatementStreamSources typically know the correct sizing for substatement
list even when they do not understand them (and thus have not emitted
them) and pass this hint down when they finish processing the statement.
Take advantage of this information by allocating sufficient capacity to
hold all resolved children.
Change-Id: Ib4a96a8d42bad747d56d92e07846724607346e97
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Tue, 27 Feb 2018 12:06:45 +0000 (13:06 +0100)]
Optimize YinStatementStreamSource
This patch converts YinStatementStreamSource to use stateful
StatementWriter interfaces, skipping expensive lookups.
JIRA: YANGTOOLS-854
Change-Id: I4d0931a78f9a08fed3d23045df1763ea4e4a02d9
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Tue, 27 Feb 2018 08:24:32 +0000 (09:24 +0100)]
Allow StatementWriter to be stateful
This patch adds a stateful protocol betwen SourceSpecificContext
and StatementStreamSources, so they do not need to allocate/lookup
objects for statements defined in previous phases.
JIRA: YANGTOOLS-854
Change-Id: I600208a384776a601967bc7b5719cc6632b226db
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Tue, 27 Feb 2018 12:27:57 +0000 (13:27 +0100)]
Populate Extension/FeatureEffectiveNamespace
Modules are the primary providers of these namespaces, make sure
ModuleEffectiveStatementImpl populates them correctly.
JIRA: YANGTOOLS-853
Change-Id: I9e0313e36a2b7de2bc258a263ac376dc8bd99dc0
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Sat, 24 Feb 2018 21:43:04 +0000 (22:43 +0100)]
Add Case/Extension/Feature/IdentityEffectiveStatementNamespace
This patch adds simple RFC7950 namespaces.
JIRA: YANGTOOLS-853
Change-Id: I753a297a782fc3f9f81f9d1659fc12a7c70b8c28
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Sun, 25 Feb 2018 23:30:13 +0000 (00:30 +0100)]
Deprecate PrefixToModule.isPreLinkageMap()
This property is only consulted at places which can be inferred
to set it to true. Deprecate this property, as it is a state leak
defying encapsulation.
Change-Id: I1f159214e6487f482c7801ff73bd697bad6d470a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Sun, 25 Feb 2018 21:05:16 +0000 (22:05 +0100)]
Turn YangStatementParserListenerImpl into a visitor
Rather than using a listener with two methods, which needs to keep
and re-lookup state, implement such visitStatement(). This allows us
to skip duplicate lookups and will allow us to completely eliminate
all state tracking.
As it turns out we do not need any visitor logic, because we are
always walking statements and descending into their children. Rework
logic to reflect that, eliminating the need for any statekeeping,
as we can track all of the state inline.
JIRA: YANGTOOLS-713
Change-Id: I22a289fdbb2d8ea1501dd4a8eacd7780afbf1c6c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Sun, 25 Feb 2018 22:13:02 +0000 (23:13 +0100)]
Mark missed StatementStreamSource methods
We have failed to mark methods in this interface for API movement
before 2.0.0, hence they were left out. Mark them for 3.0.0 so we
do not forget again.
Change-Id: Ic24e12e6f9c984f6d92d53aeb2aa38f542306beb
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Sun, 25 Feb 2018 20:02:35 +0000 (21:02 +0100)]
Encapsulate YangStatementParserListenerImpl.walk()
As it turns out, the contract between YangStatementStreamSource
is one of walking a tree with a set of parameters. Make sure we
encapsulate this contract, so that it can be efficiently implemented
using a visitor.
This has the benefit of discarding unneeded state more quickly
and not retaining it past errors. It will also allow us to very
simply convert YangStatementParserListenerImpl into a visitor.
JIRA: YANGTOOLS-713
Change-Id: Iac8c4979fb31cb527788837b41d4bbf17ce4b3cf
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Sun, 25 Feb 2018 19:34:18 +0000 (20:34 +0100)]
Privatize YangStatementParserListenerImpl
This class is package-visible, hence public methods should only be
the @Override ones.
JIRA: YANGTOOLS-713
Change-Id: Id092b12cf6f2ad309aaf5920b31ae9fb4ab25b58
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Sun, 25 Feb 2018 18:43:49 +0000 (19:43 +0100)]
Make QName/QNameModule a WritableObject
Serializing these objects into a stream is useful, make them implement
WritableObject.
Change-Id: I3fbb147b4deb17afb2ead0dedc716e5a9a5cefc6
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Sat, 24 Feb 2018 21:42:24 +0000 (22:42 +0100)]
QNameModule/QName should implement Identifier
These classes are inherently identifier-like, and hence should be
implementing Identifier concept.
Change-Id: Ic494ec42788a176555c56446105511bc4868fad8
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Fri, 23 Feb 2018 15:03:39 +0000 (16:03 +0100)]
Expose identities from ModuleEffectiveStatement
Parser has an accurate, indexed view of all identities defined in
a particular module. Expose this namespace to ModuleEffectiveStatement
users.
Change-Id: I9692cb91b23155191545224bceaf436fd0f6c67e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Fri, 23 Feb 2018 12:02:55 +0000 (13:02 +0100)]
Eliminate unneeded @BeforeClass
Constructing QNames does not entail exceptions, so we can initialize
them as simple constants.
Change-Id: I84fa394cda4d8478b60a40b8ea7080d4e6b88558
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Fri, 23 Feb 2018 11:22:28 +0000 (12:22 +0100)]
Report parent SchemaPath on error
When we fail to find a child node, report the full schemapath
of the parent node, so the input can be properly diagnosed.
Change-Id: Id5cf3f55f3c745b55f2a485746dd995b0f056657
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Fri, 23 Feb 2018 11:21:58 +0000 (12:21 +0100)]
Correct error message
Expand "doesn't" to "does not".
Change-Id: I2b530985dd5982d7bcbc95866c1e7e26e52c4b98
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Thu, 22 Feb 2018 13:42:48 +0000 (14:42 +0100)]
Optimize QNameModule.equals() a bit
The namespace cannot be null, so we can safely call equals() on it,
skipping checks in Objects.equals().
Change-Id: Ic1b94e2239fb9fd906711c8cbb03dd252a190c49
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Thu, 22 Feb 2018 13:02:42 +0000 (14:02 +0100)]
Speed up JSON codec operations
With the improved SchemaContext, we can perform direct lookup
of Module based on QNameModule -- use that instead of iteration.
Change-Id: Ib5c1146b8c13ac3f52a18ed8334b89b66f6ca40c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Sat, 3 Feb 2018 19:20:52 +0000 (20:20 +0100)]
Fix maven plugin ignoring import resolution mode
While BasicCodeGenerator has knobs to express required import resolution
mode, the plugin ignores them. This patch reorganizes YangToSourcesProcessor
so that we determine what import resolution mode we need before we start
assembling the SchemaContext.
JIRA: YANGTOOLS-825
Change-Id: Iaec12e3c8ada2173262533cc6d59e54f18095826
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Wed, 21 Feb 2018 13:51:03 +0000 (14:51 +0100)]
Do not fake an errorMessage for pattern constraints
Eagerly-formatting a replacement error message is actively hurting
callers of getErrorMessage(), which really expect that method
to return model-defined error message. Fix that.
JIRA: YANGTOOLS-850
Change-Id: Iddb5f9ae529f1ed49eed735a8931ee396334f578
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Wed, 21 Feb 2018 14:12:26 +0000 (15:12 +0100)]
Add DeclaredStatementFormatter
Working with downstreams it became apparent they really are using
same YangTextBuilder customizations across multiple statements.
This patch exposes DeclaredStatementFormatter, which acts as
a customization holder off of which YangTextSnippets can be created.
JIRA: MDSAL-301
Change-Id: I4733313dcb98c9b1d244088b5b46d8a197ab2f5d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Tue, 20 Feb 2018 18:12:19 +0000 (19:12 +0100)]
Encapsulate regexes in a non-capturing group
Regular expressions are pesky, nwo we are being bitten by branches.
Let's just encapsulate the internal pattern into a non-capturing
group and be done with it.
JIRA: YANGTOOLS-798
Change-Id: If3b3b2fb35ecd336bc23fd7acaf29efa48eb9b74
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Wed, 21 Feb 2018 09:43:03 +0000 (10:43 +0100)]
Move Bug4079/Bug5410 tests from yang-parser to yang-model-util
This co-locates the unit test with the class tested.
Change-Id: Ib7d044208946be3347e1b1aedbd87a0cfe1e5a23
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Mon, 19 Feb 2018 22:49:47 +0000 (23:49 +0100)]
Move yang-model-export unit tests
This will allow us to co-locate within the same package, leading
to better interaction, as we can use package-private methods to look
at state.
Change-Id: I0ab59c32c166505ac44d5f21ae0aa374eaa08aac
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Wed, 14 Feb 2018 09:37:11 +0000 (10:37 +0100)]
Add the ability to build effective model
The effective model consists of ModuleEffectiveStatements
which are guaranteed to have unique QNameModules. Express
that in YangParser.
Change-Id: Id094c40cf5dcf49e6289d3b929f4abf2f9cb6436
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Mon, 19 Feb 2018 20:08:56 +0000 (21:08 +0100)]
Add submodule lookup namespace
ModuleEffectiveStatement needs to allow looking up which submodules
were included as the effect of include statements. Since submodule
names need to be unique, it is natural to express this as a namespace.
Change-Id: I782caba8dfb9ff4dbea5b81e335f06dc797518d5
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Mon, 19 Feb 2018 15:22:54 +0000 (16:22 +0100)]
Add YANG/YIN namespace string literals
Interacting with Java XML machinery requires the use of Strings
for namespaces. It is useful to implement javax.xml.NamespaceContext
with switch() statement, which unfortunately can only work on explicit
string literals. Expose these literals, improving the ergonomics.
Change-Id: I534d2a6e13960ba7587bfe77ed581e8593e65a17
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Mon, 19 Feb 2018 07:02:52 +0000 (08:02 +0100)]
Export ResourceYangTextSchemaSource
YangTextSchemaSource.forResource() returns this class, which is hidden,
leading to end user confusion, as the return class cannot be imported.
We cannot change the return value, as that would cause ABI breakage,
hence expose ResourceYangTextSchemaSource and mark it for hiding
in next major release.
Change-Id: Ib03e3df73824172dcd80a58fc33f7bdb4e26c6f0
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Sat, 3 Feb 2018 19:33:57 +0000 (20:33 +0100)]
Add YangTextSnippet to yang-model-export
This is a simple class generating a sequence of strings, concatenation
of which produces YANG text corresponding to a DeclaredStatement.
The snipped is properly indented, can omit user-specified statements,
and by default omits statements with default values as per RFC6087.
JIRA: MDSAL-301
Change-Id: Ie45e947dccd33b851e23effb827ddc66690451f6
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Mon, 5 Feb 2018 05:01:34 +0000 (06:01 +0100)]
Add DefaultStatementDefinition
Implementing StatementDefinition contract can be tricky and it is
often misused by using implementation classes. Introduce a utility
default implementation, which enforces statement representations
being interfaces.
Change-Id: Icd2ce998dc8001cfa4a1d44f48017204c6dd02f4
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Sat, 3 Feb 2018 12:35:24 +0000 (13:35 +0100)]
Expose EffectiveModuleStatement prefix mapping
ModuleEffectiveStatement should expose mapping of prefixes
to imported modules (and self) as well as reverse mapping of
QNameModule to prefix, so that users can map properly map
QNames encountered within a module.
This patch exposes that information via two new namespaces,
which are present only in ModuleEffectiveStatements. Furthermore
EffectiveStatementBase is updated to allow subclasses to contain
namespaces.
JIRA: MDSAL-301
Change-Id: I5139c32eff18c1fa703dd8d3c98882939f82b109
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Sun, 4 Feb 2018 15:31:11 +0000 (16:31 +0100)]
Correct double-quoted string whitespace trimming
We need to trim leading and trailing whitespace when it comes from
YANG text, so that the resulting string matches expectations.
This patch adds the required trimming.
JIRA: YANGTOOLS-845
Change-Id: I21777583c5d18819e68c089cd9f2cf51179b0530
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Thu, 1 Feb 2018 12:39:17 +0000 (13:39 +0100)]
Switch YangToSourcesProcessor to use YangParser
Rather than going through YangTextSchemaContextResolver, use
YangParser to assemble the SchemaContext. This gives us better
control over the parsing process and also allows us to build
only sources which are required to generate code in local directory.
JIRA: YANGTOOLS-825
Change-Id: Ie3c49517aedd5ae3604ed27dc5bd1f1f1fa7a4d1
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Tue, 30 Jan 2018 22:48:40 +0000 (23:48 +0100)]
Deprecate CopyableNode at al.
isAddedByUses(), isAugmenting() and similar constructs relate to how
a particular node became effective. This really has not place in the
effective model of the world.
This patch concentrates duplicate methods into an interface hierarchy
and marks them as @deprecated, along with justification. This allows
us to track down users and the semantics they really are after.
Since we are touching SchemaContext, mark its future direction, which
should see it shed a lot of nonsensical methods.
Change-Id: Ibdaf52e45076006e979204ac75e7bae6aeffd29a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Thu, 1 Feb 2018 11:27:33 +0000 (12:27 +0100)]
yang-parser-impl supports ASTSchemaSource
yang-parser-rfc7950 supports bridging parsing from ASTSchemaSource,
which is an intermediate product of parsing from YangTextSchemaSource.
Make sure we propagate this capability from YangParserImpl, so that
users can efficiently integrate with it. While we're in the area
teach YangStatementStreamSource how to instantiate itself from
an ASTSchemaSource and add ASTSchemaSource.toString().
Change-Id: I0b6440b6fc4e7522c70261cffcef0afafed8ba53
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Thu, 1 Feb 2018 10:09:35 +0000 (11:09 +0100)]
Fix invalid enum definition error string
This is a copy&paste problem, the string should not be referencing
bits but enums.
Change-Id: I5adc98a5db92b88bf7e20dcc6141213347858f58
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Thu, 25 Jan 2018 15:17:11 +0000 (16:17 +0100)]
Mark metainf-services
Until we get odlparent-3.0.3 with a fixed declaration, fix our features
by marking metainf-services as provided.
Change-Id: If54a0a89dade4e2a4aed4ddf84d0abae5b11fc24
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Fri, 19 Jan 2018 08:50:41 +0000 (09:50 +0100)]
Add checkstyle-logging to yangtools-artifacts
All artifacts should be communicated to downstreams, fix that.
Change-Id: Ida1ca8cfd6162ed7fb54d512b69821df5d666686
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Thu, 18 Jan 2018 18:14:51 +0000 (19:14 +0100)]
Start 2.0.2 release cycle
Bump versions by 0.0.1.
Change-Id: I67e5db2ed702ed53336c7ba207c0c89c4b9fa17a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Tue, 16 Jan 2018 16:21:50 +0000 (17:21 +0100)]
YANGTOOLS-844: Filtering/SimpleSchemaContext violate getModules() contract
getModules() is explicit about how the modules should be ordered,
which is not compatible with ModuleDependencySort. As it turns out
ModuleDependencySort is only needed in MD-SAL codegen, where we
already invoke it explicitly.
Explicitly sort modules according to requirements of getModules(),
fulfilling that contract.
This also affects findModule(String) and related functions, which
are sorted, but in inverse order of what is specified. Fix that
by adjusting AbstractSchemaContext.REVISION_COMPARATOR and
introducing NAME_REVISION_COMPARATOR for use in places where modules
are not guaranteed to have a unique name.
Change-Id: Ie91685b830694764158381e4696e3f7d5bb57fba
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Tue, 16 Jan 2018 16:18:04 +0000 (17:18 +0100)]
Fix a nullness thinko
toRevision cannot reasonably be null, as it already is an Optional,
hence the check here is incorrect and should instead check for
non-presence.
Change-Id: I93658ce5993aed1a02f4ad25121e11b3f31d356a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Mon, 8 Jan 2018 19:40:48 +0000 (20:40 +0100)]
Bump odlparent version to 3.0.2
This adopts odlparent 3.0.2 to speed up builds.
Change-Id: If5155e1d070133ccd673efe3d5bb95d97127571a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Tue, 2 Jan 2018 10:23:44 +0000 (11:23 +0100)]
YANGTOOLS-841: Fix SchemaContextUtil.findNodeInSchemaContext()
When performing recursive node lookup, consider
{Action,Notification}NodeContainers, so that we correctly resolved
nested actions and notifications -- which are new elements in RFC7950
metamodel.
Also generalized RPC input/output lookup to work on actions, too.
Change-Id: I877061c7f0370caf1ed04eb9420a43af3b2d3915
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit
d027a59601cfbbc912e00e351eeb35a27dcc3bc2)
Atul Gosain [Wed, 29 Nov 2017 02:07:08 +0000 (18:07 -0800)]
Handling empty text nodes
This is a fix for an issue seen in the patch 63984 on yangtools.
It handles text nodes which are empty.
Change-Id: I6cf1096c511758154df6121d26bf36184385403f
Signed-off-by: Atul Gosain <agosain@luminanetworks.com>
Robert Varga [Wed, 27 Dec 2017 15:48:01 +0000 (16:48 +0100)]
YANGTOOLS-766: expand test suite
This patch adds explicit tests for serialization/deserialization
of instance identifiers for both JSONCodecFactorySuppliers.
Change-Id: Id1ba4764573bf2bde566c89c28e2ffc55cb982dc
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Wed, 27 Dec 2017 01:00:26 +0000 (02:00 +0100)]
YANGTOOLS-766: add RFC7951JSONInstanceIdentifierCodec
RFC7951 non-present prefixes result in last argument namespace reuse,
hence refactor AbstractStringInstanceIdentifierCodec to allow for QNames
to be instantiated using a memoized QNameModule.
The default implementation routes to createQName("", localName), which
preserves backwards compatibility. A specialized subclass
of JSONInstanceIdetifierCodec is created to use memoized QNameModule,
and it is wired to RFC7951 codec supplier.
A similar update is done in AbstractNamespaceCodec, where appendQName()
alternative, which is forwarded the last encountered QNameModule is
added -- the default routes to normal appendQName(), with RFC7951
comparing last QNameModule with current QName's and skipping prefix
serialization if they match.
This is sufficient to make related unit test pass, so remove @Ignore
from it and expand it to assert the decoded YangInstanceIdentifier.
Change-Id: Iec7996d0e1d759623c3cabcbaf0164737afa1649
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Tue, 26 Dec 2017 10:57:08 +0000 (11:57 +0100)]
YANGTOOLS-766: introduce JSONCodecFactorySupplier
We need two separate instances of JSONCodecFactory factory methods,
each with its own conformance, so that we can properly spin out
codecs compliant to RFC7951 and draft-lhotka-netmod-yang-json-02.
This patch provides a new API entrypoints for specifying these, without
actually providing distinct codecs. It also provides proper JsonParserStream
factory methods which take JSONCodecFactory instead of plain SchemaContext
(and thus assuming JSONCodecFactory implementation).
Change-Id: Ib2b402ed865903432645632e89c9b0e04851a05c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Tue, 26 Dec 2017 11:21:29 +0000 (12:21 +0100)]
YANGTOOLS-678: enable empty key verification
Now that we are using a non-null value to represent empty leaves,
empty types are a fair game in codecs. Remove @Ignore from JSON/XML
tests which demonstrate the ability to decode empty keys in
YangInstanceIdentifier, which means proper addressing can be done
and works as expected.
Change-Id: Ib0aee3b99d40868d32e62811c2f82c1c42ef0833
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Mon, 25 Dec 2017 18:41:05 +0000 (19:41 +0100)]
Expand yang-parser-spi unit tests
This patch adds a very basic unit test suite to assert various
aspects of the SPI package.
Change-Id: Ifd68fad33bff3b74579202327b28822b8ce5626d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Mon, 25 Dec 2017 12:53:37 +0000 (13:53 +0100)]
Implement Uint{8,16}.valueOf(String, int)
This adds a simplistic implementation deferring parsing to
Short/Integer.valueOf(String, int) and performing range checking.
Also expands the test suite to cover Uint{8,16,32,64}, which flushes
out a bug in Uint64's handling of cache slots -- this is fixed, too.
Change-Id: I8fa977028a6f00ee8f25a19fdd2fd5d2b08b4bfa
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Mon, 25 Dec 2017 11:58:44 +0000 (12:58 +0100)]
Add Decimal64.{int,long,short}ValueExact()
Add alternative methods which prevent loss of precision by throwing
ArithmeticException. Testing has revealed that valueOf(Integer.MIN_VALUE)
does not work correctly due to the fact negation does results in incorrect
bitmask -- which is fixed by widening conversion.
Change-Id: I206ced685d2edb753507f5d45e29bb6b405ff421
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Mon, 25 Dec 2017 15:09:48 +0000 (16:09 +0100)]
Add Revision test suite
This adds a simplistic test suite for testing Revision class.
Change-Id: Ibed986f5c53e7f201c3eb16cf448e022b09e6b85
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Mon, 25 Dec 2017 14:29:17 +0000 (15:29 +0100)]
Add YangNames test
This adds a simplistic test to ensure YangNames.parseFileName() works
as expected.
Change-Id: Ic619ebdce2a0641418283b4621be4c676341a053
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Mon, 25 Dec 2017 14:24:44 +0000 (15:24 +0100)]
Add YangVersion test
Add a simple test suite to ascertain YangVersion works as expected.
Change-Id: I52d4d81f25f35443309dae8c93cbc91e705810ba
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Michael Vorburger [Wed, 13 Dec 2017 23:35:14 +0000 (00:35 +0100)]
Fix slf4j usage errors found by checkstyle-logging
Change-Id: Iff0203d373d33a77ebfe2a8da190e6b927913b4e
Signed-off-by: Michael Vorburger <vorburger@redhat.com>
Robert Varga [Wed, 20 Dec 2017 13:07:21 +0000 (14:07 +0100)]
YANGTOOLS-838: detect grouping identifier shadowing
RFC7950 sections 5.5 and 6.2.1 explicitly forbid identifier
shadowing. Update grouping support to detect and report this
violation.
This patch also fixes typedef support to correctly detect
forward shadowing, when a nested conflicting typedef shadows
a sibling which occurs later in the model text.
Change-Id: I7c67c93c5f13b24657454e13d8b329338f98d7b4
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Sun, 3 Dec 2017 13:08:50 +0000 (14:08 +0100)]
Fix javadoc typo
Remove a repeated sentence.
Change-Id: I4d5f8faad2c23fe89bdba0f91847cba10dc76ecb
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Stephen Kitt [Mon, 27 Nov 2017 17:21:05 +0000 (18:21 +0100)]
Drop obsolete Maven site configuration
See
https://lists.opendaylight.org/pipermail/odlparent-dev/2017-November/001492.html
Change-Id: I2735d334673209dd08b677be7de0c4d368e3a8ca
Signed-off-by: Stephen Kitt <skitt@redhat.com>
Robert Varga [Mon, 27 Nov 2017 18:05:38 +0000 (19:05 +0100)]
Bump versions to next development cycle
Change-Id: I3e243ab59fbaa1ef0662761d03f6ac03db2ce755
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
jenkins-releng [Sat, 25 Nov 2017 01:09:04 +0000 (01:09 +0000)]
Release yangtools
Change-Id: I154e2a2bec3171736675e3ac8d574184ce441d2b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Fri, 24 Nov 2017 14:14:44 +0000 (15:14 +0100)]
Bump odlparent to 3.0.1
Pull in 3.0.1, as it fixes karaf distribution build.
Change-Id: I9ef1e93987a58393ebb2d32eb71c81cb872ef265
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Wed, 22 Nov 2017 00:20:31 +0000 (01:20 +0100)]
Clarify SchemaContext getModules() API contract
This clarifies the API contract with regards to iteration ordering
and shuffles the methods around a bit. Also creates additional index
for looking up Module by its QNameModule, which is common when
dealing with NormalizedNode encoding.
Change-Id: I76a8f2f24f4a70e0cf4fab544de6d79e1b476103
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Michael Vorburger [Tue, 21 Nov 2017 15:54:08 +0000 (16:54 +0100)]
Remove deprecated methods without loggerIdentity from SpecialExecutors
for https://jira.opendaylight.org/browse/CONTROLLER-1793
in order to force downstream projects (controller & mdsal) to use the
new methods when they upgrade to yangtools 2.0.0. The thing is that we
cannot fix CONTROLLER-1793 in the current controller & mdsal before
switching to yangtools 2.0.0 anyway, because SpecialExecutors didn't
have the (my) previous change adding the loggerIdentity anyway. So we
might as well do this in one round, instead of keeping these deprecated,
then once we are on yangtools 2.0.0 switch them, and then remove them?
Change-Id: I6a401979d71696536f23e1c5d1665149600f9876
Signed-off-by: Michael Vorburger <vorburger@redhat.com>
Robert Varga [Tue, 21 Nov 2017 12:31:53 +0000 (13:31 +0100)]
Eliminate use of deprecated checkstyle interfaces
Update constructors to use their non-deprecated equivalents.
Change-Id: Ibbb72e21b74f6a9c7f0ba90af7b3ec7717d68d81
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Tue, 21 Nov 2017 11:49:29 +0000 (12:49 +0100)]
Cleanup DataTree interfaces and InMemmoryDataTreeFactory
TipProducingDataTree is a remnant of an API freeze, merge its behavior
into baseline DataTree, adjusting callers.
Also make sure we publish DataTreeFactory properly, so users do not
have to rely on specific implementation -- cleaning up tests in process.
Change-Id: Ic2263a084ba7b8d2c611eb14407e09a78f6d922a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Stephen Kitt [Wed, 15 Nov 2017 20:31:37 +0000 (21:31 +0100)]
Bump odlparent dependencies to 3.0.0
Change-Id: I6efb03faf8913c5f4ad21fa7783ce8b6342447af
Signed-off-by: Stephen Kitt <skitt@redhat.com>