yangtools.git
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>
7 years agoBUG-7464: Encapsupate special objects. 18/49918/8
Robert Varga [Sun, 1 Jan 2017 23:17:28 +0000 (00:17 +0100)]
BUG-7464: Encapsupate special objects.

These really are singletons, hence making them type-safe
as enums makes sense, as it expresses their nature.

Change-Id: I3f1b7f953bcb36ea7d72b594bfedcd4782e6767e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoBUG-7464: cleanup TrieMap retry logic 17/49917/8
Robert Varga [Sun, 1 Jan 2017 22:27:55 +0000 (23:27 +0100)]
BUG-7464: cleanup TrieMap retry logic

We have a couple of while(true) loops, which can we written
concisely using a 'do { ... } while (retry);' pattern.

Also check if the from-serialization codepath does not encounter
a does not observe a concurrent modification.

Change-Id: I7970a3d11fcd6715fb86a3c669d4eb195d10fa26
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoBUG-7464: Improve Map contract compliance 16/49916/8
Robert Varga [Sun, 1 Jan 2017 21:07:09 +0000 (22:07 +0100)]
BUG-7464: Improve Map contract compliance

Add explicit precondition guards against null keys and values
and fix iterators not currectly throwing exceptions. Also make
sure entrySet().contains() and remove() operations do not throw,
but return correct results.

Change-Id: I645686112ebb3675b73349d0c3096a3901243522
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoBUG-7464: Hide INode.gen field 15/49915/8
Robert Varga [Sun, 1 Jan 2017 19:26:16 +0000 (20:26 +0100)]
BUG-7464: Hide INode.gen field

This field is accessed only from TrieMap when initializing an operation
on a root node. Hide the field by exposing generation-less package-visible
methods, which pass the generation field to INode-private methods.

Change-Id: Ibf281c5975fe96d2cd2b1d58e93203a806932b57
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoBUG-7464: Rework TrieMap serialization 14/49914/8
Robert Varga [Sun, 1 Jan 2017 18:58:43 +0000 (19:58 +0100)]
BUG-7464: Rework TrieMap serialization

Using Externalizable proxy pattern has multiple advantages,
hence use that instead of plain serialization. This gets rid
of reflection-based access to readOnly field and generally
much cleaner.

Change-Id: I471dfe5a65972309b10393a91bc1cf702959a866
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoBUG-7464: remove TrieMap.nonReadOnly() 13/49913/8
Robert Varga [Sun, 1 Jan 2017 18:22:24 +0000 (19:22 +0100)]
BUG-7464: remove TrieMap.nonReadOnly()

This is a superfluous utility method, remove it and align
call sites.

Change-Id: I65266640bc74b2548b56a4712534b135bb92bcf0
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoBUG-7464: Eliminate {C,I}NodeBase 12/49912/9
Robert Varga [Sun, 1 Jan 2017 17:30:15 +0000 (18:30 +0100)]
BUG-7464: Eliminate {C,I}NodeBase

{C,I}NodeBase are just field holders for their sole subclasses.
This arrangement comes from Scala, where the Base classes are implemented
in Java and the rest of the code is in Scala.

Remove both base classes by inlining the fields into CNode/INode.

Change-Id: I349f1e1eeeb4301a1d6175ca5e16e7127ae1b540
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoBUG-7464: fix INode.rec_lookup() return type 11/49911/8
Robert Varga [Sun, 1 Jan 2017 17:14:49 +0000 (18:14 +0100)]
BUG-7464: fix INode.rec_lookup() return type

Undo a blanket check for Optional in TrieMap.lookup(),
which is caused by passing LNode's result back to the caller.

With Optional being used, this can be simplified by
unwrapping the result with orElse(null).

Change-Id: Ic70e65f76e7132db93e28d55141fef992ef00692
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoBUG-7464: Migrate to use java.util.Optional 95/49895/12
Robert Varga [Sat, 31 Dec 2016 18:59:37 +0000 (19:59 +0100)]
BUG-7464: Migrate to use java.util.Optional

Standard Java provides better interface than the custom-ported
Option/None/Some. Migrate to use it.

Change-Id: I6f4892d224bc8cbc5c37549cf7a54df86f97f207
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoBUG-7464: remove TestHelper 04/49904/9
Robert Varga [Sun, 1 Jan 2017 13:07:14 +0000 (14:07 +0100)]
BUG-7464: remove TestHelper

TestHelper is an unneeded wrapper around Assert's methods,
use them directly as appropriate instead of the constraining
abstraction.

Change-Id: I8648d3dc731100b562c64b657f4e78e8787d9f61
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoBUG-7464: cleanup and disable instantiation speed test 03/49903/9
Robert Varga [Sun, 1 Jan 2017 14:25:19 +0000 (15:25 +0100)]
BUG-7464: cleanup and disable instantiation speed test

Remove use of System.out and use a Guava stopwatch. This
test takes some time and is not really useful, hence disable
it.

Change-Id: Ib4b09b8e53e319230178c7898d7a2d14e4e2c1a0
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoBUG-7464: Cleanup Triemap 94/49894/12
Robert Varga [Sat, 31 Dec 2016 18:06:20 +0000 (19:06 +0100)]
BUG-7464: Cleanup Triemap

Remove unused methods, make the public contract more lean
and eliminate unneeded else branches.

Change-Id: I79d74b2dd13b912fef493294e7afc01a1fd7c85a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoBUG-7464: Fix StackOverflowError on hash collisions 93/49893/12
Robert Varga [Sat, 31 Dec 2016 16:52:12 +0000 (17:52 +0100)]
BUG-7464: Fix StackOverflowError on hash collisions

If LNodes get saturated due to poor key hash function, the ListMap
chain can grow large. Since ListMap.get() was implemented using recursion
this can easily trigger StackOverflowError. The same problem impacts
ListMap.contains(), which is triggered in the add() path.

Turn recursion into a loop, which provides defence against the error,
while not alleviating the performance impact.

Change-Id: Id04d30b9cb4d75dc4535ff20bd11a16ed96ab0ff
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoBUG-7464: Fix original porting damage in conditional operations 91/49891/11
Robert Varga [Sat, 31 Dec 2016 16:30:53 +0000 (17:30 +0100)]
BUG-7464: Fix original porting damage in conditional operations

Scala version of INode returns a correct empty Option
in case an LNode does not contain the expected key, whereas
this implementation happily falls through to a RuntimeException,
this this porting damage, adding an appropriate comment.

Removal of values through Map.remove(Object, Object) was
inconsistent in that the SNode case uses v.equals() whereas
the LNode case uses identity check. This is inconsistent
and runs contrary to the interface specitication, which calls
for using Objects.equals() -- which boils down to v.equals()
just as the SNode case does.

Change-Id: I33dd986e59211aa4c0be3648ae35e2818ebce8ad
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoBUG-7464: Use Guava-like Equivalence instead of custom interfaces 90/49890/9
Robert Varga [Sat, 31 Dec 2016 15:48:40 +0000 (16:48 +0100)]
BUG-7464: Use Guava-like Equivalence instead of custom interfaces

Rather than open-coding hash and equal interfaces, unify them
to form an Equivalence class similar to Guava's one. We opt not
to use Guava, because we post-process the object's hash code and
we do not support null keys, hence null checking done by Guava
internally is completely unneeded.

Change-Id: I28ef68d6bed6c07bc8e4ec780988122360825677
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoBUG-7446: pull in guava-21 21/49821/3
Robert Varga [Mon, 26 Dec 2016 20:26:30 +0000 (21:26 +0100)]
BUG-7446: pull in guava-21

This is a preparatory patch for pulling in guava-21, so both versions
are available at run-time. Once the switch upstream has been flipped
we will drop guava-18.

Change-Id: I35d52ffc19abcfb0f4090a9132d0f48339f697ea
Signed-off-by: Robert Varga <rovarga@cisco.com>
7 years agoBUG-7464: Make INode.equal() static 89/49889/6
Robert Varga [Sat, 31 Dec 2016 15:30:22 +0000 (16:30 +0100)]
BUG-7464: Make INode.equal() static

The method is not touching any state, we can safely make it
static.

Change-Id: I9d12db025fdc446f793b23b463696a158ec047f1
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoBUG-7464: Make ListMap a final implementation 88/49888/6
Robert Varga [Sat, 31 Dec 2016 13:10:55 +0000 (14:10 +0100)]
BUG-7464: Make ListMap a final implementation

We are not using EmptyListMap anywhere, so remove the unused class
which makes the code a lot cleaner, as we can flatten the implementation
hierarchy.

Change-Id: I6ec12a4225e380c9e546515c947389cf68f476b6
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoBUG-7464: Cleanup if-else branches in CNode 87/49887/6
Robert Varga [Sat, 31 Dec 2016 12:44:57 +0000 (13:44 +0100)]
BUG-7464: Cleanup if-else branches in CNode

Fixes eclipse warnings and makes the code more readable
by having a more flat structure.

Change-Id: If9241e9f5b0557090785afe375e8b3dccda37390
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoBUG-7464: Cleanup INode 86/49886/6
Robert Varga [Sat, 31 Dec 2016 12:38:28 +0000 (13:38 +0100)]
BUG-7464: Cleanup INode

Unwind if-else branches so the code becomes more readable, addressing
eclipse warnings.

Also reduce visibility of methods which are not called from anywere
else.

Change-Id: I5a9ab886394d2dedd3c390cde6bdf70a585f4ef9
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoBUG-7464: Remove unused TrieMap.apply() 85/49885/5
Robert Varga [Sat, 31 Dec 2016 12:05:05 +0000 (13:05 +0100)]
BUG-7464: Remove unused TrieMap.apply()

This method is not used anywhere, remove it.

Change-Id: I5ab2311cdf0352b21a7f8832aa8fe414082eb074
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoBUG-7464: Eliminate else branches in INode.GCAS_Complete 78/49878/6
Robert Varga [Fri, 30 Dec 2016 15:16:29 +0000 (16:16 +0100)]
BUG-7464: Eliminate else branches in INode.GCAS_Complete

Eclipse warnings of using else branch when the code
in that branch cannot be normally reached. Cleans up
the logic, showing more potential for tail recursion.

Change-Id: Iab48ca01acdf67ec5f80324732718576a8f00611
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoBUG-7464: Do not check twice for prev to be null 77/49877/6
Robert Varga [Fri, 30 Dec 2016 15:12:52 +0000 (16:12 +0100)]
BUG-7464: Do not check twice for prev to be null

Since we have performed a null check first and then downgraded
the unneeded instanceof check, we are left with a pure else-branch,
which proves the RuntimeException is not thrown.

Change-Id: I9dd8ba2d20738854a2790891dd6cfe099df91146
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoBUG-7464: Reduce instanceof checks to null checks 76/49876/6
Robert Varga [Fri, 30 Dec 2016 15:07:31 +0000 (16:07 +0100)]
BUG-7464: Reduce instanceof checks to null checks

These instanceof checks function as null checks only,
hence they are not needed.

Change-Id: Iaf4df7a2b0c8b0d8d2e9bd46a02523f0693c07c0
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoBUG-7464: Refactor Option/None/Some and its callers 75/49875/6
Robert Varga [Fri, 30 Dec 2016 13:54:55 +0000 (14:54 +0100)]
BUG-7464: Refactor Option/None/Some and its callers

Make NONE a proper constant within Option, hide Some's
value field and optimize constant callers.

Change-Id: Ifefd47ed7fb565e51c5adf8db58aa09017bfe3fa
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoBUG-7464: Cleanup CNode instantiation 74/49874/6
Robert Varga [Fri, 30 Dec 2016 13:36:36 +0000 (14:36 +0100)]
BUG-7464: Cleanup CNode instantiation

Reorder arguments being passed in so we can use variadic
arguments for nodes. This allows us to make the code more
concise by leaving array allocation up to the compiler.

For root nodes reuse an empty array instance, hosted in
CNode instead of allocating a new one for each new TrieMap.

Change-Id: Ic0574917d5d38c62b94594d1bce27a731c90838c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoBUG-7464: Move INode.newRootNode() 73/49873/6
Robert Varga [Fri, 30 Dec 2016 13:15:00 +0000 (14:15 +0100)]
BUG-7464: Move INode.newRootNode()

This method is called from TrieMap only, hence we can safely
move it there and make it private.

Change-Id: I842c2c473482b0c081fa51a11bc3f703eaefdc6d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoBUG-7464: Hide INodeBase.mainnode 72/49872/6
Robert Varga [Fri, 30 Dec 2016 12:58:11 +0000 (13:58 +0100)]
BUG-7464: Hide INodeBase.mainnode

This field is accessed either as CAS or READ, with writes being
a falso positiive, in that they are performed only at initialization
time.

Refactor access patterns to hide the updater and the field, passing
down explicit initializer from the subclass.

Also remove INodeBase.prev(), as it is not called from anywhere.

Change-Id: I3bfcc7e7a606b3a0622ed04b99abbc67e41eb407
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoBUG-7464: Hide LNode's listmap 71/49871/6
Robert Varga [Fri, 30 Dec 2016 12:32:19 +0000 (13:32 +0100)]
BUG-7464: Hide LNode's listmap

The only access to it is to acquire an iterator, hence provide
an Iterable wrapper and make the field final.

Change-Id: Ifff37e80d6275dc0b72b5c3f83ac089052d39b3e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoBUG-7464: Hide CNodeBase.csize 70/49870/6
Robert Varga [Fri, 30 Dec 2016 12:22:41 +0000 (13:22 +0100)]
BUG-7464: Hide CNodeBase.csize

This field should be accessed only through its accessor, hide it,
along with its updater.

Change-Id: I873ac0abc7d94d616e917d9c87317a55b0280747
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoBUG-7464: Expose MainNode(prev) constructor 69/49869/6
Robert Varga [Fri, 30 Dec 2016 12:18:07 +0000 (13:18 +0100)]
BUG-7464: Expose MainNode(prev) constructor

FailedNode wants to initialize previous node in its constructor,
hence expose the appropriate overload, preventing another volatile
write.

Change-Id: I1f8889e91a9e7e96173863e60df76d9156e1faa5
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoBUG-7464: Hide MainNode.prev field and its updater 68/49868/6
Robert Varga [Fri, 30 Dec 2016 12:07:56 +0000 (13:07 +0100)]
BUG-7464: Hide MainNode.prev field and its updater

This field is only ever read from other classes, hence we can
hide it behind READ_PREV(). The updater is also not accessed
from anywhere else, hence make it private.

Change-Id: I13e2e5a85ef502e7ad12f27d0309cd7a9ec6803a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoBUG-7464: Fix MainNode.cachedSize() 67/49867/6
Robert Varga [Fri, 30 Dec 2016 11:57:01 +0000 (12:57 +0100)]
BUG-7464: Fix MainNode.cachedSize()

These classes are not visible to the outside world, hence should
have package visibility. It should also take TrieMap as an argument,
thus eliminating the need for a cast in CNode's implementation.

Change-Id: I3995385fe8cb41bd0134ee1317c466cc1f2baaa9
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoBUG-7464: Remove inner classes 66/49866/7
Robert Varga [Fri, 30 Dec 2016 10:33:03 +0000 (11:33 +0100)]
BUG-7464: Remove inner classes

These classes form the internals of TrieMap, but there is no need
to keep them as inner classes. Move them to their own files, which
allows more precise control over access into their internals.

Change-Id: I3b79a285e186af09a7f0c0e0ece43dc455c40de3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoBUG-7464: Apply copyright headers 65/49865/7
Robert Varga [Fri, 30 Dec 2016 10:30:23 +0000 (11:30 +0100)]
BUG-7464: Apply copyright headers

Source code lacks explicit copyright headers, make sure we mark
all sources as licensed by APL2.

Change-Id: I218a55e3ea7e32a3e9d38ffb869b78523e97d077
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoBUG-7464: Reformat source code 64/49864/7
Robert Varga [Fri, 30 Dec 2016 10:18:13 +0000 (11:18 +0100)]
BUG-7464: Reformat source code

This is an automatic reformat, performing the following:
- remove trailing whitespace
- organize imports
- make arguments final
- add explicit braces
- use diamond for instantiation

Change-Id: I08f578bf40b72c0a592f3adf5add4a275c376f3d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoBUG-7464: Eliminate custom Map.Entry implementation 63/49863/7
Robert Varga [Fri, 30 Dec 2016 10:02:07 +0000 (11:02 +0100)]
BUG-7464: Eliminate custom Map.Entry implementation

AbstractMap.SimpleImmutableEntry serves the same purpose,
so use that instead of home-grown class.

Change-Id: Ifdb27bff9b87ef0d208a03b2e2d870c42ef82822
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoBUG-7464: Make TestInstantiationSpeed.runIteration() static 62/49862/7
Robert Varga [Fri, 30 Dec 2016 09:55:24 +0000 (10:55 +0100)]
BUG-7464: Make TestInstantiationSpeed.runIteration() static

This method does not reference the object, hence we can
make it static.

Change-Id: Iea371e845a312cc15e30d7a973b1f48100688fe6
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoBUG-7464: Update junit import 61/49861/7
Robert Varga [Fri, 30 Dec 2016 09:54:41 +0000 (10:54 +0100)]
BUG-7464: Update junit import

Assert has been moved to org.junit, import from new location.

Change-Id: Id0be53f8c13319897492ea99a90405634fa42ccd
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoBUG-7464: Update pom.xml 60/49860/6
Robert Varga [Thu, 29 Dec 2016 12:25:51 +0000 (13:25 +0100)]
BUG-7464: Update pom.xml

Update pom.xml and move source to yangtools-specific
package. Also add triemap as a third-party module, attaching
it to default compilation.

Change-Id: I0554be2c99a6aa42ca1e25bf290693117a5b8920
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoBUG-5222: Optimize use of declared substatements 15/49815/4
Robert Varga [Mon, 26 Dec 2016 16:31:13 +0000 (17:31 +0100)]
BUG-5222: Optimize use of declared substatements

Do not store the return in local variable, as that serves
no real purpose.

Change-Id: Iff1ae8d2d5fe6035c283c559a38fd928637cb3c6
Signed-off-by: Robert Varga <rovarga@cisco.com>
7 years agoRemove StatementIdentifier 12/49812/3
Robert Varga [Mon, 26 Dec 2016 14:05:44 +0000 (15:05 +0100)]
Remove StatementIdentifier

Since we have started identifying children using their declaration
offset, we have no real use for StatementIdentifier. Remove it and
adjust internal users to refer to the raw argument instead.

Change-Id: I7a789935142c8cd63848fb185d6350bfb501e475
Signed-off-by: Robert Varga <rovarga@cisco.com>
7 years agoDo not confuse statement and argument names 18/49818/4
Robert Varga [Mon, 26 Dec 2016 18:28:45 +0000 (19:28 +0100)]
Do not confuse statement and argument names

Our extension handling is still flaky, in that it assumes
that implicit extensions take an argument. As we progress
to make these special-cases handled, the confusion is being
flushed out.

This particular error was found when we made argument name
conditional on whether we actually are seeing an argument
being used in the model.

Change-Id: I4b8a0e3aa133343fc65dca38c1dd9e083113fb00
Signed-off-by: Robert Varga <rovarga@cisco.com>
7 years agoFix mandatory statement checking 14/49814/3
Robert Varga [Mon, 26 Dec 2016 16:34:10 +0000 (17:34 +0100)]
Fix mandatory statement checking

This fixes a mismatch between the comment and what the method
actually does. For some reason we ended up iterating over the same
collection twice.

Furthermore use .forEach() with a self-referencing lambda instead
of Iterables.concat(), as that can be optimized by the implementation.

Change-Id: I6f74794fd58576b9ce34b6f27217b5e81bef4457
Signed-off-by: Robert Varga <rovarga@cisco.com>
7 years agoMove StatementContextBase.getStorageNodeType() 11/49811/3
Robert Varga [Mon, 26 Dec 2016 13:04:55 +0000 (14:04 +0100)]
Move StatementContextBase.getStorageNodeType()

We have two implementations of this node, move it out from
StatementContextBase to its only subclass. This way it does
not get overridden in RootStatementContext.

Also move javadoc to the interface definition so it gets
shared by all implementations.

Change-Id: I3d230062ed5e76eaf3032f7c2b09113c94093091
Signed-off-by: Robert Varga <rovarga@cisco.com>
7 years agoTurn Prerequisite into a FunctionInterface 00/49800/4
Robert Varga [Sun, 25 Dec 2016 17:15:06 +0000 (18:15 +0100)]
Turn Prerequisite into a FunctionInterface

isDone() method should never be used by callers, hence it should be removed,
hence we can turn Prerequisite into a FunctionalInterface, with the actual
property being tracked in the implementation.

This allows us to neatly use a lambda for implementing the transformation.

Change-Id: I8cd588f0c6b6fcf926e530e781db35a39b0a8eb8
Signed-off-by: Robert Varga <rovarga@cisco.com>
7 years agoEnhance phase sequencing assertions 99/49799/4
Robert Varga [Sun, 25 Dec 2016 16:03:55 +0000 (17:03 +0100)]
Enhance phase sequencing assertions

Rather than throwing non-descript exceptions, add explicit messages about
what went wrong. Also promote phase sequencing ISE to VerifyException, as
it indicate a reactor implementation error.

Change-Id: I36d4450a3e81c2f4688065f63d686a24fa11a039
Signed-off-by: Robert Varga <rovarga@cisco.com>
7 years agoEliminate superfluous onFullDefinitionDeclared overrides 98/49798/4
Robert Varga [Sun, 25 Dec 2016 15:32:40 +0000 (16:32 +0100)]
Eliminate superfluous onFullDefinitionDeclared overrides

This patch moves invocation of the validator back into AbstractStatementSupport,
rendering majority of overrides useless, as all they did was call (then no-op)
super and then the validator.

This also fixes problems if a subclass redefines the validator to be non-existent
and fails to override (again) onFullDefinitionDeclared().

Drive-by cleanup reduces verbosity of specification implementation classes by
importing the nested interface directly.

The end effect is that it is again possible to reason about hooks being performed
in statements by looking at what implementation overrides there are.

Change-Id: Ibed4cd5eeb128e69637fcf124331aeeeaeb7b4ea
Signed-off-by: Robert Varga <rovarga@cisco.com>
7 years agoValidate identity-ref on full definition 97/49797/4
Robert Varga [Sun, 25 Dec 2016 14:57:44 +0000 (15:57 +0100)]
Validate identity-ref on full definition

This fixes an inconsistency where this statement is the only one
validated on declaration, not on full definition.

Change-Id: Icf454fc3157ce9b568911649b9fcbe4a3a02c397
Signed-off-by: Robert Varga <rovarga@cisco.com>
7 years agoDocumented StatementSupport's SourceException throwing 96/49796/4
Robert Varga [Sun, 25 Dec 2016 15:06:22 +0000 (16:06 +0100)]
Documented StatementSupport's SourceException throwing

Instead of adding a superfluous throws declaration, add javadoc
about the possibility of that exception being thrown. Also adjust
AbstractStatementSupport to reflect that change.

Change-Id: I80dcb3a3b3bd75b415988a021e1489641fb96f87
Signed-off-by: Robert Varga <rovarga@cisco.com>
7 years agoAdd ModelActionBuilder javadocs 01/49801/4
Robert Varga [Sun, 25 Dec 2016 16:24:51 +0000 (17:24 +0100)]
Add ModelActionBuilder javadocs

This adds sorely-needed documentation around ModelActionBuilder,
so that users can actually reason about what they are actually
doing instead of guessing.

Methods which do not have a caller are marked as deprecated so
that potential users are warned that their API contract is
undefined.

Change-Id: Iceb391a6648ea1ab1f920a0f564c37ba5d6bc5e5
Signed-off-by: Robert Varga <rovarga@cisco.com>
7 years agoBug 7159: Stop using deprecated methods from YangParserTestUtils 06/50006/1
Igor Foltin [Wed, 4 Jan 2017 09:24:23 +0000 (10:24 +0100)]
Bug 7159: Stop using deprecated methods from YangParserTestUtils

YangParserTestUtils methods which take YangStatementSourceImpl as parameter
have been deprecated recently. Convert all places that used them
to non-deprecated version of those methods.

Change-Id: I18caddbe2583283db890269318104890064c4c0e
Signed-off-by: Igor Foltin <ifoltin@cisco.com>
7 years agoBUG-7464: Initial import of java-concurrent-hash-trie-map 59/49859/3
Robert Varga [Thu, 29 Dec 2016 12:11:38 +0000 (13:11 +0100)]
BUG-7464: Initial import of java-concurrent-hash-trie-map

This is the initial import of java-concurrent-hash-trie-map, as available
at https://github.com/rovarga/java-concurrent-hash-trie-map/tree/odl-0.2.23.

The upstream from which this code was forked is dead for all intents
and purposes, as demonstrated by lack of reaction to multiple pull requests
over the past year, including the critical correctness fix needed
in OpenDaylight.

This fork will be evolved to clean up the code base according to OpenDaylight
coding practices and to take advantage of both Java 8 and Guava.

Change-Id: I16e6e8c724f391e262e7b192c2e1f875364785db
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoFix checkstyle warnings 95/49795/3
Robert Varga [Sun, 25 Dec 2016 14:15:54 +0000 (15:15 +0100)]
Fix checkstyle warnings

Just missing spaces, add them.

Change-Id: Ia5413278efc0948ab337a1ed087e6f99e30fa90a
Signed-off-by: Robert Varga <rovarga@cisco.com>
7 years agoReturn specialized TypeDefinitions 94/49794/3
Robert Varga [Sun, 25 Dec 2016 12:06:07 +0000 (13:06 +0100)]
Return specialized TypeDefinitions

BuiltinEffectiveStatements should declare specialized return
rather than generic TypeDefinition.

Change-Id: I6b5f74c7c13002eb27c37054ed88e2d87ba70a05
Signed-off-by: Robert Varga <rovarga@cisco.com>
7 years agoExpand StatementSupport documentation 02/49802/3
Robert Varga [Sun, 25 Dec 2016 13:44:54 +0000 (14:44 +0100)]
Expand StatementSupport documentation

It is not immediately clear why we have onStatementAdded(),
but it is a critical piece of the parser machinery. Expand its
documentation to provide an example when it is useful.

Change-Id: I52d4da7795a6cbd5271cf6b7aa53e09940e67efd
Signed-off-by: Robert Varga <rovarga@cisco.com>
7 years agoAdd StatementFactory javadocs 92/49792/2
Robert Varga [Sun, 25 Dec 2016 12:04:56 +0000 (13:04 +0100)]
Add StatementFactory javadocs

Adds basic javadocs and @Nonnull annotation.

Change-Id: I32d09d24c002d0912229a3c20880e607bb8ea5fe
Signed-off-by: Robert Varga <rovarga@cisco.com>
7 years agoCleanup YangParserTestUtils 91/49791/2
Robert Varga [Sun, 25 Dec 2016 10:05:53 +0000 (11:05 +0100)]
Cleanup YangParserTestUtils

- add array-based utility methods
- mark YangStatementStreamSource-based methods as deprecated
- add a Resource-based method

Change-Id: I9856d60d9cfaecfcba4f078650e66ef44d799fd0
Signed-off-by: Robert Varga <rovarga@cisco.com>
7 years agoBug 7440: Fix empty parent in deviate "replace" 79/49779/3
Igor Foltin [Fri, 23 Dec 2016 13:29:40 +0000 (14:29 +0100)]
Bug 7440: Fix empty parent in deviate "replace"

Restricted type statement within deviate "replace" statement
now has its SchemaPath properly initialized.

Change-Id: If8a9c6add61ccdda8210f19e5626c925c3c5785e
Signed-off-by: Igor Foltin <ifoltin@cisco.com>
7 years agoBug 7395: yang-system-test is unable to access yang files 63/49563/3
Igor Foltin [Mon, 19 Dec 2016 15:50:33 +0000 (16:50 +0100)]
Bug 7395: yang-system-test is unable to access yang files

- yang-system-test should now be able to access yang files

Change-Id: I49535fdf9d39e66f7578a52491aa90ecfc5bb5a4
Signed-off-by: Igor Foltin <ifoltin@cisco.com>
7 years agoBUG-6533: add immutable implementations of yang.model.api 57/44657/8
Robert Varga [Thu, 25 Aug 2016 11:14:27 +0000 (13:14 +0200)]
BUG-6533: add immutable implementations of yang.model.api

This patch introduces Immutables.org annotations to generate
immutable/builder implementation of yang.model.api interfaces.

These are contained in a separate artifact and not available
as a feature, since they currently do not have a user.

Change-Id: I98a9969138a702b67139f323e77fa955162c3d74
Signed-off-by: Robert Varga <rovarga@cisco.com>
7 years agoBug 6880: [Yang 1.1] Allow leaf-lists to have default values 73/49473/3
Peter Kajsa [Wed, 14 Dec 2016 09:59:10 +0000 (10:59 +0100)]
Bug 6880: [Yang 1.1] Allow leaf-lists to have default values

Allow leaf-lists to have default values in Yang 1.1 models.

Change-Id: I84df558e886eb695e83686e972f5cb9e1086b061
Signed-off-by: Peter Kajsa <pkajsa@cisco.com>
7 years agoBUG-6522: cache isConfiguration() result 67/49567/4
Robert Varga [Mon, 19 Dec 2016 18:56:50 +0000 (19:56 +0100)]
BUG-6522: cache isConfiguration() result

Profiling runs have identified the recursive search for
default config statements as a potential hotspot.

The problem here is that config statements are not common,
hence most of the time we end up traversing up the to the
root context (which is hard-coded config=true) and walk
the declared and effective statements over and over.

By the time this method is called its result should be
invariant, hence add a cache field and use it to side-step
both the recursion and substatement list walk.

Change-Id: I51383a9af0a7594b1d56b954ca9bbda0933b7231
Signed-off-by: Robert Varga <rovarga@cisco.com>
7 years agoBUG-7051: move isModuleIdentifierWithoutSpecifiedRevision 25/49525/1
Robert Varga [Sun, 18 Dec 2016 13:00:10 +0000 (14:00 +0100)]
BUG-7051: move isModuleIdentifierWithoutSpecifiedRevision

UtilsisModuleIdentifierWithoutSpecifiedRevision() is used only
in NamespaceStorageSupport, move it to remove cross-package
dependency.

Change-Id: I7e6dbdc5f73f08289851f04e3092e63f0d40fa5a
Signed-off-by: Robert Varga <rovarga@cisco.com>
7 years agoBug 6870: [Yang 1.1] Support for new "modifier" statement 58/49158/12
Peter Kajsa [Thu, 8 Dec 2016 17:49:59 +0000 (18:49 +0100)]
Bug 6870: [Yang 1.1] Support for new "modifier" statement

The "modifier" statement, which is an optional substatement to the
"pattern" statement, takes as an argument the string "invert-match".
If a pattern has the "invert-match" modifier present, the type is
restricted to values that do not match the pattern.

Change-Id: I9e9d993a16077c1f3af1ab20c197d2e6c9e8c6af
Signed-off-by: Peter Kajsa <pkajsa@cisco.com>
Signed-off-by: Robert Varga <rovarga@cisco.com>
7 years agoBug 6869: [Yang 1.1] Allow if-feature in bit, enum, refine & identity 42/49242/9
Peter Kajsa [Mon, 12 Dec 2016 12:23:45 +0000 (13:23 +0100)]
Bug 6869: [Yang 1.1] Allow if-feature in bit, enum, refine & identity

Allow "if-feature" in "bit", "enum", "identity" and "refine"
statements. Presence of an "if-feature" statement in a "bit"
statement does not affect the automatically assigned position.

Change-Id: I487620bc08fc4f57c51172821087feaad04db5fe
Signed-off-by: Peter Kajsa <pkajsa@cisco.com>
7 years agoBug 6896: [Yang 1.1] Add support for new statement "action" 20/49320/8
Igor Foltin [Tue, 13 Dec 2016 20:04:00 +0000 (21:04 +0100)]
Bug 6896: [Yang 1.1] Add support for new statement "action"

This patch introduces the "action" statement as defined in YANG 1.1 (RFC7950).
The "action" statement is used to define an operation connected to a specific
container or list data node.

Yang statement parser is now able to parse this statement.

Change-Id: I683be78ee041d1202d6cbc688f34802e2818145a
Signed-off-by: Igor Foltin <ifoltin@cisco.com>
7 years agoBug 6871: [YANG 1.1] Allow "must" in "input", "output" and "notification" statements 39/49339/5
Igor Foltin [Wed, 14 Dec 2016 11:24:03 +0000 (12:24 +0100)]
Bug 6871: [YANG 1.1] Allow "must" in "input", "output" and "notification" statements

Starting with YANG 1.1 (RFC7950), "must" statements can be defined in
"input", "output" and "notification" statements.

Yang statement parser can now parse models containing such statements.

Change-Id: I6b81dd3447bfc50f5a21b79fbdaacfb6e2bf9689
Signed-off-by: Igor Foltin <ifoltin@cisco.com>
7 years agoBug 6883: [Yang 1.1] Add support for a new data definition statement "anydata" 02/49102/9
Peter Kajsa [Wed, 7 Dec 2016 18:27:18 +0000 (19:27 +0100)]
Bug 6883: [Yang 1.1] Add support for a new data definition statement "anydata"

The "anydata" statement is used to represent an unknown set of nodes
that can be modeled with YANG, except anyxml, but for which the data
model is not known at module design time.

Change-Id: I0a7470dbd571087fcc3b8fd8cb2b21668d99d6f1
Signed-off-by: Peter Kajsa <pkajsa@cisco.com>
7 years agoBug 6897: [Yang 1.1] Allow notifications to be tied to data nodes 26/48926/18
Igor Foltin [Fri, 9 Dec 2016 15:22:05 +0000 (16:22 +0100)]
Bug 6897: [Yang 1.1] Allow notifications to be tied to data nodes

Since Yang 1.1, a notification can be defined at the top level of a
module, or connected to a specific container or list data node
in the schema tree

Change-Id: Ieac7d9f9962fb9d6d02e1dd89e491d47f4fd99e6
Signed-off-by: Peter Kajsa <pkajsa@cisco.com>
Signed-off-by: Igor Foltin <ifoltin@cisco.com>
Signed-off-by: Robert Varga <rovarga@cisco.com>
7 years agoBug 6897: Adding getSubstatementValidator() method to AbstractStatementSupport 62/49462/4
Peter Kajsa [Fri, 16 Dec 2016 09:14:35 +0000 (10:14 +0100)]
Bug 6897: Adding getSubstatementValidator() method to AbstractStatementSupport

Change-Id: Ice3d198b83d3c1f533a918af4f9747331ff21c63
Signed-off-by: Peter Kajsa <pkajsa@cisco.com>
7 years agoBUG-4599: enforce QName's localname 48/49448/2
Robert Varga [Thu, 15 Dec 2016 18:09:03 +0000 (19:09 +0100)]
BUG-4599: enforce QName's localname

Localname should not contain colons, make sure we enforce
this, preventing invalid use of QNames.

Change-Id: Ie8012f266f47a48942890573d924d414b06b7fa5
Signed-off-by: Robert Varga <rovarga@cisco.com>
7 years agoBUG-4599: do not attempt to construct invalid QNames 19/29519/17
Robert Varga [Mon, 9 Nov 2015 08:27:39 +0000 (09:27 +0100)]
BUG-4599: do not attempt to construct invalid QNames

QName should not allow for localname to contain ':', so do
not construct it just for lookups. Also move the code to its
only user, so we can evolve it.

Change-Id: Ib6c2b9aa0ea3fa14c1d843162a4b232a12e10cc4
Signed-off-by: Robert Varga <robert.varga@pantheon.sk>
7 years agoBUG-4688: add Revision as a dedicated class 72/49372/5
Robert Varga [Wed, 14 Dec 2016 17:18:04 +0000 (18:18 +0100)]
BUG-4688: add Revision as a dedicated class

Defines Revision and adds basic marker to methods whose return value
needs to change complete the transition.

Change-Id: I853ad6f221712a9a6f28b29050ec30ae09d846e9
Signed-off-by: Robert Varga <rovarga@cisco.com>
7 years agoCodify DataTree{Candidate,Tip} hashCode/equals() 97/49397/3
Robert Varga [Wed, 14 Dec 2016 23:31:07 +0000 (00:31 +0100)]
Codify DataTree{Candidate,Tip} hashCode/equals()

Tighten the interface contract to ensure implementations
of these interfaces will always use identity comparisons. This
allows users dealing with these objects to rely on the fact that
they can be compared for equality quickly.

Change-Id: I679c4bebdb35465adf5fefcbd0af65a3ab48ef1f
Signed-off-by: Robert Varga <rovarga@cisco.com>
7 years agoAdd YANG Library NETCONF capability 48/49348/4
Robert Varga [Wed, 14 Dec 2016 12:51:40 +0000 (13:51 +0100)]
Add YANG Library NETCONF capability

This extends YangConstants with the IANA allocation made
in RFC7950.

Change-Id: Iaa291578b51a35d3ca33ae0199cdd444a0d0a286
Signed-off-by: Robert Varga <rovarga@cisco.com>
7 years agoBug 6874 - [Yang 1.1] Allow "description" and "reference" in "import" and "include" 17/49117/13
Rashmi Pujar [Wed, 7 Dec 2016 21:52:47 +0000 (16:52 -0500)]
Bug 6874 - [Yang 1.1] Allow "description" and "reference" in "import" and "include"

Implementation in yang-parser-impl bundle

Change-Id: Iaa1573144c0939b6954d855d43c0a58379216d75
Signed-off-by: Rashmi Pujar <rpujar@inocybe.com>