yangtools.git
8 years agoBug3659: UnknownSchemaNodeImpl retains empty ArrayLists FIX 53/22353/5
Martin Ciglan [Thu, 11 Jun 2015 11:55:22 +0000 (13:55 +0200)]
Bug3659: UnknownSchemaNodeImpl retains empty ArrayLists FIX

Change-Id: I291eb3f87a3bc1655d0966513e1c74154558cbce
Signed-off-by: Martin Ciglan <mciglan@cisco.com>
8 years agoRemove deprecated YangInstanceIdentifier methods 45/22545/4
Robert Varga [Sun, 14 Jun 2015 08:58:46 +0000 (10:58 +0200)]
Remove deprecated YangInstanceIdentifier methods

this patch removes the internal bridge methods to Iterable path
arguments as well as the long-deprecated getPath() method.

Change-Id: I28168741a5ad852a108b1aa6f711d44bc4748b6a
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoTypeDefinition is a generic type 74/22874/2
Robert Varga [Thu, 11 Jun 2015 11:15:54 +0000 (13:15 +0200)]
TypeDefinition is a generic type

Do not use it in raw format, eliminating warnings.

Change-Id: I6012f812ce7a5aba75f163a8910fb0583fefd6cc
Signed-off-by: Robert Varga <rovarga@cisco.com>
(cherry picked from commit 35e731b1818688f2aee43f525873087aca25110e)

8 years agoBUG-3793 71/22871/1
Shaleen Saxena [Wed, 17 Jun 2015 22:16:22 +0000 (15:16 -0700)]
BUG-3793
Manually patching in changes from Bug 2291 as it does not cherry-pick cleanly.

Change-Id: I17f1c2347d7aa3a120fac0171253e88c46e99fae
Signed-off-by: Shaleen Saxena <ssaxena@brocade.com>
(cherry picked from commit 9e4ce88404e59aed92fdf8d4242587720d8650ab)

8 years agoBug 3645 - instance-identifier parsing error 93/22693/2
Jan Hajnar [Tue, 16 Jun 2015 07:14:40 +0000 (09:14 +0200)]
Bug 3645 - instance-identifier parsing error

* added method deserializeKeyValue in AbstractStringInstanceIdentifierCodec
* added implementations for deserializeKeyValue for XML and JSON codecs

Change-Id: I97f68534d4ecc7b0cbb8e67ba899c9b4bfe91650
Signed-off-by: Jan Hajnar <jhajnar@cisco.com>
(cherry picked from commit 0c092cbca774271a87578432212fb398f61543a4)

8 years agoBug 2583 - illegal escape character if generated files 93/14193/9
Peter Kajsa [Fri, 16 Jan 2015 12:48:44 +0000 (13:48 +0100)]
Bug 2583 - illegal escape character if generated files

When a module file name starts with 'u' character, YangTools generates
comments in file containing '\u...' character sequences which java compiler
interprets as illegal escape character.
Problem is related most probably to windows builds only.

Change-Id: I81329b754710a68ada4e9c034c8980a1acd8a1b7
Signed-off-by: Peter Kajsa <pkajsa@cisco.com>
8 years agoBug 3191: Optimisation of serialisation of IdentityrefTypeDefinition 72/22272/2
Maros Marsalek [Tue, 9 Jun 2015 14:16:30 +0000 (16:16 +0200)]
Bug 3191: Optimisation of serialisation of IdentityrefTypeDefinition

Workaround for the case when prefix and namespace within element
and its value is same as parent namespace.

Change-Id: I1c8f8b503dc38385aa8cd23a517e067531081661
Signed-off-by: Marian Dubai <mdubai@cisco.com>
Signed-off-by: Tomas Cere <tcere@cisco.com>
Signed-off-by: Maros Marsalek <mmarsale@cisco.com>
8 years agoBug 2721: StackOverflowError for leafref FIX 98/22698/2
Martin Ciglan [Tue, 16 Jun 2015 14:12:51 +0000 (16:12 +0200)]
Bug 2721: StackOverflowError for leafref FIX

Leafref XPath needs to be checked whether it references itself
in order to detect incoming StackOverflowError
and throw appropriate exception if necessary.

Change-Id: Iacfa1a9f9d85f947e590b1d6412c9c482b417dbf
Signed-off-by: Martin Ciglan <mciglan@cisco.com>
8 years agoSonar: remove unused modifiers 23/22723/1
Robert Varga [Tue, 16 Jun 2015 18:59:27 +0000 (20:59 +0200)]
Sonar: remove unused modifiers

public/static/final modifies are implied by the context, e.g. by being
declared in an interface.

Change-Id: Ic2f97172595d7cdb2119510c077eabac55fa0798
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoIntroduce MapAdaptor.initialSnapshot() 67/22667/2
Robert Varga [Mon, 15 Jun 2015 22:28:54 +0000 (00:28 +0200)]
Introduce MapAdaptor.initialSnapshot()

In some circumstances we have an idea about how many entries will there
be in a map. This could cost us perform one additional copy, so expose a
method to create the appropriate map, behaving just as the one returned
by takeSnapshot(Collections.emptyMap()).

Also use ImmutableMaps for empty map, as it being immutable is recognized
by Guava, leading to quick reuse.

Change-Id: I40925e5d643c074277e9d11365a3b10fb9f22c1d
Signed-off-by: Robert Varga <rovarga@cisco.com>
(cherry picked from commit 92fc5cc4436a65c3a63e1fc7afbff2ac42a70880)

8 years agoBUG-1014: TreeType should be Beta 66/22666/1
Robert Varga [Mon, 15 Jun 2015 23:25:03 +0000 (01:25 +0200)]
BUG-1014: TreeType should be Beta

It is not a finalized concept yet, so users should we vary before
relying on it.

Change-Id: I6af61e2cc402b34126c4631cfaec1791180c8ce0
Signed-off-by: Robert Varga <rovarga@cisco.com>
(cherry picked from commit d122c09b076187b1719d1670fb3ecff4344c1907)

8 years agoUse sizeHints in ImmutableNode builders 02/22602/1
Robert Varga [Fri, 12 Jun 2015 01:09:13 +0000 (03:09 +0200)]
Use sizeHints in ImmutableNode builders

Instead of ignoring the size hint, use it.

Change-Id: I516fbb2a8c18bb6276b5863292f8b0e956ceb6da
Signed-off-by: Robert Varga <rovarga@cisco.com>
(cherry picked from commit 43a86587a3fa6402a4eee19ecffb119b178994f5)

8 years agoBug 1014 - Non-configuration items in the model appear in the config 01/22601/1
Jan Hajnar [Thu, 14 May 2015 12:30:49 +0000 (14:30 +0200)]
Bug 1014 - Non-configuration items in the model appear in the config
namespace

* added TreeType enum for tree type identification
* modified factory methods and constructor for InMemoryDataTree
* Modified factory of SchemaApplyOperation to filter subtree by tree type
* reworked verifyStructure() to recursivelly walk data tree
* added tests for config statement check

Change-Id: I3f4ebe84e4387965ff43714a1f45f75c738d4475
Signed-off-by: Jan Hajnar <jhajnar@cisco.com>
(cherry picked from commit 54271a74d07bfd0b4b7e9ed2a061a3ceb23b12f6)

8 years agoIntroduce YangInstanceIdentifier.toOptimized() 00/22600/1
Robert Varga [Sun, 14 Jun 2015 09:12:29 +0000 (11:12 +0200)]
Introduce YangInstanceIdentifier.toOptimized()

Users often need to retain a YangInstanceIdentifier for use in either
addressing the same element in the data tree, or to create child
instance identifiers. Create a new method, toOptimized(), which returns
an equivalent FixedYangInstanceIdentifier instance.

Change-Id: I057db1d539520195cd38c1bfc77a8be1384108e2
Signed-off-by: Robert Varga <rovarga@cisco.com>
(cherry picked from commit 696e5e72e58b1e227b509c8307ddddf9f70beecf)

8 years agoRemove use of deprecated parser method 99/22599/1
Robert Varga [Fri, 12 Jun 2015 17:04:39 +0000 (19:04 +0200)]
Remove use of deprecated parser method

This simplifies SchemaContext construction in test.

Change-Id: I784075dd28a36aae9e679abbdb8370d9ea415388
Signed-off-by: Robert Varga <rovarga@cisco.com>
(cherry picked from commit 51cea429d220de41d4383e789512043b2bad1707)

8 years agoLower the size of ModifiedNode children maps 98/22598/1
Robert Varga [Fri, 12 Jun 2015 01:17:20 +0000 (03:17 +0200)]
Lower the size of ModifiedNode children maps

This lowers the default allocation of 16 to 8, hopefully lowering memory
pressure.

Change-Id: I72218f71a4407e0cdd802984b2edaf8fdfe8d3b2
Signed-off-by: Robert Varga <rovarga@cisco.com>
(cherry picked from commit e7aa2724f81a2eaae2b56d3e0e2d7f4a11a93b67)

8 years agoUse an ImmutableMap for empty case 97/22597/1
Robert Varga [Thu, 11 Jun 2015 22:25:34 +0000 (00:25 +0200)]
Use an ImmutableMap for empty case

Instead of using Collections.emptyMap(), use ImmutableMap.of(). This
will result in an immutable map, taking the immutable shortcut in the
previous check.

Change-Id: I83a58b0dcd5f075d0ac7a7b5073b801ce8a47d08
Signed-off-by: Robert Varga <rovarga@cisco.com>
(cherry picked from commit 03add667832ab33d50eabd046d5c9a93c75a62ab)

8 years agoBUG-2402: introduce CloneableChildrenMap 96/22596/1
Robert Varga [Thu, 11 Jun 2015 20:28:38 +0000 (22:28 +0200)]
BUG-2402: introduce CloneableChildrenMap

This exposes the appropriate interface to create a copy of the
underlying map in the most efficient manner. Makes
AbstractImmutableDataContainerNodeBuilder check for presence of the
interface and use it to create an efficient copy.

Change-Id: I8ad8159076fa199f315857e339fc83363ce73289
Signed-off-by: Robert Varga <rovarga@cisco.com>
(cherry picked from commit 05442d7e5fb59112453c5096851f2cd0a2b26a7f)

8 years agoCleanup NodeIdentifierWithPredicates references 95/22595/1
Robert Varga [Thu, 11 Jun 2015 21:05:01 +0000 (23:05 +0200)]
Cleanup NodeIdentifierWithPredicates references

Import NodeIdentifierWithPredicates directly, so we do not have to
qualify it with YangInstanceIdentifier.

Change-Id: Ibfaf62bf808b683bae57b120749db23fed3683eb
Signed-off-by: Robert Varga <rovarga@cisco.com>
(cherry picked from commit 032463a27c486136db139d000f472c981e0633cf)

8 years agoMake methods static 94/22594/1
Robert Varga [Thu, 11 Jun 2015 10:40:28 +0000 (12:40 +0200)]
Make methods static

All these can be made static, so improve their efficiency.

Change-Id: Ie6aa238eab7fef728dd22af12a64a155a9db776e
Signed-off-by: Robert Varga <rovarga@cisco.com>
(cherry picked from commit 12beaed7c9f1953562f79ef9699273d0ea53926c)

8 years agoMake BaseYangTypes.TYPE_MAP immutable 93/22593/1
Robert Varga [Thu, 11 Jun 2015 10:32:44 +0000 (12:32 +0200)]
Make BaseYangTypes.TYPE_MAP immutable

The lookup map is expected to be immutable.

Change-Id: I0ed6c263d34e585dcca2445ec963ea785c934ab8
Signed-off-by: Robert Varga <rovarga@cisco.com>
(cherry picked from commit c8e3e8de1506e8571651f430024c14157cdb61bb)

8 years agoImprove stored map memory efficiency 92/22592/1
Robert Varga [Wed, 10 Jun 2015 09:25:01 +0000 (11:25 +0200)]
Improve stored map memory efficiency

When we deal with small maps, we can improve our memory efficiency by
turning it into an ImmutableMap instead of wrapping it in another
instance.

For 1M fake BGP routes, this lowers the memory footprint by ~300MB,
which is about 10%.

Change-Id: I7fbac729f635ea089ac144e8a264df884d94c512
Signed-off-by: Robert Varga <rovarga@cisco.com>
(cherry picked from commit 877489ac0ab40d8a0d71fe041f9c8ea66a7e3446)

8 years agoThrow an exception from private constructor 91/22591/1
Robert Varga [Tue, 9 Jun 2015 22:58:12 +0000 (00:58 +0200)]
Throw an exception from private constructor

This is a utility class, it should never be instantiated.

Change-Id: Ic2edd90d0cf084a3a38e5a6c068172b9d774799e
Signed-off-by: Robert Varga <rovarga@cisco.com>
(cherry picked from commit 2e0878d894f821db411c87f2ffff094e9b32b5ee)

8 years agoBug 3336 - Binding DTOs: fix binary-derived constructor 90/22590/1
Jan Hajnar [Mon, 1 Jun 2015 14:40:16 +0000 (16:40 +0200)]
Bug 3336 - Binding DTOs: fix binary-derived constructor

* added condition to only check for null in value assignmet if class has
one property (because then CheckNull is generated before assgnment)

Change-Id: I3bd18ec60347b3d1d5dec32e7bcafa432c56b5ad
Signed-off-by: Jan Hajnar <jhajnar@cisco.com>
(cherry picked from commit 0c58b4c45c1caedd1e3ecdfa056c0c4f98185c63)

8 years agoBug 3669 - ietf-restconf binding is incomplete 72/22572/3
Peter Kajsa [Mon, 15 Jun 2015 09:36:29 +0000 (11:36 +0200)]
Bug 3669 - ietf-restconf binding is incomplete

- added implementation of ModuleRevisionBuilder.java

Change-Id: If50041c1b0befcb5fb8678cf95f915ef4b079bfb
Signed-off-by: Peter Kajsa <pkajsa@cisco.com>
8 years agoProvide better error messages when parsing JSON. 67/20167/6
Colin Dixon [Fri, 10 Apr 2015 00:36:49 +0000 (20:36 -0400)]
Provide better error messages when parsing JSON.

Change-Id: Ia3a613964ce74a6179a568098b83f9d3755fb9a4
Signed-off-by: Colin Dixon <colin@colindixon.com>
8 years agoBUG-3674: delete of non-existing data is a no-op 64/22564/1
Robert Varga [Fri, 12 Jun 2015 13:59:56 +0000 (15:59 +0200)]
BUG-3674: delete of non-existing data is a no-op

As noted in the comments, a delete on non-existing data is a no-op. That
means the user should see an UNMODIFIED modification, not a DELETE.

Change-Id: Ic9f79b99eefa352549b363c4754566da66ed0d55
Signed-off-by: Robert Varga <rovarga@cisco.com>
(cherry picked from commit 130683fbb867372bfa1a1d63fd491b182081aa1b)

8 years agoBug 3687 - StreamWriterGenerator emits UNKNOWN_SIZE 64/22464/2
Tony Tkacik [Fri, 12 Jun 2015 10:28:04 +0000 (12:28 +0200)]
Bug 3687 - StreamWriterGenerator emits UNKNOWN_SIZE

StreamWriterGenerator always emitted sizing hint
for fully-completed data and sometimes even
counting all availble augmentations, which actually
lead-up to larger sizes of collections then needed.

Fix changes the SIZE HINT for "constant" max-sized
types (containers, augmentations, list entries)
to -1 so underlaying implementation could size
them based on actual data.

Change-Id: Ibd446f71c4b066f4dab4a7d73b1bc851d9e62c99
Signed-off-by: Tony Tkacik <ttkacik@cisco.com>
Signed-off-by: Robert Varga <rovarga@cisco.com>
(cherry picked from commit b6fdf49d349662ffa82ae6477f99bac405799a3f)

8 years agoFix inefficient String buffering 29/22029/3
Robert Varga [Sat, 6 Jun 2015 13:57:12 +0000 (15:57 +0200)]
Fix inefficient String buffering

Instead of using string concatenation before adding to stribuilder, add
the componets directly.

Change-Id: Ibbd9131f1a1ec5df5f32c84e86c140e52c5ec84d
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoFix sonar warnings 28/22028/3
Robert Varga [Sat, 6 Jun 2015 13:53:10 +0000 (15:53 +0200)]
Fix sonar warnings

Declaring specific implementation class is a no-no, fix that up.

Change-Id: I55f6048fc737046ffd08518eddc0419ee61b276a
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoMake methods static 27/22027/3
Robert Varga [Sat, 6 Jun 2015 13:34:44 +0000 (15:34 +0200)]
Make methods static

These methods can be made static, make them such. Also fix raw types.

Change-Id: I4b697026857aae8579f0545e7e1284a7b8d00d04
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoBUG-3641: cache hashCode value 33/22333/1
Robert Varga [Tue, 9 Jun 2015 23:09:51 +0000 (01:09 +0200)]
BUG-3641: cache hashCode value

Builder-derived classes can be used as HashMap keys, which means they
can see their hashcode computed multiple times. Since this is a
recursive operation, the cost of it can be quite high, so dedicate two
fields for caching the hashcode result.

Change-Id: I0d95fd94187a421e4018b2f6992dfeaf2e126732
Signed-off-by: Robert Varga <rovarga@cisco.com>
(cherry picked from commit 0158f45b9078cdb867d3ce3c44a4ed4746f311fe)

8 years agoBug 1485: Invoke lengthCheck only on non-null object. 73/22273/1
Tony Tkacik [Tue, 9 Jun 2015 12:59:25 +0000 (14:59 +0200)]
Bug 1485: Invoke lengthCheck only on non-null object.

Change-Id: Iec3cf2fe08fbdac4e5139acab7865cd4c4b6224f
Signed-off-by: Tony Tkacik <ttkacik@cisco.com>
(cherry picked from commit 8dfd02dec37d796ce7a51866416675b021e85b7c)

8 years agoBUG-706 Ignore anyxml nodes in binding serializer 67/22167/2
Maros Marsalek [Mon, 8 Jun 2015 12:39:02 +0000 (14:39 +0200)]
BUG-706 Ignore anyxml nodes in binding serializer

AnyXml is not supported on that level and currently leads to null pointer ex.

Change-Id: I5c2a64ab9502e4bba02efd822d2b5294ef456cef
Signed-off-by: Maros Marsalek <mmarsale@cisco.com>
(cherry picked from commit 8c4ddc66b0b1ef31a65b8cabf55173a16615bab2)

8 years agoBUG-3051: Fix error reporting string 57/22157/3
Robert Varga [Mon, 8 Jun 2015 16:43:05 +0000 (18:43 +0200)]
BUG-3051: Fix error reporting string

The exception thrown does not accurately describe what has happened. Be
more user-friendly and report the exact pattern which failed to match.

Change-Id: I0818c92c4a8cdf8c180234635c1efe059ff1c4e2
Signed-off-by: Robert Varga <rovarga@cisco.com>
(cherry picked from commit 3680886f73ef87fb2818c57b12d3bc76525c3669)

8 years agoBUG-1485: convert BuilderTemplate to use LengthGenerator 56/22156/3
Robert Varga [Sun, 31 May 2015 17:51:43 +0000 (19:51 +0200)]
BUG-1485: convert BuilderTemplate to use LengthGenerator

This converts BuilderTemplate to use the LengthGenerator class as
appropriate, speeding operations up. Also removes caching fields.

Change-Id: I1a0bfc56df8ab36880ae8e14c111cb9aca68c626
Signed-off-by: Robert Varga <rovarga@cisco.com>
(cherry picked from commit 7998081d8e1761bf4798c1642e8e6107fc4666fc)

8 years agoBUG-1485: Switch ClassTemplate length checker 55/22155/3
Robert Varga [Sun, 31 May 2015 12:05:02 +0000 (14:05 +0200)]
BUG-1485: Switch ClassTemplate length checker

Switch ClassTemplate to use LengthGenerator. Also removes the static field
used to hold ranges, as that is only used by deprecated length() method.

Change-Id: I2a084a71d21c8c63a2d9733fc767aa7ecd3cff67
Signed-off-by: Robert Varga <rovarga@cisco.com>
(cherry picked from commit 65cf5ea01d87cbe65633a8e13fcbb6713e334ec2)

8 years agoBUG-1485: Create LengthGenerator 64/22164/2
Robert Varga [Sun, 31 May 2015 11:33:03 +0000 (13:33 +0200)]
BUG-1485: Create LengthGenerator

LengthGenerator is akin to AbstractRangeGenerator, only simpler. Since
the type of the checked property can only be an integer, we can live
without subclasses. One weirdness is that it needs to support both
String and byte[] fields, but that is easily catered with two distinct
methods.

Change-Id: I6b714b4094c332c18ee210451b3bd1672ca74129
Signed-off-by: Robert Varga <rovarga@cisco.com>
(cherry picked from commit b8e6be6a350b8dd39de74ca33fa039e92b198b17)

8 years agoIntroduce NormalizedNodes.findDuplicates() 54/22154/1
Robert Varga [Tue, 2 Jun 2015 08:29:20 +0000 (10:29 +0200)]
Introduce NormalizedNodes.findDuplicates()

This is an analytics utility method to find duplicate entries within a
NormalizedNode subtree.

Change-Id: Iedb3c9f71848c546f6e303b66e3f129b5f4da54f
Signed-off-by: Robert Varga <rovarga@cisco.com>
(cherry picked from commit 6397b5c1773f5ea825e592a0c27259b5e8631c06)

8 years agoBug 3224 - Parsing data with choice in case via augmentation results in 75/21975/2
Jan Hajnar [Thu, 7 May 2015 15:09:37 +0000 (17:09 +0200)]
Bug 3224 - Parsing data with choice in case via augmentation results in
incorrect parsing

* added tests for multiple choices from augmentation parsing
for json, xml and bindinging aware context
* modified json parsing tests
* fixed choice augmentation resolution in ChoiceNodeCodecContext
and CompositeNodeDataWithSchema
* moved findCorrespondingAugment to SchemaUtils since it is useful for
multiple Classes
* replaced getNodeIdentifierForAugmentation code in SchemaUtils  with
the one from CompositeNodeDataWithSchema.

Change-Id: Ibf57a771b92de14ecb70dcbbe250d7c559066882
Signed-off-by: Jan Hajnar <jhajnar@cisco.com>
(cherry picked from commit a8f512b80e661dac1ff85db6c16c72bfbf7f5891)

8 years agoBug 3325 - RPC returns 500. 74/21974/2
Jan Hajnar [Fri, 22 May 2015 11:02:03 +0000 (13:02 +0200)]
Bug 3325 - RPC returns 500.

* added original schema node resolution to getBaseTypeForLeafRef method
(we need to resolve leafref nodes added by grouping  according
to original module)

Change-Id: I80bf350cc442e966986c57ab2a352939a9f687a9
Signed-off-by: Jan Hajnar <jhajnar@cisco.com>
(cherry picked from commit dfdb6ad916fe5d9f5ad7b36858e85a6db3ac75c4)

8 years agoAdd a quick identity check for map comparison 72/21972/3
Robert Varga [Wed, 3 Jun 2015 13:14:06 +0000 (15:14 +0200)]
Add a quick identity check for map comparison

This should speed up the case of copied values. Also add a TODO for
future improvement.

Change-Id: Ie5122bd9b4941f05b6a94d30ecacbaab8dab2923
Signed-off-by: Robert Varga <rovarga@cisco.com>
(cherry picked from commit 9f42a2bded6bb3ac541ce37fcf07598659a87f03)

8 years agoInvoke equals() on a constant reference 71/21971/3
Robert Varga [Thu, 28 May 2015 14:54:54 +0000 (16:54 +0200)]
Invoke equals() on a constant reference

Inverting how we perform the equality check makes it obvious that the
invoked method is bound to a specific class object, helping compiler
just a tiny bit.

Change-Id: Ia8209f50143b0c3af71a962ab2a3ab167396836f
Signed-off-by: Robert Varga <rovarga@cisco.com>
(cherry picked from commit 1e51b859a08cfdda436fb12d0cf55dd89f00213b)

8 years agoBUG-1485: remove holder for deprecated Class ranges 70/21970/2
Robert Varga [Thu, 28 May 2015 20:34:01 +0000 (22:34 +0200)]
BUG-1485: remove holder for deprecated Class ranges

With the switchover to new range checks, the static caching field is not
needed. We still retain compatibility with possible users out there, but
they are now responsible for caching the result.

Change-Id: I119615255559263f98fc382b324026c4f5d35cfc
Signed-off-by: Robert Varga <rovarga@cisco.com>
(cherry picked from commit 924235feb5540c5a453c522e85d13fbd1d140c5a)

8 years agoBUG-1485: remove holder for deprecated Builder field ranges 69/21969/2
Robert Varga [Thu, 28 May 2015 20:05:51 +0000 (22:05 +0200)]
BUG-1485: remove holder for deprecated Builder field ranges

Caching the result was important as long as ranges were used internally,
now that they are not, do not retain them and re-generate them on each
call. Any callers out there are now responsible for caching them
themselves.

Change-Id: Idcba7fe54c59e33d6eedb6b596a2bf4f4a5ca10c
Signed-off-by: Robert Varga <rovarga@cisco.com>
(cherry picked from commit 8d510398ba320a17ba932d27b98423e8bcad1a10)

8 years agoBUG-1485: switch BuilderTemplate to new range enforcement 68/21968/2
Robert Varga [Thu, 28 May 2015 19:33:18 +0000 (21:33 +0200)]
BUG-1485: switch BuilderTemplate to new range enforcement

This switches the template for builders to the new range enforcement
code.

Change-Id: I1368a6a6922b2e982b9f4274dca32cf73b888d4b
Signed-off-by: Robert Varga <rovarga@cisco.com>
(cherry picked from commit 5b7dc4042d5827c60bf9ca9daaaf369242c931f9)

8 years agoBUG-1485: switch ClassTemplate to new range enformcement 67/21967/2
Robert Varga [Wed, 27 May 2015 20:00:18 +0000 (22:00 +0200)]
BUG-1485: switch ClassTemplate to new range enformcement

Switch range checks for simple classes (typedefs and similar) to the new
range checker. Also move printRangeConstraint() from BaseTemplate to
BuilderTemplate, as it ends up being used only there.

Change-Id: I16e4c1faf239d838ff415c0173ef3d06acc61701
Signed-off-by: Robert Varga <rovarga@cisco.com>
(cherry picked from commit 02e503a09314f2e3192b85ed9fccaff5efb4942c)

8 years agoBUG-1485: optimize primitive range checks 66/21966/2
Robert Varga [Thu, 28 May 2015 23:50:23 +0000 (01:50 +0200)]
BUG-1485: optimize primitive range checks

When we are dealing with a primitive type, we can force unboxing of the
type by declaring the range checker method's argument as the primitive
type. This will result in the stack not containing references for the
fast path (e.g. successful check) as well as reduce the number of
virtual calls to one. Checks will then be performed using primitive
manipulation instructions, which should result in better fast-path
execution.

The slow path will take a hit, as for throwing the exception, we will
end up re-boxing the primitive type.

Change-Id: I7e6b0e25790f9a43dc99f2fc7426bb9fe25c505c
Signed-off-by: Robert Varga <rovarga@cisco.com>
(cherry picked from commit 9b5366d775b93f0e2a37f028cda11832ba65ce6d)

8 years agoBUG-1485: make AbstractRangeGenerator deal with GTOs 65/21965/2
Robert Varga [Thu, 28 May 2015 14:57:20 +0000 (16:57 +0200)]
BUG-1485: make AbstractRangeGenerator deal with GTOs

For enforcement of ranges in builders, we will need to deal with types
other than ConcreteType. Also clean up internal interfaces, add some
javadocs and remove some trailing whitespace.

Also perform Number class conversion silently if it does not result in
loss of precision. Emit a warning if it does.

Change-Id: I8f3ba96c104fb28f6d2cfc4b05b5d24bb7f80aa1
Signed-off-by: Robert Varga <rovarga@cisco.com>
(cherry picked from commit d8f544b093f024ff156873c66eebf976f6738382)

8 years agoBUG-1485: deprecate public static range/length methods 64/21964/2
Robert Varga [Thu, 28 May 2015 00:46:35 +0000 (02:46 +0200)]
BUG-1485: deprecate public static range/length methods

These methods are not efficient and expose implementation internals.
Mark them as deprecated for removal. This mirrors the deprecation in
ClassTemplate, which was not instantiated before due to how the code is
structured.

Change-Id: I7fcb831f00fd3baab02e1f25e10655c8288c6d4e
Signed-off-by: Robert Varga <rovarga@cisco.com>
(cherry picked from commit da603ecd3b0e093bf00ff75d80c0957196d9856d)

8 years agoBUG-1485: move generateLengthMethod to BuilderTemplate 63/21963/2
Robert Varga [Thu, 28 May 2015 00:26:42 +0000 (02:26 +0200)]
BUG-1485: move generateLengthMethod to BuilderTemplate

While it looks this method is shared, it is not, as ClassTemplate
defines its own. Move it to BuilderTemplate and make it private,
reducing confusion.

Change-Id: I998f200a963dea39b1e2fedaf7a9fd1e394db58d
Signed-off-by: Robert Varga <rovarga@cisco.com>
(cherry picked from commit c2bf3960924fd870b8d3183f396c5e43b84e0aa3)

8 years agoBUG-1485: move *Range* methods to BuilderTemplate 62/21962/2
Robert Varga [Thu, 28 May 2015 00:14:29 +0000 (02:14 +0200)]
BUG-1485: move *Range* methods to BuilderTemplate

printRangeConstraint and generateRangeMethod are used by BuilderTemplate
only, move them there to preserve locality and stop them from spreading.

Change-Id: I5d5421b50bd5e4ac65182ad1a11e7bfad199df51
Signed-off-by: Robert Varga <rovarga@cisco.com>
(cherry picked from commit c49ff3a94cc0b0f98dc73647a7fdc308fdaa3052)

8 years agoBUG-1485: Move restriction generation 61/21961/2
Robert Varga [Wed, 27 May 2015 19:24:59 +0000 (21:24 +0200)]
BUG-1485: Move restriction generation

It is only used in the class template, so move it and make it private to
increase clarity.

Change-Id: I751c4a5a0af06dd89a79ce43546ec9c12490f166
Signed-off-by: Robert Varga <rovarga@cisco.com>
(cherry picked from commit 76c57ce16f7b1b90325214e05f916bc486ad792d)

8 years agoBUG-3399: fix BaseYangTypes' range constraints 60/21960/2
Robert Varga [Wed, 27 May 2015 23:06:14 +0000 (01:06 +0200)]
BUG-3399: fix BaseYangTypes' range constraints

Constraints Number type should match the Java type a particular type is
bound to. Users dealing with values trying to correlate it to the
metadata available can then rely on things like
value.getClass.cast(rangeMin) just working instead of concocting
conversions to deal with all possible combinations of types.

Also changes BaseConstraints to enforce the two components of a
constraint being the same type, preventing things like min being Integer
while max is a Long.

Change-Id: I38e646b4c08b032248349f3e618354aa2114efd3
Signed-off-by: Robert Varga <rovarga@cisco.com>
(cherry picked from commit af2244fc083e788645ac689b543af447efdf5b70)

8 years agoBUG-1485: Introduce AbstractRangeGenerator and friends 59/21959/2
Robert Varga [Tue, 26 May 2015 20:49:36 +0000 (22:49 +0200)]
BUG-1485: Introduce AbstractRangeGenerator and friends

Adds utility classes for dealing with various range constraints in
generated code. These classes are implemented in pure Java and attempt
to make sure generated code runs as efficiently as possible.

Change-Id: Ie1d05b514937507e225b9bc7559b1949a7e6eb76
Signed-off-by: Robert Varga <rovarga@cisco.com>
(cherry picked from commit c5e1800bc2851c90273b6218295ffe2e59fccf91)

8 years agoBUG-1485: store patterns in an array 58/21958/2
Robert Varga [Tue, 26 May 2015 18:32:20 +0000 (20:32 +0200)]
BUG-1485: store patterns in an array

Internal compiled patters are only ever iterated over, hence there is no
need to store them in a list. Convert the field into an array, improving
both CPU and memory efficiency very slightly. Also saves instantiation
of a temporary list.

Change-Id: I5140bc81d0a78d4f91d4ad2d6f81cbd6ed1f6d55
Signed-off-by: Robert Varga <rovarga@cisco.com>
(cherry picked from commit 29c2d3351bdf371274433e71909236f133130bfb)

8 years agoImprove deltaChildren() 57/21957/2
Robert Varga [Thu, 4 Jun 2015 00:48:40 +0000 (02:48 +0200)]
Improve deltaChildren()

Instead of instantiating and mutating an index map, we perform a full
search in both old and new data, building the result as we go.

Change-Id: I4aae9cdbf18080a63da3416728b3b5dbb8e312ab
Signed-off-by: Robert Varga <rovarga@cisco.com>
(cherry picked from commit 32f3ca2fb7ab6cdf6e8df5cf83ba3d16f21ffb01)

8 years agoFix performance of RecursiveReplaceCandidateNode.getModifiedChild() 27/21927/4
Robert Varga [Wed, 3 Jun 2015 08:16:17 +0000 (10:16 +0200)]
Fix performance of RecursiveReplaceCandidateNode.getModifiedChild()

This implementation was accidentally left out of conversion which
introduced AbstractDataTreeCandidateNode.deltaChild(). Convert the
callsite, increasing its efficiency.

Change-Id: I3bf434fb5fa843ade0c64999e1cf75dd1374b393
Signed-off-by: Robert Varga <rovarga@cisco.com>
(cherry picked from commit 8c542f8aad8b79cd2ecf5a721e725f9076a1ca0b)

8 years agoSpeed up getModifiedChild() 56/21956/2
Robert Varga [Wed, 20 May 2015 19:44:29 +0000 (21:44 +0200)]
Speed up getModifiedChild()

As it turns out, the original implementation transformed all children
before performing a lookup. Methods involved in that conversion can be
easily applied to transform a single child, so address the FIXME by
first performing a lookup and then running transformation, if
appropriate.

Change-Id: I11a87a69ce3e8552926017c51db7d4899af74a2a
Signed-off-by: Robert Varga <rovarga@cisco.com>
(cherry picked from commit 73262077092195b800edbeb89f0eeb80006d621b)

8 years agoMark mAbstractModifiedNodeBasedCandidateNode final 55/21955/2
Robert Varga [Wed, 20 May 2015 20:06:22 +0000 (22:06 +0200)]
Mark mAbstractModifiedNodeBasedCandidateNode final

These methods are not to be overridden, so mark them as final.

Change-Id: Ibce6eb5f54b0e1730767b8a9d7c142f784649516
Signed-off-by: Robert Varga <rovarga@cisco.com>
(cherry picked from commit f3b12934576efbb0a5fb296c4eac785929fbcd19)

8 years agoMake optionalData() static 54/21954/2
Robert Varga [Wed, 20 May 2015 19:55:40 +0000 (21:55 +0200)]
Make optionalData() static

This private utility method does not touch the object, hence make it
static.

Change-Id: Ifc50b713792cd3e8096173dbdaf3cdb41b9f42e2
Signed-off-by: Robert Varga <rovarga@cisco.com>
(cherry picked from commit 41bbe5b3632734e4a0486c7edd71901879cc9f88)

8 years agoBug 3189 Special case of checking root node QName. 53/21953/2
Tony Tkacik [Wed, 20 May 2015 08:23:14 +0000 (10:23 +0200)]
Bug 3189 Special case of checking root node QName.

Root instance identifier is special in that it does not have a path
argument.

Change-Id: I59d699b786b3ce117511785dc4f8227ca86057f2
Signed-off-by: Tony Tkacik <ttkacik@cisco.com>
Signed-off-by: Robert Varga <rovarga@cisco.com>
(cherry picked from commit 1f29c046d27af10f5228396a94213ebc59aa0b9b)

8 years agoBUG-3189: Check consistency of Instance Identifier and Data 78/21978/1
Tony Tkacik [Wed, 13 May 2015 09:23:27 +0000 (11:23 +0200)]
BUG-3189: Check consistency of Instance Identifier and Data

DataTree allows for a NormalizedNode to be stored at a position which is
inconsistent with its identifier. This can lead to weird errors, as
child metadata nodes are created. Add an explicit check to ensure this
cannot occur.

Change-Id: I0fbbec13a5c4121b3441869d244666e218305d57
Signed-off-by: Tony Tkacik <ttkacik@cisco.com>
(cherry picked from commit 8bb72bff26c4f1d2da94af6463ba8ae212e2223a)

8 years agoBUG-3189: Check consistency of Instance Identifier and Data 52/21952/2
Tony Tkacik [Wed, 13 May 2015 09:23:27 +0000 (11:23 +0200)]
BUG-3189: Check consistency of Instance Identifier and Data

DataTree allows for a NormalizedNode to be stored at a position which is
inconsistent with its identifier. This can lead to weird errors, as
child metadata nodes are created. Add an explicit check to ensure this
cannot occur.

Change-Id: I25918f1f866beadb1ba7c9687ba1a880942a0d9e
Signed-off-by: Tony Tkacik <ttkacik@cisco.com>
(cherry picked from commit 8bb72bff26c4f1d2da94af6463ba8ae212e2223a)

8 years agoAdd an explicit guard for root presence 51/21951/2
Robert Varga [Wed, 6 May 2015 09:57:35 +0000 (11:57 +0200)]
Add an explicit guard for root presence

A modification could potentially remove the root node, which would
trigger a failure in Optional.get(). Add an explicit check to provide
better diagnostic in that case.

Change-Id: I0e27910497169a080aa8185c66f65c9639ccf2e7
Signed-off-by: Robert Varga <rovarga@cisco.com>
(cherry picked from commit 5ef3b21212ef72fea2602adb8ca0719ffe4092e5)

8 years agoAdd YangInstanceIdentifierBuilder.node(PathArgument) 50/21950/2
Robert Varga [Wed, 3 Jun 2015 17:17:20 +0000 (19:17 +0200)]
Add YangInstanceIdentifierBuilder.node(PathArgument)

Forcing users of builder to not reuse PathArgument instances seems
wrong. Allow passing of pre-made PathArguments to a builder.

Change-Id: Iae7d2a8c8dd60542a11c946dc3ced18e09afb62b
Signed-off-by: Robert Varga <rovarga@cisco.com>
(cherry picked from commit 4c7b873ec4c5e90819647e8dd167da05852635d9)

8 years agoRemove code duplication in YangInstanceIdentifierBuilder 49/21949/2
Robert Varga [Wed, 3 Jun 2015 17:13:03 +0000 (19:13 +0200)]
Remove code duplication in YangInstanceIdentifierBuilder

The various node() methods share a tail-end, concentrate in a private
method.

Change-Id: Ice0f1b8824b6c5a11a2fdec696a1453817493b5e
Signed-off-by: Robert Varga <rovarga@cisco.com>
(cherry picked from commit 113de9e01137d9f3ef99cc1ac9450cb4c17ae08e)

8 years agoTake advantage of YangInstanceIdentifier methods 48/21948/2
Robert Varga [Fri, 22 May 2015 16:45:02 +0000 (18:45 +0200)]
Take advantage of YangInstanceIdentifier methods

getPathArguments() returns a list, so we can ditch Iterables.

Change-Id: I5f83a46505bdea0c0b89d634a8b5e708b95a96bd
Signed-off-by: Robert Varga <rovarga@cisco.com>
(cherry picked from commit 2accf0476feb1078dd365970ab609be1ae17de58)

8 years agoBug 3344: Make sure StackedPathArgument stack is non empty. 46/21946/2
Tony Tkacik [Wed, 3 Jun 2015 15:26:32 +0000 (17:26 +0200)]
Bug 3344: Make sure StackedPathArgument stack is non empty.

The while cycle in StackedYangInstanceIdentifier did double
check of tryPathArguments for same instance identifier,
which led to shared state during creation. This may have
resulted in StackedPathArgumements with empty stack.

Changing it into do-while cycle makes sure stack is non empty
and also state during construction is not shared between
multiple invokers.

Change-Id: I834c1f22c477bb03a6bae9c4a366308a0988ce4e
Signed-off-by: Tony Tkacik <ttkacik@cisco.com>
(cherry picked from commit 73b8669288832cd1d573bde23666dd0ba05abb8a)

8 years agoBUG-3263: remove bridge Collection-based methods 45/21945/2
Robert Varga [Tue, 19 May 2015 08:57:24 +0000 (10:57 +0200)]
BUG-3263: remove bridge Collection-based methods

This class and its methods were used in transition on Lithium and are no
longer needed, so remove them.

Change-Id: I2e67d173f87b409803e46861b77aa165784444e0
Signed-off-by: Robert Varga <rovarga@cisco.com>
(cherry picked from commit 12b6252d832dc4c7e0a965acc0136ca4a9574db4)

8 years agoBUG-3263: return a List of PathArguments 44/21944/2
Robert Varga [Mon, 18 May 2015 23:05:42 +0000 (01:05 +0200)]
BUG-3263: return a List of PathArguments

This is a further improvement to the interface, we return a List of path
arguments for both getPathArguments() and getReversePathArguments().
This makes it possible for StackedYangInstanceIdentifier to not retain a
legacy list of path arguments.

Change-Id: I98ebc2bec139a0e02b4a428bc783ea23981e3658
Signed-off-by: Robert Varga <rovarga@cisco.com>
(cherry picked from commit 607cac45417bc76143d56d230f60a0293f99276f)

8 years agoBUG-3263: return a Collection for path arguments 43/21943/2
Robert Varga [Mon, 18 May 2015 22:29:06 +0000 (00:29 +0200)]
BUG-3263: return a Collection for path arguments

With the rework in place, we can now return a Collection from both
getPathArguments() and getReversePathArguments() even in the stacked
case.

Change-Id: I51179320022f060d9fb2597f473d0919d391092c
Signed-off-by: Robert Varga <rovarga@cisco.com>
(cherry picked from commit 5ad97de7baf1ea8575349e4c5625525101d7749a)

8 years agoBUG-3263: Split off Fixed/Stacked YangInstanceIdentifier 42/21942/2
Robert Varga [Mon, 18 May 2015 19:03:09 +0000 (21:03 +0200)]
BUG-3263: Split off Fixed/Stacked YangInstanceIdentifier

This patch makes YangInstanceIdentifier an abstract class, with two
subclasses: FixedYangInstanceIdentifier and
StackedYangInstanceIdentifier.

The fixed version uses an internal ImmutableList and derives efficiency
from it to the maximum extent allowed.

The stacked version stores a reference to the parent identifier and the
last path argument. It caches the support classes which provide
getPathArguments and getReversePathArguments.

Also introduce a getParent() method, as it can now be implemented
efficiently.

Change-Id: I0c4a771e74d031cae0b53a7f97221213222729f6
Signed-off-by: Robert Varga <rovarga@cisco.com>
(cherry picked from commit d3d9f5ba02c0264f57083ccbde6e7f3c3548898e)

8 years agoBaseTypes' QNameModule should be cached 29/21929/2
Robert Varga [Thu, 28 May 2015 10:24:08 +0000 (12:24 +0200)]
BaseTypes' QNameModule should be cached

This QNameModule may be incoming from multiple places, make sure we seed
it into the cache on load.

Change-Id: I764edf3520a37d853eff519ca4139dc2f60480b3
Signed-off-by: Robert Varga <rovarga@cisco.com>
(cherry picked from commit a434cb4c9cea4c4d65a4b764814b14d9a5f74a4e)

8 years agoMake sure we cache QNameModule instances 30/21930/2
Robert Varga [Thu, 28 May 2015 10:21:55 +0000 (12:21 +0200)]
Make sure we cache QNameModule instances

Parser should be taking advantege of cached QNameModules, as multiple
generations/independent instances within a JVM should still be sharing
them.

Change-Id: I3c670519056456f8c93591b1e8e24f095131fb9a
Signed-off-by: Robert Varga <rovarga@cisco.com>
(cherry picked from commit 9c29d20c9efaaac3f11b0ca54b484fca87afe719)

8 years agoMake test utilities static 31/21931/2
Robert Varga [Thu, 28 May 2015 01:59:22 +0000 (03:59 +0200)]
Make test utilities static

These two can be static, make them static.

Change-Id: I3fe54607edbadea4250928e99260906cbaef4629
Signed-off-by: Robert Varga <rovarga@cisco.com>
(cherry picked from commit 0341b340283af8efa8c7604c1d65ac87aaeecfd1)

8 years agoDo not instantiate augmentation HashMap in DTO builders 32/21932/2
Robert Varga [Tue, 26 May 2015 22:18:57 +0000 (00:18 +0200)]
Do not instantiate augmentation HashMap in DTO builders

Tracing has revealed that the OpenFlowPlugin creates a lot of builders,
instantiation a million HashMaps, which accounts for 1% of CPU time.
Most of these maps are never touched, so we can easily optimize this
away by lazily instantiating a HashMap when the first augmentation is
added. Also prevents copying of empty augmentation in the copy
constructor.

Change-Id: I592fe6af65c9f3b65038def8bb4069666bfdc375
Signed-off-by: Robert Varga <rovarga@cisco.com>
(cherry picked from commit 2cb012f4e814859e10726d02cb1c073321316ab3)

8 years agoGuard against null data in AbstractLeafCandidateNode 33/21933/2
Robert Varga [Wed, 20 May 2015 19:56:22 +0000 (21:56 +0200)]
Guard against null data in AbstractLeafCandidateNode

An instance of this class is defunct if data is ever null, as accessors
will throw a NPE from Optional.of(). Make sure data passed down is never
null, catching any possible offenders.

This transitively fixes the transformation functions, as they will throw
NPE when they get a null input, as per Function API contract.

Change-Id: I8851e3c68dc9aa5abab4874f019fd214b20c0415
Signed-off-by: Robert Varga <rovarga@cisco.com>
(cherry picked from commit 540b47bdefb25b8edb8481499efcd51d402bd57c)

8 years agoClarify GeneratedTransferObject.getSuperType() 28/21928/1
Robert Varga [Thu, 28 May 2015 15:23:27 +0000 (17:23 +0200)]
Clarify GeneratedTransferObject.getSuperType()

The Javadoc for this method is confusing and actually misleading.
Clarify it a bit for future's sake.

Change-Id: I52f09e2e9cf864dc00fb4883099ca4df5219327f
Signed-off-by: Robert Varga <rovarga@cisco.com>
(cherry picked from commit a2a7dee2cc6a9e83f53acd08408b227416f29bff)

8 years agoBindingReflections' cache should use cached references 64/21864/2
Robert Varga [Wed, 3 Jun 2015 17:32:11 +0000 (19:32 +0200)]
BindingReflections' cache should use cached references

Since we will be giving out these all over the place, it is a good idea
to make sure the returned reference is system-global.

Change-Id: I46c4f62c5ea8f8ee13e7745e6c9efd7d865bd6d4
Signed-off-by: Robert Varga <rovarga@cisco.com>
(cherry picked from commit 47e801b7f26d9e8ce68738bdfd0d1b6e6c83ae0c)

8 years agoBUG 2970 : Throw a specific exception when schema validation fails 82/21882/2
Moiz Raja [Sat, 23 May 2015 00:46:00 +0000 (17:46 -0700)]
BUG 2970 : Throw a specific exception when schema validation fails

When resolving a modification if there is a failure in validating
a data node because it's schema is not present we should throw
a specific exception instead of just an IllegalArgument exception.

This specific exception can be used by CDS to determine if the failure
to add a node was due to a schema validation failure and then we will
attempt to prune data from the normalized node so that the invalid
data elements are removed.

Change-Id: Ieba347c29a9e92ea6aa7ccc2570935cd7a233b8e
Signed-off-by: Moiz Raja <moraja@cisco.com>
8 years agoBug 2816: Changed BooleanStringCodec deserialization 12/20412/7
Debalina Ghosh [Thu, 14 May 2015 16:59:57 +0000 (09:59 -0700)]
Bug 2816: Changed BooleanStringCodec deserialization

Added validate() to deserialize that checks whether input string is true or false.
If some other string is given, IllegalArgumentException is thrown.
Unit test is changed accordingly.

Change-Id: I51e7da19bd4cce85aa707d7741ae3956cc3e8890
Signed-off-by: Debalina Ghosh <debalina.ghosh@hp.com>
8 years agoStop calling get on a possible absent value. 57/21857/1
Tomas Cere [Tue, 2 Jun 2015 12:03:58 +0000 (14:03 +0200)]
Stop calling get on a possible absent value.

Change-Id: I76cc4d6decd7cf65f988dcb87553b280aab21b24
Signed-off-by: Tomas Cere <tcere@cisco.com>
8 years agoAllow instantiation of more efficient RpcServiceInvokers 33/21233/1
Robert Varga [Wed, 27 May 2015 10:54:03 +0000 (12:54 +0200)]
Allow instantiation of more efficient RpcServiceInvokers

Current invoker derived from binding class has the downside of
performing localName->methodName conversion on each invocation, which
costs us in the lookup path, as deriving the binding method name is a
costly operation.

Add a new static factory method for creating a RpcServiceInvoker
instance base on a QName->Method map. Provide two additional
implementations: a generic one, which performs a direct lookup in the
map and a specialized one, which performs lookup only on the localName
part of the qname. The latter is used after we have made sure all QNames
come from the same QNameModule.

Change-Id: I6a4b33f0487838b3ae6c15470823e4bc01114aa5
Signed-off-by: Robert Varga <rovarga@cisco.com>
(cherry picked from commit aab5a09be514bc7622416bf2a6d4d6a7465f9d7c)

8 years agoOptimize binding InstanceIdentifier methods 35/21135/2
Robert Varga [Tue, 26 May 2015 13:09:00 +0000 (15:09 +0200)]
Optimize binding InstanceIdentifier methods

Openflow traces show some overhead from UnmodifiableIterable. As it
turns out, we are instantiating them needlessly for internal iteration.
This stems from accessing getPathArguments() instead of pathArguments,
which are exposed precisely for this optimization.

Make sure to access pathArguments directly, eliminating this overhead.

Change-Id: I3ef053baa35c80f555b6b9f0b8813692236afa48
Signed-off-by: Robert Varga <rovarga@cisco.com>
(cherry picked from commit 96639b4fd02beb3590f62fdfc096936e71ad4a32)

8 years agoClarify the correctness of Optional.get() 75/21175/2
Robert Varga [Wed, 6 May 2015 09:37:58 +0000 (11:37 +0200)]
Clarify the correctness of Optional.get()

The check of Optional.isPresent() exists in all codepaths, but it is not
immediately obvious. Make it more explicit.

Change-Id: I73b6931299ee8cd8e40d0331acc6d6e753db8612
Signed-off-by: Robert Varga <rovarga@cisco.com>
(cherry picked from commit c49971ebea9f449efb529ae54cd9b8f8a996d111)

8 years agoAdd an explicit guard to child modifications 76/21176/2
Robert Varga [Wed, 6 May 2015 09:45:46 +0000 (11:45 +0200)]
Add an explicit guard to child modifications

If we attempt to apply a merge operation to a non-existent child, we may
end up throwing an IllegalStateException stemming from unchecked
Optional.get().

Add an explicit argument check for child node presence to provide better
diagnostics.

Change-Id: I9e319aa994f01b97a14d5499fba6b1c33dad9a63
Signed-off-by: Robert Varga <rovarga@cisco.com>
(cherry picked from commit c5c1c745440f660bfdc3c3efef25cf750a6ebc39)

9 years agoBUG-3263: Split out YangInstanceIdentifierBuilder 77/21177/1
Robert Varga [Mon, 18 May 2015 18:29:20 +0000 (20:29 +0200)]
BUG-3263: Split out YangInstanceIdentifierBuilder

The builder is not visible, so increase clarity by splitting it out into
its own file. This reduces clutter in YangInstanceIdentifier.

Change-Id: I9c3bcd141e54129777f0c8dd8efd7ce02ae5e8cc
Signed-off-by: Robert Varga <rovarga@cisco.com>
(cherry picked from commit afbeab40f406b932a44451d9a7fb8482dbb6d09d)

9 years agoBUG-2453 Add enum yang <-> Java mapping to BindingRuntimeContext 30/20030/5
Maros Marsalek [Mon, 11 May 2015 14:40:26 +0000 (16:40 +0200)]
BUG-2453 Add enum yang <-> Java mapping to BindingRuntimeContext

BindingRuntimeContext already posses the information about all generated
classes from yang (also enums). This commit makes it public.

Change-Id: I638d73625bdc4720ee6427027246455c6c05aa03
Signed-off-by: Maros Marsalek <mmarsale@cisco.com>
9 years agoBug 2528 - Binding Generator: Generated notification implements ChildOf 94/13994/10
Peter Kajsa [Thu, 8 Jan 2015 12:50:02 +0000 (13:50 +0100)]
Bug 2528 - Binding Generator: Generated notification implements ChildOf
interface

Generated Notification interface implements ChildOf<DataObject> interface
which is incorrect. Generated Notification should not implement ChildOf
interface since it is not part of data tree. This could lead to use of
Notification in wrong context and may confuse consumers of APIs.

Notice: The solution replaces "implements ChildOf<DataObject>" with
"implements DataObject" in generated Notification interface. Notification
has structured content, so I think the generated Notification interface should
implements at least DataObject interface in order to be able to construct
InstanceIdentifier for the notification (analogously as it is by RPC's input
and output).

Change-Id: I55c7a8cc4ce450fd712c63f8e77881d4a18674e6
Signed-off-by: Peter Kajsa <pkajsa@cisco.com>
9 years agoBUG-2453 Remove custom hashcode/equals from Enum type 29/20029/3
Maros Marsalek [Thu, 7 May 2015 12:12:17 +0000 (14:12 +0200)]
BUG-2453 Remove custom hashcode/equals from Enum type

Custom hashcode and equals made it impossible to match Enum types based on
packageName and name.

Change-Id: Ib3eed1f0892234b44f8e3459e48f303732a86ffe
Signed-off-by: Maros Marsalek <mmarsale@cisco.com>
9 years agoBug 2988 - DTO equality appears to be broken by proxy 48/21048/2
Martin Bobak [Mon, 25 May 2015 13:09:01 +0000 (15:09 +0200)]
Bug 2988 - DTO equality appears to be broken by proxy

Change-Id: Ib068be34371e8863ef6f2ef8d936d3d6918aba37
Signed-off-by: Martin Bobak <mbobak@cisco.com>
9 years agoDo not instantiate objects for hash values 25/20625/1
Robert Varga [Fri, 15 May 2015 17:06:17 +0000 (19:06 +0200)]
Do not instantiate objects for hash values

While having a reference saves us from having an additional field, it will
cost us an additional object overhead once it is materialized. Opt for a
primitive type with a volatile guard.

Change-Id: Ib3a71eb9d00555f3929d8bc104a5065d0252561e
Signed-off-by: Robert Varga <rovarga@cisco.com>
(cherry picked from commit 81bbf5f1a7c88c45969f48222dee635ad5e388fb)

9 years agoMark JSON writers as @Deprecated 65/18065/4
Colin Dixon [Fri, 10 Apr 2015 00:36:49 +0000 (20:36 -0400)]
Mark JSON writers as @Deprecated

Also fixing a few typos.

Change-Id: I69bb45e564149de510ce0cbd2ef0c5c700b0b3e4
Signed-off-by: Colin Dixon <colin@colindixon.com>
9 years agoBUG 2973 - correction of output for empty yang type 36/13736/5
Jozef Gloncak [Thu, 18 Dec 2014 14:08:49 +0000 (15:08 +0100)]
BUG 2973 - correction of output for empty yang type

Empty" type supports (de)serializiation from
JSON array with null ( [null] ) as was specified in
Section 3.3.9 of draft-lhotka-netmod-yang-json-02

Change-Id: I6650893c00212828cd771e477b81811917000713
Signed-off-by: Jozef Gloncak <jgloncak@cisco.com>
Signed-off-by: Tony Tkacik <ttkacik@cisco.com>
(cherry picked from commit b18ea8d1646806849f0f1ffbba333a04b9ce93f8)

9 years agoBug 3067: Improved error reporting in Binding Data Codec 23/19523/3
Tony Tkacik [Wed, 29 Apr 2015 13:35:08 +0000 (15:35 +0200)]
Bug 3067: Improved error reporting in Binding Data Codec

Error reporting in Binding Data Codec was reworked
to throw three additional subclasses of IllegalArgumentException
for specific case of failure:

MissingSchema and MissingSchemaForClass - exception thrown
when schema context associated with codec does not contain
models for supplied class or DOM argument.

IncorrectNesting is thrown when schema is available an user
constructed data with invalid nesting (bypassed generic
compile-time checks).

The checks to determine type of exception are done only
if error condition is detected, so non-error fast path
should not be affected by advanced checks.

Added test which tests these types of exceptions.

Change-Id: Iad020a42317ab46df4d2240568fd6e8205383857
Signed-off-by: Tony Tkacik <ttkacik@cisco.com>
(cherry picked from commit 3f754cccb393b989bafb8b194edf9da0ec3e9e8a)

9 years agoFixing magic numbers 17/18217/10
Debalina Ghosh [Mon, 13 Apr 2015 20:31:43 +0000 (13:31 -0700)]
Fixing magic numbers

Change-Id: Id844166d94e9d8059bb48fadfbccec95fe45cf46
Signed-off-by: Debalina Ghosh <debalina.ghosh@hp.com>
9 years agoElimitating redundant modifiers 34/19734/2
Debalina Ghosh [Wed, 6 May 2015 18:12:25 +0000 (11:12 -0700)]
Elimitating redundant modifiers

Change-Id: I01e55a903937cd2344ef90aac10a247c269bf560
Signed-off-by: Debalina Ghosh <debalina.ghosh@hp.com>
9 years agoBug 3151: Fix Not a Proxy Instance Exception 11/19811/1
Thomas Bachman [Thu, 7 May 2015 14:55:03 +0000 (10:55 -0400)]
Bug 3151: Fix Not a Proxy Instance Exception

This fixes a bug where a "Not a Proxy Instance"
exception (also IllegalArgumentException) is thrown
when hashCode is invoked in a yangtools generated
builder.

Change-Id: Iddc7ca6e4785e5ce11e41900a438dbb49baeaf6d
Signed-off-by: Thomas Bachman <tbachman@yahoo.com>
9 years agoBug 2333 - Java code generation error, when yang model contains Choice node 13/12813/13
pkajsa [Thu, 13 Nov 2014 13:51:20 +0000 (14:51 +0100)]
Bug 2333 - Java code generation error, when yang model contains Choice node
in module body at top level

BindingGeneratorImpl fails (NoSuchElementException) during java source code
generation from yang model which contains Choice node directly in module body
at top level. The parent path of Choice node is empty (because the parent
is the module) and therefore iterator.next() on the path fails. For more
information see Bug 2333.

Change-Id: I6e617eca91bb5d8d2b91ad058a4df5c2793ec81d
Signed-off-by: pkajsa <pkajsa@cisco.com>