From e5e06d81bed0a7cb520e94a4b018d0e2bb7f0c62 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Fri, 23 Apr 2021 09:29:09 +0200 Subject: [PATCH] Centralize substatement validators Most statement supports have a constant validator and we end up duplicating things. Furthermore we are ending up with megamorphic dispatch which could easily be squashed into a simple field read. AbstractStatementSupport now requires an explicit SubstatementValidator, which it stores in a field, thus reducing the number of StatementSupport.substatementValidator() instances. Change-Id: I4d7f6247403ee64b65ddcd81ac91a5e8eef20539 Signed-off-by: Robert Varga --- ...AbstractIdentityAwareStatementSupport.java | 12 +----- .../AugmentIdentifierStatementSupport.java | 8 +--- .../ContextInstanceStatementSupport.java | 6 ++- .../ContextReferenceStatementSupport.java | 6 ++- .../InstanceTargetStatementSupport.java | 8 +--- .../RpcContextReferenceStatementSupport.java | 8 +--- .../AbstractHashedValueStatementSupport.java | 13 ++----- .../EncryptedValueStatementSupport.java | 6 ++- .../parser/HashedValueStatementSupport.java | 6 ++- yang/rfc6241-parser-support/pom.xml | 1 - ...lterElementAttributesStatementSupport.java | 7 +--- .../DefaultDenyAllStatementSupport.java | 7 +--- .../DefaultDenyWriteStatementSupport.java | 7 +--- .../rfc6643/parser/AliasStatementSupport.java | 9 +---- .../parser/DefValStatementSupport.java | 9 +---- .../parser/DisplayHintStatementSupport.java | 9 +---- .../parser/ImpliedStatementSupport.java | 9 +---- .../parser/MaxAccessStatementSupport.java | 9 +---- .../rfc6643/parser/OidStatementSupport.java | 9 +---- .../rfc6643/parser/SubIdStatementSupport.java | 9 +---- .../parser/AnnotationStatementSupport.java | 7 +--- .../parser/YangDataStatementSupport.java | 16 +++----- .../parser/MountPointStatementSupport.java | 7 +--- .../stmt/OpenConfigVersionSupport.java | 7 +--- .../AbstractAugmentStatementSupport.java | 5 ++- .../AugmentStatementRFC6020Support.java | 7 +--- .../AugmentStatementRFC7950Support.java | 7 +--- .../AbstractDeviateStatementSupport.java | 9 ++--- .../extension/ExtensionStatementSupport.java | 7 +--- .../UnrecognizedStatementSupport.java | 9 +---- .../AbstractIfFeatureStatementSupport.java | 12 ++---- .../stmt/import_/ImportStatementSupport.java | 10 +---- .../leaf_list/LeafListStatementSupport.java | 12 +----- .../stmt/list/ListStatementSupport.java | 11 +----- .../AbstractImplicitStatementSupport.java | 9 +++-- ...actOperationContainerStatementSupport.java | 6 ++- .../stmt/meta/ActionStatementSupport.java | 7 +--- .../stmt/meta/AnydataStatementSupport.java | 7 +--- .../stmt/meta/AnyxmlStatementSupport.java | 7 +--- .../stmt/meta/ArgumentStatementSupport.java | 7 +--- .../stmt/meta/BaseStatementSupport.java | 7 +--- .../stmt/meta/BelongsToStatementSupport.java | 7 +--- .../stmt/meta/BitStatementSupport.java | 10 +---- .../stmt/meta/CaseStatementSupport.java | 12 +----- .../stmt/meta/ChoiceStatementSupport.java | 9 +---- .../stmt/meta/ConfigStatementSupport.java | 7 +--- .../stmt/meta/ContactStatementSupport.java | 7 +--- .../stmt/meta/ContainerStatementSupport.java | 12 +----- .../stmt/meta/DefaultStatementSupport.java | 7 +--- .../meta/DescriptionStatementSupport.java | 7 +--- .../stmt/meta/DeviationStatementSupport.java | 19 ++++----- .../stmt/meta/EnumStatementSupport.java | 12 +----- .../meta/ErrorAppTagStatementSupport.java | 11 ++---- .../meta/ErrorMessageStatementSupport.java | 7 +--- .../stmt/meta/FeatureStatementSupport.java | 7 +--- .../meta/FractionDigitsStatementSupport.java | 7 +--- .../stmt/meta/GroupingStatementSupport.java | 12 +----- .../stmt/meta/IdentityStatementSupport.java | 11 +----- .../stmt/meta/IncludeStatementSupport.java | 11 +----- .../stmt/meta/InputStatementSupport.java | 12 +----- .../stmt/meta/KeyStatementSupport.java | 8 +--- .../stmt/meta/LeafStatementSupport.java | 7 +--- .../stmt/meta/LengthStatementSupport.java | 7 +--- .../stmt/meta/MandatoryStatementSupport.java | 7 +--- .../meta/MaxElementsStatementSupport.java | 7 +--- .../meta/MinElementsStatementSupport.java | 7 +--- .../stmt/meta/ModifierStatementSupport.java | 7 +--- .../stmt/meta/MustStatementSupport.java | 7 +--- .../stmt/meta/NamespaceStatementSupport.java | 7 +--- .../stmt/meta/OrderedByStatementSupport.java | 7 +--- .../meta/OrganizationStatementSupport.java | 7 +--- .../stmt/meta/OutputStatementSupport.java | 12 +----- .../stmt/meta/PositionStatementSupport.java | 7 +--- .../stmt/meta/PrefixStatementSupport.java | 7 +--- .../stmt/meta/PresenceStatementSupport.java | 7 +--- .../stmt/meta/RangeStatementSupport.java | 7 +--- .../stmt/meta/ReferenceStatementSupport.java | 7 +--- .../meta/RequireInstanceStatementSupport.java | 7 +--- .../meta/RevisionDateStatementSupport.java | 7 +--- .../stmt/meta/RevisionStatementSupport.java | 7 +--- .../stmt/meta/RpcStatementSupport.java | 7 +--- .../stmt/meta/StatusStatementSupport.java | 7 +--- .../stmt/meta/TypedefStatementSupport.java | 7 +--- .../stmt/meta/UniqueStatementSupport.java | 7 +--- .../stmt/meta/UnitsStatementSupport.java | 7 +--- .../stmt/meta/ValueStatementSupport.java | 7 +--- .../stmt/meta/WhenStatementSupport.java | 17 +++----- .../meta/YangVersionStatementSupport.java | 7 +--- .../stmt/meta/YinElementStatementSupport.java | 11 ++---- .../stmt/module/ModuleStatementSupport.java | 10 +---- .../AbstractNotificationStatementSupport.java | 5 ++- .../NotificationStatementRFC6020Support.java | 39 ++++++++----------- .../NotificationStatementRFC7950Support.java | 7 +--- .../stmt/path/PathStatementSupport.java | 7 +--- .../stmt/pattern/PatternStatementSupport.java | 12 +----- .../stmt/refine/RefineStatementSupport.java | 11 +----- .../submodule/SubmoduleStatementSupport.java | 11 +----- .../type/AbstractTypeStatementSupport.java | 11 ++---- .../stmt/type/AbstractTypeSupport.java | 7 +++- .../stmt/type/BitsSpecificationSupport.java | 7 +--- .../type/Decimal64SpecificationSupport.java | 7 +--- .../stmt/type/EnumSpecificationSupport.java | 9 +---- ...dentityRefSpecificationRFC6020Support.java | 26 ------------- ...dentityRefSpecificationRFC7950Support.java | 29 -------------- ...a => IdentityRefSpecificationSupport.java} | 30 ++++++++++---- ...nstanceIdentifierSpecificationSupport.java | 7 +--- .../LeafrefSpecificationRFC6020Support.java | 26 ------------- .../LeafrefSpecificationRFC7950Support.java | 33 ---------------- ....java => LeafrefSpecificationSupport.java} | 28 ++++++++++--- .../type/TypeStatementRFC7950Support.java | 4 +- .../stmt/type/UnionSpecificationSupport.java | 7 +--- .../stmt/uses/UsesStatementSupport.java | 27 ++++++------- .../plugin/ThirdPartyExtensionSupport.java | 8 +--- .../meta/AbstractBooleanStatementSupport.java | 5 ++- .../meta/AbstractEmptyStatementSupport.java | 6 ++- .../AbstractInternedStatementSupport.java | 6 ++- ...bstractInternedStringStatementSupport.java | 6 ++- .../meta/AbstractQNameStatementSupport.java | 6 ++- .../AbstractSchemaTreeStatementSupport.java | 6 ++- .../spi/meta/AbstractStatementSupport.java | 9 ++++- .../meta/AbstractStringStatementSupport.java | 6 ++- .../spi/meta/ForwardingStatementSupport.java | 4 +- .../parser/spi/meta/StatementSupport.java | 13 +++---- 123 files changed, 294 insertions(+), 885 deletions(-) delete mode 100644 yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/type/IdentityRefSpecificationRFC6020Support.java delete mode 100644 yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/type/IdentityRefSpecificationRFC7950Support.java rename yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/type/{AbstractIdentityRefSpecificationSupport.java => IdentityRefSpecificationSupport.java} (76%) delete mode 100644 yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/type/LeafrefSpecificationRFC6020Support.java delete mode 100644 yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/type/LeafrefSpecificationRFC7950Support.java rename yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/type/{AbstractLeafrefSpecificationSupport.java => LeafrefSpecificationSupport.java} (70%) diff --git a/yang/odlext-parser-support/src/main/java/org/opendaylight/yangtools/odlext/parser/AbstractIdentityAwareStatementSupport.java b/yang/odlext-parser-support/src/main/java/org/opendaylight/yangtools/odlext/parser/AbstractIdentityAwareStatementSupport.java index 2b118b6d10..a8f7294427 100644 --- a/yang/odlext-parser-support/src/main/java/org/opendaylight/yangtools/odlext/parser/AbstractIdentityAwareStatementSupport.java +++ b/yang/odlext-parser-support/src/main/java/org/opendaylight/yangtools/odlext/parser/AbstractIdentityAwareStatementSupport.java @@ -34,12 +34,9 @@ import org.opendaylight.yangtools.yang.parser.spi.meta.SubstatementValidator; abstract class AbstractIdentityAwareStatementSupport, E extends EffectiveStatement> extends AbstractStatementSupport { - private final SubstatementValidator validator; - AbstractIdentityAwareStatementSupport(final StatementDefinition publicDefinition, - final YangParserConfiguration config) { - super(publicDefinition, StatementPolicy.exactReplica(), config); - validator = SubstatementValidator.builder(publicDefinition).build(); + final YangParserConfiguration config, final SubstatementValidator validator) { + super(publicDefinition, StatementPolicy.exactReplica(), config, validator); } @Override @@ -65,11 +62,6 @@ abstract class AbstractIdentityAwareStatementSupport stmt, final ImmutableList> substatements) { diff --git a/yang/odlext-parser-support/src/main/java/org/opendaylight/yangtools/odlext/parser/AugmentIdentifierStatementSupport.java b/yang/odlext-parser-support/src/main/java/org/opendaylight/yangtools/odlext/parser/AugmentIdentifierStatementSupport.java index dc1077901f..9f05f85965 100644 --- a/yang/odlext-parser-support/src/main/java/org/opendaylight/yangtools/odlext/parser/AugmentIdentifierStatementSupport.java +++ b/yang/odlext-parser-support/src/main/java/org/opendaylight/yangtools/odlext/parser/AugmentIdentifierStatementSupport.java @@ -31,7 +31,8 @@ public final class AugmentIdentifierStatementSupport SubstatementValidator.builder(OpenDaylightExtensionsStatements.AUGMENT_IDENTIFIER).build(); public AugmentIdentifierStatementSupport(final YangParserConfiguration config) { - super(OpenDaylightExtensionsStatements.AUGMENT_IDENTIFIER, StatementPolicy.contextIndependent(), config); + super(OpenDaylightExtensionsStatements.AUGMENT_IDENTIFIER, StatementPolicy.contextIndependent(), config, + VALIDATOR); } @Override @@ -43,11 +44,6 @@ public final class AugmentIdentifierStatementSupport } } - @Override - protected SubstatementValidator getSubstatementValidator() { - return VALIDATOR; - } - @Override protected AugmentIdentifierStatement createDeclared( final StmtContext ctx, diff --git a/yang/odlext-parser-support/src/main/java/org/opendaylight/yangtools/odlext/parser/ContextInstanceStatementSupport.java b/yang/odlext-parser-support/src/main/java/org/opendaylight/yangtools/odlext/parser/ContextInstanceStatementSupport.java index d135f8ed62..b877f508db 100644 --- a/yang/odlext-parser-support/src/main/java/org/opendaylight/yangtools/odlext/parser/ContextInstanceStatementSupport.java +++ b/yang/odlext-parser-support/src/main/java/org/opendaylight/yangtools/odlext/parser/ContextInstanceStatementSupport.java @@ -19,12 +19,16 @@ import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement; import org.opendaylight.yangtools.yang.model.api.stmt.IdentityEffectiveStatement; import org.opendaylight.yangtools.yang.parser.api.YangParserConfiguration; import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext; +import org.opendaylight.yangtools.yang.parser.spi.meta.SubstatementValidator; @Beta public final class ContextInstanceStatementSupport extends AbstractIdentityAwareStatementSupport { + private static final SubstatementValidator VALIDATOR = + SubstatementValidator.builder(OpenDaylightExtensionsStatements.CONTEXT_INSTANCE).build(); + public ContextInstanceStatementSupport(final YangParserConfiguration config) { - super(OpenDaylightExtensionsStatements.CONTEXT_INSTANCE, config); + super(OpenDaylightExtensionsStatements.CONTEXT_INSTANCE, config, VALIDATOR); } @Override diff --git a/yang/odlext-parser-support/src/main/java/org/opendaylight/yangtools/odlext/parser/ContextReferenceStatementSupport.java b/yang/odlext-parser-support/src/main/java/org/opendaylight/yangtools/odlext/parser/ContextReferenceStatementSupport.java index 4792cdca22..36f807086e 100644 --- a/yang/odlext-parser-support/src/main/java/org/opendaylight/yangtools/odlext/parser/ContextReferenceStatementSupport.java +++ b/yang/odlext-parser-support/src/main/java/org/opendaylight/yangtools/odlext/parser/ContextReferenceStatementSupport.java @@ -19,12 +19,16 @@ import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement; import org.opendaylight.yangtools.yang.model.api.stmt.IdentityEffectiveStatement; import org.opendaylight.yangtools.yang.parser.api.YangParserConfiguration; import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext; +import org.opendaylight.yangtools.yang.parser.spi.meta.SubstatementValidator; @Beta public final class ContextReferenceStatementSupport extends AbstractIdentityAwareStatementSupport { + private static final SubstatementValidator VALIDATOR = + SubstatementValidator.builder(OpenDaylightExtensionsStatements.CONTEXT_REFERENCE).build(); + public ContextReferenceStatementSupport(final YangParserConfiguration config) { - super(OpenDaylightExtensionsStatements.CONTEXT_REFERENCE, config); + super(OpenDaylightExtensionsStatements.CONTEXT_REFERENCE, config, VALIDATOR); } @Override diff --git a/yang/odlext-parser-support/src/main/java/org/opendaylight/yangtools/odlext/parser/InstanceTargetStatementSupport.java b/yang/odlext-parser-support/src/main/java/org/opendaylight/yangtools/odlext/parser/InstanceTargetStatementSupport.java index f94cb00d2c..f5a246a5b4 100644 --- a/yang/odlext-parser-support/src/main/java/org/opendaylight/yangtools/odlext/parser/InstanceTargetStatementSupport.java +++ b/yang/odlext-parser-support/src/main/java/org/opendaylight/yangtools/odlext/parser/InstanceTargetStatementSupport.java @@ -28,12 +28,8 @@ public final class InstanceTargetStatementSupport SubstatementValidator.builder(OpenDaylightExtensionsStatements.INSTANCE_TARGET).build(); public InstanceTargetStatementSupport(final YangParserConfiguration config) { - super(OpenDaylightExtensionsStatements.INSTANCE_TARGET, StatementPolicy.contextIndependent(), config); - } - - @Override - protected SubstatementValidator getSubstatementValidator() { - return VALIDATOR; + super(OpenDaylightExtensionsStatements.INSTANCE_TARGET, StatementPolicy.contextIndependent(), config, + VALIDATOR); } @Override diff --git a/yang/odlext-parser-support/src/main/java/org/opendaylight/yangtools/odlext/parser/RpcContextReferenceStatementSupport.java b/yang/odlext-parser-support/src/main/java/org/opendaylight/yangtools/odlext/parser/RpcContextReferenceStatementSupport.java index df421544ef..31df9215ab 100644 --- a/yang/odlext-parser-support/src/main/java/org/opendaylight/yangtools/odlext/parser/RpcContextReferenceStatementSupport.java +++ b/yang/odlext-parser-support/src/main/java/org/opendaylight/yangtools/odlext/parser/RpcContextReferenceStatementSupport.java @@ -28,12 +28,8 @@ public final class RpcContextReferenceStatementSupport SubstatementValidator.builder(OpenDaylightExtensionsStatements.RPC_CONTEXT_REFERENCE).build(); public RpcContextReferenceStatementSupport(final YangParserConfiguration config) { - super(OpenDaylightExtensionsStatements.RPC_CONTEXT_REFERENCE, StatementPolicy.contextIndependent(), config); - } - - @Override - protected SubstatementValidator getSubstatementValidator() { - return VALIDATOR; + super(OpenDaylightExtensionsStatements.RPC_CONTEXT_REFERENCE, StatementPolicy.contextIndependent(), config, + VALIDATOR); } @Override diff --git a/yang/openconfig-parser-support/src/main/java/org/opendaylight/yangtools/openconfig/parser/AbstractHashedValueStatementSupport.java b/yang/openconfig-parser-support/src/main/java/org/opendaylight/yangtools/openconfig/parser/AbstractHashedValueStatementSupport.java index 768e1eea4f..5e43f55f37 100644 --- a/yang/openconfig-parser-support/src/main/java/org/opendaylight/yangtools/openconfig/parser/AbstractHashedValueStatementSupport.java +++ b/yang/openconfig-parser-support/src/main/java/org/opendaylight/yangtools/openconfig/parser/AbstractHashedValueStatementSupport.java @@ -23,16 +23,9 @@ import org.opendaylight.yangtools.yang.parser.spi.meta.SubstatementValidator; abstract class AbstractHashedValueStatementSupport extends AbstractEmptyStatementSupport { - private final SubstatementValidator validator; - - AbstractHashedValueStatementSupport(final StatementDefinition definition, final YangParserConfiguration config) { - super(definition, StatementPolicy.contextIndependent(), config); - this.validator = SubstatementValidator.builder(definition).build(); - } - - @Override - protected final SubstatementValidator getSubstatementValidator() { - return validator; + AbstractHashedValueStatementSupport(final StatementDefinition definition, final YangParserConfiguration config, + final SubstatementValidator validator) { + super(definition, StatementPolicy.contextIndependent(), config, validator); } @Override diff --git a/yang/openconfig-parser-support/src/main/java/org/opendaylight/yangtools/openconfig/parser/EncryptedValueStatementSupport.java b/yang/openconfig-parser-support/src/main/java/org/opendaylight/yangtools/openconfig/parser/EncryptedValueStatementSupport.java index 2200b88ab2..500bb2249a 100644 --- a/yang/openconfig-parser-support/src/main/java/org/opendaylight/yangtools/openconfig/parser/EncryptedValueStatementSupport.java +++ b/yang/openconfig-parser-support/src/main/java/org/opendaylight/yangtools/openconfig/parser/EncryptedValueStatementSupport.java @@ -9,9 +9,13 @@ package org.opendaylight.yangtools.openconfig.parser; import org.opendaylight.yangtools.openconfig.model.api.OpenConfigStatements; import org.opendaylight.yangtools.yang.parser.api.YangParserConfiguration; +import org.opendaylight.yangtools.yang.parser.spi.meta.SubstatementValidator; public final class EncryptedValueStatementSupport extends AbstractHashedValueStatementSupport { + private static final SubstatementValidator VALIDATOR = + SubstatementValidator.builder(OpenConfigStatements.OPENCONFIG_ENCRYPTED_VALUE).build(); + public EncryptedValueStatementSupport(final YangParserConfiguration config) { - super(OpenConfigStatements.OPENCONFIG_ENCRYPTED_VALUE, config); + super(OpenConfigStatements.OPENCONFIG_ENCRYPTED_VALUE, config, VALIDATOR); } } diff --git a/yang/openconfig-parser-support/src/main/java/org/opendaylight/yangtools/openconfig/parser/HashedValueStatementSupport.java b/yang/openconfig-parser-support/src/main/java/org/opendaylight/yangtools/openconfig/parser/HashedValueStatementSupport.java index b98703be10..8abe7d87c2 100644 --- a/yang/openconfig-parser-support/src/main/java/org/opendaylight/yangtools/openconfig/parser/HashedValueStatementSupport.java +++ b/yang/openconfig-parser-support/src/main/java/org/opendaylight/yangtools/openconfig/parser/HashedValueStatementSupport.java @@ -9,9 +9,13 @@ package org.opendaylight.yangtools.openconfig.parser; import org.opendaylight.yangtools.openconfig.model.api.OpenConfigStatements; import org.opendaylight.yangtools.yang.parser.api.YangParserConfiguration; +import org.opendaylight.yangtools.yang.parser.spi.meta.SubstatementValidator; public final class HashedValueStatementSupport extends AbstractHashedValueStatementSupport { + private static final SubstatementValidator VALIDATOR = + SubstatementValidator.builder(OpenConfigStatements.OPENCONFIG_HASHED_VALUE).build(); + public HashedValueStatementSupport(final YangParserConfiguration config) { - super(OpenConfigStatements.OPENCONFIG_HASHED_VALUE, config); + super(OpenConfigStatements.OPENCONFIG_HASHED_VALUE, config, VALIDATOR); } } diff --git a/yang/rfc6241-parser-support/pom.xml b/yang/rfc6241-parser-support/pom.xml index 71a24921ad..9bbb971ebe 100644 --- a/yang/rfc6241-parser-support/pom.xml +++ b/yang/rfc6241-parser-support/pom.xml @@ -17,7 +17,6 @@ rfc6241-parser-support - 7.0.0-SNAPSHOT bundle ${project.artifactId} RFC6241 parser support diff --git a/yang/rfc6241-parser-support/src/main/java/org/opendaylight/yangtools/rfc6241/parser/GetFilterElementAttributesStatementSupport.java b/yang/rfc6241-parser-support/src/main/java/org/opendaylight/yangtools/rfc6241/parser/GetFilterElementAttributesStatementSupport.java index 53d8a62e01..f5824bb854 100644 --- a/yang/rfc6241-parser-support/src/main/java/org/opendaylight/yangtools/rfc6241/parser/GetFilterElementAttributesStatementSupport.java +++ b/yang/rfc6241-parser-support/src/main/java/org/opendaylight/yangtools/rfc6241/parser/GetFilterElementAttributesStatementSupport.java @@ -34,7 +34,7 @@ public final class GetFilterElementAttributesStatementSupport extends AbstractEm SubstatementValidator.builder(NetconfStatements.GET_FILTER_ELEMENT_ATTRIBUTES).build(); public GetFilterElementAttributesStatementSupport(final YangParserConfiguration config) { - super(NetconfStatements.GET_FILTER_ELEMENT_ATTRIBUTES, StatementPolicy.reject(), config); + super(NetconfStatements.GET_FILTER_ELEMENT_ATTRIBUTES, StatementPolicy.reject(), config, VALIDATOR); } @Override @@ -44,11 +44,6 @@ public final class GetFilterElementAttributesStatementSupport extends AbstractEm stmt.setIsSupportedToBuildEffective(computeSupported(stmt)); } - @Override - protected SubstatementValidator getSubstatementValidator() { - return VALIDATOR; - } - @Override protected GetFilterElementAttributesStatement createDeclared( final StmtContext ctx, diff --git a/yang/rfc6536-parser-support/src/main/java/org/opendaylight/yangtools/rfc6536/parser/DefaultDenyAllStatementSupport.java b/yang/rfc6536-parser-support/src/main/java/org/opendaylight/yangtools/rfc6536/parser/DefaultDenyAllStatementSupport.java index 1f983b9d84..259fc403bd 100644 --- a/yang/rfc6536-parser-support/src/main/java/org/opendaylight/yangtools/rfc6536/parser/DefaultDenyAllStatementSupport.java +++ b/yang/rfc6536-parser-support/src/main/java/org/opendaylight/yangtools/rfc6536/parser/DefaultDenyAllStatementSupport.java @@ -27,12 +27,7 @@ public final class DefaultDenyAllStatementSupport SubstatementValidator.builder(NACMStatements.DEFAULT_DENY_ALL).build(); public DefaultDenyAllStatementSupport(final YangParserConfiguration config) { - super(NACMStatements.DEFAULT_DENY_ALL, StatementPolicy.contextIndependent(), config); - } - - @Override - protected SubstatementValidator getSubstatementValidator() { - return VALIDATOR; + super(NACMStatements.DEFAULT_DENY_ALL, StatementPolicy.contextIndependent(), config, VALIDATOR); } @Override diff --git a/yang/rfc6536-parser-support/src/main/java/org/opendaylight/yangtools/rfc6536/parser/DefaultDenyWriteStatementSupport.java b/yang/rfc6536-parser-support/src/main/java/org/opendaylight/yangtools/rfc6536/parser/DefaultDenyWriteStatementSupport.java index 143ded2ff3..2032861277 100644 --- a/yang/rfc6536-parser-support/src/main/java/org/opendaylight/yangtools/rfc6536/parser/DefaultDenyWriteStatementSupport.java +++ b/yang/rfc6536-parser-support/src/main/java/org/opendaylight/yangtools/rfc6536/parser/DefaultDenyWriteStatementSupport.java @@ -27,12 +27,7 @@ public final class DefaultDenyWriteStatementSupport SubstatementValidator.builder(NACMStatements.DEFAULT_DENY_WRITE).build(); public DefaultDenyWriteStatementSupport(final YangParserConfiguration config) { - super(NACMStatements.DEFAULT_DENY_WRITE, StatementPolicy.contextIndependent(), config); - } - - @Override - protected SubstatementValidator getSubstatementValidator() { - return VALIDATOR; + super(NACMStatements.DEFAULT_DENY_WRITE, StatementPolicy.contextIndependent(), config, VALIDATOR); } @Override diff --git a/yang/rfc6643-parser-support/src/main/java/org/opendaylight/yangtools/rfc6643/parser/AliasStatementSupport.java b/yang/rfc6643-parser-support/src/main/java/org/opendaylight/yangtools/rfc6643/parser/AliasStatementSupport.java index b8bb4f8dfb..a989a3adc9 100644 --- a/yang/rfc6643-parser-support/src/main/java/org/opendaylight/yangtools/rfc6643/parser/AliasStatementSupport.java +++ b/yang/rfc6643-parser-support/src/main/java/org/opendaylight/yangtools/rfc6643/parser/AliasStatementSupport.java @@ -25,7 +25,7 @@ import org.opendaylight.yangtools.yang.parser.spi.meta.SubstatementValidator; @Beta public final class AliasStatementSupport extends AbstractStringStatementSupport { - private static final SubstatementValidator SUBSTATEMENT_VALIDATOR = + private static final SubstatementValidator VALIDATOR = SubstatementValidator.builder(IetfYangSmiv2ExtensionsMapping.ALIAS) .add(YangStmtMapping.DESCRIPTION, 0, 1) .add(YangStmtMapping.REFERENCE, 0, 1) @@ -34,12 +34,7 @@ public final class AliasStatementSupport .build(); public AliasStatementSupport(final YangParserConfiguration config) { - super(IetfYangSmiv2ExtensionsMapping.ALIAS, StatementPolicy.contextIndependent(), config); - } - - @Override - protected SubstatementValidator getSubstatementValidator() { - return SUBSTATEMENT_VALIDATOR; + super(IetfYangSmiv2ExtensionsMapping.ALIAS, StatementPolicy.contextIndependent(), config, VALIDATOR); } @Override diff --git a/yang/rfc6643-parser-support/src/main/java/org/opendaylight/yangtools/rfc6643/parser/DefValStatementSupport.java b/yang/rfc6643-parser-support/src/main/java/org/opendaylight/yangtools/rfc6643/parser/DefValStatementSupport.java index 7ad6adacea..cd69339d44 100644 --- a/yang/rfc6643-parser-support/src/main/java/org/opendaylight/yangtools/rfc6643/parser/DefValStatementSupport.java +++ b/yang/rfc6643-parser-support/src/main/java/org/opendaylight/yangtools/rfc6643/parser/DefValStatementSupport.java @@ -24,16 +24,11 @@ import org.opendaylight.yangtools.yang.parser.spi.meta.SubstatementValidator; @Beta public final class DefValStatementSupport extends AbstractStringStatementSupport { - private static final SubstatementValidator SUBSTATEMENT_VALIDATOR = + private static final SubstatementValidator VALIDATOR = SubstatementValidator.builder(IetfYangSmiv2ExtensionsMapping.DEFVAL).build(); public DefValStatementSupport(final YangParserConfiguration config) { - super(IetfYangSmiv2ExtensionsMapping.DEFVAL, StatementPolicy.contextIndependent(), config); - } - - @Override - protected SubstatementValidator getSubstatementValidator() { - return SUBSTATEMENT_VALIDATOR; + super(IetfYangSmiv2ExtensionsMapping.DEFVAL, StatementPolicy.contextIndependent(), config, VALIDATOR); } @Override diff --git a/yang/rfc6643-parser-support/src/main/java/org/opendaylight/yangtools/rfc6643/parser/DisplayHintStatementSupport.java b/yang/rfc6643-parser-support/src/main/java/org/opendaylight/yangtools/rfc6643/parser/DisplayHintStatementSupport.java index b36dc96a9f..48a390dc79 100644 --- a/yang/rfc6643-parser-support/src/main/java/org/opendaylight/yangtools/rfc6643/parser/DisplayHintStatementSupport.java +++ b/yang/rfc6643-parser-support/src/main/java/org/opendaylight/yangtools/rfc6643/parser/DisplayHintStatementSupport.java @@ -24,16 +24,11 @@ import org.opendaylight.yangtools.yang.parser.spi.meta.SubstatementValidator; @Beta public final class DisplayHintStatementSupport extends AbstractStringStatementSupport { - private static final SubstatementValidator SUBSTATEMENT_VALIDATOR = + private static final SubstatementValidator VALIDATOR = SubstatementValidator.builder(IetfYangSmiv2ExtensionsMapping.DISPLAY_HINT).build(); public DisplayHintStatementSupport(final YangParserConfiguration config) { - super(IetfYangSmiv2ExtensionsMapping.DISPLAY_HINT, StatementPolicy.contextIndependent(), config); - } - - @Override - protected SubstatementValidator getSubstatementValidator() { - return SUBSTATEMENT_VALIDATOR; + super(IetfYangSmiv2ExtensionsMapping.DISPLAY_HINT, StatementPolicy.contextIndependent(), config, VALIDATOR); } @Override diff --git a/yang/rfc6643-parser-support/src/main/java/org/opendaylight/yangtools/rfc6643/parser/ImpliedStatementSupport.java b/yang/rfc6643-parser-support/src/main/java/org/opendaylight/yangtools/rfc6643/parser/ImpliedStatementSupport.java index 32b489aa03..8349d05be5 100644 --- a/yang/rfc6643-parser-support/src/main/java/org/opendaylight/yangtools/rfc6643/parser/ImpliedStatementSupport.java +++ b/yang/rfc6643-parser-support/src/main/java/org/opendaylight/yangtools/rfc6643/parser/ImpliedStatementSupport.java @@ -24,16 +24,11 @@ import org.opendaylight.yangtools.yang.parser.spi.meta.SubstatementValidator; @Beta public final class ImpliedStatementSupport extends AbstractStringStatementSupport { - private static final SubstatementValidator SUBSTATEMENT_VALIDATOR = + private static final SubstatementValidator VALIDATOR = SubstatementValidator.builder(IetfYangSmiv2ExtensionsMapping.IMPLIED).build(); public ImpliedStatementSupport(final YangParserConfiguration config) { - super(IetfYangSmiv2ExtensionsMapping.IMPLIED, StatementPolicy.contextIndependent(), config); - } - - @Override - protected SubstatementValidator getSubstatementValidator() { - return SUBSTATEMENT_VALIDATOR; + super(IetfYangSmiv2ExtensionsMapping.IMPLIED, StatementPolicy.contextIndependent(), config, VALIDATOR); } @Override diff --git a/yang/rfc6643-parser-support/src/main/java/org/opendaylight/yangtools/rfc6643/parser/MaxAccessStatementSupport.java b/yang/rfc6643-parser-support/src/main/java/org/opendaylight/yangtools/rfc6643/parser/MaxAccessStatementSupport.java index abcb1faf23..2d50afdea5 100644 --- a/yang/rfc6643-parser-support/src/main/java/org/opendaylight/yangtools/rfc6643/parser/MaxAccessStatementSupport.java +++ b/yang/rfc6643-parser-support/src/main/java/org/opendaylight/yangtools/rfc6643/parser/MaxAccessStatementSupport.java @@ -26,11 +26,11 @@ import org.opendaylight.yangtools.yang.parser.spi.source.SourceException; @Beta public final class MaxAccessStatementSupport extends AbstractStatementSupport { - private static final SubstatementValidator SUBSTATEMENT_VALIDATOR = + private static final SubstatementValidator VALIDATOR = SubstatementValidator.builder(IetfYangSmiv2ExtensionsMapping.MAX_ACCESS).build(); public MaxAccessStatementSupport(final YangParserConfiguration config) { - super(IetfYangSmiv2ExtensionsMapping.MAX_ACCESS, StatementPolicy.contextIndependent(), config); + super(IetfYangSmiv2ExtensionsMapping.MAX_ACCESS, StatementPolicy.contextIndependent(), config, VALIDATOR); } @Override @@ -48,11 +48,6 @@ public final class MaxAccessStatementSupport return val == null ? rawArgument : val.stringLiteral(); } - @Override - protected SubstatementValidator getSubstatementValidator() { - return SUBSTATEMENT_VALIDATOR; - } - @Override protected MaxAccessStatement createDeclared(final StmtContext ctx, final ImmutableList> substatements) { diff --git a/yang/rfc6643-parser-support/src/main/java/org/opendaylight/yangtools/rfc6643/parser/OidStatementSupport.java b/yang/rfc6643-parser-support/src/main/java/org/opendaylight/yangtools/rfc6643/parser/OidStatementSupport.java index 260232e8b6..044285d743 100644 --- a/yang/rfc6643-parser-support/src/main/java/org/opendaylight/yangtools/rfc6643/parser/OidStatementSupport.java +++ b/yang/rfc6643-parser-support/src/main/java/org/opendaylight/yangtools/rfc6643/parser/OidStatementSupport.java @@ -26,11 +26,11 @@ import org.opendaylight.yangtools.yang.parser.spi.source.SourceException; @Beta public final class OidStatementSupport extends AbstractStatementSupport { - private static final SubstatementValidator SUBSTATEMENT_VALIDATOR = + private static final SubstatementValidator VALIDATOR = SubstatementValidator.builder(IetfYangSmiv2ExtensionsMapping.OBJECT_ID).build(); public OidStatementSupport(final YangParserConfiguration config) { - super(IetfYangSmiv2ExtensionsMapping.OBJECT_ID, StatementPolicy.contextIndependent(), config); + super(IetfYangSmiv2ExtensionsMapping.OBJECT_ID, StatementPolicy.contextIndependent(), config, VALIDATOR); } @Override @@ -42,11 +42,6 @@ public final class OidStatementSupport } } - @Override - protected SubstatementValidator getSubstatementValidator() { - return SUBSTATEMENT_VALIDATOR; - } - @Override protected OidStatement createDeclared(final StmtContext ctx, final ImmutableList> substatements) { diff --git a/yang/rfc6643-parser-support/src/main/java/org/opendaylight/yangtools/rfc6643/parser/SubIdStatementSupport.java b/yang/rfc6643-parser-support/src/main/java/org/opendaylight/yangtools/rfc6643/parser/SubIdStatementSupport.java index 33e39d4797..0aa3719234 100644 --- a/yang/rfc6643-parser-support/src/main/java/org/opendaylight/yangtools/rfc6643/parser/SubIdStatementSupport.java +++ b/yang/rfc6643-parser-support/src/main/java/org/opendaylight/yangtools/rfc6643/parser/SubIdStatementSupport.java @@ -25,11 +25,11 @@ import org.opendaylight.yangtools.yang.parser.spi.meta.SubstatementValidator; @Beta public final class SubIdStatementSupport extends AbstractStatementSupport { - private static final SubstatementValidator SUBSTATEMENT_VALIDATOR = + private static final SubstatementValidator VALIDATOR = SubstatementValidator.builder(IetfYangSmiv2ExtensionsMapping.SUB_ID).build(); public SubIdStatementSupport(final YangParserConfiguration config) { - super(IetfYangSmiv2ExtensionsMapping.SUB_ID, StatementPolicy.contextIndependent(), config); + super(IetfYangSmiv2ExtensionsMapping.SUB_ID, StatementPolicy.contextIndependent(), config, VALIDATOR); } @Override @@ -37,11 +37,6 @@ public final class SubIdStatementSupport return Uint32.valueOf(value); } - @Override - protected SubstatementValidator getSubstatementValidator() { - return SUBSTATEMENT_VALIDATOR; - } - @Override protected SubIdStatement createDeclared(final StmtContext ctx, final ImmutableList> substatements) { diff --git a/yang/rfc7952-parser-support/src/main/java/org/opendaylight/yangtools/rfc7952/parser/AnnotationStatementSupport.java b/yang/rfc7952-parser-support/src/main/java/org/opendaylight/yangtools/rfc7952/parser/AnnotationStatementSupport.java index bca16f5423..2e838f81e5 100644 --- a/yang/rfc7952-parser-support/src/main/java/org/opendaylight/yangtools/rfc7952/parser/AnnotationStatementSupport.java +++ b/yang/rfc7952-parser-support/src/main/java/org/opendaylight/yangtools/rfc7952/parser/AnnotationStatementSupport.java @@ -38,7 +38,7 @@ public final class AnnotationStatementSupport .build(); public AnnotationStatementSupport(final YangParserConfiguration config) { - super(MetadataStatements.ANNOTATION, StatementPolicy.reject(), config); + super(MetadataStatements.ANNOTATION, StatementPolicy.reject(), config, VALIDATOR); } @Override @@ -53,11 +53,6 @@ public final class AnnotationStatementSupport stmt, "Annotations may only be defined at root of either a module or a submodule"); } - @Override - protected SubstatementValidator getSubstatementValidator() { - return VALIDATOR; - } - @Override protected AnnotationStatement createDeclared(final StmtContext ctx, final ImmutableList> substatements) { diff --git a/yang/rfc8040-parser-support/src/main/java/org/opendaylight/yangtools/rfc8040/parser/YangDataStatementSupport.java b/yang/rfc8040-parser-support/src/main/java/org/opendaylight/yangtools/rfc8040/parser/YangDataStatementSupport.java index 72df7beedf..98a22df30c 100644 --- a/yang/rfc8040-parser-support/src/main/java/org/opendaylight/yangtools/rfc8040/parser/YangDataStatementSupport.java +++ b/yang/rfc8040-parser-support/src/main/java/org/opendaylight/yangtools/rfc8040/parser/YangDataStatementSupport.java @@ -36,14 +36,13 @@ import org.opendaylight.yangtools.yang.parser.spi.source.SourceException; @Beta public final class YangDataStatementSupport extends AbstractStringStatementSupport { - private final SubstatementValidator declaredValidator; + private static final SubstatementValidator VALIDATOR = SubstatementValidator.builder(YangDataStatements.YANG_DATA) + .addMandatory(YangStmtMapping.CONTAINER) + .addOptional(YangStmtMapping.USES) + .build(); public YangDataStatementSupport(final YangParserConfiguration config) { - super(YangDataStatements.YANG_DATA, StatementPolicy.reject(), config); - declaredValidator = SubstatementValidator.builder(YangDataStatements.YANG_DATA) - .addMandatory(YangStmtMapping.CONTAINER) - .addOptional(YangStmtMapping.USES) - .build(); + super(YangDataStatements.YANG_DATA, StatementPolicy.reject(), config, VALIDATOR); } @Override @@ -73,11 +72,6 @@ public final class YangDataStatementSupport return true; } - @Override - protected SubstatementValidator getSubstatementValidator() { - return declaredValidator; - } - @Override protected YangDataStatement createDeclared(@NonNull final StmtContext ctx, final ImmutableList> substatements) { diff --git a/yang/rfc8528-parser-support/src/main/java/org/opendaylight/yangtools/rfc8528/parser/MountPointStatementSupport.java b/yang/rfc8528-parser-support/src/main/java/org/opendaylight/yangtools/rfc8528/parser/MountPointStatementSupport.java index 0a35a86ae7..3eef9a27cf 100644 --- a/yang/rfc8528-parser-support/src/main/java/org/opendaylight/yangtools/rfc8528/parser/MountPointStatementSupport.java +++ b/yang/rfc8528-parser-support/src/main/java/org/opendaylight/yangtools/rfc8528/parser/MountPointStatementSupport.java @@ -45,7 +45,7 @@ public final class MountPointStatementSupport // Implied by UnknownSchemaNode && copy.history().isAugmenting() == current.history().isAugmenting() && copy.history().isAddedByUses() == current.history().isAddedByUses() - && copy.equalParentPath(current)), config); + && copy.equalParentPath(current)), config, VALIDATOR); } // FIXME: these two methods are not quite right. RFC8528 states that: @@ -72,11 +72,6 @@ public final class MountPointStatementSupport "Mount points may only be defined at either a container or a list"); } - @Override - protected SubstatementValidator getSubstatementValidator() { - return VALIDATOR; - } - @Override protected MountPointStatement createDeclared(@NonNull final StmtContext ctx, final ImmutableList> substatements) { diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/openconfig/stmt/OpenConfigVersionSupport.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/openconfig/stmt/OpenConfigVersionSupport.java index ede06a5c76..d80c66e7ff 100644 --- a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/openconfig/stmt/OpenConfigVersionSupport.java +++ b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/openconfig/stmt/OpenConfigVersionSupport.java @@ -29,7 +29,7 @@ public final class OpenConfigVersionSupport SubstatementValidator.builder(OpenConfigStatements.OPENCONFIG_VERSION).build(); public OpenConfigVersionSupport(final YangParserConfiguration config) { - super(OpenConfigStatements.OPENCONFIG_VERSION, StatementPolicy.reject(), config); + super(OpenConfigStatements.OPENCONFIG_VERSION, StatementPolicy.reject(), config, SUBSTATEMENT_VALIDATOR); } @Override @@ -43,11 +43,6 @@ public final class OpenConfigVersionSupport stmt.addToNs(SemanticVersionNamespace.class, stmt.getParentContext(), stmt.argument()); } - @Override - protected SubstatementValidator getSubstatementValidator() { - return SUBSTATEMENT_VALIDATOR; - } - @Override protected OpenConfigVersionStatement createDeclared(final StmtContext ctx, final ImmutableList> substatements) { diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/augment/AbstractAugmentStatementSupport.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/augment/AbstractAugmentStatementSupport.java index a656d7bd81..a6df687892 100644 --- a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/augment/AbstractAugmentStatementSupport.java +++ b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/augment/AbstractAugmentStatementSupport.java @@ -45,6 +45,7 @@ import org.opendaylight.yangtools.yang.parser.spi.meta.ModelProcessingPhase; import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext; import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext.Mutable; import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContextUtils; +import org.opendaylight.yangtools.yang.parser.spi.meta.SubstatementValidator; import org.opendaylight.yangtools.yang.parser.spi.source.SourceException; import org.opendaylight.yangtools.yang.parser.stmt.reactor.StatementContextBase; @@ -53,13 +54,13 @@ abstract class AbstractAugmentStatementSupport private static final Pattern PATH_REL_PATTERN1 = Pattern.compile("\\.\\.?\\s*/(.+)"); private static final Pattern PATH_REL_PATTERN2 = Pattern.compile("//.*"); - AbstractAugmentStatementSupport(final YangParserConfiguration config) { + AbstractAugmentStatementSupport(final YangParserConfiguration config, final SubstatementValidator validator) { super(YangStmtMapping.AUGMENT, StatementPolicy.copyDeclared( (copy, current, substatements) -> copy.getArgument().equals(current.getArgument()) && copy.moduleName().getModule().equals(current.moduleName().getModule()) && Objects.equals(copy.original(), current.original()) - ), config); + ), config, validator); } @Override diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/augment/AugmentStatementRFC6020Support.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/augment/AugmentStatementRFC6020Support.java index 0ed54d65e2..7304ebb345 100644 --- a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/augment/AugmentStatementRFC6020Support.java +++ b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/augment/AugmentStatementRFC6020Support.java @@ -31,12 +31,7 @@ public final class AugmentStatementRFC6020Support extends AbstractAugmentStateme .build(); public AugmentStatementRFC6020Support(final YangParserConfiguration config) { - super(config); - } - - @Override - protected SubstatementValidator getSubstatementValidator() { - return SUBSTATEMENT_VALIDATOR; + super(config, SUBSTATEMENT_VALIDATOR); } @Override diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/augment/AugmentStatementRFC7950Support.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/augment/AugmentStatementRFC7950Support.java index a79a2492f8..9280c4b4a7 100644 --- a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/augment/AugmentStatementRFC7950Support.java +++ b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/augment/AugmentStatementRFC7950Support.java @@ -39,12 +39,7 @@ public final class AugmentStatementRFC7950Support extends AbstractAugmentStateme .build(); public AugmentStatementRFC7950Support(final YangParserConfiguration config) { - super(config); - } - - @Override - protected SubstatementValidator getSubstatementValidator() { - return SUBSTATEMENT_VALIDATOR; + super(config, SUBSTATEMENT_VALIDATOR); } @Override diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/deviate/AbstractDeviateStatementSupport.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/deviate/AbstractDeviateStatementSupport.java index 0f876cdcb3..e76d9a1f7c 100644 --- a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/deviate/AbstractDeviateStatementSupport.java +++ b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/deviate/AbstractDeviateStatementSupport.java @@ -105,7 +105,9 @@ abstract class AbstractDeviateStatementSupport YangStmtMapping.MANDATORY, YangStmtMapping.MAX_ELEMENTS, YangStmtMapping.MIN_ELEMENTS); AbstractDeviateStatementSupport(final YangParserConfiguration config) { - super(YangStmtMapping.DEVIATE, StatementPolicy.contextIndependent(), config); + // Note: we are performing our own validation based on deviate kind. + // TODO: perhaps we should do argumentSpecificSupport? + super(YangStmtMapping.DEVIATE, StatementPolicy.contextIndependent(), config, null); } @Override @@ -188,11 +190,6 @@ abstract class AbstractDeviateStatementSupport } } - @Override - protected final SubstatementValidator getSubstatementValidator() { - return null; - } - @Override protected final DeviateStatement createDeclared(final StmtContext ctx, final ImmutableList> substatements) { diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/extension/ExtensionStatementSupport.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/extension/ExtensionStatementSupport.java index 325e70158b..18ccd825e9 100644 --- a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/extension/ExtensionStatementSupport.java +++ b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/extension/ExtensionStatementSupport.java @@ -46,7 +46,7 @@ public final class ExtensionStatementSupport private final YangParserConfiguration config; public ExtensionStatementSupport(final YangParserConfiguration config) { - super(YangStmtMapping.EXTENSION, StatementPolicy.reject(), config); + super(YangStmtMapping.EXTENSION, StatementPolicy.reject(), config, SUBSTATEMENT_VALIDATOR); this.config = requireNonNull(config); } @@ -78,11 +78,6 @@ public final class ExtensionStatementSupport config)); } - @Override - protected SubstatementValidator getSubstatementValidator() { - return SUBSTATEMENT_VALIDATOR; - } - @Override protected ExtensionStatement createDeclared(final StmtContext ctx, final ImmutableList> substatements) { diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/extension/UnrecognizedStatementSupport.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/extension/UnrecognizedStatementSupport.java index 2554948612..b45d9c1ceb 100644 --- a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/extension/UnrecognizedStatementSupport.java +++ b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/extension/UnrecognizedStatementSupport.java @@ -27,7 +27,6 @@ import org.opendaylight.yangtools.yang.parser.spi.meta.InferenceException; import org.opendaylight.yangtools.yang.parser.spi.meta.OverrideChildStatementSupport; import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext; import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext.Mutable; -import org.opendaylight.yangtools.yang.parser.spi.meta.SubstatementValidator; final class UnrecognizedStatementSupport extends AbstractStatementSupport @@ -37,7 +36,7 @@ final class UnrecognizedStatementSupport UnrecognizedStatementSupport(final StatementDefinition publicDefinition, final YangParserConfiguration config) { // We have no idea about the statement's semantics, hence there should be noone interested in its semantics. // Nevertheless it may be of interest for various hacks to understand there was an extension involved. - super(publicDefinition, StatementPolicy.exactReplica(), config); + super(publicDefinition, StatementPolicy.exactReplica(), config, null); this.config = requireNonNull(config); } @@ -66,12 +65,6 @@ final class UnrecognizedStatementSupport return new UnrecognizedStatementSupport(def, config); } - @Override - protected SubstatementValidator getSubstatementValidator() { - // We know nothing about this statement - return null; - } - @Override protected UnrecognizedStatement createDeclared(final StmtContext ctx, final ImmutableList> substatements) { diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/if_feature/AbstractIfFeatureStatementSupport.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/if_feature/AbstractIfFeatureStatementSupport.java index a8d846751e..7e4b63f0f8 100644 --- a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/if_feature/AbstractIfFeatureStatementSupport.java +++ b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/if_feature/AbstractIfFeatureStatementSupport.java @@ -45,12 +45,11 @@ import org.slf4j.LoggerFactory; abstract class AbstractIfFeatureStatementSupport extends AbstractStatementSupport { private static final Logger LOG = LoggerFactory.getLogger(AbstractIfFeatureStatementSupport.class); - private static final SubstatementValidator SUBSTATEMENT_VALIDATOR = SubstatementValidator.builder( - YangStmtMapping.IF_FEATURE) - .build(); + private static final SubstatementValidator SUBSTATEMENT_VALIDATOR = + SubstatementValidator.builder(YangStmtMapping.IF_FEATURE).build(); AbstractIfFeatureStatementSupport(final YangParserConfiguration config) { - super(YangStmtMapping.IF_FEATURE, StatementPolicy.contextIndependent(), config); + super(YangStmtMapping.IF_FEATURE, StatementPolicy.contextIndependent(), config, SUBSTATEMENT_VALIDATOR); } @Override @@ -84,11 +83,6 @@ abstract class AbstractIfFeatureStatementSupport }); } - @Override - protected final SubstatementValidator getSubstatementValidator() { - return SUBSTATEMENT_VALIDATOR; - } - @Override protected final IfFeatureStatement createDeclared(final StmtContext ctx, final ImmutableList> substatements) { diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/import_/ImportStatementSupport.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/import_/ImportStatementSupport.java index 25e5592ffd..0ec75ec6ad 100644 --- a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/import_/ImportStatementSupport.java +++ b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/import_/ImportStatementSupport.java @@ -9,7 +9,6 @@ package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.import_; import static com.google.common.base.Verify.verify; import static com.google.common.base.Verify.verifyNotNull; -import static java.util.Objects.requireNonNull; import static org.opendaylight.yangtools.yang.parser.spi.meta.ModelProcessingPhase.SOURCE_PRE_LINKAGE; import static org.opendaylight.yangtools.yang.parser.spi.meta.StmtContextUtils.firstAttributeOf; @@ -65,12 +64,10 @@ public final class ImportStatementSupport .addOptional(YangStmtMapping.REFERENCE) .build(); - private final SubstatementValidator validator; private final boolean semanticVersioning; private ImportStatementSupport(final YangParserConfiguration config, final SubstatementValidator validator) { - super(YangStmtMapping.IMPORT, StatementPolicy.reject(), config); - this.validator = requireNonNull(validator); + super(YangStmtMapping.IMPORT, StatementPolicy.reject(), config, validator); semanticVersioning = config.importResolutionMode() == ImportResolutionMode.OPENCONFIG_SEMVER; } @@ -128,11 +125,6 @@ public final class ImportStatementSupport } } - @Override - protected SubstatementValidator getSubstatementValidator() { - return validator; - } - @Override protected ImportStatement createDeclared(final StmtContext ctx, final ImmutableList> substatements) { diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/leaf_list/LeafListStatementSupport.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/leaf_list/LeafListStatementSupport.java index 7e7d7f4acf..5cf1ab349e 100644 --- a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/leaf_list/LeafListStatementSupport.java +++ b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/leaf_list/LeafListStatementSupport.java @@ -7,8 +7,6 @@ */ package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.leaf_list; -import static java.util.Objects.requireNonNull; - import com.google.common.annotations.Beta; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; @@ -76,11 +74,8 @@ public final class LeafListStatementSupport .addOptional(YangStmtMapping.WHEN) .build(); - private final SubstatementValidator validator; - private LeafListStatementSupport(final YangParserConfiguration config, final SubstatementValidator validator) { - super(YangStmtMapping.LEAF_LIST, instantiatedPolicy(), config); - this.validator = requireNonNull(validator); + super(YangStmtMapping.LEAF_LIST, instantiatedPolicy(), config, validator); } public static @NonNull LeafListStatementSupport rfc6020Instance(final YangParserConfiguration config) { @@ -91,11 +86,6 @@ public final class LeafListStatementSupport return new LeafListStatementSupport(config, RFC7950_VALIDATOR); } - @Override - protected SubstatementValidator getSubstatementValidator() { - return validator; - } - @Override protected LeafListStatement createDeclared(final StmtContext ctx, final ImmutableList> substatements) { diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/list/ListStatementSupport.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/list/ListStatementSupport.java index e8b22386c4..0adb85324d 100644 --- a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/list/ListStatementSupport.java +++ b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/list/ListStatementSupport.java @@ -8,7 +8,6 @@ package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.list; import static com.google.common.base.Verify.verify; -import static java.util.Objects.requireNonNull; import com.google.common.annotations.Beta; import com.google.common.collect.ImmutableList; @@ -114,11 +113,8 @@ public final class ListStatementSupport .addOptional(YangStmtMapping.WHEN) .build(); - private final SubstatementValidator validator; - ListStatementSupport(final YangParserConfiguration config, final SubstatementValidator validator) { - super(YangStmtMapping.LIST, instantiatedPolicy(), config); - this.validator = requireNonNull(validator); + super(YangStmtMapping.LIST, instantiatedPolicy(), config, validator); } public static @NonNull ListStatementSupport rfc6020Instance(final YangParserConfiguration config) { @@ -129,11 +125,6 @@ public final class ListStatementSupport return new ListStatementSupport(config, RFC7950_VALIDATOR); } - @Override - protected SubstatementValidator getSubstatementValidator() { - return validator; - } - @Override protected ListStatement createDeclared(final StmtContext ctx, final ImmutableList> substatements) { diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/AbstractImplicitStatementSupport.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/AbstractImplicitStatementSupport.java index a1859bcf11..7d834e1153 100644 --- a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/AbstractImplicitStatementSupport.java +++ b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/AbstractImplicitStatementSupport.java @@ -7,6 +7,8 @@ */ package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.meta; +import static java.util.Objects.requireNonNull; + import com.google.common.collect.ImmutableList; import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.yangtools.yang.common.QName; @@ -18,6 +20,7 @@ import org.opendaylight.yangtools.yang.model.api.stmt.SchemaTreeEffectiveStateme import org.opendaylight.yangtools.yang.parser.api.YangParserConfiguration; import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractSchemaTreeStatementSupport; import org.opendaylight.yangtools.yang.parser.spi.meta.EffectiveStmtCtx.Current; +import org.opendaylight.yangtools.yang.parser.spi.meta.SubstatementValidator; /** * A massively-misnamed superclass for statements which are both schema tree participants and can be created as implicit @@ -28,9 +31,9 @@ import org.opendaylight.yangtools.yang.parser.spi.meta.EffectiveStmtCtx.Current; */ abstract class AbstractImplicitStatementSupport, E extends SchemaTreeEffectiveStatement> extends AbstractSchemaTreeStatementSupport { - AbstractImplicitStatementSupport(final StatementDefinition publicDefinition, - final StatementPolicy policy, final YangParserConfiguration config) { - super(publicDefinition, policy, config); + AbstractImplicitStatementSupport(final StatementDefinition publicDefinition, final StatementPolicy policy, + final YangParserConfiguration config, final SubstatementValidator validator) { + super(publicDefinition, policy, config, requireNonNull(validator)); } @Override diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/AbstractOperationContainerStatementSupport.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/AbstractOperationContainerStatementSupport.java index e28a999f03..796f8eb297 100644 --- a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/AbstractOperationContainerStatementSupport.java +++ b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/AbstractOperationContainerStatementSupport.java @@ -25,6 +25,7 @@ import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractQNameStatementSup import org.opendaylight.yangtools.yang.parser.spi.meta.EffectiveStmtCtx.Current; import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext; import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContextUtils; +import org.opendaylight.yangtools.yang.parser.spi.meta.SubstatementValidator; import org.opendaylight.yangtools.yang.parser.spi.source.SourceException; /** @@ -38,8 +39,9 @@ abstract class AbstractOperationContainerStatementSupport createArgument; AbstractOperationContainerStatementSupport(final StatementDefinition publicDefinition, - final YangParserConfiguration config, final Function createArgument) { - super(publicDefinition, uninstantiatedPolicy(), config); + final YangParserConfiguration config, final SubstatementValidator validator, + final Function createArgument) { + super(publicDefinition, uninstantiatedPolicy(), config, validator); this.createArgument = requireNonNull(createArgument); } diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/ActionStatementSupport.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/ActionStatementSupport.java index 95f4190745..17ee582aad 100644 --- a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/ActionStatementSupport.java +++ b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/ActionStatementSupport.java @@ -61,7 +61,7 @@ public final class ActionStatementSupport extends public ActionStatementSupport(final YangParserConfiguration config, final InputStatementSupport implicitInput, final OutputStatementSupport implicitOutput) { - super(YangStmtMapping.ACTION, uninstantiatedPolicy(), config); + super(YangStmtMapping.ACTION, uninstantiatedPolicy(), config, SUBSTATEMENT_VALIDATOR); this.implicitInput = requireNonNull(implicitInput); this.implicitOutput = requireNonNull(implicitOutput); } @@ -93,11 +93,6 @@ public final class ActionStatementSupport extends } } - @Override - protected SubstatementValidator getSubstatementValidator() { - return SUBSTATEMENT_VALIDATOR; - } - @Override protected ActionStatement createDeclared(final StmtContext ctx, final ImmutableList> substatements) { diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/AnydataStatementSupport.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/AnydataStatementSupport.java index d3ccbb7d68..43ba7726e9 100644 --- a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/AnydataStatementSupport.java +++ b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/AnydataStatementSupport.java @@ -45,12 +45,7 @@ public final class AnydataStatementSupport .build(); public AnydataStatementSupport(final YangParserConfiguration config) { - super(YangStmtMapping.ANYDATA, instantiatedPolicy(), config); - } - - @Override - protected SubstatementValidator getSubstatementValidator() { - return SUBSTATEMENT_VALIDATOR; + super(YangStmtMapping.ANYDATA, instantiatedPolicy(), config, SUBSTATEMENT_VALIDATOR); } @Override diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/AnyxmlStatementSupport.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/AnyxmlStatementSupport.java index 4610fa27dd..d1d43d0215 100644 --- a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/AnyxmlStatementSupport.java +++ b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/AnyxmlStatementSupport.java @@ -45,12 +45,7 @@ public final class AnyxmlStatementSupport .build(); public AnyxmlStatementSupport(final YangParserConfiguration config) { - super(YangStmtMapping.ANYXML, instantiatedPolicy(), config); - } - - @Override - protected SubstatementValidator getSubstatementValidator() { - return SUBSTATEMENT_VALIDATOR; + super(YangStmtMapping.ANYXML, instantiatedPolicy(), config, SUBSTATEMENT_VALIDATOR); } @Override diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/ArgumentStatementSupport.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/ArgumentStatementSupport.java index 7b6812c4b1..50cdc628f1 100644 --- a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/ArgumentStatementSupport.java +++ b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/ArgumentStatementSupport.java @@ -31,7 +31,7 @@ public final class ArgumentStatementSupport SubstatementValidator.builder(YangStmtMapping.ARGUMENT).addOptional(YangStmtMapping.YIN_ELEMENT).build(); public ArgumentStatementSupport(final YangParserConfiguration config) { - super(YangStmtMapping.ARGUMENT, StatementPolicy.reject(), config); + super(YangStmtMapping.ARGUMENT, StatementPolicy.reject(), config, SUBSTATEMENT_VALIDATOR); } @Override @@ -39,11 +39,6 @@ public final class ArgumentStatementSupport return StmtContextUtils.parseIdentifier(ctx, value); } - @Override - protected SubstatementValidator getSubstatementValidator() { - return SUBSTATEMENT_VALIDATOR; - } - @Override protected ArgumentStatement createDeclared(final StmtContext ctx, final ImmutableList> substatements) { diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/BaseStatementSupport.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/BaseStatementSupport.java index 2a84fd181e..2bb3d4238f 100644 --- a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/BaseStatementSupport.java +++ b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/BaseStatementSupport.java @@ -40,7 +40,7 @@ public final class BaseStatementSupport extends AbstractQNameStatementSupport ctx, final ImmutableList> substatements) { diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/BelongsToStatementSupport.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/BelongsToStatementSupport.java index da35338e47..aa22cfcfb7 100644 --- a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/BelongsToStatementSupport.java +++ b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/BelongsToStatementSupport.java @@ -45,7 +45,7 @@ public final class BelongsToStatementSupport SubstatementValidator.builder(YangStmtMapping.BELONGS_TO).addMandatory(YangStmtMapping.PREFIX).build(); public BelongsToStatementSupport(final YangParserConfiguration config) { - super(YangStmtMapping.BELONGS_TO, StatementPolicy.reject(), config); + super(YangStmtMapping.BELONGS_TO, StatementPolicy.reject(), config, SUBSTATEMENT_VALIDATOR); } @Override @@ -104,9 +104,4 @@ public final class BelongsToStatementSupport BelongsToEffectiveStatement> belongsToCtx) { return RevisionSourceIdentifier.create(belongsToCtx.getArgument()); } - - @Override - protected SubstatementValidator getSubstatementValidator() { - return SUBSTATEMENT_VALIDATOR; - } } diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/BitStatementSupport.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/BitStatementSupport.java index 40d11b8ecc..14457bd045 100644 --- a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/BitStatementSupport.java +++ b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/BitStatementSupport.java @@ -46,11 +46,8 @@ public final class BitStatementSupport extends AbstractStatementSupport ctx, final ImmutableList> substatements) { diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/CaseStatementSupport.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/CaseStatementSupport.java index 05918d03d3..6879078635 100644 --- a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/CaseStatementSupport.java +++ b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/CaseStatementSupport.java @@ -7,8 +7,6 @@ */ package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.meta; -import static java.util.Objects.requireNonNull; - import com.google.common.annotations.Beta; import com.google.common.collect.ImmutableList; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; @@ -74,11 +72,8 @@ public final class CaseStatementSupport .addOptional(YangStmtMapping.WHEN) .build(); - private final SubstatementValidator validator; - private CaseStatementSupport(final YangParserConfiguration config, final SubstatementValidator validator) { - super(YangStmtMapping.CASE, instantiatedPolicy(), config); - this.validator = requireNonNull(validator); + super(YangStmtMapping.CASE, instantiatedPolicy(), config, validator); } public static @NonNull CaseStatementSupport rfc6020Instance(final YangParserConfiguration config) { @@ -89,11 +84,6 @@ public final class CaseStatementSupport return new CaseStatementSupport(config, RFC7950_VALIDATOR); } - @Override - protected SubstatementValidator getSubstatementValidator() { - return validator; - } - @Override protected CaseStatement createDeclared(final StmtContext ctx, final ImmutableList> substatements) { diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/ChoiceStatementSupport.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/ChoiceStatementSupport.java index bc8fde8cb1..784c70b3b6 100644 --- a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/ChoiceStatementSupport.java +++ b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/ChoiceStatementSupport.java @@ -83,13 +83,11 @@ public final class ChoiceStatementSupport .addOptional(YangStmtMapping.WHEN) .build(); - private final SubstatementValidator validator; private final CaseStatementSupport implicitCase; private ChoiceStatementSupport(final YangParserConfiguration config, final SubstatementValidator validator, final CaseStatementSupport implicitCase) { - super(YangStmtMapping.CHOICE, instantiatedPolicy(), config); - this.validator = requireNonNull(validator); + super(YangStmtMapping.CHOICE, instantiatedPolicy(), config, requireNonNull(validator)); this.implicitCase = requireNonNull(implicitCase); } @@ -109,11 +107,6 @@ public final class ChoiceStatementSupport : Optional.empty(); } - @Override - protected SubstatementValidator getSubstatementValidator() { - return validator; - } - @Override protected ChoiceStatement createDeclared(@NonNull final StmtContext ctx, final ImmutableList> substatements) { diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/ConfigStatementSupport.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/ConfigStatementSupport.java index 5984d4368e..fa1e959aee 100644 --- a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/ConfigStatementSupport.java +++ b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/ConfigStatementSupport.java @@ -31,12 +31,7 @@ public final class ConfigStatementSupport EffectiveStatements.createConfig(false), EffectiveStatements.createConfig(true), // FIXME: This is not quite true. If we are instantiated in a context which ignores config, which should // really fizzle. This needs some more analysis. - StatementPolicy.contextIndependent(), config); - } - - @Override - protected SubstatementValidator getSubstatementValidator() { - return SUBSTATEMENT_VALIDATOR; + StatementPolicy.contextIndependent(), config, SUBSTATEMENT_VALIDATOR); } @Override diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/ContactStatementSupport.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/ContactStatementSupport.java index 2eb9e2b540..1f48e6da9e 100644 --- a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/ContactStatementSupport.java +++ b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/ContactStatementSupport.java @@ -27,12 +27,7 @@ public final class ContactStatementSupport SubstatementValidator.builder(YangStmtMapping.CONTACT).build(); public ContactStatementSupport(final YangParserConfiguration config) { - super(YangStmtMapping.CONTACT, StatementPolicy.reject(), config); - } - - @Override - protected SubstatementValidator getSubstatementValidator() { - return SUBSTATEMENT_VALIDATOR; + super(YangStmtMapping.CONTACT, StatementPolicy.reject(), config, SUBSTATEMENT_VALIDATOR); } @Override diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/ContainerStatementSupport.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/ContainerStatementSupport.java index 7d90f2b9d7..4ca2a1a05b 100644 --- a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/ContainerStatementSupport.java +++ b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/ContainerStatementSupport.java @@ -7,8 +7,6 @@ */ package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.meta; -import static java.util.Objects.requireNonNull; - import com.google.common.annotations.Beta; import com.google.common.collect.ImmutableList; import java.util.Collection; @@ -85,11 +83,8 @@ public final class ContainerStatementSupport .addOptional(YangStmtMapping.WHEN) .build(); - private final SubstatementValidator validator; - private ContainerStatementSupport(final YangParserConfiguration config, final SubstatementValidator validator) { - super(YangStmtMapping.CONTAINER, instantiatedPolicy(), config); - this.validator = requireNonNull(validator); + super(YangStmtMapping.CONTAINER, instantiatedPolicy(), config, validator); } public static @NonNull ContainerStatementSupport rfc6020Instance(final YangParserConfiguration config) { @@ -100,11 +95,6 @@ public final class ContainerStatementSupport return new ContainerStatementSupport(config, RFC7950_VALIDATOR); } - @Override - protected SubstatementValidator getSubstatementValidator() { - return validator; - } - @Override protected ContainerStatement createDeclared(final StmtContext ctx, final ImmutableList> substatements) { diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/DefaultStatementSupport.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/DefaultStatementSupport.java index f7a14d161a..36d4cc307a 100644 --- a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/DefaultStatementSupport.java +++ b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/DefaultStatementSupport.java @@ -30,12 +30,7 @@ public final class DefaultStatementSupport public DefaultStatementSupport(final YangParserConfiguration config) { // Note: if we start interpreting the string we'll need to use StatementPolicy.declaredCopy() - super(YangStmtMapping.DEFAULT, StatementPolicy.contextIndependent(), config); - } - - @Override - protected SubstatementValidator getSubstatementValidator() { - return SUBSTATEMENT_VALIDATOR; + super(YangStmtMapping.DEFAULT, StatementPolicy.contextIndependent(), config, SUBSTATEMENT_VALIDATOR); } @Override diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/DescriptionStatementSupport.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/DescriptionStatementSupport.java index d7d173afea..5ab841a233 100644 --- a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/DescriptionStatementSupport.java +++ b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/DescriptionStatementSupport.java @@ -29,12 +29,7 @@ public final class DescriptionStatementSupport SubstatementValidator.builder(YangStmtMapping.DESCRIPTION).build(); public DescriptionStatementSupport(final YangParserConfiguration config) { - super(YangStmtMapping.DESCRIPTION, StatementPolicy.contextIndependent(), config); - } - - @Override - protected SubstatementValidator getSubstatementValidator() { - return SUBSTATEMENT_VALIDATOR; + super(YangStmtMapping.DESCRIPTION, StatementPolicy.contextIndependent(), config, SUBSTATEMENT_VALIDATOR); } @Override diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/DeviationStatementSupport.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/DeviationStatementSupport.java index dbfa1bc2d8..2e55b8b382 100644 --- a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/DeviationStatementSupport.java +++ b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/DeviationStatementSupport.java @@ -32,15 +32,15 @@ import org.opendaylight.yangtools.yang.parser.spi.source.ModuleCtxToModuleQName; public final class DeviationStatementSupport extends AbstractStatementSupport { - private static final SubstatementValidator SUBSTATEMENT_VALIDATOR = SubstatementValidator.builder(YangStmtMapping - .DEVIATION) - .addOptional(YangStmtMapping.DESCRIPTION) - .addAny(YangStmtMapping.DEVIATE) - .addOptional(YangStmtMapping.REFERENCE) - .build(); + private static final SubstatementValidator SUBSTATEMENT_VALIDATOR = + SubstatementValidator.builder(YangStmtMapping.DEVIATION) + .addOptional(YangStmtMapping.DESCRIPTION) + .addAny(YangStmtMapping.DEVIATE) + .addOptional(YangStmtMapping.REFERENCE) + .build(); public DeviationStatementSupport(final YangParserConfiguration config) { - super(YangStmtMapping.DEVIATION, StatementPolicy.reject(), config); + super(YangStmtMapping.DEVIATION, StatementPolicy.reject(), config, SUBSTATEMENT_VALIDATOR); } @Override @@ -60,11 +60,6 @@ public final class DeviationStatementSupport } } - @Override - protected SubstatementValidator getSubstatementValidator() { - return SUBSTATEMENT_VALIDATOR; - } - @Override protected DeviationStatement createDeclared(final StmtContext ctx, final ImmutableList> substatements) { diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/EnumStatementSupport.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/EnumStatementSupport.java index e3cc4f109a..f1bf1c513d 100644 --- a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/EnumStatementSupport.java +++ b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/EnumStatementSupport.java @@ -7,8 +7,6 @@ */ package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.meta; -import static java.util.Objects.requireNonNull; - import com.google.common.annotations.Beta; import com.google.common.collect.ImmutableList; import org.eclipse.jdt.annotation.NonNull; @@ -44,11 +42,8 @@ public final class EnumStatementSupport .addOptional(YangStmtMapping.VALUE) .build(); - private final SubstatementValidator validator; - private EnumStatementSupport(final YangParserConfiguration config, final SubstatementValidator validator) { - super(YangStmtMapping.ENUM, StatementPolicy.contextIndependent(), config); - this.validator = requireNonNull(validator); + super(YangStmtMapping.ENUM, StatementPolicy.contextIndependent(), config, validator); } public static @NonNull EnumStatementSupport rfc6020Instance(final YangParserConfiguration config) { @@ -65,11 +60,6 @@ public final class EnumStatementSupport return value; } - @Override - protected SubstatementValidator getSubstatementValidator() { - return validator; - } - @Override protected EnumStatement createDeclared(final StmtContext ctx, final ImmutableList> substatements) { diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/ErrorAppTagStatementSupport.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/ErrorAppTagStatementSupport.java index 850f4a071e..475aa81b93 100644 --- a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/ErrorAppTagStatementSupport.java +++ b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/ErrorAppTagStatementSupport.java @@ -25,16 +25,11 @@ import org.opendaylight.yangtools.yang.parser.spi.meta.SubstatementValidator; public final class ErrorAppTagStatementSupport extends AbstractStringStatementSupport { - private static final SubstatementValidator SUBSTATEMENT_VALIDATOR = SubstatementValidator.builder( - YangStmtMapping.ERROR_APP_TAG).build(); + private static final SubstatementValidator SUBSTATEMENT_VALIDATOR = + SubstatementValidator.builder(YangStmtMapping.ERROR_APP_TAG).build(); public ErrorAppTagStatementSupport(final YangParserConfiguration config) { - super(YangStmtMapping.ERROR_APP_TAG, StatementPolicy.contextIndependent(), config); - } - - @Override - protected SubstatementValidator getSubstatementValidator() { - return SUBSTATEMENT_VALIDATOR; + super(YangStmtMapping.ERROR_APP_TAG, StatementPolicy.contextIndependent(), config, SUBSTATEMENT_VALIDATOR); } @Override diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/ErrorMessageStatementSupport.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/ErrorMessageStatementSupport.java index 80751923c2..5a935e60de 100644 --- a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/ErrorMessageStatementSupport.java +++ b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/ErrorMessageStatementSupport.java @@ -29,12 +29,7 @@ public final class ErrorMessageStatementSupport SubstatementValidator.builder(YangStmtMapping.ERROR_MESSAGE).build(); public ErrorMessageStatementSupport(final YangParserConfiguration config) { - super(YangStmtMapping.ERROR_MESSAGE, StatementPolicy.contextIndependent(), config); - } - - @Override - protected SubstatementValidator getSubstatementValidator() { - return SUBSTATEMENT_VALIDATOR; + super(YangStmtMapping.ERROR_MESSAGE, StatementPolicy.contextIndependent(), config, SUBSTATEMENT_VALIDATOR); } @Override diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/FeatureStatementSupport.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/FeatureStatementSupport.java index 38f6d800de..7b78289ef6 100644 --- a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/FeatureStatementSupport.java +++ b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/FeatureStatementSupport.java @@ -41,7 +41,7 @@ public final class FeatureStatementSupport .build(); public FeatureStatementSupport(final YangParserConfiguration config) { - super(YangStmtMapping.FEATURE, StatementPolicy.reject(), config); + super(YangStmtMapping.FEATURE, StatementPolicy.reject(), config, SUBSTATEMENT_VALIDATOR); } @Override @@ -55,11 +55,6 @@ public final class FeatureStatementSupport stmt.addContext(FeatureNamespace.class, stmt.getArgument(), stmt); } - @Override - protected SubstatementValidator getSubstatementValidator() { - return SUBSTATEMENT_VALIDATOR; - } - @Override protected FeatureStatement createDeclared(final StmtContext ctx, final ImmutableList> substatements) { diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/FractionDigitsStatementSupport.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/FractionDigitsStatementSupport.java index 9f9ae2c676..c69037f6e9 100644 --- a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/FractionDigitsStatementSupport.java +++ b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/FractionDigitsStatementSupport.java @@ -45,7 +45,7 @@ public final class FractionDigitsStatementSupport } public FractionDigitsStatementSupport(final YangParserConfiguration config) { - super(YangStmtMapping.FRACTION_DIGITS, StatementPolicy.contextIndependent(), config); + super(YangStmtMapping.FRACTION_DIGITS, StatementPolicy.contextIndependent(), config, SUBSTATEMENT_VALIDATOR); } @Override @@ -62,11 +62,6 @@ public final class FractionDigitsStatementSupport return fractionDigits; } - @Override - protected SubstatementValidator getSubstatementValidator() { - return SUBSTATEMENT_VALIDATOR; - } - @Override protected FractionDigitsStatement createDeclared(final StmtContext ctx, final ImmutableList> substatements) { diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/GroupingStatementSupport.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/GroupingStatementSupport.java index b82d205b08..2b7842afaf 100644 --- a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/GroupingStatementSupport.java +++ b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/GroupingStatementSupport.java @@ -7,8 +7,6 @@ */ package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.meta; -import static java.util.Objects.requireNonNull; - import com.google.common.annotations.Beta; import com.google.common.collect.ImmutableList; import java.util.Collection; @@ -77,15 +75,12 @@ public final class GroupingStatementSupport .addAny(YangStmtMapping.USES) .build(); - private final SubstatementValidator validator; - GroupingStatementSupport(final YangParserConfiguration config, final SubstatementValidator validator) { super(YangStmtMapping.GROUPING, StatementPolicy.copyDeclared( (copy, current, substatements) -> copy.history().isAddedByUses() == current.history().isAddedByUses() && copy.getArgument().equals(current.getArgument()) - && copy.equalParentPath(current)), config); - this.validator = requireNonNull(validator); + && copy.equalParentPath(current)), config, validator); } public static @NonNull GroupingStatementSupport rfc6020Instance(final YangParserConfiguration config) { @@ -135,11 +130,6 @@ public final class GroupingStatementSupport } } - @Override - protected SubstatementValidator getSubstatementValidator() { - return validator; - } - @Override protected GroupingStatement createDeclared(final StmtContext ctx, final ImmutableList> substatements) { diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/IdentityStatementSupport.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/IdentityStatementSupport.java index e8ed3225af..cf25d18740 100644 --- a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/IdentityStatementSupport.java +++ b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/IdentityStatementSupport.java @@ -9,7 +9,6 @@ package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.meta; import static com.google.common.base.Verify.verify; import static com.google.common.base.Verify.verifyNotNull; -import static java.util.Objects.requireNonNull; import com.google.common.annotations.Beta; import com.google.common.collect.ImmutableList; @@ -61,11 +60,8 @@ public final class IdentityStatementSupport .addOptional(YangStmtMapping.STATUS) .build(); - private final SubstatementValidator validator; - private IdentityStatementSupport(final YangParserConfiguration config, final SubstatementValidator validator) { - super(YangStmtMapping.IDENTITY, StatementPolicy.reject(), config); - this.validator = requireNonNull(validator); + super(YangStmtMapping.IDENTITY, StatementPolicy.reject(), config, validator); } public static @NonNull IdentityStatementSupport rfc6020Instance(final YangParserConfiguration config) { @@ -90,11 +86,6 @@ public final class IdentityStatementSupport stmt.addToNs(IdentityNamespace.class, qname, stmt); } - @Override - protected SubstatementValidator getSubstatementValidator() { - return validator; - } - @Override protected IdentityStatement createDeclared(final StmtContext ctx, final ImmutableList> substatements) { diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/IncludeStatementSupport.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/IncludeStatementSupport.java index 6efe34df01..2701a3069c 100644 --- a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/IncludeStatementSupport.java +++ b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/IncludeStatementSupport.java @@ -7,7 +7,6 @@ */ package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.meta; -import static java.util.Objects.requireNonNull; import static org.opendaylight.yangtools.yang.parser.spi.meta.ModelProcessingPhase.SOURCE_LINKAGE; import static org.opendaylight.yangtools.yang.parser.spi.meta.StmtContextUtils.findFirstDeclaredSubstatement; @@ -58,11 +57,8 @@ public final class IncludeStatementSupport .addOptional(YangStmtMapping.REFERENCE) .build(); - private final SubstatementValidator validator; - IncludeStatementSupport(final YangParserConfiguration config, final SubstatementValidator validator) { - super(YangStmtMapping.INCLUDE, StatementPolicy.reject(), config); - this.validator = requireNonNull(validator); + super(YangStmtMapping.INCLUDE, StatementPolicy.reject(), config, validator); } public static @NonNull IncludeStatementSupport rfc6020Instance(final YangParserConfiguration config) { @@ -115,11 +111,6 @@ public final class IncludeStatementSupport }); } - @Override - protected SubstatementValidator getSubstatementValidator() { - return validator; - } - @Override protected IncludeStatement createDeclared(final StmtContext ctx, final ImmutableList> substatements) { diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/InputStatementSupport.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/InputStatementSupport.java index 075601ab28..136bfb8083 100644 --- a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/InputStatementSupport.java +++ b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/InputStatementSupport.java @@ -7,8 +7,6 @@ */ package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.meta; -import static java.util.Objects.requireNonNull; - import com.google.common.annotations.Beta; import com.google.common.collect.ImmutableList; import org.eclipse.jdt.annotation.NonNull; @@ -60,11 +58,8 @@ public final class InputStatementSupport .addAny(YangStmtMapping.USES) .build(); - private final SubstatementValidator validator; - private InputStatementSupport(final YangParserConfiguration config, final SubstatementValidator validator) { - super(YangStmtMapping.INPUT, config, YangConstants::operationInputQName); - this.validator = requireNonNull(validator); + super(YangStmtMapping.INPUT, config, validator, YangConstants::operationInputQName); } public static @NonNull InputStatementSupport rfc6020Instance(final YangParserConfiguration config) { @@ -75,11 +70,6 @@ public final class InputStatementSupport return new InputStatementSupport(config, RFC7950_VALIDATOR); } - @Override - protected SubstatementValidator getSubstatementValidator() { - return validator; - } - @Override protected InputStatement createDeclared(final StmtContext ctx, final ImmutableList> substatements) { diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/KeyStatementSupport.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/KeyStatementSupport.java index a2a828b6e8..51fa88be22 100644 --- a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/KeyStatementSupport.java +++ b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/KeyStatementSupport.java @@ -62,7 +62,8 @@ public final class KeyStatementSupport public KeyStatementSupport(final YangParserConfiguration config) { super(YangStmtMapping.KEY, StatementPolicy.copyDeclared( // Identity comparison is sufficient because adaptArgumentValue() is careful about reuse. - (copy, current, substatements) -> copy.getArgument() == current.getArgument()), config); + (copy, current, substatements) -> copy.getArgument() == current.getArgument()), + config, SUBSTATEMENT_VALIDATOR); } @Override @@ -99,11 +100,6 @@ public final class KeyStatementSupport return replaced ? builder.build() : ctx.argument(); } - @Override - protected SubstatementValidator getSubstatementValidator() { - return SUBSTATEMENT_VALIDATOR; - } - @Override protected KeyStatement createDeclared(final StmtContext, KeyStatement, ?> ctx, final ImmutableList> substatements) { diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/LeafStatementSupport.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/LeafStatementSupport.java index cd6d3f5fb0..c0b0af1f47 100644 --- a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/LeafStatementSupport.java +++ b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/LeafStatementSupport.java @@ -54,7 +54,7 @@ public final class LeafStatementSupport .build(); public LeafStatementSupport(final YangParserConfiguration config) { - super(YangStmtMapping.LEAF, instantiatedPolicy(), config); + super(YangStmtMapping.LEAF, instantiatedPolicy(), config, SUBSTATEMENT_VALIDATOR); } @Override @@ -63,11 +63,6 @@ public final class LeafStatementSupport StmtContextUtils.validateIfFeatureAndWhenOnListKeys(ctx); } - @Override - protected SubstatementValidator getSubstatementValidator() { - return SUBSTATEMENT_VALIDATOR; - } - @Override protected LeafStatement createDeclared(final StmtContext ctx, final ImmutableList> substatements) { diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/LengthStatementSupport.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/LengthStatementSupport.java index e28eec6aa9..4f5a45bad4 100644 --- a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/LengthStatementSupport.java +++ b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/LengthStatementSupport.java @@ -45,7 +45,7 @@ public final class LengthStatementSupport .build(); public LengthStatementSupport(final YangParserConfiguration config) { - super(YangStmtMapping.LENGTH, StatementPolicy.contextIndependent(), config); + super(YangStmtMapping.LENGTH, StatementPolicy.contextIndependent(), config, SUBSTATEMENT_VALIDATOR); } @Override @@ -79,11 +79,6 @@ public final class LengthStatementSupport return ImmutableList.copyOf(ranges); } - @Override - protected SubstatementValidator getSubstatementValidator() { - return SUBSTATEMENT_VALIDATOR; - } - @Override protected LengthStatement createDeclared(final StmtContext, LengthStatement, ?> ctx, final ImmutableList> substatements) { diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/MandatoryStatementSupport.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/MandatoryStatementSupport.java index b39a554ffe..1aced24666 100644 --- a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/MandatoryStatementSupport.java +++ b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/MandatoryStatementSupport.java @@ -30,12 +30,7 @@ public final class MandatoryStatementSupport extends super(YangStmtMapping.MANDATORY, EffectiveStatements.createMandatory(DeclaredStatements.createMandatory(Boolean.FALSE)), EffectiveStatements.createMandatory(DeclaredStatements.createMandatory(Boolean.TRUE)), - StatementPolicy.contextIndependent(), config); - } - - @Override - protected SubstatementValidator getSubstatementValidator() { - return SUBSTATEMENT_VALIDATOR; + StatementPolicy.contextIndependent(), config, SUBSTATEMENT_VALIDATOR); } @Override diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/MaxElementsStatementSupport.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/MaxElementsStatementSupport.java index 62e51f9de7..021dde9da2 100644 --- a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/MaxElementsStatementSupport.java +++ b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/MaxElementsStatementSupport.java @@ -29,7 +29,7 @@ public final class MaxElementsStatementSupport SubstatementValidator.builder(YangStmtMapping.MAX_ELEMENTS).build(); public MaxElementsStatementSupport(final YangParserConfiguration config) { - super(YangStmtMapping.MAX_ELEMENTS, StatementPolicy.contextIndependent(), config); + super(YangStmtMapping.MAX_ELEMENTS, StatementPolicy.contextIndependent(), config, SUBSTATEMENT_VALIDATOR); } @Override @@ -37,11 +37,6 @@ public final class MaxElementsStatementSupport return "unbounded".equals(rawArgument) ? "unbounded" : rawArgument; } - @Override - protected SubstatementValidator getSubstatementValidator() { - return SUBSTATEMENT_VALIDATOR; - } - @Override protected MaxElementsStatement createDeclared(final StmtContext ctx, final ImmutableList> substatements) { diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/MinElementsStatementSupport.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/MinElementsStatementSupport.java index b1880d3985..bc19dc3b0f 100644 --- a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/MinElementsStatementSupport.java +++ b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/MinElementsStatementSupport.java @@ -29,7 +29,7 @@ public final class MinElementsStatementSupport SubstatementValidator.builder(YangStmtMapping.MIN_ELEMENTS).build(); public MinElementsStatementSupport(final YangParserConfiguration config) { - super(YangStmtMapping.MIN_ELEMENTS, StatementPolicy.contextIndependent(), config); + super(YangStmtMapping.MIN_ELEMENTS, StatementPolicy.contextIndependent(), config, SUBSTATEMENT_VALIDATOR); } @Override @@ -41,11 +41,6 @@ public final class MinElementsStatementSupport } } - @Override - protected SubstatementValidator getSubstatementValidator() { - return SUBSTATEMENT_VALIDATOR; - } - @Override protected MinElementsStatement createDeclared(final Integer argument, final ImmutableList> substatements) { diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/ModifierStatementSupport.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/ModifierStatementSupport.java index acaff663b8..513966b340 100644 --- a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/ModifierStatementSupport.java +++ b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/ModifierStatementSupport.java @@ -31,7 +31,7 @@ public final class ModifierStatementSupport SubstatementValidator.builder(YangStmtMapping.MODIFIER).build(); public ModifierStatementSupport(final YangParserConfiguration config) { - super(YangStmtMapping.MODIFIER, StatementPolicy.contextIndependent(), config); + super(YangStmtMapping.MODIFIER, StatementPolicy.contextIndependent(), config, SUBSTATEMENT_VALIDATOR); } @Override @@ -40,11 +40,6 @@ public final class ModifierStatementSupport "'%s' is not valid argument of modifier statement", value); } - @Override - protected SubstatementValidator getSubstatementValidator() { - return SUBSTATEMENT_VALIDATOR; - } - @Override public String internArgument(final String rawArgument) { return "invert-match".equals(rawArgument) ? "invert-match" : rawArgument; diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/MustStatementSupport.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/MustStatementSupport.java index eed8b1b61c..680dadc03e 100644 --- a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/MustStatementSupport.java +++ b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/MustStatementSupport.java @@ -41,7 +41,7 @@ public final class MustStatementSupport public MustStatementSupport(final XPathSupport xpathSupport, final YangParserConfiguration config) { // Note: if we end up binding expressions, this needs to become declaredCopy() - super(YangStmtMapping.MUST, StatementPolicy.contextIndependent(), config); + super(YangStmtMapping.MUST, StatementPolicy.contextIndependent(), config, SUBSTATEMENT_VALIDATOR); this.xpathSupport = requireNonNull(xpathSupport); } @@ -50,11 +50,6 @@ public final class MustStatementSupport return xpathSupport.parseXPath(ctx, value); } - @Override - protected SubstatementValidator getSubstatementValidator() { - return SUBSTATEMENT_VALIDATOR; - } - @Override protected MustStatement createDeclared(final StmtContext ctx, final ImmutableList> substatements) { diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/NamespaceStatementSupport.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/NamespaceStatementSupport.java index 0455399f5a..4dc6f5b8df 100644 --- a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/NamespaceStatementSupport.java +++ b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/NamespaceStatementSupport.java @@ -32,7 +32,7 @@ public final class NamespaceStatementSupport SubstatementValidator.builder(YangStmtMapping.NAMESPACE).build(); public NamespaceStatementSupport(final YangParserConfiguration config) { - super(YangStmtMapping.NAMESPACE, StatementPolicy.reject(), config); + super(YangStmtMapping.NAMESPACE, StatementPolicy.reject(), config, SUBSTATEMENT_VALIDATOR); } @Override @@ -44,11 +44,6 @@ public final class NamespaceStatementSupport } } - @Override - protected SubstatementValidator getSubstatementValidator() { - return SUBSTATEMENT_VALIDATOR; - } - @Override protected NamespaceStatement createDeclared(@NonNull final StmtContext ctx, final ImmutableList> substatements) { diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/OrderedByStatementSupport.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/OrderedByStatementSupport.java index d445c9e4f9..6476b32618 100644 --- a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/OrderedByStatementSupport.java +++ b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/OrderedByStatementSupport.java @@ -46,7 +46,7 @@ public final class OrderedByStatementSupport EffectiveStatements.createOrderedBy(EMPTY_USER_DECL); public OrderedByStatementSupport(final YangParserConfiguration config) { - super(YangStmtMapping.ORDERED_BY, StatementPolicy.contextIndependent(), config); + super(YangStmtMapping.ORDERED_BY, StatementPolicy.contextIndependent(), config, SUBSTATEMENT_VALIDATOR); } @Override @@ -69,11 +69,6 @@ public final class OrderedByStatementSupport } } - @Override - protected SubstatementValidator getSubstatementValidator() { - return SUBSTATEMENT_VALIDATOR; - } - @Override protected OrderedByStatement createDeclared(final StmtContext ctx, final ImmutableList> substatements) { diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/OrganizationStatementSupport.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/OrganizationStatementSupport.java index 9c953d88ee..339bd2c9e1 100644 --- a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/OrganizationStatementSupport.java +++ b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/OrganizationStatementSupport.java @@ -27,12 +27,7 @@ public final class OrganizationStatementSupport SubstatementValidator.builder(YangStmtMapping.ORGANIZATION).build(); public OrganizationStatementSupport(final YangParserConfiguration config) { - super(YangStmtMapping.ORGANIZATION, StatementPolicy.reject(), config); - } - - @Override - protected SubstatementValidator getSubstatementValidator() { - return SUBSTATEMENT_VALIDATOR; + super(YangStmtMapping.ORGANIZATION, StatementPolicy.reject(), config, SUBSTATEMENT_VALIDATOR); } @Override diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/OutputStatementSupport.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/OutputStatementSupport.java index c45699555e..46de5c5e0f 100644 --- a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/OutputStatementSupport.java +++ b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/OutputStatementSupport.java @@ -7,8 +7,6 @@ */ package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.meta; -import static java.util.Objects.requireNonNull; - import com.google.common.annotations.Beta; import com.google.common.collect.ImmutableList; import org.eclipse.jdt.annotation.NonNull; @@ -60,11 +58,8 @@ public final class OutputStatementSupport .addAny(YangStmtMapping.USES) .build(); - private final SubstatementValidator validator; - private OutputStatementSupport(final YangParserConfiguration config, final SubstatementValidator validator) { - super(YangStmtMapping.OUTPUT, config, YangConstants::operationOutputQName); - this.validator = requireNonNull(validator); + super(YangStmtMapping.OUTPUT, config, validator, YangConstants::operationOutputQName); } public static @NonNull OutputStatementSupport rfc6020Instance(final YangParserConfiguration config) { @@ -75,11 +70,6 @@ public final class OutputStatementSupport return new OutputStatementSupport(config, RFC7950_VALIDATOR); } - @Override - protected SubstatementValidator getSubstatementValidator() { - return validator; - } - @Override protected OutputStatement createDeclared(final StmtContext ctx, final ImmutableList> substatements) { diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/PositionStatementSupport.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/PositionStatementSupport.java index 57ef79941b..66f10df1dc 100644 --- a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/PositionStatementSupport.java +++ b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/PositionStatementSupport.java @@ -30,7 +30,7 @@ public final class PositionStatementSupport SubstatementValidator.builder(YangStmtMapping.POSITION).build(); public PositionStatementSupport(final YangParserConfiguration config) { - super(YangStmtMapping.POSITION, StatementPolicy.contextIndependent(), config); + super(YangStmtMapping.POSITION, StatementPolicy.contextIndependent(), config, SUBSTATEMENT_VALIDATOR); } @Override @@ -42,11 +42,6 @@ public final class PositionStatementSupport } } - @Override - protected SubstatementValidator getSubstatementValidator() { - return SUBSTATEMENT_VALIDATOR; - } - @Override protected PositionStatement createDeclared(final Uint32 argument, final ImmutableList> substatements) { diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/PrefixStatementSupport.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/PrefixStatementSupport.java index 47164b0e40..974699f5a3 100644 --- a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/PrefixStatementSupport.java +++ b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/PrefixStatementSupport.java @@ -29,12 +29,7 @@ public final class PrefixStatementSupport SubstatementValidator.builder(YangStmtMapping.PREFIX).build(); public PrefixStatementSupport(final YangParserConfiguration config) { - super(YangStmtMapping.PREFIX, StatementPolicy.reject(), config); - } - - @Override - protected SubstatementValidator getSubstatementValidator() { - return SUBSTATEMENT_VALIDATOR; + super(YangStmtMapping.PREFIX, StatementPolicy.reject(), config, SUBSTATEMENT_VALIDATOR); } @Override diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/PresenceStatementSupport.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/PresenceStatementSupport.java index 562fbacf0c..49b46022cb 100644 --- a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/PresenceStatementSupport.java +++ b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/PresenceStatementSupport.java @@ -29,12 +29,7 @@ public final class PresenceStatementSupport SubstatementValidator.builder(YangStmtMapping.PRESENCE).build(); public PresenceStatementSupport(final YangParserConfiguration config) { - super(YangStmtMapping.PRESENCE, StatementPolicy.contextIndependent(), config); - } - - @Override - protected SubstatementValidator getSubstatementValidator() { - return SUBSTATEMENT_VALIDATOR; + super(YangStmtMapping.PRESENCE, StatementPolicy.contextIndependent(), config, SUBSTATEMENT_VALIDATOR); } @Override diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/RangeStatementSupport.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/RangeStatementSupport.java index 22b61e23bb..a839d34a54 100644 --- a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/RangeStatementSupport.java +++ b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/RangeStatementSupport.java @@ -46,7 +46,7 @@ public final class RangeStatementSupport .build(); public RangeStatementSupport(final YangParserConfiguration config) { - super(YangStmtMapping.RANGE, StatementPolicy.contextIndependent(), config); + super(YangStmtMapping.RANGE, StatementPolicy.contextIndependent(), config, SUBSTATEMENT_VALIDATOR); } @Override @@ -98,11 +98,6 @@ public final class RangeStatementSupport return EffectiveStatements.createRange(stmt.declared(), substatements); } - @Override - protected SubstatementValidator getSubstatementValidator() { - return SUBSTATEMENT_VALIDATOR; - } - private static @NonNull Number parseDecimalConstraintValue(final @NonNull StmtContext ctx, final @NonNull String value) { if ("max".equals(value)) { diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/ReferenceStatementSupport.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/ReferenceStatementSupport.java index d627a168a3..bf46fbc0bb 100644 --- a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/ReferenceStatementSupport.java +++ b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/ReferenceStatementSupport.java @@ -27,12 +27,7 @@ public final class ReferenceStatementSupport SubstatementValidator.builder(YangStmtMapping.REFERENCE).build(); public ReferenceStatementSupport(final YangParserConfiguration config) { - super(YangStmtMapping.REFERENCE, StatementPolicy.contextIndependent(), config); - } - - @Override - protected SubstatementValidator getSubstatementValidator() { - return SUBSTATEMENT_VALIDATOR; + super(YangStmtMapping.REFERENCE, StatementPolicy.contextIndependent(), config, SUBSTATEMENT_VALIDATOR); } @Override diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/RequireInstanceStatementSupport.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/RequireInstanceStatementSupport.java index 844d5b9195..2530bb4c58 100644 --- a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/RequireInstanceStatementSupport.java +++ b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/RequireInstanceStatementSupport.java @@ -29,12 +29,7 @@ public final class RequireInstanceStatementSupport public RequireInstanceStatementSupport(final YangParserConfiguration config) { super(YangStmtMapping.REQUIRE_INSTANCE, EffectiveStatements.createRequireInstance(false), EffectiveStatements.createRequireInstance(true), - StatementPolicy.contextIndependent(), config); - } - - @Override - protected SubstatementValidator getSubstatementValidator() { - return SUBSTATEMENT_VALIDATOR; + StatementPolicy.contextIndependent(), config, SUBSTATEMENT_VALIDATOR); } @Override diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/RevisionDateStatementSupport.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/RevisionDateStatementSupport.java index 1c94f62f95..809ce341b5 100644 --- a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/RevisionDateStatementSupport.java +++ b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/RevisionDateStatementSupport.java @@ -32,7 +32,7 @@ public final class RevisionDateStatementSupport SubstatementValidator.builder(YangStmtMapping.REVISION_DATE).build(); public RevisionDateStatementSupport(final YangParserConfiguration config) { - super(YangStmtMapping.REVISION_DATE, StatementPolicy.contextIndependent(), config); + super(YangStmtMapping.REVISION_DATE, StatementPolicy.contextIndependent(), config, SUBSTATEMENT_VALIDATOR); } @Override @@ -44,11 +44,6 @@ public final class RevisionDateStatementSupport } } - @Override - protected SubstatementValidator getSubstatementValidator() { - return SUBSTATEMENT_VALIDATOR; - } - @Override protected RevisionDateStatement createDeclared(final StmtContext ctx, final ImmutableList> substatements) { diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/RevisionStatementSupport.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/RevisionStatementSupport.java index c1a1605561..b5fc20ab07 100644 --- a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/RevisionStatementSupport.java +++ b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/RevisionStatementSupport.java @@ -35,7 +35,7 @@ public final class RevisionStatementSupport .build(); public RevisionStatementSupport(final YangParserConfiguration config) { - super(YangStmtMapping.REVISION, StatementPolicy.reject(), config); + super(YangStmtMapping.REVISION, StatementPolicy.reject(), config, SUBSTATEMENT_VALIDATOR); } @Override @@ -47,11 +47,6 @@ public final class RevisionStatementSupport } } - @Override - protected SubstatementValidator getSubstatementValidator() { - return SUBSTATEMENT_VALIDATOR; - } - @Override protected RevisionStatement createDeclared(final StmtContext ctx, final ImmutableList> substatements) { diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/RpcStatementSupport.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/RpcStatementSupport.java index b80538507f..7a848fe98f 100644 --- a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/RpcStatementSupport.java +++ b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/RpcStatementSupport.java @@ -58,7 +58,7 @@ public final class RpcStatementSupport extends AbstractSchemaTreeStatementSuppor public RpcStatementSupport(final YangParserConfiguration config, final InputStatementSupport implicitInput, final OutputStatementSupport implicitOutput) { - super(YangStmtMapping.RPC, StatementPolicy.reject(), config); + super(YangStmtMapping.RPC, StatementPolicy.reject(), config, SUBSTATEMENT_VALIDATOR); this.implicitInput = requireNonNull(implicitInput); this.implicitOutput = requireNonNull(implicitOutput); } @@ -76,11 +76,6 @@ public final class RpcStatementSupport extends AbstractSchemaTreeStatementSuppor } } - @Override - protected SubstatementValidator getSubstatementValidator() { - return SUBSTATEMENT_VALIDATOR; - } - @Override protected RpcStatement createDeclared(final StmtContext ctx, final ImmutableList> substatements) { diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/StatusStatementSupport.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/StatusStatementSupport.java index e63141eb32..f9be0030bb 100644 --- a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/StatusStatementSupport.java +++ b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/StatusStatementSupport.java @@ -31,7 +31,7 @@ public final class StatusStatementSupport SubstatementValidator.builder(YangStmtMapping.STATUS).build(); public StatusStatementSupport(final YangParserConfiguration config) { - super(YangStmtMapping.STATUS, StatementPolicy.contextIndependent(), config); + super(YangStmtMapping.STATUS, StatementPolicy.contextIndependent(), config, SUBSTATEMENT_VALIDATOR); } @Override @@ -62,11 +62,6 @@ public final class StatusStatementSupport } } - @Override - protected SubstatementValidator getSubstatementValidator() { - return SUBSTATEMENT_VALIDATOR; - } - @Override protected StatusStatement createDeclared(final StmtContext ctx, final ImmutableList> substatements) { diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/TypedefStatementSupport.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/TypedefStatementSupport.java index 0af4489341..b064a5fc97 100644 --- a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/TypedefStatementSupport.java +++ b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/TypedefStatementSupport.java @@ -55,7 +55,7 @@ public final class TypedefStatementSupport extends .build(); public TypedefStatementSupport(final YangParserConfiguration config) { - super(YangStmtMapping.TYPEDEF, StatementPolicy.exactReplica(), config); + super(YangStmtMapping.TYPEDEF, StatementPolicy.exactReplica(), config, SUBSTATEMENT_VALIDATOR); } @Override @@ -97,11 +97,6 @@ public final class TypedefStatementSupport extends } } - @Override - protected SubstatementValidator getSubstatementValidator() { - return SUBSTATEMENT_VALIDATOR; - } - @Override protected TypedefStatement createDeclared(final StmtContext ctx, final ImmutableList> substatements) { diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/UniqueStatementSupport.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/UniqueStatementSupport.java index 47a002035a..ff85bb7c1d 100644 --- a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/UniqueStatementSupport.java +++ b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/UniqueStatementSupport.java @@ -50,7 +50,7 @@ public final class UniqueStatementSupport public UniqueStatementSupport(final YangParserConfiguration config) { // FIXME: This reflects what the current implementation does. We really want to define an adaptArgumentValue(), // but how that plays with the argument and expectations needs to be investigated. - super(YangStmtMapping.UNIQUE, StatementPolicy.contextIndependent(), config); + super(YangStmtMapping.UNIQUE, StatementPolicy.contextIndependent(), config, SUBSTATEMENT_VALIDATOR); } @Override @@ -62,11 +62,6 @@ public final class UniqueStatementSupport return uniqueConstraints; } - @Override - protected SubstatementValidator getSubstatementValidator() { - return SUBSTATEMENT_VALIDATOR; - } - @Override protected UniqueStatement createDeclared(final StmtContext, UniqueStatement, ?> ctx, final ImmutableList> substatements) { diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/UnitsStatementSupport.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/UnitsStatementSupport.java index da73d40934..1cfd62eff9 100644 --- a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/UnitsStatementSupport.java +++ b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/UnitsStatementSupport.java @@ -29,12 +29,7 @@ public final class UnitsStatementSupport SubstatementValidator.builder(YangStmtMapping.UNITS).build(); public UnitsStatementSupport(final YangParserConfiguration config) { - super(YangStmtMapping.UNITS, StatementPolicy.contextIndependent(), config); - } - - @Override - protected SubstatementValidator getSubstatementValidator() { - return SUBSTATEMENT_VALIDATOR; + super(YangStmtMapping.UNITS, StatementPolicy.contextIndependent(), config, SUBSTATEMENT_VALIDATOR); } @Override diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/ValueStatementSupport.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/ValueStatementSupport.java index 7ce4819f81..a7f2e2a4a3 100644 --- a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/ValueStatementSupport.java +++ b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/ValueStatementSupport.java @@ -30,7 +30,7 @@ public final class ValueStatementSupport SubstatementValidator.builder(YangStmtMapping.VALUE).build(); public ValueStatementSupport(final YangParserConfiguration config) { - super(YangStmtMapping.VALUE, StatementPolicy.contextIndependent(), config); + super(YangStmtMapping.VALUE, StatementPolicy.contextIndependent(), config, SUBSTATEMENT_VALIDATOR); } @Override @@ -43,11 +43,6 @@ public final class ValueStatementSupport } } - @Override - protected SubstatementValidator getSubstatementValidator() { - return SUBSTATEMENT_VALIDATOR; - } - @Override protected ValueStatement createDeclared(final Integer argument, final ImmutableList> substatements) { diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/WhenStatementSupport.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/WhenStatementSupport.java index 3e34e32ee4..7f8cbd4498 100644 --- a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/WhenStatementSupport.java +++ b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/WhenStatementSupport.java @@ -29,17 +29,17 @@ import org.opendaylight.yangtools.yang.xpath.api.YangXPathExpression.QualifiedBo public final class WhenStatementSupport extends AbstractStatementSupport { - private static final SubstatementValidator SUBSTATEMENT_VALIDATOR = SubstatementValidator.builder( - YangStmtMapping.WHEN) - .addOptional(YangStmtMapping.DESCRIPTION) - .addOptional(YangStmtMapping.REFERENCE) - .build(); + private static final SubstatementValidator SUBSTATEMENT_VALIDATOR = + SubstatementValidator.builder(YangStmtMapping.WHEN) + .addOptional(YangStmtMapping.DESCRIPTION) + .addOptional(YangStmtMapping.REFERENCE) + .build(); private final @NonNull XPathSupport xpathSupport; public WhenStatementSupport(final XPathSupport xpathSupport, final YangParserConfiguration config) { // Note: if we end up binding expressions, this needs to become declaredCopy() - super(YangStmtMapping.WHEN, StatementPolicy.contextIndependent(), config); + super(YangStmtMapping.WHEN, StatementPolicy.contextIndependent(), config, SUBSTATEMENT_VALIDATOR); this.xpathSupport = requireNonNull(xpathSupport); } @@ -48,11 +48,6 @@ public final class WhenStatementSupport return xpathSupport.parseXPath(ctx, value); } - @Override - protected SubstatementValidator getSubstatementValidator() { - return SUBSTATEMENT_VALIDATOR; - } - @Override protected WhenStatement createDeclared(final StmtContext ctx, final ImmutableList> substatements) { diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/YangVersionStatementSupport.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/YangVersionStatementSupport.java index a3f18faaca..b3f6aa8505 100644 --- a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/YangVersionStatementSupport.java +++ b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/YangVersionStatementSupport.java @@ -32,7 +32,7 @@ public final class YangVersionStatementSupport SubstatementValidator.builder(YangStmtMapping.YANG_VERSION).build(); public YangVersionStatementSupport(final YangParserConfiguration config) { - super(YangStmtMapping.YANG_VERSION, StatementPolicy.reject(), config); + super(YangStmtMapping.YANG_VERSION, StatementPolicy.reject(), config, SUBSTATEMENT_VALIDATOR); } @Override @@ -46,11 +46,6 @@ public final class YangVersionStatementSupport stmt.setRootVersion(stmt.argument()); } - @Override - protected SubstatementValidator getSubstatementValidator() { - return SUBSTATEMENT_VALIDATOR; - } - @Override protected YangVersionStatement createDeclared(final StmtContext ctx, final ImmutableList> substatements) { diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/YinElementStatementSupport.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/YinElementStatementSupport.java index f2ef06a2bc..ec75fc9c34 100644 --- a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/YinElementStatementSupport.java +++ b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/meta/YinElementStatementSupport.java @@ -23,19 +23,14 @@ import org.opendaylight.yangtools.yang.parser.spi.meta.SubstatementValidator; public final class YinElementStatementSupport extends AbstractBooleanStatementSupport { - private static final SubstatementValidator SUBSTATEMENT_VALIDATOR = SubstatementValidator.builder( - YangStmtMapping.YIN_ELEMENT).build(); + private static final SubstatementValidator SUBSTATEMENT_VALIDATOR = + SubstatementValidator.builder(YangStmtMapping.YIN_ELEMENT).build(); public YinElementStatementSupport(final YangParserConfiguration config) { super(YangStmtMapping.YIN_ELEMENT, EffectiveStatements.createYinElement(DeclaredStatements.createYinElement(false)), EffectiveStatements.createYinElement(DeclaredStatements.createYinElement(true)), - StatementPolicy.reject(), config); - } - - @Override - protected SubstatementValidator getSubstatementValidator() { - return SUBSTATEMENT_VALIDATOR; + StatementPolicy.reject(), config, SUBSTATEMENT_VALIDATOR); } @Override diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/module/ModuleStatementSupport.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/module/ModuleStatementSupport.java index b05def0186..9026d06136 100644 --- a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/module/ModuleStatementSupport.java +++ b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/module/ModuleStatementSupport.java @@ -9,7 +9,6 @@ package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.module; import static com.google.common.base.Verify.verify; import static com.google.common.base.Verify.verifyNotNull; -import static java.util.Objects.requireNonNull; import static org.opendaylight.yangtools.yang.parser.spi.meta.StmtContextUtils.firstAttributeOf; import com.google.common.annotations.Beta; @@ -132,12 +131,10 @@ public final class ModuleStatementSupport .addOptional(OpenConfigStatements.OPENCONFIG_VERSION) .build(); - private final SubstatementValidator validator; private final boolean semanticVersioning; private ModuleStatementSupport(final YangParserConfiguration config, final SubstatementValidator validator) { - super(YangStmtMapping.MODULE, StatementPolicy.reject(), config); - this.validator = requireNonNull(validator); + super(YangStmtMapping.MODULE, StatementPolicy.reject(), config, validator); semanticVersioning = config.importResolutionMode() == ImportResolutionMode.OPENCONFIG_SEMVER; } @@ -220,11 +217,6 @@ public final class ModuleStatementSupport } } - @Override - protected SubstatementValidator getSubstatementValidator() { - return validator; - } - @Override protected ImmutableList> buildEffectiveSubstatements( final Current stmt, diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/notification/AbstractNotificationStatementSupport.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/notification/AbstractNotificationStatementSupport.java index 1586fb7899..e0d9c201fb 100644 --- a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/notification/AbstractNotificationStatementSupport.java +++ b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/notification/AbstractNotificationStatementSupport.java @@ -24,12 +24,13 @@ import org.opendaylight.yangtools.yang.parser.api.YangParserConfiguration; import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractSchemaTreeStatementSupport; import org.opendaylight.yangtools.yang.parser.spi.meta.EffectiveStmtCtx.Current; import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext; +import org.opendaylight.yangtools.yang.parser.spi.meta.SubstatementValidator; import org.opendaylight.yangtools.yang.parser.spi.source.SourceException; abstract class AbstractNotificationStatementSupport extends AbstractSchemaTreeStatementSupport { - AbstractNotificationStatementSupport(final YangParserConfiguration config) { - super(YangStmtMapping.NOTIFICATION, uninstantiatedPolicy(), config); + AbstractNotificationStatementSupport(final YangParserConfiguration config, final SubstatementValidator validator) { + super(YangStmtMapping.NOTIFICATION, uninstantiatedPolicy(), config, validator); } @Override diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/notification/NotificationStatementRFC6020Support.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/notification/NotificationStatementRFC6020Support.java index bb6b82d5b1..ef30bbe341 100644 --- a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/notification/NotificationStatementRFC6020Support.java +++ b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/notification/NotificationStatementRFC6020Support.java @@ -12,29 +12,24 @@ import org.opendaylight.yangtools.yang.parser.api.YangParserConfiguration; import org.opendaylight.yangtools.yang.parser.spi.meta.SubstatementValidator; public final class NotificationStatementRFC6020Support extends AbstractNotificationStatementSupport { - private static final SubstatementValidator SUBSTATEMENT_VALIDATOR = SubstatementValidator.builder( - YangStmtMapping.NOTIFICATION) - .addAny(YangStmtMapping.ANYXML) - .addAny(YangStmtMapping.CHOICE) - .addAny(YangStmtMapping.CONTAINER) - .addOptional(YangStmtMapping.DESCRIPTION) - .addAny(YangStmtMapping.GROUPING) - .addAny(YangStmtMapping.IF_FEATURE) - .addAny(YangStmtMapping.LEAF) - .addAny(YangStmtMapping.LEAF_LIST) - .addAny(YangStmtMapping.LIST) - .addOptional(YangStmtMapping.REFERENCE) - .addOptional(YangStmtMapping.STATUS) - .addAny(YangStmtMapping.TYPEDEF) - .addAny(YangStmtMapping.USES) - .build(); + private static final SubstatementValidator SUBSTATEMENT_VALIDATOR = + SubstatementValidator.builder(YangStmtMapping.NOTIFICATION) + .addAny(YangStmtMapping.ANYXML) + .addAny(YangStmtMapping.CHOICE) + .addAny(YangStmtMapping.CONTAINER) + .addOptional(YangStmtMapping.DESCRIPTION) + .addAny(YangStmtMapping.GROUPING) + .addAny(YangStmtMapping.IF_FEATURE) + .addAny(YangStmtMapping.LEAF) + .addAny(YangStmtMapping.LEAF_LIST) + .addAny(YangStmtMapping.LIST) + .addOptional(YangStmtMapping.REFERENCE) + .addOptional(YangStmtMapping.STATUS) + .addAny(YangStmtMapping.TYPEDEF) + .addAny(YangStmtMapping.USES) + .build(); public NotificationStatementRFC6020Support(final YangParserConfiguration config) { - super(config); - } - - @Override - protected SubstatementValidator getSubstatementValidator() { - return SUBSTATEMENT_VALIDATOR; + super(config, SUBSTATEMENT_VALIDATOR); } } \ No newline at end of file diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/notification/NotificationStatementRFC7950Support.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/notification/NotificationStatementRFC7950Support.java index 561a456354..eb207be714 100644 --- a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/notification/NotificationStatementRFC7950Support.java +++ b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/notification/NotificationStatementRFC7950Support.java @@ -49,7 +49,7 @@ public final class NotificationStatementRFC7950Support extends AbstractNotificat ImmutableSet.of(YangStmtMapping.NOTIFICATION, YangStmtMapping.RPC, YangStmtMapping.ACTION); public NotificationStatementRFC7950Support(final YangParserConfiguration config) { - super(config); + super(config, SUBSTATEMENT_VALIDATOR); } @Override @@ -63,9 +63,4 @@ public final class NotificationStatementRFC7950Support extends AbstractNotificat super.onStatementAdded(stmt); } - - @Override - protected SubstatementValidator getSubstatementValidator() { - return SUBSTATEMENT_VALIDATOR; - } } diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/path/PathStatementSupport.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/path/PathStatementSupport.java index 92856f5a5f..12139e3c4d 100644 --- a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/path/PathStatementSupport.java +++ b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/path/PathStatementSupport.java @@ -35,7 +35,7 @@ public final class PathStatementSupport private PathStatementSupport(final YangParserConfiguration config, final PathExpressionParser parser) { // TODO: can 'path' really be copied? - super(YangStmtMapping.PATH, StatementPolicy.contextIndependent(), config); + super(YangStmtMapping.PATH, StatementPolicy.contextIndependent(), config, SUBSTATEMENT_VALIDATOR); this.parser = requireNonNull(parser); } @@ -52,11 +52,6 @@ public final class PathStatementSupport return parser.parseExpression(ctx, value); } - @Override - protected SubstatementValidator getSubstatementValidator() { - return SUBSTATEMENT_VALIDATOR; - } - @Override protected PathStatement createDeclared(final StmtContext ctx, final ImmutableList> substatements) { diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/pattern/PatternStatementSupport.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/pattern/PatternStatementSupport.java index 96213d839e..7ee798f1d0 100644 --- a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/pattern/PatternStatementSupport.java +++ b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/pattern/PatternStatementSupport.java @@ -7,8 +7,6 @@ */ package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.pattern; -import static java.util.Objects.requireNonNull; - import com.google.common.annotations.Beta; import com.google.common.collect.ImmutableList; import java.util.regex.Pattern; @@ -50,11 +48,8 @@ public final class PatternStatementSupport .addOptional(YangStmtMapping.REFERENCE) .build(); - private final SubstatementValidator validator; - private PatternStatementSupport(final YangParserConfiguration config, final SubstatementValidator validator) { - super(YangStmtMapping.PATTERN, StatementPolicy.contextIndependent(), config); - this.validator = requireNonNull(validator); + super(YangStmtMapping.PATTERN, StatementPolicy.contextIndependent(), config, validator); } public static @NonNull PatternStatementSupport rfc6020Instance(final YangParserConfiguration config) { @@ -76,11 +71,6 @@ public final class PatternStatementSupport return PatternExpression.of(value, pattern); } - @Override - protected SubstatementValidator getSubstatementValidator() { - return validator; - } - @Override protected PatternStatement createDeclared(final StmtContext ctx, final ImmutableList> substatements) { diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/refine/RefineStatementSupport.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/refine/RefineStatementSupport.java index 83010dd00e..ce26204b21 100644 --- a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/refine/RefineStatementSupport.java +++ b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/refine/RefineStatementSupport.java @@ -8,7 +8,6 @@ package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.refine; import static com.google.common.base.Verify.verifyNotNull; -import static java.util.Objects.requireNonNull; import com.google.common.annotations.Beta; import com.google.common.collect.ImmutableList; @@ -58,11 +57,8 @@ public final class RefineStatementSupport .addOptional(YangStmtMapping.MAX_ELEMENTS) .build(); - private final SubstatementValidator validator; - private RefineStatementSupport(final YangParserConfiguration config, final SubstatementValidator validator) { - super(YangStmtMapping.REFINE, StatementPolicy.reject(), config); - this.validator = requireNonNull(validator); + super(YangStmtMapping.REFINE, StatementPolicy.reject(), config, validator); } public static @NonNull RefineStatementSupport rfc6020Instance(final YangParserConfiguration config) { @@ -78,11 +74,6 @@ public final class RefineStatementSupport return ArgumentUtils.parseDescendantSchemaNodeIdentifier(ctx, value); } - @Override - protected SubstatementValidator getSubstatementValidator() { - return validator; - } - @Override protected RefineStatement createDeclared(final StmtContext ctx, final ImmutableList> substatements) { diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/submodule/SubmoduleStatementSupport.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/submodule/SubmoduleStatementSupport.java index f3dc64b77c..b3846638d9 100644 --- a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/submodule/SubmoduleStatementSupport.java +++ b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/submodule/SubmoduleStatementSupport.java @@ -7,7 +7,6 @@ */ package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.submodule; -import static java.util.Objects.requireNonNull; import static org.opendaylight.yangtools.yang.parser.spi.meta.StmtContextUtils.findFirstDeclaredSubstatement; import static org.opendaylight.yangtools.yang.parser.spi.meta.StmtContextUtils.firstAttributeOf; @@ -101,11 +100,8 @@ public final class SubmoduleStatementSupport .addOptional(YangStmtMapping.YANG_VERSION) .build(); - private final SubstatementValidator validator; - private SubmoduleStatementSupport(final YangParserConfiguration config, final SubstatementValidator validator) { - super(YangStmtMapping.SUBMODULE, StatementPolicy.reject(), config); - this.validator = requireNonNull(validator); + super(YangStmtMapping.SUBMODULE, StatementPolicy.reject(), config, validator); } public static @NonNull SubmoduleStatementSupport rfc6020Instance(final YangParserConfiguration config) { @@ -156,11 +152,6 @@ public final class SubmoduleStatementSupport stmt.addToNs(BelongsToPrefixToModuleName.class, prefix, belongsToModuleName); } - @Override - protected SubstatementValidator getSubstatementValidator() { - return validator; - } - @Override protected SubmoduleStatement createDeclared(final StmtContext ctx, final ImmutableList> substatements) { diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/type/AbstractTypeStatementSupport.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/type/AbstractTypeStatementSupport.java index fd42b002bc..44cad1f9e0 100644 --- a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/type/AbstractTypeStatementSupport.java +++ b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/type/AbstractTypeStatementSupport.java @@ -119,14 +119,14 @@ abstract class AbstractTypeStatementSupport extends AbstractTypeSupport> dynamicBuiltInTypes; AbstractTypeStatementSupport(final YangParserConfiguration config) { - super(config); + super(config, SUBSTATEMENT_VALIDATOR); dynamicBuiltInTypes = ImmutableMap.>builder() .put(TypeDefinitions.BITS.getLocalName(), new BitsSpecificationSupport(config)) .put(TypeDefinitions.DECIMAL64.getLocalName(), new Decimal64SpecificationSupport(config)) .put(TypeDefinitions.ENUMERATION.getLocalName(), new EnumSpecificationSupport(config)) - .put(TypeDefinitions.IDENTITYREF.getLocalName(), new IdentityRefSpecificationRFC6020Support(config)) + .put(TypeDefinitions.IDENTITYREF.getLocalName(), IdentityRefSpecificationSupport.rfc6020Instance(config)) .put(TypeDefinitions.INSTANCE_IDENTIFIER.getLocalName(), new InstanceIdentifierSpecificationSupport(config)) - .put(TypeDefinitions.LEAFREF.getLocalName(), new LeafrefSpecificationRFC6020Support(config)) + .put(TypeDefinitions.LEAFREF.getLocalName(), LeafrefSpecificationSupport.rfc6020Instance(config)) .put(TypeDefinitions.UNION.getLocalName(), new UnionSpecificationSupport(config)) .build(); } @@ -176,11 +176,6 @@ abstract class AbstractTypeStatementSupport extends AbstractTypeSupport ctx, final ImmutableList> substatements) { diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/type/AbstractTypeSupport.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/type/AbstractTypeSupport.java index 0aba7c55ab..73a3471bf7 100644 --- a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/type/AbstractTypeSupport.java +++ b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/type/AbstractTypeSupport.java @@ -7,6 +7,8 @@ */ package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.type; +import static java.util.Objects.requireNonNull; + import com.google.common.collect.ImmutableMap; import com.google.common.collect.Maps; import java.util.List; @@ -19,6 +21,7 @@ import org.opendaylight.yangtools.yang.parser.api.YangParserConfiguration; import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractQNameStatementSupport; import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext; import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContextUtils; +import org.opendaylight.yangtools.yang.parser.spi.meta.SubstatementValidator; /** * Abstract base of all type-related statement support classes. @@ -47,8 +50,8 @@ abstract class AbstractTypeSupport TypeDefinitions.UNION), QName::getLocalName); - AbstractTypeSupport(final YangParserConfiguration config) { - super(YangStmtMapping.TYPE, StatementPolicy.exactReplica(), config); + AbstractTypeSupport(final YangParserConfiguration config, final SubstatementValidator validator) { + super(YangStmtMapping.TYPE, StatementPolicy.exactReplica(), config, requireNonNull(validator)); } @Override diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/type/BitsSpecificationSupport.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/type/BitsSpecificationSupport.java index cccae5df12..96dec62e10 100644 --- a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/type/BitsSpecificationSupport.java +++ b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/type/BitsSpecificationSupport.java @@ -32,12 +32,7 @@ final class BitsSpecificationSupport extends AbstractTypeSupport { private static final SubstatementValidator SUBSTATEMENT_VALIDATOR = - SubstatementValidator.builder(YangStmtMapping.TYPE).addMultiple(YangStmtMapping.ENUM).build(); + SubstatementValidator.builder(YangStmtMapping.TYPE).addMultiple(YangStmtMapping.ENUM).build(); EnumSpecificationSupport(final YangParserConfiguration config) { - super(config); - } - - @Override - protected SubstatementValidator getSubstatementValidator() { - return SUBSTATEMENT_VALIDATOR; + super(config, SUBSTATEMENT_VALIDATOR); } @Override diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/type/IdentityRefSpecificationRFC6020Support.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/type/IdentityRefSpecificationRFC6020Support.java deleted file mode 100644 index d793fa111e..0000000000 --- a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/type/IdentityRefSpecificationRFC6020Support.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (c) 2017 Pantheon Technologies, s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.type; - -import org.opendaylight.yangtools.yang.model.api.YangStmtMapping; -import org.opendaylight.yangtools.yang.parser.api.YangParserConfiguration; -import org.opendaylight.yangtools.yang.parser.spi.meta.SubstatementValidator; - -final class IdentityRefSpecificationRFC6020Support extends AbstractIdentityRefSpecificationSupport { - private static final SubstatementValidator SUBSTATEMENT_VALIDATOR = - SubstatementValidator.builder(YangStmtMapping.TYPE).addMandatory(YangStmtMapping.BASE).build(); - - IdentityRefSpecificationRFC6020Support(final YangParserConfiguration config) { - super(config); - } - - @Override - protected SubstatementValidator getSubstatementValidator() { - return SUBSTATEMENT_VALIDATOR; - } -} \ No newline at end of file diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/type/IdentityRefSpecificationRFC7950Support.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/type/IdentityRefSpecificationRFC7950Support.java deleted file mode 100644 index 671d6f4ea4..0000000000 --- a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/type/IdentityRefSpecificationRFC7950Support.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2017 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.type; - -import org.opendaylight.yangtools.yang.model.api.YangStmtMapping; -import org.opendaylight.yangtools.yang.parser.api.YangParserConfiguration; -import org.opendaylight.yangtools.yang.parser.spi.meta.SubstatementValidator; - -/** - * Class providing necessary support for processing YANG 1.1 identityref statement. - */ -final class IdentityRefSpecificationRFC7950Support extends AbstractIdentityRefSpecificationSupport { - private static final SubstatementValidator SUBSTATEMENT_VALIDATOR = - SubstatementValidator.builder(YangStmtMapping.TYPE).addMultiple(YangStmtMapping.BASE).build(); - - IdentityRefSpecificationRFC7950Support(final YangParserConfiguration config) { - super(config); - } - - @Override - protected SubstatementValidator getSubstatementValidator() { - return SUBSTATEMENT_VALIDATOR; - } -} diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/type/AbstractIdentityRefSpecificationSupport.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/type/IdentityRefSpecificationSupport.java similarity index 76% rename from yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/type/AbstractIdentityRefSpecificationSupport.java rename to yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/type/IdentityRefSpecificationSupport.java index 9101f65d09..bff6808ca2 100644 --- a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/type/AbstractIdentityRefSpecificationSupport.java +++ b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/type/IdentityRefSpecificationSupport.java @@ -12,8 +12,10 @@ import static com.google.common.base.Verify.verifyNotNull; import com.google.common.collect.ImmutableList; import java.util.Collection; +import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.model.api.IdentitySchemaNode; +import org.opendaylight.yangtools.yang.model.api.YangStmtMapping; import org.opendaylight.yangtools.yang.model.api.meta.DeclarationReference; import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement; import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement; @@ -31,16 +33,30 @@ import org.opendaylight.yangtools.yang.parser.spi.meta.InferenceException; import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext; import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext.Mutable; import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContextUtils; +import org.opendaylight.yangtools.yang.parser.spi.meta.SubstatementValidator; import org.opendaylight.yangtools.yang.parser.spi.source.SourceException; -abstract class AbstractIdentityRefSpecificationSupport - extends AbstractTypeSupport { - AbstractIdentityRefSpecificationSupport(final YangParserConfiguration config) { - super(config); +final class IdentityRefSpecificationSupport extends AbstractTypeSupport { + private static final SubstatementValidator RFC6020_VALIDATOR = + SubstatementValidator.builder(YangStmtMapping.TYPE).addMandatory(YangStmtMapping.BASE).build(); + private static final SubstatementValidator RFC7950_VALIDATOR = + SubstatementValidator.builder(YangStmtMapping.TYPE).addMultiple(YangStmtMapping.BASE).build(); + + private IdentityRefSpecificationSupport(final YangParserConfiguration config, + final SubstatementValidator validator) { + super(config, validator); + } + + static @NonNull IdentityRefSpecificationSupport rfc6020Instance(final YangParserConfiguration config) { + return new IdentityRefSpecificationSupport(config, RFC6020_VALIDATOR); + } + + static @NonNull IdentityRefSpecificationSupport rfc7950Instance(final YangParserConfiguration config) { + return new IdentityRefSpecificationSupport(config, RFC7950_VALIDATOR); } @Override - public final void onFullDefinitionDeclared(final Mutable> stmt) { super.onFullDefinitionDeclared(stmt); @@ -56,7 +72,7 @@ abstract class AbstractIdentityRefSpecificationSupport } @Override - protected final IdentityRefSpecification createDeclared(final StmtContext ctx, + protected IdentityRefSpecification createDeclared(final StmtContext ctx, final ImmutableList> substatements) { if (substatements.isEmpty()) { throw noBase(ctx); @@ -71,7 +87,7 @@ abstract class AbstractIdentityRefSpecificationSupport } @Override - protected final EffectiveStatement createEffective( + protected EffectiveStatement createEffective( final Current stmt, final ImmutableList> substatements) { if (substatements.isEmpty()) { diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/type/InstanceIdentifierSpecificationSupport.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/type/InstanceIdentifierSpecificationSupport.java index bc525268eb..1e9956b335 100644 --- a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/type/InstanceIdentifierSpecificationSupport.java +++ b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/type/InstanceIdentifierSpecificationSupport.java @@ -29,12 +29,7 @@ final class InstanceIdentifierSpecificationSupport SubstatementValidator.builder(YangStmtMapping.TYPE).addOptional(YangStmtMapping.REQUIRE_INSTANCE).build(); InstanceIdentifierSpecificationSupport(final YangParserConfiguration config) { - super(config); - } - - @Override - protected SubstatementValidator getSubstatementValidator() { - return SUBSTATEMENT_VALIDATOR; + super(config, SUBSTATEMENT_VALIDATOR); } @Override diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/type/LeafrefSpecificationRFC6020Support.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/type/LeafrefSpecificationRFC6020Support.java deleted file mode 100644 index 001c28c9c3..0000000000 --- a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/type/LeafrefSpecificationRFC6020Support.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (c) 2017 Pantheon Technologies, s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.type; - -import org.opendaylight.yangtools.yang.model.api.YangStmtMapping; -import org.opendaylight.yangtools.yang.parser.api.YangParserConfiguration; -import org.opendaylight.yangtools.yang.parser.spi.meta.SubstatementValidator; - -final class LeafrefSpecificationRFC6020Support extends AbstractLeafrefSpecificationSupport { - private static final SubstatementValidator SUBSTATEMENT_VALIDATOR = - SubstatementValidator.builder(YangStmtMapping.TYPE).addMandatory(YangStmtMapping.PATH).build(); - - LeafrefSpecificationRFC6020Support(final YangParserConfiguration config) { - super(config); - } - - @Override - protected SubstatementValidator getSubstatementValidator() { - return SUBSTATEMENT_VALIDATOR; - } -} \ No newline at end of file diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/type/LeafrefSpecificationRFC7950Support.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/type/LeafrefSpecificationRFC7950Support.java deleted file mode 100644 index d0a331f8a4..0000000000 --- a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/type/LeafrefSpecificationRFC7950Support.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2017 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.type; - -import org.opendaylight.yangtools.yang.model.api.YangStmtMapping; -import org.opendaylight.yangtools.yang.parser.api.YangParserConfiguration; -import org.opendaylight.yangtools.yang.parser.spi.meta.SubstatementValidator; - -/** - * Class providing necessary support for processing YANG 1.1 leafref statement. - */ -final class LeafrefSpecificationRFC7950Support extends AbstractLeafrefSpecificationSupport { - private static final SubstatementValidator SUBSTATEMENT_VALIDATOR = - SubstatementValidator.builder(YangStmtMapping.TYPE) - .addMandatory(YangStmtMapping.PATH) - .addOptional(YangStmtMapping.REQUIRE_INSTANCE) - .build(); - - LeafrefSpecificationRFC7950Support(final YangParserConfiguration config) { - super(config); - } - - @Override - protected SubstatementValidator getSubstatementValidator() { - return SUBSTATEMENT_VALIDATOR; - } - -} diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/type/AbstractLeafrefSpecificationSupport.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/type/LeafrefSpecificationSupport.java similarity index 70% rename from yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/type/AbstractLeafrefSpecificationSupport.java rename to yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/type/LeafrefSpecificationSupport.java index dcc647c36e..783c582090 100644 --- a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/type/AbstractLeafrefSpecificationSupport.java +++ b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/type/LeafrefSpecificationSupport.java @@ -9,6 +9,7 @@ package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.type; import com.google.common.collect.ImmutableList; import org.opendaylight.yangtools.yang.common.QName; +import org.opendaylight.yangtools.yang.model.api.YangStmtMapping; import org.opendaylight.yangtools.yang.model.api.meta.DeclarationReference; import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement; import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement; @@ -21,15 +22,32 @@ import org.opendaylight.yangtools.yang.parser.api.YangParserConfiguration; import org.opendaylight.yangtools.yang.parser.spi.meta.CommonStmtCtx; import org.opendaylight.yangtools.yang.parser.spi.meta.EffectiveStmtCtx.Current; import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext; +import org.opendaylight.yangtools.yang.parser.spi.meta.SubstatementValidator; import org.opendaylight.yangtools.yang.parser.spi.source.SourceException; -abstract class AbstractLeafrefSpecificationSupport extends AbstractTypeSupport { - AbstractLeafrefSpecificationSupport(final YangParserConfiguration config) { - super(config); +final class LeafrefSpecificationSupport extends AbstractTypeSupport { + private static final SubstatementValidator RFC6020_VALIDATOR = + SubstatementValidator.builder(YangStmtMapping.TYPE).addMandatory(YangStmtMapping.PATH).build(); + private static final SubstatementValidator RFC7950_VALIDATOR = + SubstatementValidator.builder(YangStmtMapping.TYPE) + .addMandatory(YangStmtMapping.PATH) + .addOptional(YangStmtMapping.REQUIRE_INSTANCE) + .build(); + + private LeafrefSpecificationSupport(final YangParserConfiguration config, final SubstatementValidator validator) { + super(config, validator); + } + + static LeafrefSpecificationSupport rfc6020Instance(final YangParserConfiguration config) { + return new LeafrefSpecificationSupport(config, RFC6020_VALIDATOR); + } + + static LeafrefSpecificationSupport rfc7950Instance(final YangParserConfiguration config) { + return new LeafrefSpecificationSupport(config, RFC7950_VALIDATOR); } @Override - protected final LeafrefSpecification createDeclared(final StmtContext ctx, + protected LeafrefSpecification createDeclared(final StmtContext ctx, final ImmutableList> substatements) { if (substatements.isEmpty()) { throw noPath(ctx); @@ -38,7 +56,7 @@ abstract class AbstractLeafrefSpecificationSupport extends AbstractTypeSupport { private static final Logger LOG = LoggerFactory.getLogger(UsesStatementSupport.class); - private static final SubstatementValidator SUBSTATEMENT_VALIDATOR = SubstatementValidator.builder(YangStmtMapping - .USES) - .addAny(YangStmtMapping.AUGMENT) - .addOptional(YangStmtMapping.DESCRIPTION) - .addAny(YangStmtMapping.IF_FEATURE) - .addAny(YangStmtMapping.REFINE) - .addOptional(YangStmtMapping.REFERENCE) - .addOptional(YangStmtMapping.STATUS) - .addOptional(YangStmtMapping.WHEN) - .build(); + private static final SubstatementValidator SUBSTATEMENT_VALIDATOR = + SubstatementValidator.builder(YangStmtMapping.USES) + .addAny(YangStmtMapping.AUGMENT) + .addOptional(YangStmtMapping.DESCRIPTION) + .addAny(YangStmtMapping.IF_FEATURE) + .addAny(YangStmtMapping.REFINE) + .addOptional(YangStmtMapping.REFERENCE) + .addOptional(YangStmtMapping.STATUS) + .addOptional(YangStmtMapping.WHEN) + .build(); public UsesStatementSupport(final YangParserConfiguration config) { - super(YangStmtMapping.USES, StatementPolicy.exactReplica(), config); + super(YangStmtMapping.USES, StatementPolicy.exactReplica(), config, SUBSTATEMENT_VALIDATOR); } @Override @@ -129,11 +129,6 @@ public final class UsesStatementSupport }); } - @Override - protected SubstatementValidator getSubstatementValidator() { - return SUBSTATEMENT_VALIDATOR; - } - @Override protected UsesStatement createDeclared(final StmtContext ctx, final ImmutableList> substatements) { diff --git a/yang/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/thirdparty/plugin/ThirdPartyExtensionSupport.java b/yang/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/thirdparty/plugin/ThirdPartyExtensionSupport.java index af570f977f..180b528e5b 100644 --- a/yang/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/thirdparty/plugin/ThirdPartyExtensionSupport.java +++ b/yang/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/thirdparty/plugin/ThirdPartyExtensionSupport.java @@ -17,12 +17,11 @@ import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStringStatementSu import org.opendaylight.yangtools.yang.parser.spi.meta.EffectiveStmtCtx.Current; import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext; import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext.Mutable; -import org.opendaylight.yangtools.yang.parser.spi.meta.SubstatementValidator; public final class ThirdPartyExtensionSupport extends AbstractStringStatementSupport { public ThirdPartyExtensionSupport(final YangParserConfiguration config) { - super(ThirdPartyExtensionsMapping.THIRD_PARTY_EXTENSION, StatementPolicy.contextIndependent(), config); + super(ThirdPartyExtensionsMapping.THIRD_PARTY_EXTENSION, StatementPolicy.contextIndependent(), config, null); } @Override @@ -32,11 +31,6 @@ public final class ThirdPartyExtensionSupport stmt.addToNs(ThirdPartyNamespace.class, Empty.getInstance(), "Third-party namespace test."); } - @Override - protected SubstatementValidator getSubstatementValidator() { - return null; - } - @Override protected ThirdPartyExtensionStatement createDeclared( final StmtContext ctx, diff --git a/yang/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/AbstractBooleanStatementSupport.java b/yang/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/AbstractBooleanStatementSupport.java index 11405047bc..7e8fd16dfc 100644 --- a/yang/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/AbstractBooleanStatementSupport.java +++ b/yang/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/AbstractBooleanStatementSupport.java @@ -12,6 +12,7 @@ import static java.util.Objects.requireNonNull; import com.google.common.annotations.Beta; import com.google.common.collect.ImmutableList; import org.eclipse.jdt.annotation.NonNull; +import org.eclipse.jdt.annotation.Nullable; import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement; import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement; import org.opendaylight.yangtools.yang.model.api.meta.StatementDefinition; @@ -36,8 +37,8 @@ public abstract class AbstractBooleanStatementSupport policy, - final YangParserConfiguration config) { - super(publicDefinition, policy, config); + final YangParserConfiguration config, final @Nullable SubstatementValidator validator) { + super(publicDefinition, policy, config, validator); this.emptyEffectiveFalse = requireNonNull(emptyEffectiveFalse); this.emptyEffectiveTrue = requireNonNull(emptyEffectiveTrue); emptyDeclaredFalse = requireNonNull(emptyEffectiveFalse.getDeclared()); diff --git a/yang/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/AbstractEmptyStatementSupport.java b/yang/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/AbstractEmptyStatementSupport.java index fe399206df..3b48c1e880 100644 --- a/yang/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/AbstractEmptyStatementSupport.java +++ b/yang/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/AbstractEmptyStatementSupport.java @@ -8,6 +8,7 @@ package org.opendaylight.yangtools.yang.parser.spi.meta; import com.google.common.annotations.Beta; +import org.eclipse.jdt.annotation.Nullable; import org.opendaylight.yangtools.yang.common.Empty; import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement; import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement; @@ -18,8 +19,9 @@ import org.opendaylight.yangtools.yang.parser.api.YangParserConfiguration; public abstract class AbstractEmptyStatementSupport, E extends EffectiveStatement> extends AbstractStatementSupport { protected AbstractEmptyStatementSupport(final StatementDefinition publicDefinition, - final StatementPolicy policy, final YangParserConfiguration config) { - super(publicDefinition, policy, config); + final StatementPolicy policy, final YangParserConfiguration config, + final @Nullable SubstatementValidator validator) { + super(publicDefinition, policy, config, validator); } @Override diff --git a/yang/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/AbstractInternedStatementSupport.java b/yang/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/AbstractInternedStatementSupport.java index 572810af9b..5befc19bbd 100644 --- a/yang/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/AbstractInternedStatementSupport.java +++ b/yang/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/AbstractInternedStatementSupport.java @@ -13,6 +13,7 @@ import com.google.common.cache.CacheLoader; import com.google.common.cache.LoadingCache; import com.google.common.collect.ImmutableList; import org.eclipse.jdt.annotation.NonNull; +import org.eclipse.jdt.annotation.Nullable; import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement; import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement; import org.opendaylight.yangtools.yang.model.api.meta.StatementDefinition; @@ -47,8 +48,9 @@ public abstract class AbstractInternedStatementSupport policy, final YangParserConfiguration config) { - super(publicDefinition, policy, config); + final StatementPolicy policy, final YangParserConfiguration config, + final @Nullable SubstatementValidator validator) { + super(publicDefinition, policy, config, validator); } @Override diff --git a/yang/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/AbstractInternedStringStatementSupport.java b/yang/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/AbstractInternedStringStatementSupport.java index 819b401837..8eecb3cadb 100644 --- a/yang/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/AbstractInternedStringStatementSupport.java +++ b/yang/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/AbstractInternedStringStatementSupport.java @@ -8,6 +8,7 @@ package org.opendaylight.yangtools.yang.parser.spi.meta; import com.google.common.annotations.Beta; +import org.eclipse.jdt.annotation.Nullable; import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement; import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement; import org.opendaylight.yangtools.yang.model.api.meta.StatementDefinition; @@ -23,8 +24,9 @@ import org.opendaylight.yangtools.yang.parser.api.YangParserConfiguration; public abstract class AbstractInternedStringStatementSupport, E extends EffectiveStatement> extends AbstractInternedStatementSupport { protected AbstractInternedStringStatementSupport(final StatementDefinition publicDefinition, - final StatementPolicy policy, final YangParserConfiguration config) { - super(publicDefinition, policy, config); + final StatementPolicy policy, final YangParserConfiguration config, + final @Nullable SubstatementValidator validator) { + super(publicDefinition, policy, config, validator); } @Override diff --git a/yang/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/AbstractQNameStatementSupport.java b/yang/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/AbstractQNameStatementSupport.java index b979fb46f6..a3ae4445a0 100644 --- a/yang/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/AbstractQNameStatementSupport.java +++ b/yang/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/AbstractQNameStatementSupport.java @@ -8,6 +8,7 @@ package org.opendaylight.yangtools.yang.parser.spi.meta; import com.google.common.annotations.Beta; +import org.eclipse.jdt.annotation.Nullable; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.common.QNameModule; import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement; @@ -25,8 +26,9 @@ import org.opendaylight.yangtools.yang.parser.api.YangParserConfiguration; public abstract class AbstractQNameStatementSupport, E extends EffectiveStatement> extends AbstractStatementSupport { protected AbstractQNameStatementSupport(final StatementDefinition publicDefinition, - final StatementPolicy policy, final YangParserConfiguration config) { - super(publicDefinition, policy, config); + final StatementPolicy policy, final YangParserConfiguration config, + final @Nullable SubstatementValidator validator) { + super(publicDefinition, policy, config, validator); } @Override diff --git a/yang/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/AbstractSchemaTreeStatementSupport.java b/yang/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/AbstractSchemaTreeStatementSupport.java index ce2bb38e75..2369ed24f9 100644 --- a/yang/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/AbstractSchemaTreeStatementSupport.java +++ b/yang/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/AbstractSchemaTreeStatementSupport.java @@ -10,6 +10,7 @@ package org.opendaylight.yangtools.yang.parser.spi.meta; import com.google.common.annotations.Beta; import java.util.Collection; import java.util.Objects; +import org.eclipse.jdt.annotation.Nullable; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.model.api.CopyableNode; import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement; @@ -64,8 +65,9 @@ public abstract class AbstractSchemaTreeStatementSupport()); protected AbstractSchemaTreeStatementSupport(final StatementDefinition publicDefinition, - final StatementPolicy policy, final YangParserConfiguration config) { - super(publicDefinition, policy, config); + final StatementPolicy policy, final YangParserConfiguration config, + final @Nullable SubstatementValidator validator) { + super(publicDefinition, policy, config, validator); } /** diff --git a/yang/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/AbstractStatementSupport.java b/yang/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/AbstractStatementSupport.java index 212acc5c1b..86f9134a0f 100644 --- a/yang/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/AbstractStatementSupport.java +++ b/yang/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/AbstractStatementSupport.java @@ -36,12 +36,19 @@ import org.opendaylight.yangtools.yang.parser.spi.meta.EffectiveStmtCtx.Current; @Beta public abstract class AbstractStatementSupport, E extends EffectiveStatement> extends StatementSupport { + private final SubstatementValidator substatementValidator; private final boolean retainDeclarationReference; protected AbstractStatementSupport(final StatementDefinition publicDefinition, final StatementPolicy policy, - final YangParserConfiguration config) { + final YangParserConfiguration config, final @Nullable SubstatementValidator validator) { super(publicDefinition, policy); this.retainDeclarationReference = config.retainDeclarationReferences(); + this.substatementValidator = validator; + } + + @Override + protected final SubstatementValidator substatementValidator() { + return substatementValidator; } @Override diff --git a/yang/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/AbstractStringStatementSupport.java b/yang/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/AbstractStringStatementSupport.java index 063ea45bb7..fc9ad5f0b8 100644 --- a/yang/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/AbstractStringStatementSupport.java +++ b/yang/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/AbstractStringStatementSupport.java @@ -8,6 +8,7 @@ package org.opendaylight.yangtools.yang.parser.spi.meta; import com.google.common.annotations.Beta; +import org.eclipse.jdt.annotation.Nullable; import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement; import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement; import org.opendaylight.yangtools.yang.model.api.meta.StatementDefinition; @@ -24,8 +25,9 @@ import org.opendaylight.yangtools.yang.parser.api.YangParserConfiguration; public abstract class AbstractStringStatementSupport, E extends EffectiveStatement> extends AbstractStatementSupport { protected AbstractStringStatementSupport(final StatementDefinition publicDefinition, - final StatementPolicy policy, final YangParserConfiguration config) { - super(publicDefinition, policy, config); + final StatementPolicy policy, final YangParserConfiguration config, + final @Nullable SubstatementValidator validator) { + super(publicDefinition, policy, config, validator); } @Override diff --git a/yang/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/ForwardingStatementSupport.java b/yang/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/ForwardingStatementSupport.java index 61f30ed0c8..cdcfa44dfc 100644 --- a/yang/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/ForwardingStatementSupport.java +++ b/yang/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/ForwardingStatementSupport.java @@ -92,8 +92,8 @@ public abstract class ForwardingStatementSupport, E exte * *

* Implementation may use method to perform actions on this event or register modification action using - * {@link StmtContext.Mutable#newInferenceAction(ModelProcessingPhase)}. + * {@link Mutable#newInferenceAction(ModelProcessingPhase)}. * * @param stmt Context of added statement. * @throws SourceException when an inconsistency is detected. @@ -340,7 +340,7 @@ public abstract class StatementSupport, E exte * *

* Implementation may use method to perform actions on this event or register modification action using - * {@link StmtContext.Mutable#newInferenceAction(ModelProcessingPhase)}. + * {@link Mutable#newInferenceAction(ModelProcessingPhase)}. * * @param stmt Context of added statement. Argument and statement parent is accessible. * @throws SourceException when an inconsistency is detected. @@ -355,13 +355,13 @@ public abstract class StatementSupport, E exte * *

* Implementation may use method to perform actions on this event or register modification action using - * {@link StmtContext.Mutable#newInferenceAction(ModelProcessingPhase)}. + * {@link Mutable#newInferenceAction(ModelProcessingPhase)}. * * @param stmt Context of added statement. Argument and statement parent is accessible. * @throws SourceException when an inconsistency is detected. */ - public void onFullDefinitionDeclared(final StmtContext.Mutable stmt) { - final SubstatementValidator validator = getSubstatementValidator(); + public void onFullDefinitionDeclared(final Mutable stmt) { + final SubstatementValidator validator = substatementValidator(); if (validator != null) { validator.validate(stmt); } @@ -372,8 +372,7 @@ public abstract class StatementSupport, E exte * * @return substatement validator or null, if substatement validator is not defined */ - // FIXME: rename to 'substatementValidator' and perhaps let it be passed in? - protected abstract @Nullable SubstatementValidator getSubstatementValidator(); + protected abstract @Nullable SubstatementValidator substatementValidator(); /** * Returns true if this support has argument specific supports. -- 2.36.6