yangtools.git
7 years agoUse UntrustedXML in tests 79/53179/3
Robert Varga [Sat, 11 Mar 2017 17:24:29 +0000 (18:24 +0100)]
Use UntrustedXML in tests

In order not to preliferate DocumentBuilderFactory instantiation,
use UntrustedXML everywhere in tests.

Change-Id: I412711035978679a69cc41118c006bf8d7cf5864
Signed-off-by: Robert Varga <rovarga@cisco.com>
7 years agoRemove remants of yang-data-operations 78/53178/3
Robert Varga [Sat, 11 Mar 2017 16:50:51 +0000 (17:50 +0100)]
Remove remants of yang-data-operations

This component is no longer built, remove its remnants.

Change-Id: Ibe1850ea8449cabc323c41df9025844346968af8
Signed-off-by: Robert Varga <rovarga@cisco.com>
7 years agoDo not trust documents in anyxml 76/53176/2
Robert Varga [Sat, 11 Mar 2017 16:48:36 +0000 (17:48 +0100)]
Do not trust documents in anyxml

Parsing XMLs in anyxml is an untrusted operation, as they can
include various references to outside world. Fix this by using
a DocumentBuilder from UntrustedXML.

Change-Id: If212d5cc9629d415c7d22aba7d691215644a8669
Signed-off-by: Robert Varga <rovarga@cisco.com>
7 years agoMake XmlDocumentUtils use UntrustedXML 75/53175/2
Robert Varga [Sat, 11 Mar 2017 16:44:31 +0000 (17:44 +0100)]
Make XmlDocumentUtils use UntrustedXML

When dealing with incoming XML, we should not be trusting it. Instead
of open-coded DocumentBuilderFactory, use the one encapsulated in
UntrustedXML.

Change-Id: I3bcee704de8dc73428950ac59579b33aabe15bc0
Signed-off-by: Robert Varga <rovarga@cisco.com>
7 years agoBug 6392: Fix lenient parsing of unkeyed list entries 49/53149/3
Igor Foltin [Fri, 10 Mar 2017 16:05:07 +0000 (17:05 +0100)]
Bug 6392: Fix lenient parsing of unkeyed list entries

The old xml parser can be set to ignore nodes
which do not exist in the corresponding YANG model
using a boolean flag. However, this flag is
ignored when parsing unkeyed list entries.

This patch fixes the issue

Change-Id: I798be8151d575f838e97a8fe44d04f47363491ba
Signed-off-by: Igor Foltin <ifoltin@cisco.com>
7 years agoBug 5410 - XSD regular expressions are interpreted as Java regexes (2/2) 00/53000/5
Peter Kajsa [Wed, 8 Mar 2017 12:56:30 +0000 (13:56 +0100)]
Bug 5410 - XSD regular expressions are interpreted as Java regexes (2/2)

Removal of xsd-regex parts from Yangtools.

Change-Id: I8bbe225f187c6ae215ceb9e144cac6bdbe1bddd6
Signed-off-by: Peter Kajsa <pkajsa@cisco.com>
7 years agoBug 7945: Fix schema validation for augmentation of case 25/52025/4
Xiao Liang [Fri, 17 Feb 2017 23:51:58 +0000 (07:51 +0800)]
Bug 7945: Fix schema validation for augmentation of case

Add modification strategy of case augmentation as child of choice.

Change-Id: Ie7b03f2d06ab279f0dd9c85edf9a370b0f63abac
Signed-off-by: Xiao Liang <shaw.leon@gmail.com>
7 years agoBug 5410 - XSD regular expressions are interpreted as Java regexes (1/2) 99/52999/6
Peter Kajsa [Wed, 8 Mar 2017 12:54:22 +0000 (13:54 +0100)]
Bug 5410 - XSD regular expressions are interpreted as Java regexes (1/2)

As both '^' and '$' are special anchor characters in java regular
expressions which are implicitly present in XSD regular expressions,
we need to escape them in case they are not defined as part of
character ranges i.e. inside regular square brackets.

Change-Id: Iafbf350f88ebdf96c30e1ccedbd00b90a93d521a
Signed-off-by: Peter Kajsa <pkajsa@cisco.com>
7 years agoBug 7182 related: yang-maven-plugin no hard-coded target/ (target-ide/) 40/52440/9
Michael Vorburger [Wed, 1 Mar 2017 01:12:57 +0000 (02:12 +0100)]
Bug 7182 related: yang-maven-plugin no hard-coded target/ (target-ide/)

Change-Id: Ic90f8f9b808d353cce289010b4907de55204091f
Signed-off-by: Michael Vorburger <vorburger@redhat.com>
Signed-off-by: Robert Varga <rovarga@cisco.com>
7 years agoBUG-7424: Disallow child namespace collisions 00/51400/9
Peter Kajsa [Fri, 3 Feb 2017 13:25:27 +0000 (14:25 +0100)]
BUG-7424: Disallow child namespace collisions

All leafs, leaf-lists, lists, containers, choices, rpcs,
notifications, and anyxmls defined (directly or through a uses
statement) within a parent node or at the top level of the module
or its submodules share the same identifier namespace.

Change-Id: I1852d2ca5ebd07ba6c1ed21a5ceded3e87d67467
Signed-off-by: Peter Kajsa <pkajsa@cisco.com>
Signed-off-by: Robert Varga <rovarga@cisco.com>
7 years agoBug 7865 - Extension argument is being restricted to identifier 91/52991/1
Peter Kajsa [Wed, 8 Mar 2017 08:48:11 +0000 (09:48 +0100)]
Bug 7865 - Extension argument is being restricted to identifier

Yang parser tries to create QName from unknownStatement argument by
process of SchemaPath construction what is incorrect, because argument
of unknownStatemet can be any string.

Change-Id: I60df2afb55efdc6b4c48f14809ecd77815180090
Signed-off-by: Peter Kajsa <pkajsa@cisco.com>
7 years agoBUG-7424: introduce a putIfAbsent storage operation 62/52762/2
Robert Varga [Fri, 3 Mar 2017 12:56:51 +0000 (13:56 +0100)]
BUG-7424: introduce a putIfAbsent storage operation

The interface exposed by NamespaceBehaviour is not sufficient
to express the needs of all storages. Refactor addToLocalNamespace()
into two distict operations, create-or-replace and create so
we can cleanly implement ChildSchemaNodes namespace.

Change-Id: If85f6d87238e61f34ac022ffa63e62c9ae246d0a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoBUG-7898: clean up CrossSourceStatementReactor interface 14/52814/4
Robert Varga [Sat, 4 Mar 2017 12:52:36 +0000 (13:52 +0100)]
BUG-7898: clean up CrossSourceStatementReactor interface

Warnings emitted by BuildGlobalContext about requested features
come from insufficient isolation of public and private APIs. Correct
this error by moving the warnings to the public interface methods,
so the incorrect use is allowed without breaking the API contract.

While we are touching this area, deprecate redundant BuildAction
methods.

Change-Id: Ic77df07851f15bb6faabc7c9b4b466626e028d2f
Signed-off-by: Robert Varga <rovarga@cisco.com>
7 years agoBug 6856: Rpc definition should implicitly define input/output 04/48704/22
Igor Foltin [Tue, 28 Feb 2017 12:09:56 +0000 (13:09 +0100)]
Bug 6856: Rpc definition should implicitly define input/output

Empty input and output statements are now automatically
added to every rpc statement that does not declare them.

Change-Id: I799137f18fe6ac382c8488684514b746dafbefb5
Signed-off-by: Igor Foltin <ifoltin@cisco.com>
Signed-off-by: Robert Varga <rovarga@cisco.com>
Signed-off-by: Igor Foltin <ifoltin@cisco.com>
7 years agoBug 7879 - refine target node was not found 39/52639/2
Peter Kajsa [Thu, 2 Mar 2017 11:36:11 +0000 (12:36 +0100)]
Bug 7879 - refine target node was not found

In case of uses-refine used in augment defined in submodule the yang
statment parser was not able to resolve target namespace, because augment
was definied in submodule. In consequence, leaf node retained its original
namespace and therefore refine target node was not found.

This patch fixes the bug described above.

Change-Id: I24668a2efb6853cfd07b515ea5671cd2bfde580c
Signed-off-by: Peter Kajsa <pkajsa@cisco.com>
7 years agoBug 6878: Add support for parsing yang-specific XPath functions 38/51938/9
Igor Foltin [Thu, 16 Feb 2017 08:43:15 +0000 (09:43 +0100)]
Bug 6878: Add support for parsing yang-specific XPath functions

YANG 1.1 (RFC7950) introduces a set of yang-specific XPath functions.
YANG statement parser can now parse YANG 1.1 models which contain
these functions

Change-Id: Icfbf95db0d04a3f077133c38341f250cde4e56eb
Signed-off-by: Igor Foltin <ifoltin@cisco.com>
7 years agoBug 7182: YangToSourcesProcessor deletes output directory 16/52416/3
Michael Vorburger [Tue, 28 Feb 2017 21:08:48 +0000 (22:08 +0100)]
Bug 7182: YangToSourcesProcessor deletes output directory

Now that a c/52087 has added a lifecycle-mapping-metadata.xml into the
yang-maven-plugin, for this to really properly work in-IDE even on full
builds (we're far from making this work incrementally..) it's important
that the output directory is cleaned.

This is because I've observed in testing that otherwise something else
(I'm not clear what) seems to prevent overwriting already existing
*.java files.  I've verified that with this change, the typical use case
of e.g. git pull master, some changes in *.yang files, you Project >
Clean... (full build, only) - red is gone!  (Finally.)

A full delete of an output directory (on a full rebuild) is, unrelated,
better anyway, as it gets rid of previously generated classes with names
that theoretically possibly don't exist anymore, imagine e.g. after a
renaming in YANG.

This fix is particular to in-IDE code generation, following the
lifecycle mapping.  It typically was never a problem on CLI, cauz
everyone always just does "mvn clean install" anyway - but it won't hurt
there either.  But for in-IDE, we have to clean ourselves; thus this
change.

The two *Test changes fix test failures introduced by this change.
Unless a misunderstood the intent - those tests appear to be wrong - how
can they intend the outputBaseDir to be the SOURCE dir of those YANG
models?!?  (That's what they do as-is, and that's why the test fails,
when the source gets deleted.)

Change-Id: Ie47294511b6f9c57cefdb305344045e112e8d05a
Signed-off-by: Michael Vorburger <vorburger@redhat.com>
7 years agoRemove checkstyle plugin declaration 57/52357/2
Robert Varga [Tue, 28 Feb 2017 12:17:05 +0000 (13:17 +0100)]
Remove checkstyle plugin declaration

Checkstyle should not be run in aggregator poms. This patch fixes
a maven warning about missing version and should result in faster
compilation times.

Change-Id: I07d810fd05568865eb31f2f00fcc482fa4d0e31f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoFormat Module revisions 44/52344/2
Robert Varga [Tue, 28 Feb 2017 09:09:48 +0000 (10:09 +0100)]
Format Module revisions

Rather than printing out the date, use QNameModule's
getFormattedRevision() to print out revision in correct format.

Change-Id: I953429c331548fc1e0d83449e0c339d64a9790e4
Signed-off-by: Robert Varga <rovarga@cisco.com>
7 years agoBUG-7568: account for module/submodule split 49/52349/1
Robert Varga [Tue, 28 Feb 2017 09:59:43 +0000 (10:59 +0100)]
BUG-7568: account for module/submodule split

The set of modules in the project does not map 1:1 to the set
of actual files, as modules have submodules. Correctly account
for this difference and track them separately.

Change-Id: I9eb4de37e59a9c1e9ca47143dd4be52f54ee396a
Signed-off-by: Robert Varga <rovarga@cisco.com>
7 years agoBUG-7568: fix wrong translation 14/52314/1
Robert Varga [Mon, 27 Feb 2017 14:14:49 +0000 (15:14 +0100)]
BUG-7568: fix wrong translation

Translation should occur not the file name path, not the source.

Change-Id: If90169f8144a985bc7882cb77b482fd8b463291b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoBUG-7850: make SourceIdentifier.getRevision() return null 52/52252/7
Robert Varga [Fri, 24 Feb 2017 13:18:49 +0000 (14:18 +0100)]
BUG-7850: make SourceIdentifier.getRevision() return null

getRevision() should follow its general contract and return null,
not a special string, when the revision is not found.

Change-Id: I74cd2648d218733e4ae26f7e849b72bd62b367ef
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoBUG-7568: expose file name mapping function 19/52219/10
Robert Varga [Thu, 23 Feb 2017 16:10:57 +0000 (17:10 +0100)]
BUG-7568: expose file name mapping function

We currently perform a rather nasty hack with NamedFileInputStream
to communicate the target result file to the code generators.

Update the code generation interface to allow passing down a mapping
function. Once all plugins have been updated to remove use of
SourceStreamAware, we can switch it to renaming files.

Change-Id: I4370a778ed46f759dd796dfed7436cc3bd657287
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoBug 6886 - [Yang 1.1] Update rules for handling of strings 26/51926/5
Peter Kajsa [Wed, 15 Feb 2017 19:08:25 +0000 (20:08 +0100)]
Bug 6886 - [Yang 1.1] Update rules for handling of strings

In Yang 1.1 an unquoted string cannot contain any single or double
quote characters and in double quoted string the backslash must not be
followed by any other character as those which are specified in RFC7950
Section 6.1.3.

Change-Id: Iec284b176ae04f3a908eb3c9d18eb5907d1b4c51
Signed-off-by: Peter Kajsa <pkajsa@cisco.com>
7 years agoFix resource-based YangTextSchemaSource 55/52255/3
Robert Varga [Fri, 24 Feb 2017 13:56:39 +0000 (14:56 +0100)]
Fix resource-based YangTextSchemaSource

Resource-based lookup needs to trim the specified path, so that
only the file name remains -- otherwise the resulting source
identifier ends up including the full path.

Change-Id: I517139e16a2f259b22032462a607c3bd9a2277b3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoBUG-7850: fix SourceIdentifier.toYangFileName() 51/52251/3
Robert Varga [Fri, 24 Feb 2017 12:17:56 +0000 (13:17 +0100)]
BUG-7850: fix SourceIdentifier.toYangFileName()

Internals of this method assume the original, pre-broken semantics
of revision being null when not present. Fix this by comparing
to non-present string.

Change-Id: Id057ebfd5af31e83b6dc77145349825cff8f8f16
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoEliminate custom SimpleDateFormat instances 54/52254/1
Robert Varga [Fri, 24 Feb 2017 13:49:30 +0000 (14:49 +0100)]
Eliminate custom SimpleDateFormat instances

We have SimpleDateFormatUtil to capture a fast revision parser,
use that instead of rolling our own.

Change-Id: I9b907440b73d721d306d5a946fbee58b8be47bd1
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoBUG-7182: add M2E lifecycle mapping 87/52087/4
Robert Varga [Mon, 20 Feb 2017 21:52:37 +0000 (22:52 +0100)]
BUG-7182: add M2E lifecycle mapping

Add lifecycle mapping metadata. Execution will probably not work completely,
as the plugin architecture requires BUG-175 to be addressed, i.e. individual
generators should not be touching filesystem directly.

Change-Id: I7995de75c1817fb7bbdbc5e85790ad4e61a39486
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoUpdate StmtTestUtils 70/52070/7
Robert Varga [Mon, 20 Feb 2017 12:26:23 +0000 (13:26 +0100)]
Update StmtTestUtils

Do not use deprecated YangStatementSourceImpl. Also adjust tests
to throw Exception, thus ridding them of some complexity.

Change-Id: I549197204adc64edb60d44cc439d02dbd39c815e
Signed-off-by: Robert Varga <rovarga@cisco.com>
7 years agoBug 6885: [Yang 1.1] Disallow "when" and "if-feature" on list keys. 85/50785/13
Igor Foltin [Sun, 19 Feb 2017 11:56:10 +0000 (12:56 +0100)]
Bug 6885: [Yang 1.1] Disallow "when" and "if-feature" on list keys.

Starting with YANG 1.1, a leaf which is specified as a list key
cannot contain an if-feature or a when statement

Change-Id: I4e39dfb2d7597e1012354004f1cb6f0a56638b2a
Signed-off-by: Rashmi Pujar <rashmi.c.pujar@gmail.com>
Signed-off-by: Igor Foltin <ifoltin@cisco.com>
7 years agoBug 6884 - [Yang 1.1] Submodule can reference all definitions in all submodules 03/51903/4
Peter Kajsa [Mon, 13 Feb 2017 08:23:17 +0000 (09:23 +0100)]
Bug 6884 - [Yang 1.1] Submodule can reference all definitions in all submodules

Since Yang 1.1, it has been allowed a submodule to reference all definitions
in all submodules that belong to the same module, without using the "include"
statement. This patch also deals with possible circular chains of includes
between submodules.

Change-Id: I2b3d19fc2c867882fc89f042bbe5febaf89bc2ea
Signed-off-by: Peter Kajsa <pkajsa@cisco.com>
7 years agoExpand Identifiable documentation 30/52030/4
Robert Varga [Sat, 18 Feb 2017 11:28:14 +0000 (12:28 +0100)]
Expand Identifiable documentation

Make sure the identifier returned cannot be null, as it does not make
sense.

Change-Id: I2d8c7a17487da66fe91f44a597d74abae82c10bd
Signed-off-by: Robert Varga <rovarga@cisco.com>
7 years agoBug 6887: [Yang 1.1] Allow enumerations and bits to be subtyped 53/51453/8
Igor Foltin [Mon, 6 Feb 2017 07:40:48 +0000 (08:40 +0100)]
Bug 6887: [Yang 1.1] Allow enumerations and bits to be subtyped

Starting with YANG 1.1, enumeration and bits types
can be restricted

An enumeration type can be restricted with one or more
"enum" statements, which enumerate a subset of the values
for the base type.

A bits type can be restricted with one or more "bit"
statements, which enumerate a subset of the values for
the base type.

Change-Id: If46991b858a2a9153a60de85645f6ec301fcb33f
Signed-off-by: Igor Foltin <ifoltin@cisco.com>
7 years agoBUG-7052: introduce YangStatementStreamSource 55/52055/10
Robert Varga [Sun, 19 Feb 2017 23:30:35 +0000 (00:30 +0100)]
BUG-7052: introduce YangStatementStreamSource

This untangles the parser implementation a bit, adding a more
modern StatementStreamSource.

Change-Id: Ic5fb23f088273e1a0993663bab237b6432924b47
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoAdd utility YangTextSchemaSource factories 54/52054/6
Robert Varga [Sun, 19 Feb 2017 20:51:07 +0000 (21:51 +0100)]
Add utility YangTextSchemaSource factories

This adds the ability to directly instantiate a source from a File,
a combination of a file name and a ByteSource, or from a resource.

Also add SchemaSourceRepresentation.getSymbolicName(), which can be
used in error reporting to give humans some leads as to the source
of any problems encountered.

Change-Id: I1130d43f469bfa1556b015c5aa5f26472a69c51e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoBug 7397 - yang-system-test could fail if zero yang files were found 98/51298/3
Peter Kajsa [Wed, 1 Feb 2017 13:00:02 +0000 (14:00 +0100)]
Bug 7397 - yang-system-test could fail if zero yang files were found

Yang-system-test fails with non-zero exit code, if zero yang files
were found.

Change-Id: Id9f1b08e2e937d009a029202df1591b93a1510f1
Signed-off-by: Peter Kajsa <pkajsa@cisco.com>
7 years agoBug 7396 - yang-system-test could support recursive search 95/51295/4
Peter Kajsa [Wed, 1 Feb 2017 11:07:46 +0000 (12:07 +0100)]
Bug 7396 - yang-system-test could support recursive search

Yang-system-test: added new option '-r' for recursively search
sub-directories for yang files.

Change-Id: I265c0dfa1006aee5b7bb1a85342d162866232a3b
Signed-off-by: Peter Kajsa <pkajsa@cisco.com>
7 years agoBug 7480 - yang-system-test: -p directories are for dependency search 18/51018/13
Peter Kajsa [Wed, 25 Jan 2017 17:13:45 +0000 (18:13 +0100)]
Bug 7480 - yang-system-test: -p directories are for dependency search

Yang statement parser is now able to distinguish between reqular and
library sources. Parser adds sources from library into resulting
SchemaContext only when needed to satisfy an import. In consequence,
only the sources required by regular sources are present in resulting
SchemaContext. Any other library sources are ignored and this also
applies to error reporting.

Also yang-system-test: -p directories are used now only for dependency
search.

Change-Id: I6a38fca16a923e7d2caa5a40e1c38469d98882e4
Signed-off-by: Peter Kajsa <pkajsa@cisco.com>
7 years agoBug 6901 - [Yang 1.1] Default value MUST NOT be marked with an if-feature 24/50624/13
Peter Kajsa [Wed, 11 Jan 2017 13:33:35 +0000 (14:33 +0100)]
Bug 6901 - [Yang 1.1] Default value MUST NOT be marked with an if-feature

Definition of the default values MUST NOT be marked with an
"if-feature" statement in Yang 1.1.

Change-Id: Id05519bea6f5a3f7fe9c82ede6cb5ab805dbc93c
Signed-off-by: Peter Kajsa <pkajsa@cisco.com>
7 years agoEliminate a boxing warning 77/52077/3
Robert Varga [Mon, 20 Feb 2017 14:30:49 +0000 (15:30 +0100)]
Eliminate a boxing warning

Method return type is Integer, hence use Integer.valueOf() instead
of Integer.parseInt(). Also switch to using a SourceException
constructor with built-in String.format().

Change-Id: Ie2b83d39ed8dd5c6d8ee5b15c349c2659ee9f96c
Signed-off-by: Robert Varga <rovarga@cisco.com>
7 years agoDeprecate TextToASTTransformer.TRANSFORMATION 53/52053/3
Robert Varga [Sun, 19 Feb 2017 19:44:55 +0000 (20:44 +0100)]
Deprecate TextToASTTransformer.TRANSFORMATION

This is a really clunky way of transforming text, useful for repositories.
Deprecate this field if favor of a synchronous
TextToASTTransformer.transformText() method.

Also cleanup checkstyle warnings in touched files.

Change-Id: Iebabcb84d92e480708be1180b174f57d1552d4ec
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoBUG-7568: silence YangTextSchemaContextResolver 52/52052/3
Robert Varga [Sun, 19 Feb 2017 19:20:59 +0000 (20:20 +0100)]
BUG-7568: silence YangTextSchemaContextResolver

YangTextSchemaContextResolver should understand when we are expanding
a not-present revision and not emit info's then. We still log expansions
on debug and info about mismatches.

This silences the noise on controller startup, but does not completely
fix the issue.

Change-Id: I1b5e4eed9b288e2c6d48b494630eee0dd1fa38c4
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoMove features to top level 45/51845/4
Robert Varga [Tue, 14 Feb 2017 09:19:16 +0000 (10:19 +0100)]
Move features to top level

Since our structure is more flat than it used to be there is no
need to keep features in common directory.

Change-Id: I59c8a97f3b93ae0a8fc350f866541ae93c8dd539
Signed-off-by: Robert Varga <rovarga@cisco.com>
7 years agoBUG-7464: package forked TrieMap 42/51842/3
Robert Varga [Tue, 14 Feb 2017 09:02:40 +0000 (10:02 +0100)]
BUG-7464: package forked TrieMap

Package TrieMap into features.

Change-Id: I37c8bde665c1ce445410772e38de1e594197f68a
Signed-off-by: Robert Varga <rovarga@cisco.com>
7 years agoFix RangeConstraintImpl 58/52058/3
Robert Varga [Mon, 20 Feb 2017 00:02:05 +0000 (01:02 +0100)]
Fix RangeConstraintImpl

Malformed javadoc and a stray copy&paste reference.

Change-Id: I2879a861852df01d5cdab385342bc93256f8792d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoCleanup SchemaContextUtil 57/52057/3
Robert Varga [Sun, 19 Feb 2017 23:59:46 +0000 (00:59 +0100)]
Cleanup SchemaContextUtil

Fixes checkstyle offences and eclipse warnings.

Change-Id: I8501609d6437d2177dc44f3be45ae4cd56c8983e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoUse YangConstants.RFC6020_YANG_FILE_EXTENSION 46/52046/3
Robert Varga [Sun, 19 Feb 2017 11:48:10 +0000 (12:48 +0100)]
Use YangConstants.RFC6020_YANG_FILE_EXTENSION

Do not open-code ".yang" and use it from its canonical definition.

Change-Id: I3ba65a0a645b9d3b94fac46087202cfe7476a7ef
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoEliminate unused Util.listFiles() 44/52044/2
Robert Varga [Sun, 19 Feb 2017 11:47:54 +0000 (12:47 +0100)]
Eliminate unused Util.listFiles()

This flavor is only used by its test, hence we do not need it.

Change-Id: I8cdab99e5a8d1e12b24bd21c77a6c69a60014e13
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoEliminate use of File[] 43/52043/2
Robert Varga [Sun, 19 Feb 2017 11:47:13 +0000 (12:47 +0100)]
Eliminate use of File[]

The array is used only as a filter, hence it is better to wrap it
in a collection and provide a filter on top of them.

Change-Id: I8067f128a80ded57a929fec3fcf68e84ddb7d487
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoDo not use IOUtils 33/52033/5
Robert Varga [Sun, 19 Feb 2017 11:46:39 +0000 (12:46 +0100)]
Do not use IOUtils

Guava provides a flexible alternative, so use that directly
rather than relying on commons-io.

Change-Id: I3959df3c0421e257f233d89a73a1904e67e4cfb9
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoEliminate the use of com.google.common.collect.Maps 32/52032/5
Robert Varga [Sun, 19 Feb 2017 11:46:16 +0000 (12:46 +0100)]
Eliminate the use of com.google.common.collect.Maps

We can instantiate maps conveniently using <>. Furthermore
we do not need ConcurrentMap with Java 8, as the base Map
interface implements putIfAbsent().

Change-Id: Ifa98a7e624b456425c0ba79dd325f444ee32e8ad
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoMove Util.getInstance() 31/52031/5
Robert Varga [Sun, 19 Feb 2017 11:46:00 +0000 (12:46 +0100)]
Move Util.getInstance()

This method is only used in YangToSourcesProcessor, move it there
to increase clarity.

Change-Id: I1c070f84a235c9199f86f18204d3a9b08779386b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoCleanup artifacts pom.xml 41/51841/2
Robert Varga [Tue, 14 Feb 2017 08:55:59 +0000 (09:55 +0100)]
Cleanup artifacts pom.xml

- do not use project.groupId
- do not use project.version
- remove unused property

Change-Id: I7d04399c83ff71cb39c8f85b3c8b51f3617ad6a9
Signed-off-by: Robert Varga <rovarga@cisco.com>
7 years agoDeprecate websocket-client 47/51847/2
Robert Varga [Tue, 14 Feb 2017 09:28:15 +0000 (10:28 +0100)]
Deprecate websocket-client

This component is no longer used anywhere and has no place in yangtools,
deprecate it, pending removal in 2.0.0.

Change-Id: I0b58fa7576798e4224be1f3f04fc5d49b9ed2290
Signed-off-by: Robert Varga <rovarga@cisco.com>
7 years agoBug 6875 - [Yang 1.1] Allow imports of multiple revisions of a module. 67/51567/4
Peter Kajsa [Wed, 8 Feb 2017 16:20:50 +0000 (17:20 +0100)]
Bug 6875 - [Yang 1.1] Allow imports of multiple revisions of a module.

Since Yang 1.1, it is allowed to import a module multiple times even with
different revisions. This patch introduced this functionality for Yang 1.1
sources.

Change-Id: I99f36308079cd7bd0af412b03f63eb2bb75242ef
Signed-off-by: Peter Kajsa <pkajsa@cisco.com>
7 years agoBug 6877: [Yang 1.1] Allow multiple base identities 72/49772/10
Igor Foltin [Wed, 25 Jan 2017 13:32:07 +0000 (14:32 +0100)]
Bug 6877: [Yang 1.1] Allow multiple base identities

Allow identities to be derived from multiple base
identities in Yang 1.1 models.

Change-Id: I543336f30ae593862820639ed966b9a7f59e899b
Signed-off-by: Igor Foltin <ifoltin@cisco.com>
Signed-off-by: Peter Kajsa <pkajsa@cisco.com>
7 years agoBug 6261: Introduce resolution of deviation statement during SchemaContext assembly 08/51008/9
Igor Foltin [Wed, 25 Jan 2017 13:15:30 +0000 (14:15 +0100)]
Bug 6261: Introduce resolution of deviation statement during SchemaContext assembly

YANG statement parser now resolves deviation statements in parsed YANG models.

Change-Id: Ia4dbdfd1ee196d418c94287be5ad03af5ffc485d
Signed-off-by: Igor Foltin <ifoltin@cisco.com>
7 years agoBUG-7061: mass-rename test files 53/51153/4
Robert Varga [Fri, 27 Jan 2017 20:38:58 +0000 (21:38 +0100)]
BUG-7061: mass-rename test files

This is a mass rename of .xml files to .yin.

Change-Id: Ifc8b8bcb130bfc2d60854796254220a8894c0f38
Signed-off-by: Robert Varga <rovarga@cisco.com>
7 years agoUpdate javadocs related to *SchemaSource 87/51187/1
Martin Ciglan [Mon, 30 Jan 2017 15:25:07 +0000 (16:25 +0100)]
Update javadocs related to *SchemaSource

Change-Id: Ib51ee7d60fcd21c79fcdc138f61007bd7f450742
Signed-off-by: Martin Ciglan <mciglan@cisco.com>
7 years agoSourceIdentifier.create() method deprecation explained 12/51112/3
Martin Ciglan [Fri, 27 Jan 2017 11:59:41 +0000 (12:59 +0100)]
SourceIdentifier.create() method deprecation explained

    - javadoc
    - imports optimized

Change-Id: I3dfc20fd23a57051784a691875bce0260af39a5e
Signed-off-by: Martin Ciglan <mciglan@cisco.com>
7 years agoReplace FindBugs :jsr305 by full :annotation (Bug 7663) 96/50896/3
Michael Vorburger [Mon, 23 Jan 2017 20:01:33 +0000 (21:01 +0100)]
Replace FindBugs :jsr305 by full :annotation (Bug 7663)

Change-Id: If0368dce54a853f00d69c177c3e848888e3b20b0
Signed-off-by: Michael Vorburger <vorburger@redhat.com>
7 years agoBug 7438: Allow identityref type to reference multiple base identities 98/50298/6
Igor Foltin [Wed, 11 Jan 2017 14:49:09 +0000 (15:49 +0100)]
Bug 7438: Allow identityref type to reference multiple base identities

Starting with YANG 1.1 (RFC7950), identityref type can reference multiple
base identities.

Change-Id: I448d5c002d233444c881ff26516a435825406d79
Signed-off-by: Igor Foltin <ifoltin@cisco.com>
7 years agoBUG-7474: produce Karaf 4 features 50/49550/9
Stephen Kitt [Wed, 14 Dec 2016 17:28:35 +0000 (18:28 +0100)]
BUG-7474: produce Karaf 4 features

This is a simplified version of
https://git.opendaylight.org/gerrit/38638 without any changes to
bundles; it just delegates the actual features.xml generation to the
plugin. This requires a current snapshot of Karaf 4.0.9 to reduce the
resulting dependencies. The new features are generated for Karaf 4
only. (The existing features.xml is preserved for Karaf 3.)

Change-Id: I4cc4692459f637e06e64a1a2e432448f57c32e4c
Signed-off-by: Stephen Kitt <skitt@redhat.com>
7 years agoBug 6868: If-feature argument may be boolean expression 14/49714/8
Peter Kajsa [Wed, 21 Dec 2016 18:16:07 +0000 (19:16 +0100)]
Bug 6868: If-feature argument may be boolean expression

Since Yang 1.1, "if-feature" argument may be a boolean expression over
feature names. In this expression, a feature name evaluates to "true"
if and only if the feature is supported by the server.

Change-Id: Id68d9a101641a7775d8b2a049986431e9cb27662
Signed-off-by: Peter Kajsa <pkajsa@cisco.com>
7 years agoDo not override Immutables version 36/50836/2
Robert Varga [Mon, 23 Jan 2017 15:53:02 +0000 (16:53 +0100)]
Do not override Immutables version

Immutables is define din odlparent, no need to specify
the version again.

Change-Id: I03aed6f7f52f34c0302ee930a6b2b8a723512156
Signed-off-by: Robert Varga <rovarga@cisco.com>
7 years agoBUG-5222: Reuse substatements across phases 13/49813/14
Robert Varga [Mon, 26 Dec 2016 14:35:49 +0000 (15:35 +0100)]
BUG-5222: Reuse substatements across phases

Now that we can address substatements accurately, we can reuse
the same statements instead of throwing them out and re-instantiating
them. We still need to switch the root if the YangVersion changes,
as the statement support objects need to be reemitted.

This removes the need for ContextBuilder and its subclasses, simply
because all required information is available when createDeclaredChild()
is called, bringing further simplification to StatementContextWriter.

Once that indirection is removed, the code flow is improved, which
flushed out a failure to validate when an extension requires an arugment,
hence the test models need update to pass validation.

A final effect of these changes is that StatementContextBase.declared
becomes superfluous, as it really is just a view over declared
substatements, which allows us to eliminate that field and instead
project a view of StatementMap's values.

Change-Id: I6fd3e2e2de41305457958673b77a72073215940e
Signed-off-by: Robert Varga <rovarga@cisco.com>
7 years agoMust always use mockito-core instead of mockito-all 30/50830/1
Michael Vorburger [Mon, 23 Jan 2017 15:07:56 +0000 (16:07 +0100)]
Must always use mockito-core instead of mockito-all

to prevent NoSuchMethodError: org.hamcrest.Matcher ...

Bug 7662 related
Change-Id: Ia34e4f4d0bf5a03cc311d69c3d9cfbe5362521ed
Signed-off-by: Michael Vorburger <vorburger@redhat.com>
7 years agoBug 7551 - Bad error message for pattern constrain 43/50543/3
Peter Kajsa [Tue, 17 Jan 2017 12:22:24 +0000 (13:22 +0100)]
Bug 7551 - Bad error message for pattern constrain

Correction of misleading error message that the YANG parser
associates with a pattern constraint.

Change-Id: I39a611bd864e50fea44d3baf4a210a228f974342
Signed-off-by: Peter Kajsa <pkajsa@cisco.com>
7 years agoBug 6876: [Yang 1.1] Allow "augment" to add conditionally mandatory nodes 05/50305/4
Peter Kajsa [Wed, 11 Jan 2017 16:06:26 +0000 (17:06 +0100)]
Bug 6876: [Yang 1.1] Allow "augment" to add conditionally mandatory nodes

Since Yang 1.1, if an augmentation is made conditional with a
"when" statement, it is allowed to add mandatory nodes to target in
another module.

Change-Id: I0fb2509b26f8455870aa279702b4df4b6c718750
Signed-off-by: Peter Kajsa <pkajsa@cisco.com>
7 years agoBUG-7464: update INode.GCAS_Complete() 96/50296/2
Robert Varga [Wed, 11 Jan 2017 00:43:49 +0000 (01:43 +0100)]
BUG-7464: update INode.GCAS_Complete()

Undo previous read on INode generation. It makes the the code
read a bit clunky, as the context of reasoning about the root
INode is lost.

While we're here, improve code readability with explicit
while(m != null) instead of a while(true)/if(m != null).

Change-Id: I01dde9603ff6fec98845036742375f3c5524ba00
Signed-off-by: Robert Varga <rovarga@cisco.com>
7 years agoBug 6873: [Yang 1.1] Add support for "require-instance" in leafref 97/49697/7
Igor Foltin [Wed, 21 Dec 2016 13:03:53 +0000 (14:03 +0100)]
Bug 6873: [Yang 1.1] Add support for "require-instance" in leafref

Allow leafref type to have require-instance substatement in Yang 1.1 models.

Change-Id: I96cc337176abbb3e2fdb1ae22a83ba7810190fbe
Signed-off-by: Igor Foltin <ifoltin@cisco.com>
7 years agoFix LengthConstraintImpl javadoc 24/49824/3
Robert Varga [Mon, 26 Dec 2016 21:03:52 +0000 (22:03 +0100)]
Fix LengthConstraintImpl javadoc

Add a missing closing brace.

Change-Id: I64c147e6fd50c06f6e13cc6268844e3a4def4532
Signed-off-by: Robert Varga <rovarga@cisco.com>
7 years agoRevert "BUG-7446: pull in guava-21" 03/50303/1
Robert Varga [Wed, 11 Jan 2017 14:46:37 +0000 (15:46 +0100)]
Revert "BUG-7446: pull in guava-21"

This reverts commit 75b18eff1ab6fcd22c47b837798653668bd797db.

Change-Id: I29a007f8874b480ecc55b1b4605e28f2f86b9fb9
Signed-off-by: Robert Varga <rovarga@cisco.com>
7 years agoBUG-7464: eliminate console output 36/50236/2
Robert Varga [Tue, 10 Jan 2017 22:28:38 +0000 (23:28 +0100)]
BUG-7464: eliminate console output

Use a Logger to log messages as needed instead of System.out,
fixing checkstyle warnings.

Change-Id: I07aa409856951e72a656ed35703ea29a05fd1397
Signed-off-by: Robert Varga <rovarga@cisco.com>
7 years agoBUG-7464: improve keySet()/entrySet() bytecode 35/50235/2
Robert Varga [Tue, 10 Jan 2017 22:20:44 +0000 (23:20 +0100)]
BUG-7464: improve keySet()/entrySet() bytecode

Shave off a few instructions by using expressions rather than
verbose assignment.

Change-Id: I12adc79be895cceea3feddfeb4cc100bcee0b883
Signed-off-by: Robert Varga <rovarga@cisco.com>
7 years agoBUG-7464: fix checkstyle warnings 35/50135/7
Robert Varga [Mon, 9 Jan 2017 15:31:52 +0000 (16:31 +0100)]
BUG-7464: fix checkstyle warnings

With no functional changes, this patch cleans up most
of the warnings reported by checkstyle.

Change-Id: I24833d1038eb98a04cecd18c3055757cb1ea7cbc
Signed-off-by: Robert Varga <rovarga@cisco.com>
7 years agoBUG-7464: enable checkstyle plugin 34/50134/7
Robert Varga [Mon, 9 Jan 2017 14:48:18 +0000 (15:48 +0100)]
BUG-7464: enable checkstyle plugin

Rather than skipping the plugin completely, just disable
the license check.

Change-Id: I9547ebbc16920f6921d9c0fa29e341bca80ba287
Signed-off-by: Robert Varga <rovarga@cisco.com>
7 years agoBUG-7464: do not throw ISE/RTE in "impossible" cases 54/50054/9
Robert Varga [Thu, 5 Jan 2017 10:24:21 +0000 (11:24 +0100)]
BUG-7464: do not throw ISE/RTE in "impossible" cases

Rather than throwing exceptions which may get mis-interpreted
by the callers, use Guava's VerifyException to flag the invariant
being checked.

Change-Id: I8a9431f1b578f3bb93fccd87f5138d97c0fa4242
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoBUG-7464: Add MainNode.trySize() 41/50041/9
Robert Varga [Thu, 5 Jan 2017 02:33:02 +0000 (03:33 +0100)]
BUG-7464: Add MainNode.trySize()

Having the ability to estimate size will be useful for Spliterators,
add a method for reading the currently-cached value without actually
computing it.

Also rename cachedSize() to size() and make it enforce being called
with an immutable snapshot. For CNodes this allows us to get rid
of atomic access to the size field, as the order of updates and
visibility propagation of size does not matter -- all concurrent
computations will arrive at the same result. The worst that can
happen we spend more time computing computing the value.

Change-Id: I84e33d96c7aa6f97cb33e0d1c31178916541c693
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoBUG-7464: Add dedicated key set classes 08/50008/12
Robert Varga [Tue, 3 Jan 2017 21:16:17 +0000 (22:16 +0100)]
BUG-7464: Add dedicated key set classes

These are slightly more efficient versions of the default
key set and react to Set.remove().

Change-Id: If67d4c75210d22dafbd2cd2dabeebc8554505a5e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoBUG-7464: Refactor TrieMapIterator 83/49983/14
Robert Varga [Tue, 3 Jan 2017 16:41:08 +0000 (17:41 +0100)]
BUG-7464: Refactor TrieMapIterator

This eliminates unused code and re-organizes the type hierarchy
so we have an abstract base iterator specialized for mutable
and immutable cases. This allows the immutable iterator to not
track the last returned entry, making a bit lighter-weight.

Futhermore use of iterator in LNode is removed, as LNodeEntries
can simply be used the traverse the list without object allocation.

Finally it restores assumptions made by original Scala code, which
is that the base map for an iterator, used to access, is a read-only
one. This was probably damaged during initial Java porting, as
Scala iterators are read-only and the ability to mutate was added.

The was done without differentiating the iteration (read-only) map
from the mutation map (read-write).

Change-Id: I7949cde0712e3e02de1846a51b6dd0d3704bea58
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoBUG-7464: Centralize implementation constants 82/49982/12
Robert Varga [Tue, 3 Jan 2017 14:07:00 +0000 (15:07 +0100)]
BUG-7464: Centralize implementation constants

We have a couple of constants: 5, 7 and 35 used in the codebase,
which are not explained anywhere. These are really derived from
the size of hash (32 bits) and size of bitmap (32 bits).

Centralize their definition in a new utility class, so they can
be documented and referenced uniformly.

Change-Id: I96433c3e72f41fb9bcfa6fa4a9552a7ff9202005
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoBUG-7464: Add a dedicated ImmutableEntrySet 67/49967/13
Robert Varga [Tue, 3 Jan 2017 11:39:11 +0000 (12:39 +0100)]
BUG-7464: Add a dedicated ImmutableEntrySet

Having immutability as a specialization is useful, as we can make explicit
assumptions about the map not moving. This will be important as we implement
specialized interators and spliterators.

Change-Id: I00a36a5bfc48dc31b088a46b07545f0442679b49
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoBUG-7464: enable FindBugs enforcement 62/49962/12
Robert Varga [Tue, 3 Jan 2017 02:24:15 +0000 (03:24 +0100)]
BUG-7464: enable FindBugs enforcement

So far it produces only false positives, but it is good to have
some defences.

Change-Id: Id72be114ed6d8c93e822f4325649025b7860e996
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoClean up code, incl. fix Checkstyle warnings (without real changes) 76/38876/13
Michael Vorburger [Fri, 13 May 2016 14:05:52 +0000 (16:05 +0200)]
Clean up code, incl. fix Checkstyle warnings (without real changes)

Change-Id: Ie3875d8e07b556f671fa3e8cfca099f3da6c6e8a
Signed-off-by: Michael Vorburger <vorburger@redhat.com>
7 years agoBUG-7464: Split out entryset and iterator classes 61/49961/11
Robert Varga [Tue, 3 Jan 2017 02:02:29 +0000 (03:02 +0100)]
BUG-7464: Split out entryset and iterator classes

This is a preparatory patch, splitting out support classes
so they can be fixed up and refactored as needed.

Change-Id: Ib7b994f2f4e114ec0a56d8930e7ba7320e18201c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoBUG-5222: Optimize SubstatementValidator 16/49816/8
Robert Varga [Mon, 26 Dec 2016 17:00:35 +0000 (18:00 +0100)]
BUG-5222: Optimize SubstatementValidator

SubstatementValidator's execution was quite inefficient in its
operation.

During the initial phase of counting substatements by their type
it performed multiple lookups coupled with boxing. Fix this by
introducing a simple counter class and using computeIfAbsent(),
which results in a single lookup, no replacement and only primitive
increment.

During the cardinality checking, we looked up the cardinality
three times. Fix this by performing a single lookup and store
the result in local variable for further use.

For catching missing mandatory statements we take an alternative
approach, where we pre-compute the map of mandatory statements
at construction time and instantiate a HashMap before iterating
over the statements. Everytime we hit a mandatory statement
we remove the corresponding entry, which means that if everything
is okay, the map will be empty.

Finally we remove SpecialCase and its related check, is it is
not used anywhere since BUG-6173 was addressed.

Change-Id: I38582e463a2e027aef7573baeec4923fba254018
Signed-off-by: Robert Varga <rovarga@cisco.com>
7 years agoBUG-7464: Split TrieMap into read-only and read-write 51/49951/12
Robert Varga [Mon, 2 Jan 2017 22:25:14 +0000 (23:25 +0100)]
BUG-7464: Split TrieMap into read-only and read-write

Having inter-twined mutable and immutable implementations is
a maintenance and performance drag, because mutable version
is checking for read-only on each mutation and also everytime
it needs to CAS_ROOT. On the other hand, the immutable
implementation does not need to care about RDCSS, as it never
updates its root -- and can in fact have it non-volatile.

Split the implementation into three classes, with TrieMap
definining the API contract and holding common bits, MutableTrieMap
encapsulating RDCSS and mutation bits and ImmutableTrieMap
having simple guards against mutation.

Change-Id: Icae923d6312901b37252af80b03b0a0912cacaec
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoBUG-7464: Enable parallel CNode size computation 50/49950/9
Robert Varga [Mon, 2 Jan 2017 18:35:10 +0000 (19:35 +0100)]
BUG-7464: Enable parallel CNode size computation

Re-enable code which was disabled during the initial port
from Scala, as ThreadLocalRandom is available in Java 7
and newer.

Also make the code a bit smarter by adding special-cases
for empty and single-entry arrays, when it does not make
sense to generate a random number.

Change-Id: Ie7fa98450bf1381a14a7a5e63fd9de6f3b1d17a0
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoBUG-7464: clean up CNode.dual() call convention 49/49949/9
Robert Varga [Mon, 2 Jan 2017 17:11:15 +0000 (18:11 +0100)]
BUG-7464: clean up CNode.dual() call convention

Update package-protected entrypoint to not require the second
SNode, as it can be easily instantiated. This makes the callers
a bit less verbose and allows us to adjust the recursive part
as needed.

Change-Id: Ic9b97fe23143b3a5cdab57750958237072dcda1e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoBUG-7464: Split LNodeEntries implementations 47/49947/8
Robert Varga [Mon, 2 Jan 2017 15:04:49 +0000 (16:04 +0100)]
BUG-7464: Split LNodeEntries implementations

We really have two implementations here, one which
have a single key/value pair and one which has multiple.

Split these into specialized implementations, which allows
us to save 8 bytes for each initial LNode, depending on
runtime environment configuration.

Change-Id: I40c8f6115cb0a98858c5bba51996eba414acc525
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoBUG-7464: make LNodeEntry implement Map.Entry 44/49944/12
Robert Varga [Mon, 2 Jan 2017 13:29:57 +0000 (14:29 +0100)]
BUG-7464: make LNodeEntry implement Map.Entry

Since LNodeEntry already contains a key/value mapping, it is
advantageous to make it also implement Map.Entry, simply
because that allows us to skip temporary object instantiation
when iterating over entries.

This could be done via subclassing SimpleImmutableEntry, but
that forces us to implement Serializable, which is not what
we want.

Change-Id: I3b0a2384dfbb9c2ed14dd6c9d66dfe91e883f97a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoBUG-7464: use Verify.verifyNonNull instead of assert 42/49942/9
Robert Varga [Mon, 2 Jan 2017 12:32:56 +0000 (13:32 +0100)]
BUG-7464: use Verify.verifyNonNull instead of assert

Asserts are generally not enabled, a verify is better
in that marks a reference clearly as non-nullable.

Change-Id: Ib9913ebcc08a130004e8760e6a7807e166439786
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoBUG-7464: Deduplicate code in INode.rec_insertif() 41/49941/9
Robert Varga [Mon, 2 Jan 2017 12:21:01 +0000 (13:21 +0100)]
BUG-7464: Deduplicate code in INode.rec_insertif()

CPD complains about 11 lines being shared between the no-condition
and absent cases. Move common code into a utility method, thus
removing duplication.

Change-Id: I5b5a22e54383caefc749954094e5294a3873d5bc
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoBUG-7464: remove uneeded casts and similar warnings 40/49940/9
Robert Varga [Mon, 2 Jan 2017 10:41:36 +0000 (11:41 +0100)]
BUG-7464: remove uneeded casts and similar warnings

In some places we do not need to cast nodes to their
generic arguments, so eliminate a couple of warnings.

Also remove global TrieMap @SuppressWarnings and add
suppressions as needed.

Change-Id: Ia060097673052ab5ab214704c2980db5052919f8
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoBUG-7464: Refactor KVNode 23/49923/12
Robert Varga [Mon, 2 Jan 2017 03:29:09 +0000 (04:29 +0100)]
BUG-7464: Refactor KVNode

KVNode is not really useful, as it acts like a factory method
for turning SNode/TNode into an Map.Entry.

We do not compare those nodes based on identity, hence we can
safely make them implement immutable version of Entry interface.

In order to keep some safety, we retain the interface, renamed
to EntryNode, extending Map.Entry and providing a default
setValue() implementation.

This has the added benefit of not needing object allocation
during iteration.

Change-Id: I27e3049739f4eb97ee76e8462c9ddde3c4b5b17a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoBUG-7464: Optimize LNode operations 22/49922/11
Robert Varga [Mon, 2 Jan 2017 02:30:11 +0000 (03:30 +0100)]
BUG-7464: Optimize LNode operations

Refactor ListMap into LNodeEntr{y,ies} and expose better
operations for node manipulation, since performance-critical
call sites already perform a prior lookup.

Therefore we can issue explicit insert/replace operations
insteads of generic 'add'. Insert operation becomes very fast,
as it does not need to perform any checking at all.

The replace operation does not require equivalence, as it
can use identity comparison on the entry, again improving
performance. Furthermore we can rely on the fact that
a particular entry is present exactly once, hence we can
stop iteration as soon as we find it.

Change-Id: I8c28e3521f1cbc298164b84b51dc300c3f3568a9
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoBUG-7464: Make ListMap obey TrieMap equivalence 21/49921/9
Robert Varga [Mon, 2 Jan 2017 00:33:05 +0000 (01:33 +0100)]
BUG-7464: Make ListMap obey TrieMap equivalence

Sifting through ListMap needs to have same equality
as the TrieMap it belongs to. Pass down proper equivalence
in all cases.

Change-Id: I614fbf1ed433d35babbf8b63e7cdee58280e356f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoBUG-7464: Do not recalculate hash on LNode removal 20/49920/8
Robert Varga [Mon, 2 Jan 2017 00:20:44 +0000 (01:20 +0100)]
BUG-7464: Do not recalculate hash on LNode removal

As it turns out all call sites performing a removal operation
actually have a hashcode handy, hence we do not need to
calculate it.

This really makes sense: in order to remove a node, we need to
find it first -- and for that we have to have the key's hash
code.

Change-Id: I4a26b5b4c07da4b38d90492884fa882362a171f1
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoBUG-7464: Optimize LNode.removed() 19/49919/8
Robert Varga [Sun, 1 Jan 2017 23:44:45 +0000 (00:44 +0100)]
BUG-7464: Optimize LNode.removed()

Using ListMap.size() is heavy if we have a lot of hash
collisions from a bad key hash function. LNode removal
does not need to know the precise size -- only the fact
that the ListMap is holding a single entry, so it can
compress down to an SNode.

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