yangtools.git
6 years agoYANGTOOLS-706: reorganize statement definitions 52/65352/11
Robert Varga [Thu, 9 Nov 2017 01:50:47 +0000 (02:50 +0100)]
YANGTOOLS-706: reorganize statement definitions

Declared/Effective implementation classes should be hidden behind
their respective statement support. To provide this design safety
measure we need to assign a package to each statement, so that its
implementation details can be properly hidden.

Since we are implementing a combined RFC6020/RFC7950 parser, which
is difficult to split without leaking implementation classes between
RFC6020 and RFC7950, use RFC7960 base package name.

This leaves a few statements behind, as their interactions need to
be cleaned up before they get moved and will be part of a follow-up
patch.

Change-Id: I1a21412773beffd6e3ac81eaecf13073d787526d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoYANGTOOLS-706: Split up base utility classes into rfc6020.util 50/65350/5
Robert Varga [Thu, 9 Nov 2017 01:21:28 +0000 (02:21 +0100)]
YANGTOOLS-706: Split up base utility classes into rfc6020.util

Utility classes are useful for outside extensions, who should not
be depending on the complete parser. Split them out into a separate
package, so they can be moved out of yang-parser-impl.

Change-Id: I70c5048f87eafbff06ab0f23dd814239f67ee97a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoYANGTOOLS-706: Cleanup Unknown{Effective}StatementImpl 48/65348/4
Robert Varga [Thu, 9 Nov 2017 01:06:25 +0000 (02:06 +0100)]
YANGTOOLS-706: Cleanup Unknown{Effective}StatementImpl

These classes are actually implementing the UnrecognizedStatement
contract, name them accordingly.

Change-Id: Iec5cdd4cc06a99a8252595f043e88efe9ae0efdd
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoYANGTOOLS-706: Bridge UnknownSchemaNodes on their interface 47/65347/4
Robert Varga [Thu, 9 Nov 2017 00:59:38 +0000 (01:59 +0100)]
YANGTOOLS-706: Bridge UnknownSchemaNodes on their interface

When we are constructing SchemaNode world we can safely add instances
which implement UnknownSchemaNode, as that is the bridge in SchemaNode
for tunneling external statements.

Change-Id: If684ab2fdc676ae2daea71374df9542d2e4f753e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoYANGTOOLS-706: Refactor YangInferencePipeline 31/65331/11
Robert Varga [Wed, 8 Nov 2017 17:27:40 +0000 (18:27 +0100)]
YANGTOOLS-706: Refactor YangInferencePipeline

YangInferencePipeline needs to be more modular to allow splitting
the parser up without sacrificing individual component's ability
to test.

Create yang.parser.impl.DefaultReactors to hold utilities needed
to access a combined RFC6020/RFC7950/RFC8040 reactor and migrate
users.

Change-Id: I32dac393765fa3f13cb6e181b45fb056897950e4
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoYANGTOOLS-706: Reduce inter-statement implementation coupling 41/65341/8
Robert Varga [Wed, 8 Nov 2017 22:48:27 +0000 (23:48 +0100)]
YANGTOOLS-706: Reduce inter-statement implementation coupling

Now that we have proper model.api.stmt interfaces we can reduce
reliance on effective statement implementation classes, leading
a more streamlined implementation.

This patch does not eliminate all of the reliance, as that requires
updating model.api.stmt interfaces to carry enough information
to allow cross-statement inference.

Change-Id: Ib39d8578c954a6e8ecede53ce5a7420e7dd0f2aa
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoYANGTOOLS-706: Retrofit EffectiveStatement interfaces into parser 40/65340/7
Robert Varga [Wed, 8 Nov 2017 22:24:17 +0000 (23:24 +0100)]
YANGTOOLS-706: Retrofit EffectiveStatement interfaces into parser

Effectie statement implementations should be implementing their
model.api.stmt counterparts, so they can be properly looked up
without relying on implementation details.

Also rename Any{Data,Xml}EffectiveStamentImpl to follow naming
conventions.

Change-Id: Idd79e23f636dea0595ddf8ed804b12be2e82ae66
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoYANGTOOLS-706: Correctly wire EffectiveStatements 36/65336/7
Robert Varga [Wed, 8 Nov 2017 20:09:39 +0000 (21:09 +0100)]
YANGTOOLS-706: Correctly wire EffectiveStatements

YangStmtMapping should properly define all EffectiveStatement
mappings, most of which do not even exist.

Change-Id: I7d98fbf3863a936bb4b7eb8e2847d2643bdd968a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoAllow fluent use of BuildAction 11/65311/2
Robert Varga [Wed, 8 Nov 2017 13:05:58 +0000 (14:05 +0100)]
Allow fluent use of BuildAction

This adds the ability to use BuildAction as a fluent builder, simplifying
users and their explicit dependencies.

Change-Id: I4eea2e0c56eb74a7ca0ae860bf00d11b988d54ef
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoExpose type-specific derived type builder methods 07/65307/4
Robert Varga [Wed, 8 Nov 2017 11:23:02 +0000 (12:23 +0100)]
Expose type-specific derived type builder methods

Having a generic builder method is not sufficient for type-safe
users, who have knowledge of the base type, as they will lose
the specialization. Expose already-existing concrete factory methods.

Change-Id: I91195c65801ee2bbe5a93794e410c3914a7a1d24
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoRemove DerivedTypes.isInt8() and friends 06/65306/4
Robert Varga [Wed, 8 Nov 2017 11:18:36 +0000 (12:18 +0100)]
Remove DerivedTypes.isInt8() and friends

These methods are no longer needed, as their equivalent can be
performed via a simple instanceof check. Remove them.

Change-Id: Ieb92ad6497a78b6777dd49b5d148b678c1633f20
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoRemove ModuleDependencySort.sort(Iterable) 05/65305/2
Robert Varga [Wed, 8 Nov 2017 11:16:51 +0000 (12:16 +0100)]
Remove ModuleDependencySort.sort(Iterable)

This method has been replaced with the collection-based one, remove
the old one.

Change-Id: Iecb4d7c8085869196ecff040e1e8594f368ee408
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoRemove SubstatementValidator.MAX 04/65304/2
Robert Varga [Wed, 8 Nov 2017 11:12:58 +0000 (12:12 +0100)]
Remove SubstatementValidator.MAX

This constant has been deprecated for a long time and is not used
in-tree. Remove it.

Change-Id: I724fc1c8066cd9659ebf54cf394a34a4f15439c8
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoAddress RFC7950 API changes 98/65298/3
Robert Varga [Wed, 8 Nov 2017 00:57:09 +0000 (01:57 +0100)]
Address RFC7950 API changes

This patch promotes methods marked for promotion from deault
to abstract. Documentation is updated to reflect metamodel
change and provide guidance for implementations.

Also includes *StatementContainer interfaces to properly share
methods revolving around acquiring substatements of known types.

Change-Id: I7e33b3f6e5816adc397f0dee00b1ada46856d504
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoYANGTOOLS-619: Add support for RFC7952 extensions 42/65142/16
Robert Varga [Fri, 3 Nov 2017 23:50:28 +0000 (00:50 +0100)]
YANGTOOLS-619: Add support for RFC7952 extensions

This patch adds support for md:annotation statement.

Change-Id: I912645c0e01662594346e107766dd86f704f0cca
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoYANGTOOLS-706: separate out yang-data StametementDefinition 44/65144/9
Robert Varga [Sat, 4 Nov 2017 15:44:58 +0000 (16:44 +0100)]
YANGTOOLS-706: separate out yang-data StametementDefinition

SupportedExtensions mapping is too central for what we want to achieve.
Split out yang-data StatementDefinition into its own model world, so
others can point to it without accessing parser internals.

Also co-locate the implementation of YangDataStatement with its support,
so they can be easily transported.

Change-Id: Ic7ddfed705da5a0e9e3b20eecb333bb69b3e831c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoAnnotate @Nullable argument in SourceException 43/65143/8
Robert Varga [Sat, 4 Nov 2017 08:41:08 +0000 (09:41 +0100)]
Annotate @Nullable argument in SourceException

Change-Id: I439ad3c54faa170fedf5bab5f786e74d9319884c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoYANGTOOLS-706: split out rfc8040-model-api 22/65122/8
Robert Varga [Fri, 3 Nov 2017 17:15:30 +0000 (18:15 +0100)]
YANGTOOLS-706: split out rfc8040-model-api

YangDataSchemaNode needs to live in a separate RFC8040-specific
module, as it is not part of RFC7950 semantic model. Split it
out.

This flushes out the need to properly define YangDataStatement,
which in turn cascades to discrepancies in the structure of our
support classes. Those are cleaned up, with extensions getting
their proper declared statement interfaces and packages.

Change-Id: I84f7ad882172806a5aac8362837b85b50dc3a387
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoFix LeafListSchemaNode.getDefaults() 13/65113/7
Robert Varga [Fri, 3 Nov 2017 16:41:51 +0000 (17:41 +0100)]
Fix LeafListSchemaNode.getDefaults()

This method should be non-default, as marked by FIXME. Furthermore
it should represent a readily-parsed set of values, such that they
can be fed into a data container.

Change-Id: Ib63b3a5a419b13f79901632251b7584f3d18d2b8
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoAdd DataTreeConfiguration copy builder 95/65195/5
Robert Varga [Mon, 6 Nov 2017 18:00:56 +0000 (19:00 +0100)]
Add DataTreeConfiguration copy builder

This adds convenience methods to instantiate Builder, potentially
initialized from a base configuration.

Change-Id: I1cb5db4a0d097856dec5ebcdf9490d89fa349893
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoEliminate ConstraintDefition.isMandatory() 95/65095/14
Robert Varga [Fri, 3 Nov 2017 12:37:33 +0000 (13:37 +0100)]
Eliminate ConstraintDefition.isMandatory()

This flag is not accurate for containers due to the fact that
augment can make it dependent on the document being processed.

Redefine meaning of isMandatory() to reflect just the effect
of 'mandatory' statement.

Change-Id: I0135f2ffd7df454880d8cf259cd21af9585ec857
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoFix InMemoryDataTreeFactory.create() methods 40/65240/5
Robert Varga [Tue, 7 Nov 2017 01:23:18 +0000 (02:23 +0100)]
Fix InMemoryDataTreeFactory.create() methods

All of them should be returning TipProducingDataTree, as that is
what we are constructing.

Change-Id: I459128121e954efee6a406f16563209c1a2612ac
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoYANGTOOLS-826: allow whitespace after function name 67/65267/3
Robert Varga [Tue, 7 Nov 2017 14:09:45 +0000 (15:09 +0100)]
YANGTOOLS-826: allow whitespace after function name

As per https://www.w3.org/TR/1999/REC-xpath-19991116/#exprlex:

"For readability, whitespace may be used in expressions even though
not explicitly allowed by the grammar: ExprWhitespace may be freely
added within patterns before or after any ExprToken."

Add optional whitespace to the pattern to allow for this.

Change-Id: Iea5f7c9539734a5b5d3c1bb7367e615af4d1f9cb
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoYANGTOOLS-825: extend plugin SPI with import resolution mode 94/65094/7
Robert Varga [Fri, 3 Nov 2017 13:00:56 +0000 (14:00 +0100)]
YANGTOOLS-825: extend plugin SPI with import resolution mode

This patch adds the basic API needed for codegen plugins to express
their desired import resolution mode. The default implementation
results in RFC6020/7950 compliant mode.

Change-Id: I60936171b984dab503e1933b21dbcb5bd68278c8
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoMove TypeDefinitions into yang-model-api 87/65087/9
Robert Varga [Fri, 3 Nov 2017 10:45:08 +0000 (11:45 +0100)]
Move TypeDefinitions into yang-model-api

This utility class defines hashCode/toString/equals for TypeDefinitions,
hence it should live in the API package.

Furthermore split it out among concrete TypeDefinitions, so that it is
obvious to implementors they really should be using provided static
methods.

Change-Id: I0bf79f5a20958633ee7562bd44c861e0b0218137
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoYANGTOOLS-827: fix revision compare 80/65280/1
Robert Varga [Tue, 7 Nov 2017 18:28:53 +0000 (19:28 +0100)]
YANGTOOLS-827: fix revision compare

When revision statements do not follow guidance from RFC6020/RFC7950
section 7.1.9 and are not order in the order of descending date and
the delta between previous and next version strings is not exactly 1,
we end up picking the wrong version.

This is caused by wrong compareTo() check, which should compare '< 0',
not '== -1'.

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

6 years agoEliminate (Unsigned)IntegerTypeDefinition 86/65086/8
Robert Varga [Fri, 3 Nov 2017 09:22:05 +0000 (10:22 +0100)]
Eliminate (Unsigned)IntegerTypeDefinition

These two act only as intermediaries, there is no real reason to
keep them around, as all of their functions are fulfilled either
by RangeRestrictedTypeDefinition or their sub-interfaces.

Change-Id: I48698203d9073d31defba2b0c9df3d8a5859616e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoConsolidate (Unsinged)IntegerTypeEffectiveStatementImpl 55/65055/10
Robert Varga [Thu, 2 Nov 2017 17:37:49 +0000 (18:37 +0100)]
Consolidate (Unsinged)IntegerTypeEffectiveStatementImpl

The two classes are the same, hence we can concentrate them into
a single class, called IntegralTypeEffectiveStatementImpl.

Change-Id: I8fd5fb3ebe4feaa7005faeaeb5c8f55a692cd662
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoMake RangeRestrictedTypeDefinition type-aware 50/65050/9
Robert Varga [Thu, 2 Nov 2017 14:43:54 +0000 (15:43 +0100)]
Make RangeRestrictedTypeDefinition type-aware

This brings in native type into RangeRestrictedTypeDefinition, such
that the constraint type is properly qualified.

Change-Id: I1e099edb88abe882de0e937a43629693f1d660e6
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoYANGTOOLS-621: introduce specialized integer types 43/65043/11
Robert Varga [Thu, 2 Nov 2017 11:01:05 +0000 (12:01 +0100)]
YANGTOOLS-621: introduce specialized integer types

This introduces Int{8,16,32,64}TypeDefinition and
Uint{8,16,32,64}TypeDefinition to represent type definitions based
on these 8 builtin types.

This renders (Unsigned)IntegerTypeDefinition only a family capture,
which allows sharing common code paths. Users should refer to
individual types where possible.

Furthermore this eliminates the need for DerivedTypes.is*() methods,
which are deprecated. Users can perform the same function, sans
null checking, via plain instanceof checks.

Change-Id: I2d9620287f10cb7bd4e558b59890da25d976f67a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoMake DecimalTypeDefinition.getFractionDigits() return int 52/65052/3
Robert Varga [Thu, 2 Nov 2017 16:53:34 +0000 (17:53 +0100)]
Make DecimalTypeDefinition.getFractionDigits() return int

This is required to be a non-null Integer, which may just as well
be a primitive int.

Change-Id: Ibca5afb3dda7ee56e08b60602c9256a02815c284
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoEnforce decimal64 fraction-digits in derived types 42/65042/6
Robert Varga [Thu, 2 Nov 2017 13:17:26 +0000 (14:17 +0100)]
Enforce decimal64 fraction-digits in derived types

Overriding fraction-digits to a different value than specified by
base type is invalid -- throw a SourceException if we encounter such
a thing.

Change-Id: Ibb79203377ff41eefbf70100d6e86887e2fff185
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoYANGTOOLS-706: split out yang-parser-reactor 38/65038/5
Robert Varga [Thu, 2 Nov 2017 09:57:41 +0000 (10:57 +0100)]
YANGTOOLS-706: split out yang-parser-reactor

The reactor should not have any dependencies on support packages,
which has been achieved. Split it out into a separate artifact
to ensure we do not regress in this regard.

Change-Id: I748fae1e8f03d2fdee47016c085c35c73a5fad2f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoUpdate DataTreeFactory 37/65037/5
Robert Varga [Thu, 2 Nov 2017 09:43:01 +0000 (10:43 +0100)]
Update DataTreeFactory

This patch removes deprecated methods, adds a correctness note to
the single-argument create() method and promotes the other two to
non-Beta status.

Change-Id: I2a081dfa1dadcd19aa7b70109b6cca2be88c10be
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoRemove JSONCodecFactory.create(SchemaContext) 36/65036/5
Robert Varga [Thu, 2 Nov 2017 09:35:33 +0000 (10:35 +0100)]
Remove JSONCodecFactory.create(SchemaContext)

This method has been deprecated in favor of various static factory
methods, like getShared(), getPrecomputed(), createLazy() and similar.
Those offer various computation strategies and allow users to better
fine-tune memory/cpu overhead trade-offs based on their use. Remove
the old create() method.

Change-Id: I01bb4063be2273bc7f5cc3e2361b23c01ffa11bf
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoRemove XmlParserStream.create(NormalizedNodeStreamWriter, SchemaContext) 35/65035/5
Robert Varga [Thu, 2 Nov 2017 09:34:19 +0000 (10:34 +0100)]
Remove XmlParserStream.create(NormalizedNodeStreamWriter, SchemaContext)

This method has been deprecated in favor of the three-argument variant,
which is more powerful. Remove it.

Change-Id: I0416c2931a77cb9bec74de4ad2f02f339a51b4ac
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoRemove EffectiveSchemaContext.resolveSchemaContext() 34/65034/5
Robert Varga [Thu, 2 Nov 2017 09:32:17 +0000 (10:32 +0100)]
Remove EffectiveSchemaContext.resolveSchemaContext()

This method has been deprecated in favor of SimpleSchemaContext's
forModule() static factory method. Remove it.

Change-Id: Idf4b4834d98b84ffcd8bf91046b9dd3856183d61
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoRemove SchemaTracker.leafSetEntryNode() 33/65033/5
Robert Varga [Thu, 2 Nov 2017 09:30:03 +0000 (10:30 +0100)]
Remove SchemaTracker.leafSetEntryNode()

This no-arg method is deprecated in favor of leafSetEntryNode(QName),
remove it.

Change-Id: Ifc39251bae3afd37e2d0d7e2db248e9c641a3486
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoEliminate IdentityStatement.getBase() 32/65032/5
Robert Varga [Thu, 2 Nov 2017 09:26:51 +0000 (10:26 +0100)]
Eliminate IdentityStatement.getBase()

RFC7950 metamodel indicates an identity can have multiple base
identities -- remove the singular getBase() in favor of getBases().

Change-Id: I145832a69d16d09af19849eeba3e6334e02ebb7d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoDocument Builder.build() method to throw IllegalStateException 20/65020/6
Robert Varga [Thu, 2 Nov 2017 08:32:29 +0000 (09:32 +0100)]
Document Builder.build() method to throw IllegalStateException

Implementations should be throwing ISE or its subclass when they are
requested to build an object while not enough state has been populated.

Change-Id: I837bc5a3379ffffe3806382ccac97021948673f7
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoEliminate ModuleIdentifier 26/65026/5
Robert Varga [Thu, 2 Nov 2017 08:46:17 +0000 (09:46 +0100)]
Eliminate ModuleIdentifier

It has been superseded by SourceIdentifier and its concrete subclasses.

Change-Id: I88ae6bd8fae103198ad3caa7957de32f9bbed8e5
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoRemove ModuleIdentifier from reactor namespaces 94/64994/9
Robert Varga [Wed, 1 Nov 2017 12:26:03 +0000 (13:26 +0100)]
Remove ModuleIdentifier from reactor namespaces

SourceIdentifier fills in the same role, eliminate use of ModuleIdentifier
in reactor sources.

Change-Id: I437307249ec5b88a79864bdaebbf99e90bdd4696
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoDo not use ModuleIdentifier to identify sources 93/64993/8
Robert Varga [Tue, 31 Oct 2017 17:09:14 +0000 (18:09 +0100)]
Do not use ModuleIdentifier to identify sources

This eliminates the use of ModuleIdentifier for library resolution
purposes, paving a way to support semantic imports with module
library.

Change-Id: Idfb885472b191c0685b6e385c405e18934e0b84f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoEliminate IdentityrefTypeDefinition.getIdentity() 56/64956/9
Robert Varga [Tue, 31 Oct 2017 16:07:38 +0000 (17:07 +0100)]
Eliminate IdentityrefTypeDefinition.getIdentity()

getIdentity() implies singularity, which is not correct with respect
to RFC7950 metamodel. Remove the method in favor of getIdentities().

Change-Id: Idcffd7dcbe8f9303408d0d09e46cad959b38c21e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoFix IdentityrefTypeDefinition comparison 55/64955/7
Robert Varga [Tue, 31 Oct 2017 16:01:11 +0000 (17:01 +0100)]
Fix IdentityrefTypeDefinition comparison

IdentityrefTypeDefinition can contain multiple base identities, hence
the comparison needs to take into account all of them.

Change-Id: Ibe90cf1dc7fed8a2c1f3f7f16606f85d6761bb50
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoBUG-8043: correct RangeConstraint definition 45/62445/18
Robert Varga [Tue, 29 Aug 2017 15:36:34 +0000 (17:36 +0200)]
BUG-8043: correct RangeConstraint definition

Each type has at most one range constraint attached to it, reflect
that fact in yang-model-api hiearchy.

This has implications on RangeStatement: it should not be exposing
RangeConstraints, as that is not what the argument holds. Reuse
ValueRange from previous work on LengthConstraint and model ranges
in a similar fashion.

Change-Id: Ia3d13ce2e27b37c579bf40b30032451996c59914
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoUpdate TypeDefinition design 73/64873/9
Robert Varga [Mon, 30 Oct 2017 11:04:06 +0000 (12:04 +0100)]
Update TypeDefinition design

Use Optional to communicate presence of default value and units. Update
call sites to do the right thing, also for previously-missed changes.

Change-Id: Icfffb752507e2810a6afb157faa09d07680292cf
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoMake ListSchemaNode.getUniqueConstraints() non-default 72/64872/8
Robert Varga [Mon, 30 Oct 2017 08:19:02 +0000 (09:19 +0100)]
Make ListSchemaNode.getUniqueConstraints() non-default

This method should always be overridden, make it non-default.

Change-Id: Ifdf6ed9cde3d1857db00b49b4aa5304265b7fc78
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoFix NotificationDefinition 71/64871/8
Robert Varga [Sun, 29 Oct 2017 21:48:41 +0000 (22:48 +0100)]
Fix NotificationDefinition

NotificationDefinition should provide MustDefinitions directly, as
it cannot have any other constraints.

Change-Id: Icf38b5b832979fafac8c38b09b108509014fc48c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoUpdate ChoiceSchemaNode design 52/64852/12
Robert Varga [Sat, 28 Oct 2017 14:54:46 +0000 (16:54 +0200)]
Update ChoiceSchemaNode design

ChoiceCaseSchemaNodes have unique QName, which how the only implementation
keeps track of them, hence they should be exposed as a SortedMap keyed by
QName.

This renders getCaseNodeByName() obsolete, as there are better ways of
getting the same result.

Change-Id: Ia52b6d22b3df66546a3ead7addcfd1aba9b0b6a5
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoQNameModule should implement Comparable<QNameModule> 53/64853/7
Robert Varga [Sat, 28 Oct 2017 15:04:27 +0000 (17:04 +0200)]
QNameModule should implement Comparable<QNameModule>

It is a composition of URI and Revision, both of which are Comparable.
compareTo() now compares URI first and then Revision.

Change-Id: If36815df36264b4fbd6abe9896d35a7a11f5a8f9
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoRemove LeafSchemaNode.getUnits/getDefault() 40/64840/12
Robert Varga [Fri, 27 Oct 2017 23:49:16 +0000 (01:49 +0200)]
Remove LeafSchemaNode.getUnits/getDefault()

These details are already encoded in LeafSchemaNode's type. Remove them from
LeafSchemaNode to prevent confusion and direct users to the type definition.

Change-Id: I588ccefeabc83d801122f78c4b55d1a0b863a039
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoYANGTOOLS-823: take modifier into account when enforcing patterns 49/64849/5
Robert Varga [Sat, 28 Oct 2017 11:02:07 +0000 (13:02 +0200)]
YANGTOOLS-823: take modifier into account when enforcing patterns

Modifiers are an RFC7950 addition to the metamodel and need to be
accounted for to comply with the specification.

Change-Id: Ide9625812a2df26e931a2b5d472af80bba07d730
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoMark ModuleImport technical debt 39/64839/12
Robert Varga [Fri, 27 Oct 2017 23:34:52 +0000 (01:34 +0200)]
Mark ModuleImport technical debt

ModuleImport should not be part of effective world because it's sole
purpose is to provide String->QNameModule mapping.

Change-Id: I9cabc16b7c711edffad8ba9c9306f1fe0c5c81ec
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoClean up PatternConstraint's String confusion 38/64838/12
Robert Varga [Fri, 27 Oct 2017 23:03:10 +0000 (01:03 +0200)]
Clean up PatternConstraint's String confusion

Make getRawRegularExpression() non-default and make sure we use descriptive
names for the two strings -- one is a XSD RegEx String, the other
a Pattern-compatible String.

Change-Id: I6a8be40aa172cdd2c4b0c461836245bc5a63a83b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoMake PatternConstraint.getModifier() non-default 33/64833/12
Robert Varga [Fri, 27 Oct 2017 22:34:08 +0000 (00:34 +0200)]
Make PatternConstraint.getModifier() non-default

Also change its return value to an optional, so that we properly
express its 0..1 cardinality.

Change-Id: I08ba48f31960ccbb1cc45ade46e441fb0d47deff
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoCleanup NotificationNodeContainer 32/64832/10
Robert Varga [Fri, 27 Oct 2017 22:16:22 +0000 (00:16 +0200)]
Cleanup NotificationNodeContainer

Make the API consistent with ActionNodeContainer, e.g. by not providing
a default implementation.

Change-Id: I42b74a37ea6c76b79e357e4413a94c085dbcd2ce
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoEliminate duplicate EnumPairBuilder boilerplate 31/64831/13
Robert Varga [Fri, 27 Oct 2017 21:08:19 +0000 (23:08 +0200)]
Eliminate duplicate EnumPairBuilder boilerplate

We are performing the same block of operations in two different places,
create a utility method to hold common code for both code paths.

Change-Id: Ic7adb46fe15d5d2d307833349975faa04d935517
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoCleanup DocumentedNode 21/64821/19
Robert Varga [Fri, 27 Oct 2017 18:05:33 +0000 (20:05 +0200)]
Cleanup DocumentedNode

Make description/reference work on Optional and fixup users.

Change-Id: I744b9c59c8c3cc160636ef8c3ff18298c66a275a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoRemove deploy-site.xml 94/64894/2
Thanh Ha [Mon, 30 Oct 2017 20:50:42 +0000 (16:50 -0400)]
Remove deploy-site.xml

With the javadoc jobs now available to generate javadoc it is time to
remove the maven-sites and related files.

Change-Id: I82f655c97c62befd90bf31ee6ec285fbaa4f40e4
Signed-off-by: Thanh Ha <thanh.ha@linuxfoundation.org>
6 years agoMake ConstraintMetaDefition attributes Optional 20/64820/9
Robert Varga [Fri, 27 Oct 2017 17:47:03 +0000 (19:47 +0200)]
Make ConstraintMetaDefition attributes Optional

Both error message and application tag can be null, wrap them in
an Optional, reducing confusion for users around empty string
semantics in their values.

Change-Id: Ie96850655b23bda81c864e3804b21e05ace5acbe
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoMake ConstraintMetaDefinition extend DocumentedNode 19/64819/6
Robert Varga [Fri, 27 Oct 2017 17:36:57 +0000 (19:36 +0200)]
Make ConstraintMetaDefinition extend DocumentedNode

It shares description/reference with DocumentedNode, and usuall also
unknown nodes. Tie the two together so we get consistent method
definitions across the board.

Change-Id: I4336059304715323155576e1229e2c32fc859df1
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoMake Module.getContact()/getOrganization() return Optional 18/64818/6
Robert Varga [Fri, 27 Oct 2017 17:26:32 +0000 (19:26 +0200)]
Make Module.getContact()/getOrganization() return Optional

These methods can return null, but have not been marked as such,
make the contract explicit by using an Optional return.

Change-Id: Id9e74fc7ee957fbb2f5c03255177a65bc23dd3a2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoIntroduce DataNodeContainer.findDataChildByName() 16/64816/5
Robert Varga [Fri, 27 Oct 2017 16:28:13 +0000 (18:28 +0200)]
Introduce DataNodeContainer.findDataChildByName()

This the primary, non-null returning replacement of getDataChildByName(),
which is turned into a deprecated default utility method. This forces
users to check the return, flusing out potential inconsistencies like
null nodes in collections.

Change-Id: I8e81044c21a9b5daaa63c3ba347aa13a4222ae44
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoMake AnyDataSchemaNode.getSchemaOfAnyData() return Optional 12/64812/4
Robert Varga [Fri, 27 Oct 2017 16:05:24 +0000 (18:05 +0200)]
Make AnyDataSchemaNode.getSchemaOfAnyData() return Optional

Rather than going the nullable route, return an optional, forcing
users to define behaviour when the schema is not present.

Change-Id: I220debe08c031d4490e29805fc846637043899f7
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoIntroduce WhenConditionAware 11/64811/4
Robert Varga [Fri, 27 Oct 2017 15:59:34 +0000 (17:59 +0200)]
Introduce WhenConditionAware

getWhenCondition() is used by multiple interfaces, extract it to
a dedicated interface so the individual definitions are consistent.

Change-Id: I177f8dcddd1ffa150ffe50c106475ee624343a20
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoMake ActionNodeContainer.getActions() non-default 08/64808/4
Robert Varga [Fri, 27 Oct 2017 14:09:59 +0000 (16:09 +0200)]
Make ActionNodeContainer.getActions() non-default

The API specification should not rely on particular exceptions, those
should be handled by sub-interfaces. Since we can make breaking API
changes, now is the time to change this.

Change-Id: I3bc3bee4abd8794343d811aa4bfdb5a64677eda8
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoClean up CrossSourceStatementReactor 48/64748/6
Robert Varga [Wed, 25 Oct 2017 21:22:53 +0000 (23:22 +0200)]
Clean up CrossSourceStatementReactor

Remove deprecated methods, so we move towards a more builder-like
interface.

Change-Id: I28c86e35fd7d1a258e612651f1aa3420597f6cce
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoFix Revision.ofNullable() javadoc 09/64809/1
Robert Varga [Fri, 27 Oct 2017 14:56:10 +0000 (16:56 +0200)]
Fix Revision.ofNullable() javadoc

Update javadoc to identify proper execption that is thrown.

Change-Id: Icde0b6932b7ed7769f9ed18cc205c77b060c2b82
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoYangSyntaxErrorException should identify its source 47/64747/5
Robert Varga [Wed, 25 Oct 2017 21:06:46 +0000 (23:06 +0200)]
YangSyntaxErrorException should identify its source

Having just the module name is not sufficient in reactor settings where
there may be diverse sources involved.

Update YangSyntaxErrorException to contain SourceIdentifier when available.

Change-Id: Ied076ecd60fcef000ef498f632d2288fa2f6d954
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoUpdate concepts.Registration 45/64745/5
Robert Varga [Wed, 25 Oct 2017 20:17:27 +0000 (22:17 +0200)]
Update concepts.Registration

Do not allow Registration.close() to throw checked exceptions. While it
is a good practice to check for exceptions in foreign code, it is purely
optional and should include RuntimeExceptions as well.

Also update AbstractRegistration to enforce identity hashCode/equals and
also toString() format.

Change-Id: I8d70273e1a42943288a16ac8edf40381707da186
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoClean up data.api.SchemaUtils 44/64744/4
Robert Varga [Wed, 25 Oct 2017 19:55:42 +0000 (21:55 +0200)]
Clean up data.api.SchemaUtils

Remove deprecated classes and reformulate internals to perform explicit
finds.

Change-Id: I9ad4ea68f1bbde67a7a54145679804d49cc5ff77
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoMake Module extends NamespaceAware and DocumentedNode 33/64733/5
Robert Varga [Wed, 25 Oct 2017 18:39:17 +0000 (20:39 +0200)]
Make Module extends NamespaceAware and DocumentedNode

Module already shares the same methods, make sure we inherit them
from a single place to ensure API compatibility.

Change-Id: Ib4653484fb2d619621e7eac117c862e487f8765a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoBUG-4688: update Revision design a bit more 85/64785/4
Robert Varga [Thu, 26 Oct 2017 22:10:43 +0000 (00:10 +0200)]
BUG-4688: update Revision design a bit more

As it turns out, we need to have a reasonable serialization into Java
code -- where we already are supporting @Nullable arguments in places
like QName.create(String, String, String).

Add an ofNullable(String) factory method which returns
an Optional<Revision>, forming a convenient bridge for code generators.

Change-Id: Iacea1725e9fbe304bf63fbf087f4b14a8a352ccd
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoMake Deviation extend DocumentedNode 32/64732/2
Robert Varga [Wed, 25 Oct 2017 18:35:32 +0000 (20:35 +0200)]
Make Deviation extend DocumentedNode

It shares the same attributes, make sure they are related to keep
our APIs consistent and reusable.

Change-Id: I270b9742dce5539698b0ed7a51097409031b9577
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoFix yang.model.api.AugmentationSchema 31/64731/2
Robert Varga [Wed, 25 Oct 2017 18:31:47 +0000 (20:31 +0200)]
Fix yang.model.api.AugmentationSchema

This interface has long been sticking out as not following naming
conventions. Fix that and make it extended DocumentedNode.WithStatus
to properly tie its attributes to a common definition.

Change-Id: Ibf5c477bf80175597a6d34f7370457233c5310c7
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoFix checkstyle in yang-parser-impl and enable enforcement 29/64729/1
Robert Varga [Wed, 25 Oct 2017 17:41:26 +0000 (19:41 +0200)]
Fix checkstyle in yang-parser-impl and enable enforcement

This patch sweeps the sources and flips the switch so we do not
regress over time.

Change-Id: Id1322696341c6ffdfb892ce69e5b07bde0a1543e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoBUG-4688: eliminate QName(Module).getFormattedRevision() 17/64717/2
Robert Varga [Wed, 25 Oct 2017 13:42:34 +0000 (15:42 +0200)]
BUG-4688: eliminate QName(Module).getFormattedRevision()

Since we are capturing revisions in their objects, these methods do not
really serve a purpose, remove them.

Change-Id: Iac1601fd5e049472d3cda77db9ff306b0443d4ab
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoBUG-4688: Make SourceIdentifier use Revision 11/64711/4
Robert Varga [Wed, 25 Oct 2017 12:26:37 +0000 (14:26 +0200)]
BUG-4688: Make SourceIdentifier use Revision

There is no need to treat the string representation differently,
just use Revision everywhere. This forces us to clean up module
names to actually match revisions.

Change-Id: Ibc6b268a8dc4156e9c2940018c6f696f5fe3c6ae
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoBUG-4688: remove SimpleDateFormatUtil 10/64710/2
Robert Varga [Wed, 25 Oct 2017 11:50:59 +0000 (13:50 +0200)]
BUG-4688: remove SimpleDateFormatUtil

Convert FilesystemSchemaSourceCache to use Revision and remove
SimpleDateFormatUtil as it is not used anywhere anymore.

Change-Id: Ie59921866bf84fbbe75a07cdcf3cc44f8bdafcd2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoBUG-4688: Move SourceIdentifier.REVISION_PATTERN to yang.common.Revision 09/64709/2
Robert Varga [Wed, 25 Oct 2017 11:42:17 +0000 (13:42 +0200)]
BUG-4688: Move SourceIdentifier.REVISION_PATTERN to yang.common.Revision

Revision class is the natural home for this pattern, as it already
is defining the same thing for internal purposes. Expose
REVISION_PATTERN from Revision and remove it from SourceIdentifier.

Change-Id: I994b5ad4eaeb6560334ebda088aa4492c90afa8f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoBUG-4688: switch revisions from Date to Revision 83/62083/11
Robert Varga [Wed, 25 Oct 2017 10:09:09 +0000 (12:09 +0200)]
BUG-4688: switch revisions from Date to Revision

This is a mass conversion of revision representation from java.util.Date
to yang.common.Revision. Using java.util.Date was a mistake from the get
go, causing confusion in users and implementation.

QName.parseRevision() is removed in favor of Revision.valueOf() and invalid
revision strings are updated.

Change-Id: Ifce810bab4183186b67f5f3acfad03ac9c081815
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoBUG-4688: align Optional/nullable Date usage 93/64693/2
Robert Varga [Wed, 25 Oct 2017 00:18:40 +0000 (02:18 +0200)]
BUG-4688: align Optional/nullable Date usage

This patch introduces proper nullable/Optional bridge methods, so that
we have a clear hand-off between APIs.

Change-Id: I448feffa7a64eb97cfc74b830d2242ecb55880a0
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoBUG-4688: update Revision class design 81/64681/4
Robert Varga [Tue, 24 Oct 2017 22:45:20 +0000 (00:45 +0200)]
BUG-4688: update Revision class design

Since Revision is typically captured property, with complete semantics
when it is missing, it is useful to define operations on nullable and
optional Revisions.

Furthermore we know what the proper format is, so rather than relying
on a date object, use the underlying string. This saves us some work
when communicating with others.

Change-Id: I5716f416cf87697f832c05d6223dbc9dd87dfd15
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoFix wrong comparison 27/64727/1
Robert Varga [Wed, 25 Oct 2017 16:36:25 +0000 (18:36 +0200)]
Fix wrong comparison

This is pointed out by eclipse: QName will never compare as equal
with a QNameModule. Fix the thinko.

Change-Id: I32b0856fb533189be4700a4f7e3eeb00eb319b44
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoCorrect IdentitySchemaNode documentation 80/64680/1
Robert Varga [Tue, 24 Oct 2017 22:33:40 +0000 (00:33 +0200)]
Correct IdentitySchemaNode documentation

Do not leak implementation details, but rather explain API contract.

Change-Id: I773dbd157883dab403b1468abd0bae4289a61f06
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoEnforce non-null QNameModule namespace 88/61988/18
Robert Varga [Fri, 18 Aug 2017 14:01:01 +0000 (16:01 +0200)]
Enforce non-null QNameModule namespace

QNameModule without a namespace does not really make sense,
enforce valid namespace.

Change-Id: I62e8daf71deba15e4d3bdb975046223ade57cdbe
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoBUG-4688: eliminate SimpleDateFormatUtil.DEFAULT_DATE_REV 73/64673/3
Robert Varga [Tue, 24 Oct 2017 15:49:22 +0000 (17:49 +0200)]
BUG-4688: eliminate SimpleDateFormatUtil.DEFAULT_DATE_REV

This is the final push for eliminating DEFAULT_DATE_REV, with all
other issues resolved, this removes the constant, adjusts the code
to correctly interpret non-present revisions and fixes up test
cases, eliminating the leaking 1970-01-01 string.

This actually fixes a few test cases, which relied on import with
revision 1970-01-01 matching modules which do not declare revision.

Change-Id: I59dbe8b06ad2d94e6a677959f29f5c2b52357d0b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoBUG-4688: Rework SchemaContext module lookups 41/64641/4
Robert Varga [Mon, 23 Oct 2017 23:11:49 +0000 (01:11 +0200)]
BUG-4688: Rework SchemaContext module lookups

SchemaContext.findModule*() family of methods is making the mistake
of treating null revision as a wildcard. This does not match RFC6020
and RFC7950, which allow for modules without a revision, hence we need
to mark non-existing modules with a magic constant, which maps to
1970-01-01.

While we can use identity checks and assume such a revision will not
be seen in the wild, this approach does not really work with maps
and creates confusion with users, who need to treat DEFAULT_DATE_REV
as something special.

This patch cleans up the lookup methods and makes
ModuleIdentifier.getRevision() return an Optional<Date>, in preparation
to making the transition to SourceIdentifier.

As a side-effect we switch to using QNameModule-based lookups in couple
of places, which are significantly faster than combined name/revision
lookups.

Change-Id: I5602192e26d721d2461248c612d98a1b305c6958
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoUse QName.parseRevision() instead of SimpleDateFormatUtil 46/64646/1
Robert Varga [Tue, 24 Oct 2017 11:46:07 +0000 (13:46 +0200)]
Use QName.parseRevision() instead of SimpleDateFormatUtil

It has an interface better suited for testing, simplifying test code.

Change-Id: I14fbaf3bebf3a64280d4141ba533395d2b41f015
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoBUG-4688: switch IncludeStatementImpl to use queries 27/64627/3
Robert Varga [Mon, 23 Oct 2017 22:02:15 +0000 (00:02 +0200)]
BUG-4688: switch IncludeStatementImpl to use queries

Use IdentifierKeyCriterion instead of lookups based on magic constants,
eliminating last real user of SimpleDateFormatUtil.DEFAULT_DATE_IMP and
killing that magic number completely.

Change-Id: I72cb7babe6904155d10e6c2a36d6d8731e58c7e3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoBUG-4688: switch semantic imports to queries 21/64621/4
Robert Varga [Mon, 23 Oct 2017 16:49:42 +0000 (18:49 +0200)]
BUG-4688: switch semantic imports to queries

Use NamespaceKeyCriterion-based lookup for resolution of semver-based
imports. This simplifies the code quite a bit and makes it obvious
that revision and semver imports have really different mechanics.

Change-Id: I27696fbd4903037477c8c4b091f4ab83891bc53c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoBUG-4688: switch revision imports to queries 00/64600/7
Robert Varga [Sat, 21 Oct 2017 06:44:12 +0000 (08:44 +0200)]
BUG-4688: switch revision imports to queries

Use NamespaceKeyCriterion-based lookup for resolution of revision-based
imports, which eliminates the need to use
SimpleDateFormatUtil.DEFAULT_DATE_IMP in this lookup path and re-lookups,
as those are already taken care of in the criterion resolution process.

Change-Id: Ie20f3be9591da9ff65348c3c8f5d7cb071c98769
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoLazily populate listeners and derived namespaces 19/64619/4
Robert Varga [Mon, 23 Oct 2017 18:40:51 +0000 (20:40 +0200)]
Lazily populate listeners and derived namespaces

Rather than allocating collections eagerly only allocate them as
needed, so our footprint is lower when these are not used.

Since listeners are unregistered once they fire, also make sure
we free up the collection when it is empty.

Change-Id: Ia1b20718fbc7bc41de75820b602ffb8c9fdcf0a1
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoBUG-4688: Add flexible match support to NamespaceStorageSupport 70/64570/11
Robert Varga [Fri, 20 Oct 2017 12:08:59 +0000 (14:08 +0200)]
BUG-4688: Add flexible match support to NamespaceStorageSupport

This patch adds the support for flexible match of namespace keys
based on filter/reduce mechanics -- which are required to consistently
support revisionless and semantic imports without reliance on
magic constants in public interfaces.

In order to support required mechanics, we need to fix
the ValueAddedListener implementation and their lifecycle and introduce
a predicate-based match.

Change-Id: Icb22850e44de05d59820e1974e204dc1541e1f76
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoCleanup NamespaceBehaviourWithListeners 69/64569/6
Robert Varga [Fri, 20 Oct 2017 12:43:48 +0000 (14:43 +0200)]
Cleanup NamespaceBehaviourWithListeners

Lower method visibility and eliminate unneeded method indirection,
as it makes things less clear than they could be.

Furthermore move isRequestedValue() so that it is a property of
ValueAddedListener -- eliminating the requirement of the listener
having an exact key.

Change-Id: Ibc3b207740349c9268c4a42072348c680295def8
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoBUG-8043: correct LengthConstraint definition 19/62319/13
Robert Varga [Tue, 29 Aug 2017 07:19:57 +0000 (09:19 +0200)]
BUG-8043: correct LengthConstraint definition

Each type has at most one length constraint attached to it, reflect
that fact in yang-model-api hiearchy.

This has implications on LengthStatement: it should not be exposing
LengthConstraints, as that is not what the argument holds. Define
ValueRange construct to hold the parsed-out (but unresolved) ranges
as parsed from length argument.

Change-Id: I38e1e5a40a0b7562d202816f126cc1ecec414d0e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoBug 9242: Reuse deviating statement contexts 06/64406/4
Igor Foltin [Tue, 17 Oct 2017 14:08:18 +0000 (16:08 +0200)]
Bug 9242: Reuse deviating statement contexts

In the process of deviate add/replace resolution we make
copies of deviated statement contexts which are then added
to the deviation target context.

However, making copies of these statement contexts is not
necessary except the ones which represent unknown statements.

Therefore, reuse them during the resolution of deviate add/replace.

By doing this, we also solve the failing deviate replace with
user-defined types as statement contexts that represent deviating
user-defined types are now resolved within their original context.

Change-Id: Ie61a38e270ef648fe61ea283805d149533c10f62
Signed-off-by: Igor Foltin <igor.foltin@pantheon.tech>
6 years agoImprove StatementContextBase documentation 84/64584/3
Robert Varga [Fri, 20 Oct 2017 23:16:04 +0000 (01:16 +0200)]
Improve StatementContextBase documentation

Clarify intended behavior of addPhaseCompletedListener().

Change-Id: I23025cfb64a7069e84c0f0c182f3c78e500e2e73
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoDo not accept null phase in ModifierImpl 83/64583/2
Robert Varga [Fri, 20 Oct 2017 16:59:33 +0000 (18:59 +0200)]
Do not accept null phase in ModifierImpl

This would constitute a coding error, hence detect it explicitly.

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