yangtools.git
6 years agoFix uninitialized ExtensionDefinition for openconfig-version 40/59240/2
Igor Foltin [Tue, 20 Jun 2017 14:01:17 +0000 (16:01 +0200)]
Fix uninitialized ExtensionDefinition for openconfig-version

The StatementDefinition for openconfig-version extension is
not bound to any revision. When populating the ExtensionNamespace
with openconfig-version, we have to store it with a revisionless
QName key. This way we can properly extract the corresponding
ExtensionDefinition later down the road in the
UnknownEffectiveStatementBase.

This issue causes NPE in MDSAL's binding generator v2.

Change-Id: Ie24c09b56986c87b5118d715ec6c8e755cf07ebe
Signed-off-by: Igor Foltin <igor.foltin@pantheon.tech>
6 years agoBump odlparent dependency to 2.0.0 73/50173/13
Robert Varga [Wed, 21 Jun 2017 14:03:22 +0000 (16:03 +0200)]
Bump odlparent dependency to 2.0.0

This patch updates the dependency to 2.0.0. Furthermore it eliminates
karaf 3 features and fixes Guava changes.

Change-Id: I2f9d3bda9ed12c58ca44f44e66f1110cceaf200b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoRemove use of ALTLRInputStream 22/59022/1
Robert Varga [Thu, 15 Jun 2017 12:20:37 +0000 (14:20 +0200)]
Remove use of ALTLRInputStream

As of 4.7, CharStreams is a better interface for this same
functionality.

Change-Id: I1ceadded34654fbfe3f4e4402b714c21c857fe4f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoBump antlr4 to 4.7 42/58942/3
Robert Varga [Wed, 14 Jun 2017 12:05:48 +0000 (14:05 +0200)]
Bump antlr4 to 4.7

https://github.com/antlr/antlr4/releases/tag/4.6
https://github.com/antlr/antlr4/releases/tag/4.7

Change-Id: I0600e2fe5914a966cf0cb8528f853285de83d490
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoBe strict about boolean arguments 70/58270/42
Robert Varga [Mon, 5 Jun 2017 16:55:50 +0000 (18:55 +0200)]
Be strict about boolean arguments

RFC6020 and RFC7950 mandate the argument to be either 'true' or 'false',
which is different from Boolean.valueOf(String), which accepts any
string. Fix this by providing our own parse method.

Change-Id: I87d39d5a9238f79cb34c66efa08ed67c2a02eb82
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoMigrate to odlparent 1.9.0 29/58829/3
Thanh Ha [Tue, 13 Jun 2017 15:48:44 +0000 (11:48 -0400)]
Migrate to odlparent 1.9.0

Change-Id: I03df34a82c721da72e087241c36928a668a90d45
Signed-off-by: Thanh Ha <thanh.ha@linuxfoundation.org>
6 years agoBug 2444 - fix of several issues in yang-model-export 16/57816/12
Peter Kajsa [Thu, 25 May 2017 13:42:57 +0000 (15:42 +0200)]
Bug 2444 - fix of several issues in yang-model-export

Add Yin export of:
- action, anydata and modifier statements
- must statement in notification, input and output
- description and reference in import statements
- notification statements in data nodes
- unique statement in list statements
- optional of organisation and contact statements
- require-instance statement in leafref specification
- length statement in binary specification
- multiple base identities in identity-ref type
  and identity definition
- default values in leaf-list statement

Change-Id: I1e1662716caaf8fe118bb7db55148bc13ee81951
Signed-off-by: Peter Kajsa <pkajsa@cisco.com>
6 years agoFix sonar complaints around generic type naming 15/58815/1
Robert Varga [Tue, 13 Jun 2017 12:18:41 +0000 (14:18 +0200)]
Fix sonar complaints around generic type naming

A, D are what we are using elsewhere, so shorten AT/DT to those
to keep sonar happy.

Change-Id: I3c42eb2c5bc0e87048059619e254ab52f204ad8a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoBUG-7052: extract SimpleSchemaContext 52/58752/4
Robert Varga [Mon, 12 Jun 2017 16:42:51 +0000 (18:42 +0200)]
BUG-7052: extract SimpleSchemaContext

Some parts of EffectiveSchemaContext are not dependent on parser
proper and just fill out the blanks left by AbstractSchemaContext.

Extract these bits into SimpleSchemaContext for wider reuse.

Change-Id: I72238ec67b958e3e7918e399e9643264b11860db
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoBUG-7052: deprecate YangParseException 51/58751/3
Robert Varga [Mon, 12 Jun 2017 16:15:40 +0000 (18:15 +0200)]
BUG-7052: deprecate YangParseException

This exception is no longer used and should be removed to reduce
confusion.

Change-Id: Ie5c298c8e8a5aa4bdd11ecf5768d14f5584f1344
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoBUG-7052: Move ModuleDependencySort to yang-model-util 50/58750/3
Robert Varga [Mon, 12 Jun 2017 16:05:10 +0000 (18:05 +0200)]
BUG-7052: Move ModuleDependencySort to yang-model-util

This is a useful utility which has no dependencies on parser proper,
hence should be part of yang-model-util.

Change-Id: I8c584d61e57ec513261e59f0fa306f50747b7b5a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoBypass array-based sort 46/58746/3
Robert Varga [Mon, 12 Jun 2017 15:21:42 +0000 (17:21 +0200)]
Bypass array-based sort

This makes unneeded copies, move over to Iterable-based sort.

Change-Id: I58d4b6b31e4e7927c1139bc6e2920a4e783597f8
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoBUG-7052: Move TopologicalSort to util package 44/58744/3
Robert Varga [Mon, 12 Jun 2017 14:56:50 +0000 (16:56 +0200)]
BUG-7052: Move TopologicalSort to util package

This utility has no dependencies on parser and is generally useful.
Expose it as a beta API from util package.

Change-Id: Iba50e8c0064748498307ca88f99273532c089168
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoReformulate ModuleDependencySort in terms of a Table 09/58609/7
Robert Varga [Fri, 9 Jun 2017 12:49:36 +0000 (14:49 +0200)]
Reformulate ModuleDependencySort in terms of a Table

Rather that using nested Maps, use a Table, which is what really
the graph is.

Change-Id: Ia0b8c86142e990d7d8f88885d31a3e5ddc6a5842
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoFix checkstyle offences found by newer plugin 61/58761/1
Robert Varga [Mon, 12 Jun 2017 18:59:30 +0000 (20:59 +0200)]
Fix checkstyle offences found by newer plugin

These are not caught by the old plugin, but the 1.9.0 odlparent will
expose these failures. Fix them up before that happens.

Change-Id: I93b0eb76fda3b5b3e189dc2eb2dd9bf462d7e9db
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoEnable checkstyle in yang-model-util 13/58713/3
Robert Varga [Mon, 12 Jun 2017 07:57:55 +0000 (09:57 +0200)]
Enable checkstyle in yang-model-util

Change-Id: I52d97ddfb88eaedd168a373e55ab06e0f21b8f46
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoBug 6897: [YANG 1.1] Allow notifications to be tied to data nodes 95/58695/2
xygeng [Mon, 12 Jun 2017 07:57:50 +0000 (15:57 +0800)]
Bug 6897: [YANG 1.1] Allow notifications to be tied to data nodes

Change-Id: I6143907b8d2ee1b9e78cb9d76c0db3d252419f00
Signed-off-by: Geng Xingyuan <geng.xingyuan@zte.com.cn>
6 years agoyang-maven-plugin-it: add checkstyle 12/58712/1
Robert Varga [Sat, 10 Jun 2017 15:15:28 +0000 (17:15 +0200)]
yang-maven-plugin-it: add checkstyle

Cleans up offenses and flip the switch.

Change-Id: Icdf9256ddcdffe4215bbaadcde1bd4de6f79551d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoOptimize ModuleDependencySort 90/58590/3
Robert Varga [Fri, 9 Jun 2017 10:00:58 +0000 (12:00 +0200)]
Optimize ModuleDependencySort

This class can use some love to improve its performance:
- eliminate unneeded String.format() calls
- perform revision formatting only when needed
- streamline getModuleByNameAndRevision() to eliminate duplicate
  lookups and checks

Change-Id: Iac88e223bb108110a9081ce0e6edcdd748d5b52a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoDo not duplicate findModuleByNamespaceAndRevision() 89/58589/2
Robert Varga [Fri, 9 Jun 2017 09:34:38 +0000 (11:34 +0200)]
Do not duplicate findModuleByNamespaceAndRevision()

This method is already defined as a default method in SchemaContext,
hence there is no need to re-define it.

Change-Id: I419d502bffea6e5f25c60aefb31bf3f14dd3f58e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoDo not create temporary array for module sorting 88/58588/2
Robert Varga [Fri, 9 Jun 2017 09:17:47 +0000 (11:17 +0200)]
Do not create temporary array for module sorting

ModuleDependencySort uses an internal iterable anyway, so expose
that method and pass our temporary set, skipping an unnecessary
copy operation.

Change-Id: I2253ed4edc3837ebb9182bcb1b0069d94e2f83e7
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoBUG-7052: move EffectiveSchemaContext 43/58543/6
Robert Varga [Thu, 8 Jun 2017 17:25:38 +0000 (19:25 +0200)]
BUG-7052: move EffectiveSchemaContext

EffectiveSchemaContext is used only from reactor (and some tests),
and it produces a dependency in rfc6020. Move it to reactor and
eliminate users who do not really care.

Change-Id: I46ffbfde001f07f8a29b192377e5b93c7128c624
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoMake getOriginalCtx() give out an Optional 64/58564/5
Robert Varga [Fri, 9 Jun 2017 00:11:29 +0000 (02:11 +0200)]
Make getOriginalCtx() give out an Optional

This simplifies its users and make things more streamlined, by
eliminating a source of nulls. While we are at it, migrate some
optionals.

Change-Id: I9f5c051db33b1898ca5decd523055adbd1309855
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoBUG-6972: inline copy operation modifications 63/58563/3
Robert Varga [Thu, 8 Jun 2017 23:38:56 +0000 (01:38 +0200)]
BUG-6972: inline copy operation modifications

Copy operations is really internal to StatementContextBase hence
all the work of setting state can be done in the constructor.

This allows us to make some of the state final. While it does not
help the footprint issue, it is a stepping-stone to defining a
proper set of copy operations.

Change-Id: I0586ecb0757a3126b9e4ed3dbd0ea6c5a2547544
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoBUG-7052: remove AbstractEffectiveSchemaContext 42/58542/2
Robert Varga [Thu, 8 Jun 2017 17:16:46 +0000 (19:16 +0200)]
BUG-7052: remove AbstractEffectiveSchemaContext

This is essentially a copy of AbstractSchemaContext, so reduce
code duplication by removing it.

Change-Id: I736017a379c4796a7afed6933525b354f1f852bc
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoBUG-6972: Do not allow root StmtContext to be copied 40/58540/2
Robert Varga [Thu, 8 Jun 2017 17:02:49 +0000 (19:02 +0200)]
BUG-6972: Do not allow root StmtContext to be copied

It cannot be targeted, hence it does not make sense to copy it.
Removes a chunk of duplicate code and takes this class out of the
picture where copy operations are concerned.

Change-Id: I7a8d46ba59658a534534cd8204c43d894d017247
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoEliminate StmtContext.isRootContext() 36/58536/1
Robert Varga [Thu, 8 Jun 2017 16:43:21 +0000 (18:43 +0200)]
Eliminate StmtContext.isRootContext()

This condition is already available by checking getParent(), so there
is no need for method proliferation.

Change-Id: I7eaeca1655dbdffe1a6738f439b12afa165e30b5
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoRemove appendCopyHistory from public view 29/58529/2
Robert Varga [Thu, 8 Jun 2017 15:47:53 +0000 (17:47 +0200)]
Remove appendCopyHistory from public view

This is an internal detail of the copy process, hence it should not
be visible in StmtContext.Mutable.

Change-Id: I890af7f9f8273fc3960c4acd5340fa97f5c3c6c2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoBUG-7052: Move qnameFromArgument to StmtContextUtils 57/58457/8
Robert Varga [Thu, 8 Jun 2017 00:09:44 +0000 (02:09 +0200)]
BUG-7052: Move qnameFromArgument to StmtContextUtils

This has no dependencies on RFC6020, move it to common statement
utilities. Also takes all utility methods used by it.

This removes {BuildGlobal,Substatement}Context->rfc6020.Utils and
rfc6020.Utils -> reactor.RootStatementContext dependencies, which
by defition is Good.

Change-Id: I9ff90a0be8c4eaee2c085c9333a71c12619d2d7c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoBUG-7052: reduce StatementContextBase proliferation even more 56/58456/15
Robert Varga [Wed, 7 Jun 2017 22:51:21 +0000 (00:51 +0200)]
BUG-7052: reduce StatementContextBase proliferation even more

This splits up the mutable and immutable views of declared/effective
statements so we do not access mutable state when all we need is
immutable view.

The mutable view now has only StmtContext.Mutable, hence users get
more isolation from the reactor implementation.

Change-Id: I3e77b3837beea533590cad681c1895e047c9a2a6
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoBUG-7052: Move RecursiveObjectLeader to util 58/58458/7
Robert Varga [Thu, 8 Jun 2017 06:58:07 +0000 (08:58 +0200)]
BUG-7052: Move RecursiveObjectLeader to util

This is a general utility. Expand warnings and move it to util,
reducing more reactor->rfc6020 dependencies.

Change-Id: If21a560633f31bb25edaed8ac8e87b882f27dc83
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoBUG-7052: reduce StatementContextBase proliferation 51/58451/5
Robert Varga [Wed, 7 Jun 2017 21:31:40 +0000 (23:31 +0200)]
BUG-7052: reduce StatementContextBase proliferation

In some places we require StatementContextBase where only a simple
StmtContext or Mutable is enough. Fix those places up and move mutator
methods into Mutable.

This frees up parser.spi from reactor imports and lowers rfc6020's
reliance on reactor internals.

A nice side-effect is that we do not leak the mutable aspect of
StatementContextBase from StmtContext references.

One violation of this contract is caching of 'supportedByFeatures',
which is now costing an instanceof check. Since that is an optimization
this is a fair thing.

Change-Id: I6b4991264ef8c3322260f0962d41eeaa79b1b427
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoEnforce namespace listener compatibility 81/58381/6
Robert Varga [Tue, 6 Jun 2017 23:43:46 +0000 (01:43 +0200)]
Enforce namespace listener compatibility

If we happened to register a listener to a namespace which does not
support listening, we would silently ignore the listener. Instead
of doing that, complain loudly when such a thing occurs.

Change-Id: If77bbec91571178fe7a1ada169a824d5d8a6807c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoRefactor InferenceAction 80/58380/6
Robert Varga [Tue, 6 Jun 2017 21:50:24 +0000 (23:50 +0200)]
Refactor InferenceAction

An inference action's prerequisite may only be accessed once the
action fires. Hence require a key context to give out the value
of a particular Prerequisite.

Also audit methods interfacing to StatementContextBase and lower
their expectations where possible.

Change-Id: I71cec8647d7e013598dcdf2faf9d0a46c5105938
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoMove DeviateKind parsing 71/58271/4
Robert Varga [Mon, 5 Jun 2017 17:19:06 +0000 (19:19 +0200)]
Move DeviateKind parsing

This parser is only used in DeviateStatementImpl, so move it there
and do not clutter Utils.

Change-Id: Ie878f22e5fdd28fc2e3747a1af61a25b92a44d05
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoModifierImpl has no use for phase 79/58379/2
Robert Varga [Tue, 6 Jun 2017 20:55:00 +0000 (22:55 +0200)]
ModifierImpl has no use for phase

Since the field is unused, reduce confusion by not propagating it.

Change-Id: Id541143dffc536b4487628c301950d5f4d98385e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoCleanup effectiveStatements() access 36/58336/2
Robert Varga [Tue, 6 Jun 2017 00:41:29 +0000 (02:41 +0200)]
Cleanup effectiveStatements() access

No need to cache the field, as we are typically only iterating over
it.

Change-Id: Ia5d189deca1dbc560c77c17423814db1f7700c0d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoDo not tolerate invalid status arguments 69/58269/3
Robert Varga [Mon, 5 Jun 2017 16:50:10 +0000 (18:50 +0200)]
Do not tolerate invalid status arguments

Status must be one of current, deprecated, obsolete. Make sure we
do not leak nulls when the model supplies an illegal string, but
rather flag the offender.

Change-Id: I3301eaf2f753fe74a24dfa30d8e74cbf3a571493
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoIntern low-cardinality statement arguments 68/58268/3
Robert Varga [Mon, 5 Jun 2017 16:46:02 +0000 (18:46 +0200)]
Intern low-cardinality statement arguments

config, mandatory, ordered-by, require-instance, status and
yin-element statements have a fixed number of strings they take as
an argument, hence we can lower the memory overhead by sharing
strings instances.

Change-Id: I9b3f470466db8d3463956e4fb010c77671ac3900
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoTurn BuiltinEffectiveStatements into an enum 62/58262/4
Robert Varga [Mon, 5 Jun 2017 15:59:04 +0000 (17:59 +0200)]
Turn BuiltinEffectiveStatements into an enum

This class is effectively is an enum, make that explicit, leading to
less verbose code and smaller overall memory footprint. It also
makes for slightly better debuggability, as we will no longer see
anonymous subclasses.

Change-Id: Ib76bdfb7e22f4b0ffda916febf55fd4bd7027a4f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoDo not throw IllegalArgumentException 06/58306/2
Robert Varga [Tue, 6 Jun 2017 08:13:19 +0000 (10:13 +0200)]
Do not throw IllegalArgumentException

We have enough information to throw a SourceException, so do that
to propagate relevant diagnostics.

Change-Id: I5d7b5db1cba00fc3bea6f63025091086c6d2ed34
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoBug 8523: Add support for parsing restconf:yang-data extension 75/58175/6
Igor Foltin [Fri, 2 Jun 2017 12:41:49 +0000 (14:41 +0200)]
Bug 8523: Add support for parsing restconf:yang-data extension

Add support for yang-data extension to the YANG statement parser.
This extension is defined in RFC8040:
https://tools.ietf.org/html/rfc8040#section-8

Config and if-feature statements are ignored
when placed within a yang-data extension body.

Change-Id: Iccc1ffc76cf1ba1032552e68a4591d44f586c889
Signed-off-by: Igor Foltin <igor.foltin@pantheon.tech>
6 years agoEnforce checkstyle on yang-data-codec-xml 39/58339/2
Robert Varga [Tue, 6 Jun 2017 11:59:50 +0000 (13:59 +0200)]
Enforce checkstyle on yang-data-codec-xml

Trivial cleanups and flip the switch.

Change-Id: I24e912f00d7374a894793b4ddf903a3587d85197
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoBug 8597 - Empty description and reference of ModuleImport in some cases 54/58254/5
Peter Kajsa [Mon, 5 Jun 2017 14:37:42 +0000 (16:37 +0200)]
Bug 8597 - Empty description and reference of ModuleImport in some cases

If a module import is specified without 'revision-date' or with
'revision-date' equal to '1970-01-01', ModuleImport does not have
filled description and reference, even though they are declared
in yang source.

Change-Id: I217d09f5f3718aee6557bec309f53c278895ebe7
Signed-off-by: Peter Kajsa <pkajsa@cisco.com>
6 years agoAdd missing version declaration 34/58334/1
Robert Varga [Tue, 6 Jun 2017 11:28:21 +0000 (13:28 +0200)]
Add missing version declaration

We have unfortunately had a missing version in the aggregator,
which then picks up the parent's version. Fix that.

Change-Id: Ifcbf2a63d295287a59495cebc910e2986669a727
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoMigrate to odlparent 1.8.0-Carbon 94/58294/1
Thanh Ha [Tue, 6 Jun 2017 02:10:11 +0000 (22:10 -0400)]
Migrate to odlparent 1.8.0-Carbon

Per request of odlparent project we are downgrading all Nitrogen
projects to use the released odlparent 1.8.0-Carbon to allow for the
odlparent project to start performing semver style releases.

Jira: RELENG-159
RT: 41406
Change-Id: Ib5afa65181af8837ebd3f34cb180f42424d9f4b2
Signed-off-by: Thanh Ha <thanh.ha@linuxfoundation.org>
6 years agoAdd vim gitignore rule 86/58286/2
Daniel Farrell [Mon, 5 Jun 2017 22:08:09 +0000 (18:08 -0400)]
Add vim gitignore rule

Change-Id: Ieef2faf55a4cf365bb2a12a16a1a7ccab0db4254
Signed-off-by: Daniel Farrell <dfarrell@redhat.com>
6 years agoEnable checkstyle on objectcache and mockito-config 84/58284/1
Robert Varga [Mon, 5 Jun 2017 21:12:41 +0000 (23:12 +0200)]
Enable checkstyle on objectcache and mockito-config

Just a few fixes and flip the switch.

Change-Id: I83d8b9b4e959e03a912d2cbf4c3c26311af4fc0b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoEnforce checkstyle in maven-plugin 78/58278/1
Robert Varga [Mon, 5 Jun 2017 18:57:47 +0000 (20:57 +0200)]
Enforce checkstyle in maven-plugin

Simple fixes to code and flip the switch.

Change-Id: I06bdd3d3e49c503c390a8cb46ecfeaa8fdf405d8
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoBug 4640: Change semantic-version to openconfig-version 47/58247/1
Igor Foltin [Mon, 5 Jun 2017 13:18:31 +0000 (15:18 +0200)]
Bug 4640: Change semantic-version to openconfig-version

The concept of semantic version already exists in the
openconfig-extensions YANG module in the form of
openconfig-version extension.

Rename the internal representation of semantic-version
statement to openconfig-version in the yang-parser-impl module.

Also adjust existing unit tests accordingly.

Change-Id: Ie647bfce5c1a462e6d269103e55a13e08f163dc6
Signed-off-by: Igor Foltin <igor.foltin@pantheon.tech>
6 years agoEnforce checkstyle in yang-data-util 41/58241/1
Robert Varga [Mon, 5 Jun 2017 11:58:03 +0000 (13:58 +0200)]
Enforce checkstyle in yang-data-util

Fix up code formatting and activate enforcement.

Change-Id: I92419f38833fea7b68fe13a20619b4d1641f68de
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoActivate checkstyle in yang-data-transform 40/58240/1
Robert Varga [Mon, 5 Jun 2017 11:38:35 +0000 (13:38 +0200)]
Activate checkstyle in yang-data-transform

Fix offences and make sure we enforce checkstyle.

Change-Id: Ic227322a5ce8520fd81ea17f98e43dda1ed55e2c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoActivate checkstyle in yang-data-jaxen 39/58239/1
Robert Varga [Mon, 5 Jun 2017 11:33:59 +0000 (13:33 +0200)]
Activate checkstyle in yang-data-jaxen

Cleanup the code and enforce checkstyle.

Change-Id: Ieb6087afc1b98065bc2e0c941dd5ff0277c8244b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoCleanup checkstyle in yang-{data,model}-api 30/58230/1
Robert Varga [Mon, 5 Jun 2017 08:36:36 +0000 (10:36 +0200)]
Cleanup checkstyle in yang-{data,model}-api

Clean up code and activate enforcement.

Change-Id: I66669e0ff80aefa6f3b187337d84efe73b10b320
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoBug 7037 - Improve mapping of YANG extensions 17/55717/11
Peter Kajsa [Thu, 20 Apr 2017 09:49:14 +0000 (11:49 +0200)]
Bug 7037 - Improve mapping of YANG extensions

Each extension definition is able to create an unknown statement
form of a regular yang statement. Created definitions of regular yang
statements are created only once per each yang statement and extension
definition. So we do not create a new ModelDefinedStatementDefinition
and a corresponding UnknownStatementImpl.Definition for each instance
of a regular yang statement when it is placed in an unknown statement's
body.

Change-Id: I5613eb36273e6b512637fb14456c64b023df3f1f
Signed-off-by: Peter Kajsa <pkajsa@cisco.com>
6 years agoConsolidate range to string code 20/57820/5
Robert Varga [Wed, 24 May 2017 22:52:22 +0000 (00:52 +0200)]
Consolidate range to string code

Contraint range emission code is duplicate, consolidate and speed
it up. Also fix a few sonar and eclipse warnings.

Change-Id: I9826200c0dedf9e8d1bc7b7d53a7a13655cbe283
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoFix eclipse/checkstyle warnings 16/58216/9
Robert Varga [Sun, 4 Jun 2017 06:43:11 +0000 (08:43 +0200)]
Fix eclipse/checkstyle warnings

concepts/util should have their checkstyle enforced.

Change-Id: I752ce3c75e69446a1284b511b5221553d7187bb5
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoRevert "Bug 4640: Change semantic-version to openconfig-version" 18/58218/2
Robert Varga [Sun, 4 Jun 2017 15:56:03 +0000 (17:56 +0200)]
Revert "Bug 4640: Change semantic-version to openconfig-version"

This reverts commit e826b441fd88057793b5cea7e784522ea7adcd40.

Change-Id: I823a6789a02d47d03d7c2617310221a517c16ca0
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoReplace LOGGER/logger/log by LOG 86/58186/2
David Suarez [Fri, 2 Jun 2017 18:51:46 +0000 (20:51 +0200)]
Replace LOGGER/logger/log by LOG

Replace LOGGER/logger/log by LOG to follow the OpenDaylight
recommendations [1].

[1]
https://wiki.opendaylight.org/view/BestPractices/Logging_Best_Practices
Change-Id: Ia00a0401a433c445c1fcd17ab4bc436a04abe209
Signed-off-by: David Suarez <david.suarez.fuentes@ericsson.com>
6 years agoAdd hook for interning raw argument 84/58184/3
Robert Varga [Wed, 31 May 2017 16:42:25 +0000 (18:42 +0200)]
Add hook for interning raw argument

Type statement typically has a low cardinality of arguments, hence
we can reuse the same object for things like 'type uint32'.

Change-Id: I34c11e1d1f18f8ecaf260d55eb20ffd09d8ae4b0
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 00c0868216727e5333f9af896a7a26ddff7068d6)

6 years agoBUG 8566 Introduce a fallback for ChoiceSchemaNode lookup 06/58106/2
Tomas Cere [Wed, 31 May 2017 11:28:17 +0000 (13:28 +0200)]
BUG 8566 Introduce a fallback for ChoiceSchemaNode lookup

With the way parsing callbacks are handled between netconf and yangtools
theres no hook for case nodes, which we are missing in the path when doing
SchemaNode lookup. This introduces a callback that checks Choice children
for a possible match once the normal lookup fails.

Change-Id: Ieefc6771ec3c6892e00103cbab77f6340f197d62
Signed-off-by: Tomas Cere <tcere@cisco.com>
6 years agominor NotificationNodeContainer Javadoc fix 58/57958/2
Martin Ciglan [Mon, 29 May 2017 10:51:13 +0000 (12:51 +0200)]
minor NotificationNodeContainer Javadoc fix

Change-Id: Ie6cde12272adc0d81236b1932a29b32161642934
Signed-off-by: Martin Ciglan <martin.ciglan@pantheon.tech>
6 years agoBug 4640: Change semantic-version to openconfig-version 69/57769/3
Igor Foltin [Wed, 24 May 2017 12:39:34 +0000 (14:39 +0200)]
Bug 4640: Change semantic-version to openconfig-version

The concept of semantic version already exists in the
openconfig-extensions YANG module in the form of
openconfig-version extension.

Refactor the semantic version related code to use
the openconfig-version naming.

Adjust existing unit tests accordingly.

Change-Id: I25f4f1a6e070b214d1f8ae466639c6dd41899a09
Signed-off-by: Igor Foltin <igor.foltin@pantheon.tech>
6 years agoAdd XMLInputFactory to UntrustedXML 66/57566/2
Robert Varga [Fri, 19 May 2017 18:15:27 +0000 (20:15 +0200)]
Add XMLInputFactory to UntrustedXML

Similar to other ways of accessing XML, this adds a convenience
accessor to XMLInputFactory.

Change-Id: I43f4e0fa2452d13b60e244d03cbf9d68bc391735
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoFix a couple of warnings 03/57803/1
Robert Varga [Thu, 25 May 2017 07:30:25 +0000 (09:30 +0200)]
Fix a couple of warnings

These methods can be made static.

Change-Id: I6943921e69b5291d6586ffba42fc246de80bd82a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoFix a few warnings 44/57644/2
Robert Varga [Mon, 22 May 2017 17:35:26 +0000 (19:35 +0200)]
Fix a few warnings

Raw types mostly.

Change-Id: If1facf5773c6b0ed3e1c1a5ae6ae5f1ceb862216
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoCleanup JsonParserStream 95/57595/2
Robert Varga [Sun, 21 May 2017 22:25:07 +0000 (00:25 +0200)]
Cleanup JsonParserStream

We can speed up namesakes manipulation by checking the return value
of Set.add(). Also use Preconditions.checkState().

Change-Id: I5759c426654914616925ed9144cbd909ec52245f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoFix attribute namespace lookup 87/57587/6
Robert Varga [Sun, 21 May 2017 13:36:42 +0000 (15:36 +0200)]
Fix attribute namespace lookup

During review process of Id214b78849998cf54e087685dcc78e3ded74ab69
we have broken writeAttributes() in the sense it is now sensitive
to attribute namespaces not hahving a prefix assigned in the writer.

Attributes are seldom used, but NETCONF uses them without emitting
them in the writer, hence the codec is not a drop-in replacement.

Add back the ability to map attributes, but also emit a warning if
the caller has not set up the namespace. The warning is emitted
only once for each namespace.

Also modify RandomPrefix to consult the NamespaceContext for already
existing prefix mappings.

Change-Id: Iaffcbfde06b7dffbf6e6ed02c0ba7d73fd053d6a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
6 years agoBug 8307: Add the option for activating deviation statements 52/56452/5
Igor Foltin [Tue, 16 May 2017 12:04:38 +0000 (14:04 +0200)]
Bug 8307: Add the option for activating deviation statements

YANG statement parser currently resolves all deviation statements.
Add the option to specify which of the processed YANG modules
can be deviated by the specified YANG modules. This information is
passed down to the statement parser in the form of
Map<QNameModule, Set<QNameModule>>. If no deviations should be
activated, use an empty Map. In default mode, that is when
the Map is not provided at all, all deviations are activated.

This patch handles only the statement reactor part.
SchemaContextFactory should be fixed in a separate patch.

Moreover, change the rules for allowed deviation target path.
A deviation statement cannot target nodes in the same module
as the one it is defined in. Adjust existing unit tests accordingly.

Change-Id: Ica0f8c09218e50fd4c3efeb4dc08acb4fa418798
Signed-off-by: Igor Foltin <ifoltin@cisco.com>
Signed-off-by: Igor Foltin <igor.foltin@pantheon.tech>
6 years agoBug 8083: Preliminary unit tests 06/54106/4
Igor Foltin [Thu, 30 Mar 2017 13:43:06 +0000 (15:43 +0200)]
Bug 8083: Preliminary unit tests

A bunch of unit tests which were used
for the purpose of investigation of this bug

Change-Id: I393d3fba5a0046173c1da4993f3dbd40acddd833
Signed-off-by: Igor Foltin <ifoltin@cisco.com>
6 years agoBug 7844 - Unable to create LeafRefContext for leafref 46/56946/5
Peter Kajsa [Fri, 12 May 2017 12:10:50 +0000 (14:10 +0200)]
Bug 7844 - Unable to create LeafRefContext for leafref

In order to get correct namespace for a prefix used in a leafref
path we need to find the module which contains definition
of leafref path and then a prefix need to be resolved based on
imports of this module.

Change-Id: Icfb599783e90e44935d5e18eea23b0ac0d86cbf0
Signed-off-by: Peter Kajsa <pkajsa@cisco.com>
6 years agoDo not use FileInputStream 53/56953/2
Robert Varga [Fri, 12 May 2017 13:49:47 +0000 (15:49 +0200)]
Do not use FileInputStream

https://www.cloudbees.com/blog/fileinputstream-fileoutputstream-considered-harmful

Change-Id: Ic3c9fab4ba21ac9da05d96e9a83597426f67331a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoMake repo depend on single features only 67/56567/1
Vratko Polak [Wed, 26 Apr 2017 14:13:31 +0000 (16:13 +0200)]
Make repo depend on single features only

Change-Id: I33b67267ebcbab193acbfe72611f02a0d0e32b4b
Signed-off-by: Vratko Polak <vrpolak@cisco.com>
(cherry picked from commit aed2812185a7c283e174d5aca499ca9aa048e4ed)

7 years agoSilence all info messages about all features being used 97/56097/2
Robert Varga [Wed, 26 Apr 2017 16:13:26 +0000 (18:13 +0200)]
Silence all info messages about all features being used

This message:

2017-04-26 17:55:00,136 | INFO  | l for user karaf | CrossSourceStatementReactor      | 85 - org.opendaylight.yangtools.yang-parser-impl - 1.1.0.SNAPSHOT | Set of supported features has not been provided, so all features are supported by default.

is featured prominently during startup operations. As it turns out,
we do not have a proper API to express 'use everything', hence the
callers, which really mean that, are passing down nulls.

Expose proper Optional-based methods which are as expressive, thus
allowing us to side-step this pesky flood.

Change-Id: I11c95c58be01deac8bbb587883d152fc6e647a6c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoFix warnings in EffectiveSchemaContextTest 95/56095/2
Robert Varga [Wed, 26 Apr 2017 16:16:09 +0000 (18:16 +0200)]
Fix warnings in EffectiveSchemaContextTest

Returned values are a set, hence the instanceof check really is
just a non-null check. Fix this, silencing eclipse.

Change-Id: Ib7456b5b4152a68cdef2539481a27ccc8fb1d9c7
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoBug 8291 - Unit test 45/56045/3
Peter Kajsa [Wed, 26 Apr 2017 09:08:56 +0000 (11:08 +0200)]
Bug 8291 - Unit test

Added unit test for Bug 8291.

Change-Id: Iaf41b01924f3d644b94620d2b72968725b2b2177
Signed-off-by: Peter Kajsa <pkajsa@cisco.com>
7 years agoBUG-8291: expose additional DataTreeFactory methods 25/56025/2
Robert Varga [Tue, 25 Apr 2017 20:32:06 +0000 (22:32 +0200)]
BUG-8291: expose additional DataTreeFactory methods

There are use cases when we want to instantiate a DataTree rooted
at a list itself, which is something we cannot discover from
YangInstanceIdentifier because lists and containers share the same
identifier.

Therefore we need to expose a factory method which takes an initial
SchemaContext, from which we can derive the appropriate root node.

While we are at it, we also expose another factory method, which
takes additionally the initial tree state. Since the state is not
empty, we can run full validation on it before we give out the
DataTree -- allowing us to perform full enforcement of mandatory
nodes.

Change-Id: Id362234b9ef42d93ae01577809fb004864d05d1c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoBUG-8123: fix URL naming mixup 12/56012/1
Robert Varga [Tue, 25 Apr 2017 17:17:33 +0000 (19:17 +0200)]
BUG-8123: fix URL naming mixup

As it turns out URL.getFile() does the wrong thing, leading to us
taking the whole path as the module name, resulting in wrong comparison.

Change the code to analyze URL.getPath(), stripping it down to the
last component.

Change-Id: Ica3e387caf2924712151f4da5939487872f8e98c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoYANG XPath functions - unit tests and bugfix 20/55820/1
Igor Foltin [Fri, 21 Apr 2017 15:06:37 +0000 (17:06 +0200)]
YANG XPath functions - unit tests and bugfix

Add more unit tests for YANG XPath functions
in yang-data-jaxen.

Fix deref function for leafrefs that reference
a leaf-list node.

Change-Id: I7bfe90a3a1a101b95a3b8ea3b1dd42963e5ea264
Signed-off-by: Igor Foltin <ifoltin@cisco.com>
7 years agoBUG-8123: be better at guessing identifiers 58/54958/3
Robert Varga [Wed, 12 Apr 2017 13:54:23 +0000 (15:54 +0200)]
BUG-8123: be better at guessing identifiers

Given an URI we need to attempt to interpret it to improve our
guess of the module name and revision.

Change-Id: I4d74b06fb9f949c538911d215b6d90a383560f1f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 8bfdcd0056b08db284a87b55913691c0187c34bb)
(cherry picked from commit 9f390185b2869fd215a7cb1ee86b1760506d8662)

7 years agoBug 7050 - Document parser-impl package structure 40/54840/8
Peter Kajsa [Wed, 12 Apr 2017 08:27:57 +0000 (10:27 +0200)]
Bug 7050 - Document parser-impl package structure

Added initial javadoc to yang statement parser packages.

Change-Id: I2f18eb4ad01fee297f52953f2ef2aae24a69d253
Signed-off-by: Peter Kajsa <pkajsa@cisco.com>
7 years agoBug 7038 - Rework 'type decimal64' lookup 24/54524/7
Peter Kajsa [Thu, 23 Mar 2017 16:12:33 +0000 (17:12 +0100)]
Bug 7038 - Rework 'type decimal64' lookup

Fix of hack in SourceSpecificContext, which attempts to lookup specific
complex types by considering only a QName's localName and routes
it via BUILTIN_TYPE_SUPPORTS to specific statement support.

This solution introduces argument specific statement sub-definitions.
If a StatementSupport has some argument specific sub-supports, processing
of a statement is routed to appropriate sub-support based on given
statement argument.

Change-Id: I602c0a919107a633f594a4393299f3f6623bd1c5
Signed-off-by: Peter Kajsa <pkajsa@cisco.com>
7 years agoImplement DocumentedNode interface to RevisionEffectiveStatementImpl 16/54816/3
Jakub Toth [Tue, 11 Apr 2017 21:49:18 +0000 (23:49 +0200)]
Implement DocumentedNode interface to RevisionEffectiveStatementImpl
for overriding getDescription() and getReference() methods for
exposing it to others.

Change-Id: Ida77679f952f795d06a044c0fdc8f5c40d9455a7
Signed-off-by: Jakub Toth <jatoth@cisco.com>
7 years agoUpdate the developer docs 42/54942/1
Igor Foltin [Thu, 13 Apr 2017 07:59:35 +0000 (09:59 +0200)]
Update the developer docs

Update the docs related to the usage of
if-feature resolution mode of the YANG statement parser.

Change-Id: Id2201d7082b2b744f98c09801530bc8ad2205d65
Signed-off-by: Igor Foltin <ifoltin@cisco.com>
7 years agoBUG-7698: do not allow nulls in registrations 52/51152/5
Robert Varga [Fri, 27 Jan 2017 20:05:19 +0000 (21:05 +0100)]
BUG-7698: do not allow nulls in registrations

This updates the AbstractObjectRegistration to not allow
nulls and updates ObjectRegistration to promise it will
not return a null from getInstance().

Change-Id: I10229d58af4a9f26f2f18128302b45bc721e546f
Signed-off-by: Robert Varga <rovarga@cisco.com>
7 years agoBump versions by x.(y+1).z for next dev cycle 31/54731/1
Anil Belur [Tue, 11 Apr 2017 01:46:03 +0000 (11:46 +1000)]
Bump versions by x.(y+1).z for next dev cycle

Change-Id: I8e7c50cd46198955261abc44a15fed8f0f60d671
Signed-off-by: Anil Belur <abelur@linuxfoundation.org>
7 years agoBug 7847: Implement YANG 1.1 XPath functions in YangFunctionContext 25/54525/3
Igor Foltin [Fri, 7 Apr 2017 15:17:23 +0000 (17:17 +0200)]
Bug 7847: Implement YANG 1.1 XPath functions in YangFunctionContext

Introduce implementation of functions re-match, deref, derived-from,
derived-from-or-self, enum-value and bit-is-set in the yang-data-jaxen's
YangFunctionContext.

The functionality introduced in this patch is beta-quality and will
need more thorough testing in the future

Change-Id: Ia89f8b50dd7537cfafc2297ada8720648050bdbd
Signed-off-by: Igor Foltin <ifoltin@cisco.com>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoBug 8126 - Some augments are not being processed 65/54365/5
Peter Kajsa [Wed, 5 Apr 2017 13:55:08 +0000 (15:55 +0200)]
Bug 8126 - Some augments are not being processed

If a node is marked as mandatory (e.g. "leaf" with "mandatory true;"),
yang statement parser does not perform augmentation of such node into
a target node in different module even though one of ancestors of the
target node is a non-mandatory choice or a non-mandatory list from the
same namespace as the mandatory node and so in fact it should not
be considered as augmenatation of mandatory node into different module
anymore and augmentation should be performed.

We also increase severity of the augment error log from debug to error.

Change-Id: Icb8554ba61ce0aa0fa25541dd5675f3aa8ba3d1b
Signed-off-by: Peter Kajsa <pkajsa@cisco.com>
7 years agoBUG-7833: Fix identityref codecs 70/53870/7
Robert Varga [Sun, 26 Mar 2017 19:38:00 +0000 (21:38 +0200)]
BUG-7833: Fix identityref codecs

Introduce QNameCodecUtil to help JSON and XML codecs correctly implement
their identityref codecs. As it turns out, both only need to provide
proper mapping functions without having to deal with multiple codec
hierarchies.

The patch is also more strict about parsing the string, as it rejects
malformed identityrefs, i.e. those which contain invalid characters.

This fixes BUG-7833, which is triggered by invalid PUT, where we parse
an empty string as a null identityref.

Change-Id: I1f3086a0f9e930f7782dff8d6c39329d4b28ed14
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoBUG-7983: unify JSONCodec and XmlCodec methods 69/53869/5
Robert Varga [Sun, 26 Mar 2017 18:06:21 +0000 (20:06 +0200)]
BUG-7983: unify JSONCodec and XmlCodec methods

This patch introduces TypeAwareCodec to define the common interface
which both these codecs implement. We adjust methods to conform
to this interface.

Change-Id: I25ccaf56c2e6013dee01016efe5fd7c960790f70
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoBUG-7983: make XmlCodecFactory a subclass of AbstractCodecFactory 65/53865/4
Robert Varga [Sun, 26 Mar 2017 15:49:03 +0000 (17:49 +0200)]
BUG-7983: make XmlCodecFactory a subclass of AbstractCodecFactory

AbstractCodecFactory contains everything we need for efficient caching,
the only problem we need to solve is binding to NamespaceContext. This
patch does exactly that, decoupling XmlCodec from the generic Codec
interface, so that serialization and deserialization paths are explicit.

This flushes out the fact that the codecs are not used in the egress
path at all and rely on TypeDefinitionAwareCodec instead. That deficiency
will be fixed in a subsequent patch.

Change-Id: I0bdf8af673893f2dc4fcc8842b64f9bed1bc5236
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoSpeed up XpathStringParsingPathArgumentBuilder 71/53871/7
Robert Varga [Sun, 26 Mar 2017 20:30:13 +0000 (22:30 +0200)]
Speed up XpathStringParsingPathArgumentBuilder

Use an internal ArrayList to lower the amount of pointer-chasing
we do. Also make sure we format the error string only when it is
necessary.

Change-Id: Ic2ce96b45dd44b1d1da24ceb9452a2548f883446
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoBUG-7983: factor out AbstractCodecFactory 64/53864/2
Robert Varga [Sun, 26 Mar 2017 14:57:37 +0000 (16:57 +0200)]
BUG-7983: factor out AbstractCodecFactory

Since the type decomposition logic can be shared between XML and
JSON codecs, factor it out into yang.data.util.codec, where it
can be efficiently shared.

JSONCodecFactory becomes a pure type binding provider, with all
of the logic abstracted out. We also reduce CodecCache method
visibility, as they are a package-private implementation detail.

Change-Id: I58e50dd966915e4e1a691add517c9a6d0b647c80
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoBUG-7983: extract codec caching from JSONCodecFactory 63/53863/2
Robert Varga [Sun, 26 Mar 2017 14:09:40 +0000 (16:09 +0200)]
BUG-7983: extract codec caching from JSONCodecFactory

Caching aspect of CodecFactory is independent of the actual codec,
factor it out for reuse with XML codecs.

Change-Id: Ib6678a038482a2f50a8a55a0065158e3bc840cd8
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoBUG-7996: expose different implementations of JSONCodecFactory 01/53801/2
Robert Varga [Fri, 24 Mar 2017 16:37:42 +0000 (17:37 +0100)]
BUG-7996: expose different implementations of JSONCodecFactory

We have four different implementations of JSONCodecFactory, each useful
in different circumstances. Rather than having a singleton create()
method, expose multiple methods so users can pick and choose the
implementation which is best suited to their use case.

Change-Id: I1c2e48ed2bc2734447e08e043d8505b741f1e401
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoBUG-7996: reshuffle caching logic 20/53620/10
Robert Varga [Tue, 21 Mar 2017 16:29:33 +0000 (17:29 +0100)]
BUG-7996: reshuffle caching logic

This patch reworks JSONCodecFactory internals to split the codecs
by their type, allowing simple codecs to be reused across multiple
leaves.

Efficient implementation of this split requires exposing individual
StringCodec classes -- as we need to avoid the broken union codec.
This also has the added benefit of not performing instanceof checks
multiple types.

JSONCodec interface is updated to not be directly bound to the Codec
interface, but rather provide the GSON-specific methods and to expose
the expected data type class. This change allows us to optimize
the serialization side of union codecs, as they can check the input
data without incurring a ClassCastException.

Union codec is decoupled from AbstractStringUnionCodec and contains
pre-computed codecs. This is needed to eliminate the dependency
on the JSONCodecFactory itself and allow for efficient caching
of the codec without incurring further overhead of having to deal
with mutable codec.

Change-Id: I05f18fbaa4b3160d2a7017ec2428d1577f54af7d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoBug 6183 - Shorthand case should create case node in schema tree 39/53139/11
Peter Kajsa [Fri, 10 Mar 2017 13:10:56 +0000 (14:10 +0100)]
Bug 6183 - Shorthand case should create case node in schema tree

According to Rfc7950, if a case statement is omitted and implicit case
node is created, schema node identifiers MUST always explicitly include
the implicit case node identifiers.

This patch deals with both Yang 1.1 and Yang 1 in the same way.

Change-Id: I64fef2aee85855cb6300318f7c97e694b3105a0a
Signed-off-by: Peter Kajsa <pkajsa@cisco.com>
7 years agoTrim down TypeDefinitionAwareCodec 53/53653/2
Robert Varga [Wed, 22 Mar 2017 07:29:37 +0000 (08:29 +0100)]
Trim down TypeDefinitionAwareCodec

Storing an Optional runs contrary to its usual role and wastes
memory. We can simply calculate the optional and have a nullable
internal field, saving ~16 bytes per codec instance.

Change-Id: I184fbd8f390bf5703b3342a6dd09de599c236554
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 years agoCleanup codecs a bit 69/53469/5
Robert Varga [Fri, 17 Mar 2017 09:49:43 +0000 (10:49 +0100)]
Cleanup codecs a bit

- prevent unnecessary boxing
- add type arguments
- static methods
- do not use deprecated methods

Change-Id: Ic129d327804d3b28066c84d6101cbe262e2101b1
Signed-off-by: Robert Varga <rovarga@cisco.com>
7 years agoBUG-7996: Use weak keys in SharedJSONCodecFactory 88/53388/7
Robert Varga [Thu, 16 Mar 2017 08:34:42 +0000 (09:34 +0100)]
BUG-7996: Use weak keys in SharedJSONCodecFactory

This speeds up hashing, as weak keys are forcing identity-based
hashCode/equals().

Change-Id: If6b0323ac8e80fc8833a13ff5b4406e908e7f558
Signed-off-by: Robert Varga <rovarga@cisco.com>