From: Robert Varga Date: Sun, 27 Sep 2015 15:34:02 +0000 (+0200) Subject: Use Objects.equals() in effective statements X-Git-Tag: release/beryllium~261 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=65375a4a5fba446fa4da04605d3a066626cf3645;p=yangtools.git Use Objects.equals() in effective statements This simplifies equals() method implementations and performs various obvious cleanups: - boolean assignement via trigraph - explicit isEmpty() before ImmutableList.copyOf() - private fields And adds a couple of FIXMEs for follow-up. Change-Id: Id591cef7f777efaa02e0cb77d47245762a103363 Signed-off-by: Robert Varga --- diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/AnyXmlEffectiveStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/AnyXmlEffectiveStatementImpl.java index 98d65f0e8c..ed95f87455 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/AnyXmlEffectiveStatementImpl.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/AnyXmlEffectiveStatementImpl.java @@ -17,10 +17,10 @@ import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.model.api.AnyXmlSchemaNode; import org.opendaylight.yangtools.yang.model.api.ConstraintDefinition; import org.opendaylight.yangtools.yang.model.api.DerivableSchemaNode; -import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement; import org.opendaylight.yangtools.yang.model.api.SchemaPath; -import org.opendaylight.yangtools.yang.model.api.stmt.AnyxmlStatement; import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode; +import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement; +import org.opendaylight.yangtools.yang.model.api.stmt.AnyxmlStatement; import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext; import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext.TypeOfCopy; import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.Utils; @@ -40,7 +40,7 @@ public class AnyXmlEffectiveStatementImpl extends ImmutableList unknownNodes; public AnyXmlEffectiveStatementImpl( - StmtContext> ctx) { + final StmtContext> ctx) { super(ctx); this.qname = ctx.getStatementArgument(); this.path = Utils.getSchemaPath(ctx); @@ -51,7 +51,7 @@ public class AnyXmlEffectiveStatementImpl extends } private void initCopyType( - StmtContext> ctx) { + final StmtContext> ctx) { List copyTypesFromOriginal = ctx.getCopyHistory(); @@ -141,70 +141,29 @@ public class AnyXmlEffectiveStatementImpl extends return result; } - private boolean checkQname(AnyXmlEffectiveStatementImpl other) { - if (qname == null) { - if (other.qname != null) { - return false; - } - } else if (!qname.equals(other.qname)) { - return false; - } - return true; - } - - private boolean checkPath(AnyXmlEffectiveStatementImpl other) { - if (path == null) { - if (other.path != null) { - return false; - } - } else if (!path.equals(other.path)) { - return false; - } - return true; - } - - private boolean checkObject(final Object obj) { - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - return true; - } - @Override public boolean equals(final Object obj) { if (this == obj) { return true; } - - if (!checkObject(obj)) { - return false; - } - - AnyXmlEffectiveStatementImpl other = (AnyXmlEffectiveStatementImpl) obj; - - if (!checkQname(other)) { + if (obj == null) { return false; } - - if (!checkPath(other)) { + if (getClass() != obj.getClass()) { return false; } - return true; + AnyXmlEffectiveStatementImpl other = (AnyXmlEffectiveStatementImpl) obj; + return Objects.equals(qname, other.qname) && Objects.equals(path, other.path); } @Override public String toString() { - StringBuilder sb = new StringBuilder( - AnyXmlEffectiveStatementImpl.class.getSimpleName()); + StringBuilder sb = new StringBuilder(AnyXmlEffectiveStatementImpl.class.getSimpleName()); sb.append("["); sb.append("qname=").append(qname); sb.append(", path=").append(path); sb.append("]"); return sb.toString(); } - } diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/ArgumentEffectiveStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/ArgumentEffectiveStatementImpl.java index 609bf9ca5b..2fda2ff6da 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/ArgumentEffectiveStatementImpl.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/ArgumentEffectiveStatementImpl.java @@ -11,12 +11,8 @@ import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.model.api.stmt.ArgumentStatement; import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext; -public class ArgumentEffectiveStatementImpl extends - EffectiveStatementBase { - - public ArgumentEffectiveStatementImpl( - StmtContext ctx) { +public class ArgumentEffectiveStatementImpl extends EffectiveStatementBase { + public ArgumentEffectiveStatementImpl(final StmtContext ctx) { super(ctx); } - } \ No newline at end of file diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/AugmentEffectiveStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/AugmentEffectiveStatementImpl.java index 0d004df4b1..365c461fdb 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/AugmentEffectiveStatementImpl.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/AugmentEffectiveStatementImpl.java @@ -8,7 +8,6 @@ package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective; import static com.google.common.base.Preconditions.checkNotNull; - import com.google.common.base.Optional; import com.google.common.collect.ImmutableList; import java.net.URI; @@ -21,13 +20,13 @@ import java.util.Objects; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.common.QNameModule; import org.opendaylight.yangtools.yang.model.api.AugmentationSchema; -import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement; import org.opendaylight.yangtools.yang.model.api.NamespaceRevisionAware; import org.opendaylight.yangtools.yang.model.api.RevisionAwareXPath; import org.opendaylight.yangtools.yang.model.api.SchemaPath; +import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode; +import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement; import org.opendaylight.yangtools.yang.model.api.stmt.AugmentStatement; import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier; -import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode; import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext; import org.opendaylight.yangtools.yang.parser.stmt.reactor.StatementContextBase; import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.Utils; @@ -35,20 +34,17 @@ import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.Utils; public class AugmentEffectiveStatementImpl extends AbstractEffectiveDocumentedDataNodeContainer - implements AugmentationSchema, NamespaceRevisionAware, - Comparable { - private final int order; + implements AugmentationSchema, NamespaceRevisionAware, Comparable { private final SchemaPath targetPath; - RevisionAwareXPath whenCondition; - - URI namespace; - Date revision; - ImmutableList unknownNodes; + private final URI namespace; + private final Date revision; + private final int order; + private ImmutableList unknownNodes; + private RevisionAwareXPath whenCondition; private AugmentationSchema copyOf; public AugmentEffectiveStatementImpl( - StmtContext> ctx){ - + final StmtContext> ctx) { super(ctx); SchemaNodeIdentifier schemaNodeIdentifier = ctx.getStatementArgument(); @@ -67,7 +63,7 @@ public class AugmentEffectiveStatementImpl } private void initCopyOf( - StmtContext> ctx) { + final StmtContext> ctx) { StatementContextBase originalCtx = ctx.getOriginalCtx(); if (originalCtx != null) { this.copyOf = (AugmentationSchema) originalCtx.buildEffective(); @@ -151,18 +147,10 @@ public class AugmentEffectiveStatementImpl return false; } AugmentEffectiveStatementImpl other = (AugmentEffectiveStatementImpl) obj; - if (targetPath == null) { - if (other.targetPath != null) { - return false; - } - } else if (!targetPath.equals(other.targetPath)) { + if (!Objects.equals(targetPath, other.targetPath)) { return false; } - if (whenCondition == null) { - if (other.whenCondition != null) { - return false; - } - } else if (!whenCondition.equals(other.whenCondition)) { + if (!Objects.equals(whenCondition, other.whenCondition)) { return false; } if (!getChildNodes().equals(other.getChildNodes())) { @@ -186,8 +174,7 @@ public class AugmentEffectiveStatementImpl public int compareTo(final AugmentEffectiveStatementImpl o) { checkNotNull(o); Iterator thisIt = this.targetPath.getPathFromRoot().iterator(); - Iterator otherIt = o.getTargetPath().getPathFromRoot() - .iterator(); + Iterator otherIt = o.getTargetPath().getPathFromRoot().iterator(); while (thisIt.hasNext()) { if (otherIt.hasNext()) { int comp = thisIt.next().compareTo(otherIt.next()); diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/BaseEffectiveStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/BaseEffectiveStatementImpl.java index 95e32a6b97..478bab9cce 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/BaseEffectiveStatementImpl.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/BaseEffectiveStatementImpl.java @@ -11,10 +11,9 @@ import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.model.api.stmt.BaseStatement; import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext; -public class BaseEffectiveStatementImpl extends - EffectiveStatementBase { +public class BaseEffectiveStatementImpl extends EffectiveStatementBase { - public BaseEffectiveStatementImpl(StmtContext ctx) { + public BaseEffectiveStatementImpl(final StmtContext ctx) { super(ctx); } diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/BelongsEffectiveToStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/BelongsEffectiveToStatementImpl.java index 7080bb742d..74e8fb936c 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/BelongsEffectiveToStatementImpl.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/BelongsEffectiveToStatementImpl.java @@ -10,12 +10,8 @@ package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective; import org.opendaylight.yangtools.yang.model.api.stmt.BelongsToStatement; import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext; -public class BelongsEffectiveToStatementImpl extends - EffectiveStatementBase { - - public BelongsEffectiveToStatementImpl( - StmtContext ctx) { +public class BelongsEffectiveToStatementImpl extends EffectiveStatementBase { + public BelongsEffectiveToStatementImpl(final StmtContext ctx) { super(ctx); } - } diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/CaseEffectiveStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/CaseEffectiveStatementImpl.java index 46ba0c292d..7430466832 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/CaseEffectiveStatementImpl.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/CaseEffectiveStatementImpl.java @@ -21,30 +21,28 @@ import org.opendaylight.yangtools.yang.model.api.AugmentationSchema; import org.opendaylight.yangtools.yang.model.api.ChoiceCaseNode; import org.opendaylight.yangtools.yang.model.api.ConstraintDefinition; import org.opendaylight.yangtools.yang.model.api.DerivableSchemaNode; -import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement; import org.opendaylight.yangtools.yang.model.api.SchemaPath; -import org.opendaylight.yangtools.yang.model.api.stmt.CaseStatement; import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode; +import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement; +import org.opendaylight.yangtools.yang.model.api.stmt.CaseStatement; import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext; import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext.TypeOfCopy; import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.Utils; -public class CaseEffectiveStatementImpl extends - AbstractEffectiveDocumentedDataNodeContainer +public class CaseEffectiveStatementImpl extends AbstractEffectiveDocumentedDataNodeContainer implements ChoiceCaseNode, DerivableSchemaNode { private final QName qname; private final SchemaPath path; + private final ConstraintDefinition constraints; - boolean augmenting; - boolean addedByUses; - ChoiceCaseNode original; - ConstraintDefinition constraints; - - ImmutableSet augmentations; - ImmutableList unknownNodes; + private boolean augmenting; + private boolean addedByUses; + private ChoiceCaseNode original; + private ImmutableSet augmentations; + private ImmutableList unknownNodes; public CaseEffectiveStatementImpl( - StmtContext> ctx) { + final StmtContext> ctx) { super(ctx); this.qname = ctx.getStatementArgument(); this.path = Utils.getSchemaPath(ctx); @@ -55,7 +53,7 @@ public class CaseEffectiveStatementImpl extends } private void initCopyType( - StmtContext> ctx) { + final StmtContext> ctx) { List copyTypesFromOriginal = ctx.getCopyHistory(); @@ -161,32 +159,16 @@ public class CaseEffectiveStatementImpl extends return false; } CaseEffectiveStatementImpl other = (CaseEffectiveStatementImpl) obj; - if (qname == null) { - if (other.qname != null) { - return false; - } - } else if (!qname.equals(other.qname)) { - return false; - } - if (path == null) { - if (other.path != null) { - return false; - } - } else if (!path.equals(other.path)) { - return false; - } - return true; + return Objects.equals(qname, other.qname) && Objects.equals(path, other.path); } @Override public String toString() { - StringBuilder sb = new StringBuilder( - CaseEffectiveStatementImpl.class.getSimpleName()); + StringBuilder sb = new StringBuilder(CaseEffectiveStatementImpl.class.getSimpleName()); sb.append("["); sb.append("qname="); sb.append(qname); sb.append("]"); return sb.toString(); } - } diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/CaseShorthandImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/CaseShorthandImpl.java index aaa78c178e..e5aec1f447 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/CaseShorthandImpl.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/CaseShorthandImpl.java @@ -42,17 +42,18 @@ public class CaseShorthandImpl implements ChoiceCaseNode, DerivableSchemaNode { private final boolean augmenting; private final boolean addedByUses; - ConstraintDefinition constraints; + private final ConstraintDefinition constraints; private ChoiceCaseNode original; ImmutableList unknownNodes; - public CaseShorthandImpl(DataSchemaNode caseShorthandNode) { + public CaseShorthandImpl(final DataSchemaNode caseShorthandNode) { this.caseShorthandNode = caseShorthandNode; this.qName = caseShorthandNode.getQName(); SchemaPath caseShorthandNodePath = caseShorthandNode.getPath(); Iterable pathFromRoot = caseShorthandNodePath.getPathFromRoot(); + // FIXME: cacheShorthandNodePath.getParent() should be enough this.path = SchemaPath .create(Iterables.limit(pathFromRoot, Iterables.size(pathFromRoot) - 1), @@ -134,7 +135,7 @@ public class CaseShorthandImpl implements ChoiceCaseNode, DerivableSchemaNode { } @Override - public DataSchemaNode getDataChildByName(QName name) { + public DataSchemaNode getDataChildByName(final QName name) { if (qName.equals(name)) { return caseShorthandNode; } else { @@ -143,7 +144,7 @@ public class CaseShorthandImpl implements ChoiceCaseNode, DerivableSchemaNode { } @Override - public DataSchemaNode getDataChildByName(String name) { + public DataSchemaNode getDataChildByName(final String name) { if (qName.getLocalName().equals(name)) { return caseShorthandNode; } else { @@ -187,32 +188,16 @@ public class CaseShorthandImpl implements ChoiceCaseNode, DerivableSchemaNode { return false; } CaseShorthandImpl other = (CaseShorthandImpl) obj; - if (qName == null) { - if (other.qName != null) { - return false; - } - } else if (!qName.equals(other.qName)) { - return false; - } - if (path == null) { - if (other.path != null) { - return false; - } - } else if (!path.equals(other.path)) { - return false; - } - return true; + return Objects.equals(qName, other.qName) && Objects.equals(path, other.path); } @Override public String toString() { - StringBuilder sb = new StringBuilder( - CaseShorthandImpl.class.getSimpleName()); + StringBuilder sb = new StringBuilder(CaseShorthandImpl.class.getSimpleName()); sb.append("["); sb.append("qname="); sb.append(qName); sb.append("]"); return sb.toString(); } - } diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/ChoiceEffectiveStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/ChoiceEffectiveStatementImpl.java index 0be4b49db8..1cca6d070f 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/ChoiceEffectiveStatementImpl.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/ChoiceEffectiveStatementImpl.java @@ -8,6 +8,7 @@ package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective; import com.google.common.base.Optional; +import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import java.util.Collection; @@ -45,16 +46,16 @@ public class ChoiceEffectiveStatementImpl extends private final QName qname; private final SchemaPath path; - boolean augmenting; - boolean addedByUses; - ChoiceSchemaNode original; - boolean configuration = true; - ConstraintDefinition constraints; - String defaultCase; + private boolean augmenting; + private boolean addedByUses; + private ChoiceSchemaNode original; + private boolean configuration = true; + private final ConstraintDefinition constraints; + private String defaultCase; - ImmutableSet cases; - ImmutableSet augmentations; - ImmutableList unknownNodes; + private ImmutableSet cases; + private ImmutableSet augmentations; + private ImmutableList unknownNodes; public ChoiceEffectiveStatementImpl( final StmtContext> ctx) { @@ -79,8 +80,7 @@ public class ChoiceEffectiveStatementImpl extends if (copyTypesFromOriginal.contains(TypeOfCopy.ADDED_BY_USES)) { addedByUses = true; } - if (copyTypesFromOriginal - .contains(TypeOfCopy.ADDED_BY_USES_AUGMENTATION)) { + if (copyTypesFromOriginal.contains(TypeOfCopy.ADDED_BY_USES_AUGMENTATION)) { addedByUses = augmenting = true; } @@ -118,22 +118,19 @@ public class ChoiceEffectiveStatementImpl extends || effectiveStatement instanceof LeafSchemaNode) { DataSchemaNode dataSchemaNode = (DataSchemaNode) effectiveStatement; - ChoiceCaseNode shorthandCase = new CaseShorthandImpl( - dataSchemaNode); + ChoiceCaseNode shorthandCase = new CaseShorthandImpl(dataSchemaNode); casesInit.add(shorthandCase); if (dataSchemaNode.isAugmenting() && !this.augmenting) { resetAugmenting(dataSchemaNode); } } - if (!configurationInit - && effectiveStatement instanceof ConfigEffectiveStatementImpl) { + if (!configurationInit && effectiveStatement instanceof ConfigEffectiveStatementImpl) { ConfigEffectiveStatementImpl configStmt = (ConfigEffectiveStatementImpl) effectiveStatement; this.configuration = configStmt.argument(); configurationInit = true; } - if (!defaultInit - && effectiveStatement instanceof DefaultEffectiveStatementImpl) { + if (!defaultInit && effectiveStatement instanceof DefaultEffectiveStatementImpl) { DefaultEffectiveStatementImpl defaultCaseStmt = (DefaultEffectiveStatementImpl) effectiveStatement; this.defaultCase = defaultCaseStmt.argument(); defaultInit = true; @@ -216,10 +213,8 @@ public class ChoiceEffectiveStatementImpl extends @Override public ChoiceCaseNode getCaseNodeByName(final QName name) { - if (name == null) { - throw new IllegalArgumentException( - "Choice Case QName cannot be NULL!"); - } + Preconditions.checkArgument(name != null, "Choice Case QName cannot be NULL!"); + for (final ChoiceCaseNode caseNode : cases) { if (caseNode != null && name.equals(caseNode.getQName())) { return caseNode; @@ -230,10 +225,8 @@ public class ChoiceEffectiveStatementImpl extends @Override public ChoiceCaseNode getCaseNodeByName(final String name) { - if (name == null) { - throw new IllegalArgumentException( - "Choice Case string Name cannot be NULL!"); - } + Preconditions.checkArgument(name != null, "Choice Case string Name cannot be NULL!"); + for (final ChoiceCaseNode caseNode : cases) { if (caseNode != null && (caseNode.getQName() != null) && name.equals(caseNode.getQName().getLocalName())) { @@ -269,31 +262,15 @@ public class ChoiceEffectiveStatementImpl extends return false; } ChoiceEffectiveStatementImpl other = (ChoiceEffectiveStatementImpl) obj; - if (qname == null) { - if (other.qname != null) { - return false; - } - } else if (!qname.equals(other.qname)) { - return false; - } - if (path == null) { - if (other.path != null) { - return false; - } - } else if (!path.equals(other.path)) { - return false; - } - return true; + return Objects.equals(qname, other.qname) && Objects.equals(path, other.path); } @Override public String toString() { - StringBuilder sb = new StringBuilder( - ChoiceEffectiveStatementImpl.class.getSimpleName()); + StringBuilder sb = new StringBuilder(ChoiceEffectiveStatementImpl.class.getSimpleName()); sb.append("["); sb.append("qname=").append(qname); sb.append("]"); return sb.toString(); } - } diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/ConfigEffectiveStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/ConfigEffectiveStatementImpl.java index 57f78017b6..db661bffba 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/ConfigEffectiveStatementImpl.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/ConfigEffectiveStatementImpl.java @@ -10,12 +10,8 @@ package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective; import org.opendaylight.yangtools.yang.model.api.stmt.ConfigStatement; import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext; -public class ConfigEffectiveStatementImpl extends - EffectiveStatementBase { - - public ConfigEffectiveStatementImpl( - StmtContext ctx) { +public class ConfigEffectiveStatementImpl extends EffectiveStatementBase { + public ConfigEffectiveStatementImpl(final StmtContext ctx) { super(ctx); - } } diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/ContactEffectiveStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/ContactEffectiveStatementImpl.java index 6a2ae09ec8..378d3faaf0 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/ContactEffectiveStatementImpl.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/ContactEffectiveStatementImpl.java @@ -10,12 +10,8 @@ package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective; import org.opendaylight.yangtools.yang.model.api.stmt.ContactStatement; import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext; -public class ContactEffectiveStatementImpl extends - EffectiveStatementBase { - - public ContactEffectiveStatementImpl( - StmtContext ctx) { +public class ContactEffectiveStatementImpl extends EffectiveStatementBase { + public ContactEffectiveStatementImpl(final StmtContext ctx) { super(ctx); - } } diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/ContainerEffectiveStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/ContainerEffectiveStatementImpl.java index f91c1ce577..4842358382 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/ContainerEffectiveStatementImpl.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/ContainerEffectiveStatementImpl.java @@ -21,10 +21,10 @@ import org.opendaylight.yangtools.yang.model.api.AugmentationSchema; import org.opendaylight.yangtools.yang.model.api.ConstraintDefinition; import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode; import org.opendaylight.yangtools.yang.model.api.DerivableSchemaNode; -import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement; import org.opendaylight.yangtools.yang.model.api.SchemaPath; -import org.opendaylight.yangtools.yang.model.api.stmt.ContainerStatement; import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode; +import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement; +import org.opendaylight.yangtools.yang.model.api.stmt.ContainerStatement; import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext; import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext.TypeOfCopy; import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.Utils; @@ -37,17 +37,19 @@ public class ContainerEffectiveStatementImpl extends private final SchemaPath path; private boolean presence; + + // FIXME: should be private boolean augmenting; private boolean addedByUses; private boolean configuration = true; private ContainerSchemaNode original; - private ConstraintDefinition constraints; + private final ConstraintDefinition constraints; private ImmutableSet augmentations; private ImmutableList unknownNodes; public ContainerEffectiveStatementImpl( - StmtContext> ctx) { + final StmtContext> ctx) { super(ctx); qname = ctx.getStatementArgument(); @@ -59,17 +61,17 @@ public class ContainerEffectiveStatementImpl extends } private void initCopyType( - StmtContext> ctx) { + final StmtContext> ctx) { List copyTypesFromOriginal = ctx.getCopyHistory(); - if(copyTypesFromOriginal.contains(TypeOfCopy.ADDED_BY_AUGMENTATION)) { + if (copyTypesFromOriginal.contains(TypeOfCopy.ADDED_BY_AUGMENTATION)) { augmenting = true; } - if(copyTypesFromOriginal.contains(TypeOfCopy.ADDED_BY_USES)) { + if (copyTypesFromOriginal.contains(TypeOfCopy.ADDED_BY_USES)) { addedByUses = true; } - if(copyTypesFromOriginal.contains(TypeOfCopy.ADDED_BY_USES_AUGMENTATION)) { + if (copyTypesFromOriginal.contains(TypeOfCopy.ADDED_BY_USES_AUGMENTATION)) { addedByUses = augmenting = true; } @@ -97,8 +99,7 @@ public class ContainerEffectiveStatementImpl extends if (effectiveSubstatement instanceof PresenceEffectiveStatementImpl) { presence = true; } - if (!configurationInit - && effectiveSubstatement instanceof ConfigEffectiveStatementImpl) { + if (!configurationInit && effectiveSubstatement instanceof ConfigEffectiveStatementImpl) { ConfigEffectiveStatementImpl configStmt = (ConfigEffectiveStatementImpl) effectiveSubstatement; this.configuration = configStmt.argument(); configurationInit = true; @@ -180,21 +181,7 @@ public class ContainerEffectiveStatementImpl extends return false; } ContainerEffectiveStatementImpl other = (ContainerEffectiveStatementImpl) obj; - if (qname == null) { - if (other.qname != null) { - return false; - } - } else if (!qname.equals(other.qname)) { - return false; - } - if (path == null) { - if (other.path != null) { - return false; - } - } else if (!path.equals(other.path)) { - return false; - } - return true; + return Objects.equals(qname, other.qname) && Objects.equals(path, other.path); } @Override diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/DefaultEffectiveStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/DefaultEffectiveStatementImpl.java index 26084a65f1..56aab3eef3 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/DefaultEffectiveStatementImpl.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/DefaultEffectiveStatementImpl.java @@ -10,12 +10,8 @@ package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective; import org.opendaylight.yangtools.yang.model.api.stmt.DefaultStatement; import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext; -public class DefaultEffectiveStatementImpl extends - EffectiveStatementBase { - - public DefaultEffectiveStatementImpl( - StmtContext ctx) { +public class DefaultEffectiveStatementImpl extends EffectiveStatementBase { + public DefaultEffectiveStatementImpl(final StmtContext ctx) { super(ctx); } - } \ No newline at end of file diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/DescriptionEffectiveStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/DescriptionEffectiveStatementImpl.java index 1d640ac042..837df34841 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/DescriptionEffectiveStatementImpl.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/DescriptionEffectiveStatementImpl.java @@ -7,16 +7,11 @@ */ package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective; -import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext; - import org.opendaylight.yangtools.yang.model.api.stmt.DescriptionStatement; +import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext; -public class DescriptionEffectiveStatementImpl extends - EffectiveStatementBase { - - public DescriptionEffectiveStatementImpl( - StmtContext ctx) { +public class DescriptionEffectiveStatementImpl extends EffectiveStatementBase { + public DescriptionEffectiveStatementImpl(final StmtContext ctx) { super(ctx); } - } diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/DeviateEffectiveStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/DeviateEffectiveStatementImpl.java index 6365a71552..13dd262792 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/DeviateEffectiveStatementImpl.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/DeviateEffectiveStatementImpl.java @@ -11,10 +11,8 @@ import org.opendaylight.yangtools.yang.model.api.Deviation; import org.opendaylight.yangtools.yang.model.api.stmt.DeviateStatement; import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext; -public class DeviateEffectiveStatementImpl extends - EffectiveStatementBase { - public DeviateEffectiveStatementImpl( - StmtContext ctx) { +public class DeviateEffectiveStatementImpl extends EffectiveStatementBase { + public DeviateEffectiveStatementImpl(final StmtContext ctx) { super(ctx); } } \ No newline at end of file diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/DeviationEffectiveStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/DeviationEffectiveStatementImpl.java index 88684db129..2b439a13e9 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/DeviationEffectiveStatementImpl.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/DeviationEffectiveStatementImpl.java @@ -23,12 +23,12 @@ import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext; public class DeviationEffectiveStatementImpl extends EffectiveStatementBase implements Deviation, Immutable { - private SchemaPath targetPath; + private final SchemaPath targetPath; private Deviate deviate; private String reference; - private ImmutableList unknownSchemaNodes; + private final ImmutableList unknownSchemaNodes; - public DeviationEffectiveStatementImpl(StmtContext ctx) { + public DeviationEffectiveStatementImpl(final StmtContext ctx) { super(ctx); List unknownSchemaNodesInit = new LinkedList<>(); @@ -82,7 +82,7 @@ public class DeviationEffectiveStatementImpl extends EffectiveStatementBase parent) { + public EffectiveConstraintDefinitionImpl(final EffectiveStatementBase parent) { MandatoryEffectiveStatementImpl firstMandatoryStmt = parent .firstEffective(MandatoryEffectiveStatementImpl.class); @@ -97,35 +97,19 @@ public class EffectiveConstraintDefinitionImpl implements ConstraintDefinition { return false; } EffectiveConstraintDefinitionImpl other = (EffectiveConstraintDefinitionImpl) obj; - if (whenCondition == null) { - if (other.whenCondition != null) { - return false; - } - } else if (!whenCondition.equals(other.whenCondition)) { + if (!mandatory.equals(other.mandatory)) { return false; } - if (mustConstraints == null) { - if (other.mustConstraints != null) { - return false; - } - } else if (!mustConstraints.equals(other.mustConstraints)) { + if (!Objects.equals(whenCondition, other.whenCondition)) { return false; } - if (!mandatory.equals(other.mandatory)) { + if (!Objects.equals(mustConstraints, other.mustConstraints)) { return false; } - if (minElements == null) { - if (other.minElements != null) { - return false; - } - } else if (!minElements.equals(other.minElements)) { + if (!Objects.equals(minElements, other.minElements)) { return false; } - if (maxElements == null) { - if (other.maxElements != null) { - return false; - } - } else if (!maxElements.equals(other.maxElements)) { + if (!Objects.equals(maxElements, other.maxElements)) { return false; } return true; @@ -133,8 +117,7 @@ public class EffectiveConstraintDefinitionImpl implements ConstraintDefinition { @Override public String toString() { - StringBuilder sb = new StringBuilder( - EffectiveConstraintDefinitionImpl.class.getSimpleName()); + StringBuilder sb = new StringBuilder(EffectiveConstraintDefinitionImpl.class.getSimpleName()); sb.append("["); sb.append("whenCondition=").append(whenCondition); sb.append(", mustConstraints=").append(mustConstraints); diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/EffectiveSchemaContext.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/EffectiveSchemaContext.java index 031d4cb879..3de0b1eafa 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/EffectiveSchemaContext.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/EffectiveSchemaContext.java @@ -7,28 +7,27 @@ */ package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective; -import java.util.HashMap; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; - -import com.google.common.collect.ImmutableMap; -import java.util.LinkedHashMap; -import org.opendaylight.yangtools.yang.parser.util.ModuleDependencySort; -import java.util.HashSet; import com.google.common.collect.ImmutableList; -import java.util.List; -import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement; -import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement; +import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSetMultimap; import com.google.common.collect.Multimaps; import com.google.common.collect.SetMultimap; import java.net.URI; import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedHashMap; +import java.util.List; import java.util.Map; import java.util.Set; import java.util.TreeMap; import org.opendaylight.yangtools.yang.model.api.Module; import org.opendaylight.yangtools.yang.model.api.ModuleIdentifier; +import org.opendaylight.yangtools.yang.model.api.SchemaContext; +import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement; +import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement; +import org.opendaylight.yangtools.yang.parser.util.ModuleDependencySort; public class EffectiveSchemaContext extends AbstractEffectiveSchemaContext { @@ -40,13 +39,10 @@ public class EffectiveSchemaContext extends AbstractEffectiveSchemaContext { private final ImmutableList> rootDeclaredStatements; private final ImmutableList> rootEffectiveStatements; - public EffectiveSchemaContext( - List> rootDeclaredStatements, - List> rootEffectiveStatements) { - this.rootDeclaredStatements = ImmutableList - .copyOf(rootDeclaredStatements); - this.rootEffectiveStatements = ImmutableList - .copyOf(rootEffectiveStatements); + public EffectiveSchemaContext(final List> rootDeclaredStatements, + final List> rootEffectiveStatements) { + this.rootDeclaredStatements = ImmutableList.copyOf(rootDeclaredStatements); + this.rootEffectiveStatements = ImmutableList.copyOf(rootEffectiveStatements); Set modulesInit = new HashSet<>(); for (EffectiveStatement rootEffectiveStatement : rootEffectiveStatements) { @@ -130,31 +126,26 @@ public class EffectiveSchemaContext extends AbstractEffectiveSchemaContext { @Override protected Map getIdentifiersToSources() { - return identifiersToSources; } @Override public Set getModules() { - return modules; } @Override protected SetMultimap getNamespaceToModules() { - return namespaceToModules; } @Override protected SetMultimap getNameToModules() { - return nameToModules; } @Override public String toString() { - return String.format("SchemaContextImpl{modules=%s}", modules); } } diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/EffectiveStatementBase.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/EffectiveStatementBase.java index cebfc0d924..b07669b1cc 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/EffectiveStatementBase.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/EffectiveStatementBase.java @@ -28,16 +28,13 @@ import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext; import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContextUtils; import org.opendaylight.yangtools.yang.parser.stmt.reactor.StatementContextBase; -abstract public class EffectiveStatementBase> - implements EffectiveStatement { - +abstract public class EffectiveStatementBase> implements EffectiveStatement { private final StmtContext stmtCtx; private final ImmutableList> substatements; private final StatementSource statementSource; private final StatementDefinition statementDefinition; - private D declaredInstance; - private final A argument; + private D declaredInstance; public EffectiveStatementBase(final StmtContext ctx) { @@ -46,10 +43,8 @@ abstract public class EffectiveStatementBase> this.argument = ctx.getStatementArgument(); this.statementSource = ctx.getStatementSource(); - Collection> declaredSubstatements = ctx - .declaredSubstatements(); - Collection> effectiveSubstatements = ctx - .effectiveSubstatements(); + Collection> declaredSubstatements = ctx.declaredSubstatements(); + Collection> effectiveSubstatements = ctx.effectiveSubstatements(); Collection> substatementsInit = new LinkedList<>(); @@ -94,14 +89,12 @@ abstract public class EffectiveStatementBase> } @Override - public > V get( - final Class namespace, final K identifier) { + public > V get(final Class namespace, final K identifier) { return stmtCtx.getFromNamespace(namespace, identifier); } @Override - public > Map getAll( - final Class namespace) { + public > Map getAll(final Class namespace) { return stmtCtx.getAllFromNamespace(namespace); } @@ -114,12 +107,10 @@ abstract public class EffectiveStatementBase> return stmtCtx; } - protected final > S firstEffective( - final Class type) { + protected final > S firstEffective(final Class type) { S result = null; try { - result = type.cast(Iterables.find(substatements, - Predicates.instanceOf(type))); + result = type.cast(Iterables.find(substatements, Predicates.instanceOf(type))); } catch (NoSuchElementException e) { result = null; } @@ -129,8 +120,7 @@ abstract public class EffectiveStatementBase> protected final S firstSchemaNode(final Class type) { S result = null; try { - result = type.cast(Iterables.find(substatements, - Predicates.instanceOf(type))); + result = type.cast(Iterables.find(substatements, Predicates.instanceOf(type))); } catch (NoSuchElementException e) { result = null; } @@ -138,13 +128,11 @@ abstract public class EffectiveStatementBase> } @SuppressWarnings("unchecked") - protected final Collection allSubstatementsOfType( - final Class type) { + protected final Collection allSubstatementsOfType(final Class type) { Collection result = null; try { - result = Collection.class.cast(Collections2.filter(substatements, - Predicates.instanceOf(type))); + result = Collection.class.cast(Collections2.filter(substatements, Predicates.instanceOf(type))); } catch (NoSuchElementException e) { result = Collections.emptyList(); } @@ -154,26 +142,21 @@ abstract public class EffectiveStatementBase> protected final T firstSubstatementOfType(final Class type) { T result = null; try { - result = type.cast(Iterables.find(substatements, - Predicates.instanceOf(type))); + result = type.cast(Iterables.find(substatements, Predicates.instanceOf(type))); } catch (NoSuchElementException e) { result = null; } return result; } - protected final R firstSubstatementOfType(final Class type, - final Class returnType) { + protected final R firstSubstatementOfType(final Class type, final Class returnType) { R result = null; try { - result = returnType.cast(Iterables.find( - substatements, - Predicates.and(Predicates.instanceOf(type), - Predicates.instanceOf(returnType)))); + result = returnType.cast(Iterables.find(substatements, + Predicates.and(Predicates.instanceOf(type), Predicates.instanceOf(returnType)))); } catch (NoSuchElementException e) { result = null; } return result; } - } diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/EffectiveStmtUtils.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/EffectiveStmtUtils.java index a26d2c14d9..725dc742ff 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/EffectiveStmtUtils.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/EffectiveStmtUtils.java @@ -9,19 +9,17 @@ package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective; import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement; - import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext; import org.opendaylight.yangtools.yang.parser.spi.source.SourceException; public class EffectiveStmtUtils { - private EffectiveStmtUtils(){ + private EffectiveStmtUtils() { throw new UnsupportedOperationException("Utility class"); } - public static final SourceException createNameCollisionSourceException( - final StmtContext ctx, - EffectiveStatement effectiveStatement) { + public static final SourceException createNameCollisionSourceException(final StmtContext ctx, + final EffectiveStatement effectiveStatement) { return new SourceException("Error in module '" + ctx.getRoot().getStatementArgument() + "': can not add '" diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/ErrorAppTagEffectiveStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/ErrorAppTagEffectiveStatementImpl.java index fbd7efde7b..1d46cc1613 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/ErrorAppTagEffectiveStatementImpl.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/ErrorAppTagEffectiveStatementImpl.java @@ -10,13 +10,8 @@ package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective; import org.opendaylight.yangtools.yang.model.api.stmt.ErrorAppTagStatement; import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext; -public class ErrorAppTagEffectiveStatementImpl extends - EffectiveStatementBase { - - public ErrorAppTagEffectiveStatementImpl( - StmtContext ctx) { +public class ErrorAppTagEffectiveStatementImpl extends EffectiveStatementBase { + public ErrorAppTagEffectiveStatementImpl(final StmtContext ctx) { super(ctx); - } - } \ No newline at end of file diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/ErrorMessageEffectiveStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/ErrorMessageEffectiveStatementImpl.java index 6f2a749bdb..acf6763a9e 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/ErrorMessageEffectiveStatementImpl.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/ErrorMessageEffectiveStatementImpl.java @@ -10,13 +10,8 @@ package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective; import org.opendaylight.yangtools.yang.model.api.stmt.ErrorMessageStatement; import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext; -public class ErrorMessageEffectiveStatementImpl extends - EffectiveStatementBase { - - public ErrorMessageEffectiveStatementImpl( - StmtContext ctx) { +public class ErrorMessageEffectiveStatementImpl extends EffectiveStatementBase { + public ErrorMessageEffectiveStatementImpl(final StmtContext ctx) { super(ctx); - } - } \ No newline at end of file diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/ExtendedTypeEffectiveStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/ExtendedTypeEffectiveStatementImpl.java index 9c067fbea0..ba1a9ad675 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/ExtendedTypeEffectiveStatementImpl.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/ExtendedTypeEffectiveStatementImpl.java @@ -73,8 +73,8 @@ public class ExtendedTypeEffectiveStatementImpl extends EffectiveStatementBase> typeStmt = ctx - .getFromNamespace(TypeNamespace.class, qName); + final StmtContext> typeStmt = + ctx.getFromNamespace(TypeNamespace.class, qName); if (typeStmt == null) { path = Utils.getSchemaPath(ctx); } else { diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/ExtensionEffectiveStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/ExtensionEffectiveStatementImpl.java index 51f4bec5d1..a73b904041 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/ExtensionEffectiveStatementImpl.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/ExtensionEffectiveStatementImpl.java @@ -14,25 +14,24 @@ import java.util.List; import java.util.Objects; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.model.api.ExtensionDefinition; -import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement; import org.opendaylight.yangtools.yang.model.api.SchemaPath; -import org.opendaylight.yangtools.yang.model.api.stmt.ExtensionStatement; import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode; +import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement; +import org.opendaylight.yangtools.yang.model.api.stmt.ExtensionStatement; import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext; import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.Utils; -public class ExtensionEffectiveStatementImpl extends - AbstractEffectiveDocumentedNode implements - ExtensionDefinition { +public class ExtensionEffectiveStatementImpl extends AbstractEffectiveDocumentedNode + implements ExtensionDefinition { private final QName qname; - String argument; + private String argument; private final SchemaPath schemaPath; - ImmutableList unknownNodes; - boolean yin; + private ImmutableList unknownNodes; + private boolean yin; public ExtensionEffectiveStatementImpl( - StmtContext> ctx) { + final StmtContext> ctx) { super(ctx); this.qname = ctx.getStatementArgument(); @@ -40,7 +39,6 @@ public class ExtensionEffectiveStatementImpl extends initSubstatementCollections(); initFields(); - } private void initFields() { @@ -121,27 +119,12 @@ public class ExtensionEffectiveStatementImpl extends return false; } ExtensionEffectiveStatementImpl other = (ExtensionEffectiveStatementImpl) obj; - if (qname == null) { - if (other.qname != null) { - return false; - } - } else if (!qname.equals(other.qname)) { - return false; - } - if (schemaPath == null) { - if (other.schemaPath != null) { - return false; - } - } else if (!schemaPath.equals(other.schemaPath)) { - return false; - } - return true; + return Objects.equals(qname, other.qname) && Objects.equals(schemaPath, other.schemaPath); } @Override public String toString() { - StringBuilder sb = new StringBuilder( - ExtensionEffectiveStatementImpl.class.getSimpleName()); + StringBuilder sb = new StringBuilder(ExtensionEffectiveStatementImpl.class.getSimpleName()); sb.append("["); sb.append("argument=").append(argument); sb.append(", qname=").append(qname); diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/FeatureEffectiveStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/FeatureEffectiveStatementImpl.java index a30457a268..40aae1d7c9 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/FeatureEffectiveStatementImpl.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/FeatureEffectiveStatementImpl.java @@ -13,25 +13,25 @@ import java.util.List; import java.util.Objects; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.model.api.FeatureDefinition; -import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement; import org.opendaylight.yangtools.yang.model.api.SchemaPath; import org.opendaylight.yangtools.yang.model.api.Status; -import org.opendaylight.yangtools.yang.model.api.stmt.FeatureStatement; import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode; +import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement; +import org.opendaylight.yangtools.yang.model.api.stmt.FeatureStatement; import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext; import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.Utils; public class FeatureEffectiveStatementImpl extends EffectiveStatementBase implements FeatureDefinition { - private QName qName; - private SchemaPath path; + private final QName qName; + private final SchemaPath path; private List unknownSchemaNodes; private String description; private String reference; private Status status; - public FeatureEffectiveStatementImpl(StmtContext ctx) { + public FeatureEffectiveStatementImpl(final StmtContext ctx) { super(ctx); this.qName = ctx.getStatementArgument(); @@ -114,21 +114,7 @@ public class FeatureEffectiveStatementImpl extends EffectiveStatementBase { - - public FractionDigitsEffectiveStatementImpl( - StmtContext ctx) { +public class FractionDigitsEffectiveStatementImpl extends EffectiveStatementBase { + public FractionDigitsEffectiveStatementImpl(final StmtContext ctx) { super(ctx); - } - } \ No newline at end of file diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/GroupingEffectiveStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/GroupingEffectiveStatementImpl.java index 9a337d2713..b5c95cd82e 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/GroupingEffectiveStatementImpl.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/GroupingEffectiveStatementImpl.java @@ -31,7 +31,7 @@ public class GroupingEffectiveStatementImpl extends private List unknownNodes; public GroupingEffectiveStatementImpl( - StmtContext> ctx) { + final StmtContext> ctx) { super(ctx); qname = ctx.getStatementArgument(); @@ -42,11 +42,11 @@ public class GroupingEffectiveStatementImpl extends } private void initCopyType( - StmtContext> ctx) { + final StmtContext> ctx) { List copyTypesFromOriginal = ctx.getCopyHistory(); - if(copyTypesFromOriginal.contains(TypeOfCopy.ADDED_BY_USES)) { + if (copyTypesFromOriginal.contains(TypeOfCopy.ADDED_BY_USES)) { addedByUses = true; } } @@ -62,7 +62,6 @@ public class GroupingEffectiveStatementImpl extends unknownNodes.add(unknownNode); } } - } @Override @@ -106,21 +105,7 @@ public class GroupingEffectiveStatementImpl extends return false; } final GroupingEffectiveStatementImpl other = (GroupingEffectiveStatementImpl) obj; - if (qname == null) { - if (other.qname != null) { - return false; - } - } else if (!qname.equals(other.qname)) { - return false; - } - if (path == null) { - if (other.path != null) { - return false; - } - } else if (!path.equals(other.path)) { - return false; - } - return true; + return Objects.equals(qname, other.qname) && Objects.equals(path, other.path); } @Override diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/IdentityEffectiveStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/IdentityEffectiveStatementImpl.java index b443485380..4228e9482d 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/IdentityEffectiveStatementImpl.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/IdentityEffectiveStatementImpl.java @@ -18,26 +18,24 @@ import java.util.Objects; import java.util.Set; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.model.api.IdentitySchemaNode; -import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement; import org.opendaylight.yangtools.yang.model.api.SchemaPath; -import org.opendaylight.yangtools.yang.model.api.stmt.IdentityStatement; import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode; +import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement; +import org.opendaylight.yangtools.yang.model.api.stmt.IdentityStatement; import org.opendaylight.yangtools.yang.parser.spi.meta.DerivedIdentitiesNamespace; import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext; import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.Utils; -public class IdentityEffectiveStatementImpl extends - AbstractEffectiveDocumentedNode implements - IdentitySchemaNode { +public class IdentityEffectiveStatementImpl extends AbstractEffectiveDocumentedNode + implements IdentitySchemaNode { private final QName qname; private final SchemaPath path; - IdentitySchemaNode baseIdentity; + private IdentitySchemaNode baseIdentity; private ImmutableSet derivedIdentities; - - ImmutableList unknownNodes; + private ImmutableList unknownNodes; public IdentityEffectiveStatementImpl( - StmtContext> ctx) { + final StmtContext> ctx) { super(ctx); this.qname = ctx.getStatementArgument(); @@ -48,13 +46,13 @@ public class IdentityEffectiveStatementImpl extends } private void initDerivedIdentities( - StmtContext> ctx) { + final StmtContext> ctx) { Set derivedIdentitiesInit = new HashSet(); List> derivedIdentitiesCtxList = ctx.getFromNamespace( DerivedIdentitiesNamespace.class, ctx.getStatementArgument()); - if(derivedIdentitiesCtxList == null) { + if (derivedIdentitiesCtxList == null) { this.derivedIdentities = ImmutableSet.of(); return; } @@ -68,7 +66,7 @@ public class IdentityEffectiveStatementImpl extends this.derivedIdentities = ImmutableSet.copyOf(derivedIdentitiesInit); } - private void initBaseIdentity(IdentityEffectiveStatementImpl baseIdentity) { + private void initBaseIdentity(final IdentityEffectiveStatementImpl baseIdentity) { this.baseIdentity = baseIdentity; } @@ -133,21 +131,7 @@ public class IdentityEffectiveStatementImpl extends return false; } IdentityEffectiveStatementImpl other = (IdentityEffectiveStatementImpl) obj; - if (qname == null) { - if (other.qname != null) { - return false; - } - } else if (!qname.equals(other.qname)) { - return false; - } - if (path == null) { - if (other.path != null) { - return false; - } - } else if (!path.equals(other.path)) { - return false; - } - return true; + return Objects.equals(qname, other.qname) && Objects.equals(path, other.path); } @Override diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/IfFeatureEffectiveStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/IfFeatureEffectiveStatementImpl.java index 70d3e9cdd7..903d55f5e4 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/IfFeatureEffectiveStatementImpl.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/IfFeatureEffectiveStatementImpl.java @@ -11,13 +11,8 @@ import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.model.api.stmt.IfFeatureStatement; import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext; -public class IfFeatureEffectiveStatementImpl extends - EffectiveStatementBase { - - public IfFeatureEffectiveStatementImpl( - StmtContext ctx) { +public class IfFeatureEffectiveStatementImpl extends EffectiveStatementBase { + public IfFeatureEffectiveStatementImpl(final StmtContext ctx) { super(ctx); - } - } \ No newline at end of file diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/ImportEffectiveStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/ImportEffectiveStatementImpl.java index c9a2d2c359..4462819ef6 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/ImportEffectiveStatementImpl.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/ImportEffectiveStatementImpl.java @@ -7,10 +7,9 @@ */ package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective; -import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil; - import java.util.Date; import java.util.Objects; +import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil; import org.opendaylight.yangtools.yang.model.api.ModuleImport; import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement; import org.opendaylight.yangtools.yang.model.api.stmt.ImportStatement; @@ -19,11 +18,11 @@ import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext; public class ImportEffectiveStatementImpl extends EffectiveStatementBase implements ModuleImport { - private String moduleName; + private final String moduleName; private Date revision; private String prefix; - public ImportEffectiveStatementImpl(StmtContext ctx) { + public ImportEffectiveStatementImpl(final StmtContext ctx) { super(ctx); moduleName = ctx.getStatementArgument(); @@ -65,7 +64,7 @@ public class ImportEffectiveStatementImpl extends EffectiveStatementBase { - - public IncludeEffectiveStatementImpl( - StmtContext ctx) { +public class IncludeEffectiveStatementImpl extends EffectiveStatementBase { + public IncludeEffectiveStatementImpl(final StmtContext ctx) { super(ctx); } - } \ No newline at end of file diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/InputEffectiveStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/InputEffectiveStatementImpl.java index 9d53810150..b0fb26780e 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/InputEffectiveStatementImpl.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/InputEffectiveStatementImpl.java @@ -19,10 +19,10 @@ import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.model.api.AugmentationSchema; import org.opendaylight.yangtools.yang.model.api.ConstraintDefinition; import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode; -import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement; import org.opendaylight.yangtools.yang.model.api.SchemaPath; -import org.opendaylight.yangtools.yang.model.api.stmt.InputStatement; import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode; +import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement; +import org.opendaylight.yangtools.yang.model.api.stmt.InputStatement; import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext; import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext.TypeOfCopy; import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.Utils; @@ -35,41 +35,38 @@ public class InputEffectiveStatementImpl extends private final SchemaPath path; private final boolean presence; - boolean augmenting; - boolean addedByUses; - boolean configuration = true; - ContainerSchemaNode original; - ConstraintDefinition constraints; + private boolean augmenting; + private boolean addedByUses; + private boolean configuration = true; + private ContainerSchemaNode original; + private final ConstraintDefinition constraints; private ImmutableSet augmentations; private ImmutableList unknownNodes; public InputEffectiveStatementImpl( - StmtContext> ctx) { + final StmtContext> ctx) { super(ctx); qname = ctx.getStatementArgument(); path = Utils.getSchemaPath(ctx); - presence = (firstEffective(PresenceEffectiveStatementImpl.class) == null) ? false - : true; + presence = firstEffective(PresenceEffectiveStatementImpl.class) != null; this.constraints = new EffectiveConstraintDefinitionImpl(this); initSubstatementCollectionsAndFields(); initCopyType(ctx); } - private void initCopyType( - StmtContext> ctx) { + private void initCopyType(final StmtContext> ctx) { List copyTypesFromOriginal = ctx.getCopyHistory(); - - if(copyTypesFromOriginal.contains(TypeOfCopy.ADDED_BY_AUGMENTATION)) { + if (copyTypesFromOriginal.contains(TypeOfCopy.ADDED_BY_AUGMENTATION)) { augmenting = true; } - if(copyTypesFromOriginal.contains(TypeOfCopy.ADDED_BY_USES)) { + if (copyTypesFromOriginal.contains(TypeOfCopy.ADDED_BY_USES)) { addedByUses = true; } - if(copyTypesFromOriginal.contains(TypeOfCopy.ADDED_BY_USES_AUGMENTATION)) { + if (copyTypesFromOriginal.contains(TypeOfCopy.ADDED_BY_USES_AUGMENTATION)) { addedByUses = augmenting = true; } @@ -94,8 +91,7 @@ public class InputEffectiveStatementImpl extends AugmentationSchema augmentationSchema = (AugmentationSchema) effectiveStatement; augmentationsInit.add(augmentationSchema); } - if (!configurationInit - && effectiveStatement instanceof ConfigEffectiveStatementImpl) { + if (!configurationInit && effectiveStatement instanceof ConfigEffectiveStatementImpl) { ConfigEffectiveStatementImpl configStmt = (ConfigEffectiveStatementImpl) effectiveStatement; this.configuration = configStmt.argument(); configurationInit = true; @@ -172,26 +168,11 @@ public class InputEffectiveStatementImpl extends return false; } InputEffectiveStatementImpl other = (InputEffectiveStatementImpl) obj; - if (qname == null) { - if (other.qname != null) { - return false; - } - } else if (!qname.equals(other.qname)) { - return false; - } - if (path == null) { - if (other.path != null) { - return false; - } - } else if (!path.equals(other.path)) { - return false; - } - return true; + return Objects.equals(qname, other.qname) && Objects.equals(path, other.path); } @Override public String toString() { return "RPC input " + qname.getLocalName(); } - } diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/KeyEffectiveStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/KeyEffectiveStatementImpl.java index 4d61814de7..a0c23d9f4b 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/KeyEffectiveStatementImpl.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/KeyEffectiveStatementImpl.java @@ -8,17 +8,12 @@ package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective; import java.util.Collection; -import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier; - import org.opendaylight.yangtools.yang.model.api.stmt.KeyStatement; +import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier; import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext; -public class KeyEffectiveStatementImpl extends - EffectiveStatementBase, KeyStatement> { - - public KeyEffectiveStatementImpl( - StmtContext, KeyStatement, ?> ctx) { +public class KeyEffectiveStatementImpl extends EffectiveStatementBase, KeyStatement> { + public KeyEffectiveStatementImpl(final StmtContext, KeyStatement, ?> ctx) { super(ctx); } - } diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/LeafEffectiveStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/LeafEffectiveStatementImpl.java index 60c3384017..9590f292ed 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/LeafEffectiveStatementImpl.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/LeafEffectiveStatementImpl.java @@ -17,11 +17,11 @@ import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.model.api.ConstraintDefinition; import org.opendaylight.yangtools.yang.model.api.DerivableSchemaNode; import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode; -import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement; import org.opendaylight.yangtools.yang.model.api.SchemaPath; -import org.opendaylight.yangtools.yang.model.api.stmt.LeafStatement; import org.opendaylight.yangtools.yang.model.api.TypeDefinition; import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode; +import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement; +import org.opendaylight.yangtools.yang.model.api.stmt.LeafStatement; import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext; import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext.TypeOfCopy; import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.TypeUtils; @@ -32,18 +32,19 @@ public class LeafEffectiveStatementImpl extends AbstractEffectiveDocumentedNode< private final QName qname; private final SchemaPath path; + // FIXME: should be private boolean augmenting; private boolean addedByUses; private LeafSchemaNode original; private boolean configuration = true; - private ConstraintDefinition constraintsDef; + private final ConstraintDefinition constraintsDef; private TypeDefinition type; private String defaultStr; private String unitsStr; private ImmutableList unknownNodes; - public LeafEffectiveStatementImpl(StmtContext> ctx) { + public LeafEffectiveStatementImpl(final StmtContext> ctx) { super(ctx); this.qname = ctx.getStatementArgument(); this.path = Utils.getSchemaPath(ctx); @@ -54,20 +55,19 @@ public class LeafEffectiveStatementImpl extends AbstractEffectiveDocumentedNode< } private void initCopyType( - StmtContext> ctx) { + final StmtContext> ctx) { List copyTypesFromOriginal = ctx.getCopyHistory(); - if(copyTypesFromOriginal.contains(TypeOfCopy.ADDED_BY_AUGMENTATION)) { + if (copyTypesFromOriginal.contains(TypeOfCopy.ADDED_BY_AUGMENTATION)) { augmenting = true; } - if(copyTypesFromOriginal.contains(TypeOfCopy.ADDED_BY_USES)) { + if (copyTypesFromOriginal.contains(TypeOfCopy.ADDED_BY_USES)) { addedByUses = true; } - if(copyTypesFromOriginal.contains(TypeOfCopy.ADDED_BY_USES_AUGMENTATION)) { + if (copyTypesFromOriginal.contains(TypeOfCopy.ADDED_BY_USES_AUGMENTATION)) { addedByUses = augmenting = true; } - if (ctx.getOriginalCtx() != null) { original = (LeafSchemaNode) ctx.getOriginalCtx().buildEffective(); } @@ -185,21 +185,7 @@ public class LeafEffectiveStatementImpl extends AbstractEffectiveDocumentedNode< return false; } LeafEffectiveStatementImpl other = (LeafEffectiveStatementImpl) obj; - if (qname == null) { - if (other.qname != null) { - return false; - } - } else if (!qname.equals(other.qname)) { - return false; - } - if (path == null) { - if (other.path != null) { - return false; - } - } else if (!path.equals(other.path)) { - return false; - } - return true; + return Objects.equals(qname, other.qname) && Objects.equals(path, other.path); } @Override diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/LeafListEffectiveStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/LeafListEffectiveStatementImpl.java index 96bc2ef825..92cb8de401 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/LeafListEffectiveStatementImpl.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/LeafListEffectiveStatementImpl.java @@ -17,11 +17,11 @@ import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.model.api.ConstraintDefinition; import org.opendaylight.yangtools.yang.model.api.DerivableSchemaNode; import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode; -import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement; import org.opendaylight.yangtools.yang.model.api.SchemaPath; -import org.opendaylight.yangtools.yang.model.api.stmt.LeafListStatement; import org.opendaylight.yangtools.yang.model.api.TypeDefinition; import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode; +import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement; +import org.opendaylight.yangtools.yang.model.api.stmt.LeafListStatement; import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext; import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext.TypeOfCopy; import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.TypeUtils; @@ -32,18 +32,19 @@ public class LeafListEffectiveStatementImpl extends AbstractEffectiveDocumentedN private final QName qname; private final SchemaPath path; + // FIXME: should be private boolean augmenting; private boolean addedByUses; private LeafListSchemaNode original; private boolean configuration = true; - private ConstraintDefinition constraintsDef; + private final ConstraintDefinition constraintsDef; private TypeDefinition type; private boolean userOrdered; private ImmutableList unknownNodes; public LeafListEffectiveStatementImpl( - StmtContext> ctx) { + final StmtContext> ctx) { super(ctx); this.qname = ctx.getStatementArgument(); this.path = Utils.getSchemaPath(ctx); @@ -56,17 +57,17 @@ public class LeafListEffectiveStatementImpl extends AbstractEffectiveDocumentedN } private void initCopyType( - StmtContext> ctx) { + final StmtContext> ctx) { List copyTypesFromOriginal = ctx.getCopyHistory(); - if(copyTypesFromOriginal.contains(TypeOfCopy.ADDED_BY_AUGMENTATION)) { + if (copyTypesFromOriginal.contains(TypeOfCopy.ADDED_BY_AUGMENTATION)) { augmenting = true; } - if(copyTypesFromOriginal.contains(TypeOfCopy.ADDED_BY_USES)) { + if (copyTypesFromOriginal.contains(TypeOfCopy.ADDED_BY_USES)) { addedByUses = true; } - if(copyTypesFromOriginal.contains(TypeOfCopy.ADDED_BY_USES_AUGMENTATION)) { + if (copyTypesFromOriginal.contains(TypeOfCopy.ADDED_BY_USES_AUGMENTATION)) { addedByUses = augmenting = true; } @@ -174,21 +175,7 @@ public class LeafListEffectiveStatementImpl extends AbstractEffectiveDocumentedN return false; } LeafListEffectiveStatementImpl other = (LeafListEffectiveStatementImpl) obj; - if (qname == null) { - if (other.qname != null) { - return false; - } - } else if (!qname.equals(other.qname)) { - return false; - } - if (path == null) { - if (other.path != null) { - return false; - } - } else if (!path.equals(other.path)) { - return false; - } - return true; + return Objects.equals(qname, other.qname) && Objects.equals(path, other.path); } @Override diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/ListEffectiveStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/ListEffectiveStatementImpl.java index 303604f5d2..017dfe0615 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/ListEffectiveStatementImpl.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/ListEffectiveStatementImpl.java @@ -23,11 +23,11 @@ import org.opendaylight.yangtools.yang.model.api.ConstraintDefinition; import org.opendaylight.yangtools.yang.model.api.DerivableSchemaNode; import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode; import org.opendaylight.yangtools.yang.model.api.ListSchemaNode; -import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement; import org.opendaylight.yangtools.yang.model.api.SchemaPath; +import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode; +import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement; import org.opendaylight.yangtools.yang.model.api.stmt.ListStatement; import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier; -import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode; import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext; import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext.TypeOfCopy; import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.Utils; @@ -37,18 +37,19 @@ public class ListEffectiveStatementImpl extends AbstractEffectiveDocumentedDataN private final QName qname; private final SchemaPath path; + // FIXME: should be private boolean augmenting; private boolean addedByUses; - ListSchemaNode original; - boolean configuration = true; - ConstraintDefinition constraints; - boolean userOrdered; + private ListSchemaNode original; + private boolean configuration = true; + private final ConstraintDefinition constraints; + private boolean userOrdered; - ImmutableList keyDefinition; - ImmutableSet augmentations; - ImmutableList unknownNodes; + private ImmutableList keyDefinition; + private ImmutableSet augmentations; + private ImmutableList unknownNodes; - public ListEffectiveStatementImpl(StmtContext> ctx) { + public ListEffectiveStatementImpl(final StmtContext> ctx) { super(ctx); this.qname = ctx.getStatementArgument(); this.path = Utils.getSchemaPath(ctx); @@ -61,27 +62,25 @@ public class ListEffectiveStatementImpl extends AbstractEffectiveDocumentedDataN initKeyDefinition(ctx); } - private void initCopyType( - StmtContext> ctx) { + private void initCopyType(final StmtContext> ctx) { List copyTypesFromOriginal = ctx.getCopyHistory(); - if(copyTypesFromOriginal.contains(TypeOfCopy.ADDED_BY_AUGMENTATION)) { + if (copyTypesFromOriginal.contains(TypeOfCopy.ADDED_BY_AUGMENTATION)) { augmenting = true; } - if(copyTypesFromOriginal.contains(TypeOfCopy.ADDED_BY_USES)) { + if (copyTypesFromOriginal.contains(TypeOfCopy.ADDED_BY_USES)) { addedByUses = true; } - if(copyTypesFromOriginal.contains(TypeOfCopy.ADDED_BY_USES_AUGMENTATION)) { + if (copyTypesFromOriginal.contains(TypeOfCopy.ADDED_BY_USES_AUGMENTATION)) { addedByUses = augmenting = true; } - if (ctx.getOriginalCtx() != null) { original = (ListSchemaNode) ctx.getOriginalCtx().buildEffective(); } } - private void initKeyDefinition(StmtContext> ctx) { + private void initKeyDefinition(final StmtContext> ctx) { List keyDefinitionInit = new LinkedList<>(); KeyEffectiveStatementImpl keyEffectiveSubstatement = firstEffective(KeyEffectiveStatementImpl.class); @@ -220,21 +219,7 @@ public class ListEffectiveStatementImpl extends AbstractEffectiveDocumentedDataN return false; } final ListEffectiveStatementImpl other = (ListEffectiveStatementImpl) obj; - if (qname == null) { - if (other.qname != null) { - return false; - } - } else if (!qname.equals(other.qname)) { - return false; - } - if (path == null) { - if (other.path != null) { - return false; - } - } else if (!path.equals(other.path)) { - return false; - } - return true; + return Objects.equals(qname, other.qname) && Objects.equals(path, other.path); } @Override diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/MandatoryEffectiveStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/MandatoryEffectiveStatementImpl.java index 408c97fff4..bcd8e8cb87 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/MandatoryEffectiveStatementImpl.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/MandatoryEffectiveStatementImpl.java @@ -10,13 +10,8 @@ package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective; import org.opendaylight.yangtools.yang.model.api.stmt.MandatoryStatement; import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext; -public class MandatoryEffectiveStatementImpl extends - EffectiveStatementBase { - - public MandatoryEffectiveStatementImpl( - StmtContext ctx) { +public class MandatoryEffectiveStatementImpl extends EffectiveStatementBase { + public MandatoryEffectiveStatementImpl(final StmtContext ctx) { super(ctx); - } - } \ No newline at end of file diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/MaxElementsEffectiveStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/MaxElementsEffectiveStatementImpl.java index 7055f74a7e..ee58993cfa 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/MaxElementsEffectiveStatementImpl.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/MaxElementsEffectiveStatementImpl.java @@ -10,13 +10,9 @@ package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective; import org.opendaylight.yangtools.yang.model.api.stmt.MaxElementsStatement; import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext; -public class MaxElementsEffectiveStatementImpl extends - EffectiveStatementBase { - - public MaxElementsEffectiveStatementImpl( - StmtContext ctx) { +public class MaxElementsEffectiveStatementImpl extends EffectiveStatementBase { + public MaxElementsEffectiveStatementImpl(final StmtContext ctx) { super(ctx); } - } \ No newline at end of file diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/MinElementsEffectiveStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/MinElementsEffectiveStatementImpl.java index 15819a4326..819ff549d8 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/MinElementsEffectiveStatementImpl.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/MinElementsEffectiveStatementImpl.java @@ -10,13 +10,8 @@ package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective; import org.opendaylight.yangtools.yang.model.api.stmt.MinElementsStatement; import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext; -public class MinElementsEffectiveStatementImpl extends - EffectiveStatementBase { - - public MinElementsEffectiveStatementImpl( - StmtContext ctx) { +public class MinElementsEffectiveStatementImpl extends EffectiveStatementBase { + public MinElementsEffectiveStatementImpl(final StmtContext ctx) { super(ctx); - } - } \ No newline at end of file diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/ModuleEffectiveStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/ModuleEffectiveStatementImpl.java index e415ecbfda..d92f2ba213 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/ModuleEffectiveStatementImpl.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/ModuleEffectiveStatementImpl.java @@ -53,8 +53,7 @@ import org.opendaylight.yangtools.yang.parser.spi.source.IncludedSubmoduleNameTo import org.opendaylight.yangtools.yang.parser.spi.source.ModuleCtxToModuleQName; import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.Utils; -public class ModuleEffectiveStatementImpl extends - AbstractEffectiveDocumentedNode implements +public class ModuleEffectiveStatementImpl extends AbstractEffectiveDocumentedNode implements Module, Immutable { private final QNameModule qNameModule; @@ -88,11 +87,9 @@ public class ModuleEffectiveStatementImpl extends super(ctx); name = argument(); - QNameModule qNameModuleInit = ctx.getFromNamespace( - ModuleCtxToModuleQName.class, ctx); - qNameModule = qNameModuleInit.getRevision() == null ? QNameModule - .create(qNameModuleInit.getNamespace(), - SimpleDateFormatUtil.DEFAULT_DATE_REV) + QNameModule qNameModuleInit = ctx.getFromNamespace( ModuleCtxToModuleQName.class, ctx); + qNameModule = qNameModuleInit.getRevision() == null + ? QNameModule.create(qNameModuleInit.getNamespace(), SimpleDateFormatUtil.DEFAULT_DATE_REV) : qNameModuleInit; for (EffectiveStatement effectiveStatement : effectiveSubstatements()) { @@ -138,8 +135,10 @@ public class ModuleEffectiveStatementImpl extends Set submodulesInit = new HashSet<>(); List> substatementsOfSubmodulesInit = new LinkedList<>(); for (ModuleIdentifier submoduleIdentifier : includedSubmodules) { - Mutable> submoduleCtx = (Mutable>) ctx - .getFromNamespace(SubmoduleNamespace.class, submoduleIdentifier); + @SuppressWarnings("unchecked") + Mutable> submoduleCtx = + (Mutable>) + ctx.getFromNamespace(SubmoduleNamespace.class, submoduleIdentifier); SubmoduleEffectiveStatementImpl submodule = (SubmoduleEffectiveStatementImpl) submoduleCtx .buildEffective(); submodulesInit.add(submodule); @@ -208,9 +207,7 @@ public class ModuleEffectiveStatementImpl extends mutableChildNodes.put(dataSchemaNode.getQName(), dataSchemaNode); mutablePublicChildNodes.add(dataSchemaNode); } else { - throw EffectiveStmtUtils - .createNameCollisionSourceException(ctx, - effectiveStatement); + throw EffectiveStmtUtils.createNameCollisionSourceException(ctx, effectiveStatement); } } if (effectiveStatement instanceof UsesNode) { @@ -218,9 +215,7 @@ public class ModuleEffectiveStatementImpl extends if (!mutableUses.contains(usesNode)) { mutableUses.add(usesNode); } else { - throw EffectiveStmtUtils - .createNameCollisionSourceException(ctx, - effectiveStatement); + throw EffectiveStmtUtils.createNameCollisionSourceException(ctx, effectiveStatement); } } if (effectiveStatement instanceof TypeDefEffectiveStatementImpl) { @@ -229,9 +224,7 @@ public class ModuleEffectiveStatementImpl extends if (!mutableTypeDefinitions.contains(extendedType)) { mutableTypeDefinitions.add(extendedType); } else { - throw EffectiveStmtUtils - .createNameCollisionSourceException(ctx, - effectiveStatement); + throw EffectiveStmtUtils.createNameCollisionSourceException(ctx, effectiveStatement); } } if (effectiveStatement instanceof GroupingDefinition) { @@ -239,17 +232,14 @@ public class ModuleEffectiveStatementImpl extends if (!mutableGroupings.contains(grp)) { mutableGroupings.add(grp); } else { - throw EffectiveStmtUtils - .createNameCollisionSourceException(ctx, - effectiveStatement); + throw EffectiveStmtUtils.createNameCollisionSourceException(ctx, effectiveStatement); } } } this.unknownNodes = ImmutableList.copyOf(unknownNodesInit); this.augmentations = ImmutableSet.copyOf(augmentationsInit); - this.imports = ImmutableSet.copyOf(resolveModuleImports(importsInit, - ctx)); + this.imports = ImmutableSet.copyOf(resolveModuleImports(importsInit, ctx)); this.notifications = ImmutableSet.copyOf(notificationsInit); this.rpcs = ImmutableSet.copyOf(rpcsInit); this.deviations = ImmutableSet.copyOf(deviationsInit); @@ -264,8 +254,7 @@ public class ModuleEffectiveStatementImpl extends this.uses = ImmutableSet.copyOf(mutableUses); } - private static Set resolveModuleImports( - final Set importsInit, + private static Set resolveModuleImports(final Set importsInit, final StmtContext> ctx) { Set resolvedModuleImports = new LinkedHashSet<>(); for (ModuleImport moduleImport : importsInit) { @@ -442,21 +431,13 @@ public class ModuleEffectiveStatementImpl extends return false; } ModuleEffectiveStatementImpl other = (ModuleEffectiveStatementImpl) obj; - if (name == null) { - if (other.name != null) { - return false; - } - } else if (!name.equals(other.name)) { + if (!Objects.equals(name, other.name)) { return false; } if (!qNameModule.equals(other.qNameModule)) { return false; } - if (yangVersion == null) { - if (other.yangVersion != null) { - return false; - } - } else if (!yangVersion.equals(other.yangVersion)) { + if (!Objects.equals(yangVersion, other.yangVersion)) { return false; } return true; @@ -464,8 +445,7 @@ public class ModuleEffectiveStatementImpl extends @Override public String toString() { - StringBuilder sb = new StringBuilder( - ModuleEffectiveStatementImpl.class.getSimpleName()); + StringBuilder sb = new StringBuilder(ModuleEffectiveStatementImpl.class.getSimpleName()); sb.append("["); sb.append("name=").append(name); sb.append(", namespace=").append(getNamespace()); diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/MustEffectiveStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/MustEffectiveStatementImpl.java index bbb7437c23..e8c9d4ac1e 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/MustEffectiveStatementImpl.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/MustEffectiveStatementImpl.java @@ -14,18 +14,16 @@ import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement; import org.opendaylight.yangtools.yang.model.api.stmt.MustStatement; import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext; -public class MustEffectiveStatementImpl extends - EffectiveStatementBase implements +public class MustEffectiveStatementImpl extends EffectiveStatementBase implements MustDefinition { - private RevisionAwareXPath xPath; + private final RevisionAwareXPath xPath; private String description; private String errorAppTag; private String errorMessage; private String reference; - public MustEffectiveStatementImpl( - StmtContext ctx) { + public MustEffectiveStatementImpl(final StmtContext ctx) { super(ctx); initFields(); @@ -99,25 +97,13 @@ public class MustEffectiveStatementImpl extends return false; } final MustEffectiveStatementImpl other = (MustEffectiveStatementImpl) obj; - if (xPath == null) { - if (other.xPath != null) { - return false; - } - } else if (!xPath.equals(other.xPath)) { + if (!Objects.equals(xPath, other.xPath)) { return false; } - if (description == null) { - if (other.description != null) { - return false; - } - } else if (!description.equals(other.description)) { + if (!Objects.equals(description, other.description)) { return false; } - if (reference == null) { - if (other.reference != null) { - return false; - } - } else if (!reference.equals(other.reference)) { + if (!Objects.equals(reference,other.reference)) { return false; } return true; diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/NamespaceEffectiveStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/NamespaceEffectiveStatementImpl.java index 4d2be0f802..3164a816c2 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/NamespaceEffectiveStatementImpl.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/NamespaceEffectiveStatementImpl.java @@ -8,15 +8,11 @@ package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective; import java.net.URI; - import org.opendaylight.yangtools.yang.model.api.stmt.NamespaceStatement; import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext; public class NamespaceEffectiveStatementImpl extends EffectiveStatementBase { - - public NamespaceEffectiveStatementImpl( - StmtContext ctx) { + public NamespaceEffectiveStatementImpl(final StmtContext ctx) { super(ctx); } - } diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/NotificationEffectiveStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/NotificationEffectiveStatementImpl.java index a29dba00f6..b89e34211a 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/NotificationEffectiveStatementImpl.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/NotificationEffectiveStatementImpl.java @@ -17,11 +17,11 @@ import java.util.Objects; import java.util.Set; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.model.api.AugmentationSchema; -import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement; import org.opendaylight.yangtools.yang.model.api.NotificationDefinition; import org.opendaylight.yangtools.yang.model.api.SchemaPath; -import org.opendaylight.yangtools.yang.model.api.stmt.NotificationStatement; import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode; +import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement; +import org.opendaylight.yangtools.yang.model.api.stmt.NotificationStatement; import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext; import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.Utils; @@ -30,11 +30,11 @@ public class NotificationEffectiveStatementImpl implements NotificationDefinition { private final QName qname; private final SchemaPath path; - ImmutableSet augmentations; - ImmutableList unknownNodes; + private Set augmentations; + private List unknownNodes; public NotificationEffectiveStatementImpl( - StmtContext> ctx) { + final StmtContext> ctx) { super(ctx); this.qname = ctx.getStatementArgument(); this.path = Utils.getSchemaPath(ctx); @@ -104,29 +104,13 @@ public class NotificationEffectiveStatementImpl return false; } final NotificationEffectiveStatementImpl other = (NotificationEffectiveStatementImpl) obj; - if (qname == null) { - if (other.qname != null) { - return false; - } - } else if (!qname.equals(other.qname)) { - return false; - } - if (path == null) { - if (other.path != null) { - return false; - } - } else if (!path.equals(other.path)) { - return false; - } - return true; + return Objects.equals(qname, other.qname) && Objects.equals(path, other.path); } @Override public String toString() { - StringBuilder sb = new StringBuilder( - NotificationEffectiveStatementImpl.class.getSimpleName()); - sb.append("[qname=").append(qname).append(", path=").append(path) - .append("]"); + StringBuilder sb = new StringBuilder(NotificationEffectiveStatementImpl.class.getSimpleName()); + sb.append("[qname=").append(qname).append(", path=").append(path).append("]"); return sb.toString(); } } diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/OrderedByEffectiveStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/OrderedByEffectiveStatementImpl.java index 8189e90d07..41f5f41016 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/OrderedByEffectiveStatementImpl.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/OrderedByEffectiveStatementImpl.java @@ -10,13 +10,8 @@ package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective; import org.opendaylight.yangtools.yang.model.api.stmt.OrderedByStatement; import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext; -public class OrderedByEffectiveStatementImpl extends - EffectiveStatementBase { - - public OrderedByEffectiveStatementImpl( - StmtContext ctx) { +public class OrderedByEffectiveStatementImpl extends EffectiveStatementBase { + public OrderedByEffectiveStatementImpl(final StmtContext ctx) { super(ctx); - } - } \ No newline at end of file diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/OrganizationEffectiveStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/OrganizationEffectiveStatementImpl.java index 2dd08e1131..16ef3c523a 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/OrganizationEffectiveStatementImpl.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/OrganizationEffectiveStatementImpl.java @@ -10,13 +10,8 @@ package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective; import org.opendaylight.yangtools.yang.model.api.stmt.OrganizationStatement; import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext; -public class OrganizationEffectiveStatementImpl extends -EffectiveStatementBase { - - public OrganizationEffectiveStatementImpl( - StmtContext ctx) { +public class OrganizationEffectiveStatementImpl extends EffectiveStatementBase { + public OrganizationEffectiveStatementImpl(final StmtContext ctx) { super(ctx); - } - } \ No newline at end of file diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/OutputEffectiveStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/OutputEffectiveStatementImpl.java index 068596130b..ce7648c5fb 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/OutputEffectiveStatementImpl.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/OutputEffectiveStatementImpl.java @@ -19,39 +19,37 @@ import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.model.api.AugmentationSchema; import org.opendaylight.yangtools.yang.model.api.ConstraintDefinition; import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode; -import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement; import org.opendaylight.yangtools.yang.model.api.SchemaPath; -import org.opendaylight.yangtools.yang.model.api.stmt.OutputStatement; import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode; +import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement; +import org.opendaylight.yangtools.yang.model.api.stmt.OutputStatement; import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext; import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext.TypeOfCopy; import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.Utils; -public class OutputEffectiveStatementImpl extends - AbstractEffectiveDocumentedDataNodeContainer +public class OutputEffectiveStatementImpl extends AbstractEffectiveDocumentedDataNodeContainer implements ContainerSchemaNode { private final QName qname; private final SchemaPath path; private final boolean presence; - boolean augmenting; - boolean addedByUses; - boolean configuration = true; - ContainerSchemaNode original; - ConstraintDefinition constraints; + private boolean augmenting; + private boolean addedByUses; + private boolean configuration = true; + private ContainerSchemaNode original; + private final ConstraintDefinition constraints; - private ImmutableSet augmentations; - private ImmutableList unknownNodes; + private Set augmentations; + private List unknownNodes; public OutputEffectiveStatementImpl( - StmtContext> ctx) { + final StmtContext> ctx) { super(ctx); qname = ctx.getStatementArgument(); path = Utils.getSchemaPath(ctx); - presence = (firstEffective(PresenceEffectiveStatementImpl.class) == null) ? false - : true; + presence = firstEffective(PresenceEffectiveStatementImpl.class) != null; this.constraints = new EffectiveConstraintDefinitionImpl(this); initSubstatementCollections(); @@ -59,20 +57,19 @@ public class OutputEffectiveStatementImpl extends } private void initCopyType( - StmtContext> ctx) { + final StmtContext> ctx) { List copyTypesFromOriginal = ctx.getCopyHistory(); - if(copyTypesFromOriginal.contains(TypeOfCopy.ADDED_BY_AUGMENTATION)) { + if (copyTypesFromOriginal.contains(TypeOfCopy.ADDED_BY_AUGMENTATION)) { augmenting = true; } - if(copyTypesFromOriginal.contains(TypeOfCopy.ADDED_BY_USES)) { + if (copyTypesFromOriginal.contains(TypeOfCopy.ADDED_BY_USES)) { addedByUses = true; } - if(copyTypesFromOriginal.contains(TypeOfCopy.ADDED_BY_USES_AUGMENTATION)) { + if (copyTypesFromOriginal.contains(TypeOfCopy.ADDED_BY_USES_AUGMENTATION)) { addedByUses = augmenting = true; } - if (ctx.getOriginalCtx() != null) { original = (ContainerSchemaNode) ctx.getOriginalCtx().buildEffective(); } @@ -94,8 +91,7 @@ public class OutputEffectiveStatementImpl extends AugmentationSchema augmentationSchema = (AugmentationSchema) effectiveStatement; augmentationsInit.add(augmentationSchema); } - if (!configurationInit - && effectiveStatement instanceof ConfigEffectiveStatementImpl) { + if (!configurationInit && effectiveStatement instanceof ConfigEffectiveStatementImpl) { ConfigEffectiveStatementImpl configStmt = (ConfigEffectiveStatementImpl) effectiveStatement; this.configuration = configStmt.argument(); configurationInit = true; @@ -172,21 +168,7 @@ public class OutputEffectiveStatementImpl extends return false; } OutputEffectiveStatementImpl other = (OutputEffectiveStatementImpl) obj; - if (qname == null) { - if (other.qname != null) { - return false; - } - } else if (!qname.equals(other.qname)) { - return false; - } - if (path == null) { - if (other.path != null) { - return false; - } - } else if (!path.equals(other.path)) { - return false; - } - return true; + return Objects.equals(qname, other.qname) && Objects.equals(path, other.path); } @Override diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/PathEffectiveStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/PathEffectiveStatementImpl.java index 5fa69b0aeb..cfdd800606 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/PathEffectiveStatementImpl.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/PathEffectiveStatementImpl.java @@ -11,13 +11,8 @@ import org.opendaylight.yangtools.yang.model.api.RevisionAwareXPath; import org.opendaylight.yangtools.yang.model.api.stmt.PathStatement; import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext; -public class PathEffectiveStatementImpl extends - EffectiveStatementBase { - - public PathEffectiveStatementImpl( - StmtContext ctx) { +public class PathEffectiveStatementImpl extends EffectiveStatementBase { + public PathEffectiveStatementImpl(final StmtContext ctx) { super(ctx); - } - } \ No newline at end of file diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/PositionEffectiveStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/PositionEffectiveStatementImpl.java index 4b132cc975..15638e03a9 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/PositionEffectiveStatementImpl.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/PositionEffectiveStatementImpl.java @@ -11,10 +11,7 @@ import org.opendaylight.yangtools.yang.model.api.stmt.PositionStatement; import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext; public class PositionEffectiveStatementImpl extends EffectiveStatementBase { - - public PositionEffectiveStatementImpl(StmtContext ctx) { + public PositionEffectiveStatementImpl(final StmtContext ctx) { super(ctx); - } - } \ No newline at end of file diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/PrefixEffectiveStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/PrefixEffectiveStatementImpl.java index 67f29fb0e9..294840f671 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/PrefixEffectiveStatementImpl.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/PrefixEffectiveStatementImpl.java @@ -8,14 +8,10 @@ package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective; import org.opendaylight.yangtools.yang.model.api.stmt.PrefixStatement; - import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext; public class PrefixEffectiveStatementImpl extends EffectiveStatementBase { - - public PrefixEffectiveStatementImpl( - StmtContext ctx) { + public PrefixEffectiveStatementImpl(final StmtContext ctx) { super(ctx); } - } diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/PresenceEffectiveStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/PresenceEffectiveStatementImpl.java index 0fce3312ab..9bed5d4f2e 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/PresenceEffectiveStatementImpl.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/PresenceEffectiveStatementImpl.java @@ -7,15 +7,11 @@ */ package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective; -import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext; - import org.opendaylight.yangtools.yang.model.api.stmt.PresenceStatement; +import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext; -public class PresenceEffectiveStatementImpl extends EffectiveStatementBase { - - public PresenceEffectiveStatementImpl( - StmtContext ctx) { +public class PresenceEffectiveStatementImpl extends EffectiveStatementBase { + public PresenceEffectiveStatementImpl(final StmtContext ctx) { super(ctx); } - } diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/ReferenceEffectiveStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/ReferenceEffectiveStatementImpl.java index 5e1708c192..b2d9171c49 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/ReferenceEffectiveStatementImpl.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/ReferenceEffectiveStatementImpl.java @@ -7,15 +7,11 @@ */ package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective; -import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext; - import org.opendaylight.yangtools.yang.model.api.stmt.ReferenceStatement; +import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext; public class ReferenceEffectiveStatementImpl extends EffectiveStatementBase { - - public ReferenceEffectiveStatementImpl( - StmtContext ctx) { + public ReferenceEffectiveStatementImpl(final StmtContext ctx) { super(ctx); } - } diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/RefineEffectiveStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/RefineEffectiveStatementImpl.java index 3099c8edcc..9752e4e215 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/RefineEffectiveStatementImpl.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/RefineEffectiveStatementImpl.java @@ -7,20 +7,19 @@ */ package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective; +import com.google.common.collect.ImmutableList; import java.util.Collection; import java.util.LinkedList; -import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement; - -import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.Utils; -import com.google.common.collect.ImmutableList; import java.util.List; import org.opendaylight.yangtools.yang.common.QName; +import org.opendaylight.yangtools.yang.model.api.SchemaNode; import org.opendaylight.yangtools.yang.model.api.SchemaPath; import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode; -import org.opendaylight.yangtools.yang.model.api.SchemaNode; +import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement; import org.opendaylight.yangtools.yang.model.api.stmt.RefineStatement; import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier; import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext; +import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.Utils; public class RefineEffectiveStatementImpl extends AbstractEffectiveDocumentedNode @@ -28,11 +27,11 @@ public class RefineEffectiveStatementImpl extends private final QName qname; private final SchemaPath path; - ImmutableList unknownNodes; + private List unknownNodes; private final SchemaNode refineTargetNode; public RefineEffectiveStatementImpl( - StmtContext ctx) { + final StmtContext ctx) { super(ctx); qname = ctx.getStatementArgument().getLastComponent(); @@ -40,7 +39,6 @@ public class RefineEffectiveStatementImpl extends refineTargetNode = (SchemaNode) ctx.getEffectOfStatement().iterator().next().buildEffective(); initSubstatementCollectionsAndFields(); - } public SchemaNode getRefineTargetNode() { diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/RequireInstanceEffectiveStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/RequireInstanceEffectiveStatementImpl.java index 1d66959415..f6883b18bf 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/RequireInstanceEffectiveStatementImpl.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/RequireInstanceEffectiveStatementImpl.java @@ -11,10 +11,7 @@ import org.opendaylight.yangtools.yang.model.api.stmt.RequireInstanceStatement; import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext; public class RequireInstanceEffectiveStatementImpl extends EffectiveStatementBase { - - public RequireInstanceEffectiveStatementImpl(StmtContext ctx) { + public RequireInstanceEffectiveStatementImpl(final StmtContext ctx) { super(ctx); - } - } \ No newline at end of file diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/RevisionDateEffectiveStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/RevisionDateEffectiveStatementImpl.java index 57714cfe6c..0b925b169c 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/RevisionDateEffectiveStatementImpl.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/RevisionDateEffectiveStatementImpl.java @@ -8,16 +8,11 @@ package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective; import java.util.Date; - import org.opendaylight.yangtools.yang.model.api.stmt.RevisionDateStatement; import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext; -public class RevisionDateEffectiveStatementImpl extends - EffectiveStatementBase { - - public RevisionDateEffectiveStatementImpl( - StmtContext ctx) { +public class RevisionDateEffectiveStatementImpl extends EffectiveStatementBase { + public RevisionDateEffectiveStatementImpl(final StmtContext ctx) { super(ctx); } - } diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/RevisionEffectiveStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/RevisionEffectiveStatementImpl.java index 1e75a8b783..4aff93ae0b 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/RevisionEffectiveStatementImpl.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/RevisionEffectiveStatementImpl.java @@ -11,14 +11,11 @@ import java.util.Date; import org.opendaylight.yangtools.yang.model.api.stmt.RevisionStatement; import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext; -public class RevisionEffectiveStatementImpl extends - EffectiveStatementBase { - +public class RevisionEffectiveStatementImpl extends EffectiveStatementBase { private final String reference; private final String description; - public RevisionEffectiveStatementImpl( - StmtContext ctx) { + public RevisionEffectiveStatementImpl(final StmtContext ctx) { super(ctx); DescriptionEffectiveStatementImpl descStmt = firstEffective(DescriptionEffectiveStatementImpl.class); @@ -43,5 +40,4 @@ public class RevisionEffectiveStatementImpl extends public final String getReference() { return reference; } - } \ No newline at end of file diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/RpcEffectiveStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/RpcEffectiveStatementImpl.java index 0eef258d30..65e336ca0a 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/RpcEffectiveStatementImpl.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/RpcEffectiveStatementImpl.java @@ -18,12 +18,12 @@ import java.util.Set; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode; import org.opendaylight.yangtools.yang.model.api.GroupingDefinition; -import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement; import org.opendaylight.yangtools.yang.model.api.RpcDefinition; import org.opendaylight.yangtools.yang.model.api.SchemaPath; -import org.opendaylight.yangtools.yang.model.api.stmt.RpcStatement; import org.opendaylight.yangtools.yang.model.api.TypeDefinition; import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode; +import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement; +import org.opendaylight.yangtools.yang.model.api.stmt.RpcStatement; import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext; import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.Utils; @@ -34,17 +34,16 @@ public class RpcEffectiveStatementImpl extends AbstractEffectiveDocumentedNode> typeDefinitions; - ImmutableSet groupings; - ImmutableList unknownNodes; + private Set> typeDefinitions; + private Set groupings; + private List unknownNodes; - public RpcEffectiveStatementImpl(StmtContext> ctx) { + public RpcEffectiveStatementImpl(final StmtContext> ctx) { super(ctx); this.qname = ctx.getStatementArgument(); this.path = Utils.getSchemaPath(ctx); initSubstatements(); - } private void initSubstatements() { @@ -144,21 +143,7 @@ public class RpcEffectiveStatementImpl extends AbstractEffectiveDocumentedNode { - - public StatusEffectiveStatementImpl( - StmtContext ctx) { +public class StatusEffectiveStatementImpl extends EffectiveStatementBase { + public StatusEffectiveStatementImpl(final StmtContext ctx) { super(ctx); - } - } \ No newline at end of file diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/SubmoduleEffectiveStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/SubmoduleEffectiveStatementImpl.java index faeb3d9544..b3af3c8c0b 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/SubmoduleEffectiveStatementImpl.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/SubmoduleEffectiveStatementImpl.java @@ -54,9 +54,7 @@ import org.opendaylight.yangtools.yang.parser.spi.source.IncludedSubmoduleNameTo import org.opendaylight.yangtools.yang.parser.spi.source.ModuleNameToModuleQName; import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.Utils; -public class SubmoduleEffectiveStatementImpl - extends - AbstractEffectiveDocumentedNode +public class SubmoduleEffectiveStatementImpl extends AbstractEffectiveDocumentedNode implements Module, Immutable { private final QNameModule qNameModule; @@ -91,34 +89,27 @@ public class SubmoduleEffectiveStatementImpl name = argument(); - String belongsToModuleName = firstAttributeOf( - ctx.declaredSubstatements(), BelongsToStatement.class); + String belongsToModuleName = firstAttributeOf(ctx.declaredSubstatements(), BelongsToStatement.class); final QNameModule belongsToModuleQName = ctx.getFromNamespace( ModuleNameToModuleQName.class, belongsToModuleName); RevisionEffectiveStatementImpl submoduleRevision = firstEffective(RevisionEffectiveStatementImpl.class); - qNameModule = submoduleRevision == null ? QNameModule.create( - belongsToModuleQName.getNamespace(), - SimpleDateFormatUtil.DEFAULT_DATE_REV) : QNameModule.create( - belongsToModuleQName.getNamespace(), - submoduleRevision.argument()); + qNameModule = submoduleRevision == null + ? QNameModule.create(belongsToModuleQName.getNamespace(), SimpleDateFormatUtil.DEFAULT_DATE_REV) + : QNameModule.create(belongsToModuleQName.getNamespace(), submoduleRevision.argument()); for (EffectiveStatement effectiveStatement : effectiveSubstatements()) { if (effectiveStatement instanceof PrefixEffectiveStatementImpl) { - prefix = ((PrefixEffectiveStatementImpl) effectiveStatement) - .argument(); + prefix = ((PrefixEffectiveStatementImpl) effectiveStatement).argument(); } if (effectiveStatement instanceof YangVersionEffectiveStatementImpl) { - yangVersion = ((YangVersionEffectiveStatementImpl) effectiveStatement) - .argument(); + yangVersion = ((YangVersionEffectiveStatementImpl) effectiveStatement).argument(); } if (effectiveStatement instanceof OrganizationEffectiveStatementImpl) { - organization = ((OrganizationEffectiveStatementImpl) effectiveStatement) - .argument(); + organization = ((OrganizationEffectiveStatementImpl) effectiveStatement).argument(); } if (effectiveStatement instanceof ContactEffectiveStatementImpl) { - contact = ((ContactEffectiveStatementImpl) effectiveStatement) - .argument(); + contact = ((ContactEffectiveStatementImpl) effectiveStatement).argument(); } } @@ -444,21 +435,13 @@ public class SubmoduleEffectiveStatementImpl return false; } SubmoduleEffectiveStatementImpl other = (SubmoduleEffectiveStatementImpl) obj; - if (name == null) { - if (other.name != null) { - return false; - } - } else if (!name.equals(other.name)) { + if (!Objects.equals(name, other.name)) { return false; } if (!qNameModule.equals(other.qNameModule)) { return false; } - if (yangVersion == null) { - if (other.yangVersion != null) { - return false; - } - } else if (!yangVersion.equals(other.yangVersion)) { + if (!Objects.equals(yangVersion, other.yangVersion)) { return false; } return true; diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/TypeDefEffectiveStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/TypeDefEffectiveStatementImpl.java index fe9e1389c7..4a806d6405 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/TypeDefEffectiveStatementImpl.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/TypeDefEffectiveStatementImpl.java @@ -7,16 +7,9 @@ */ package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective; -import org.opendaylight.yangtools.yang.model.api.stmt.TypeStatement; - -import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContextUtils; -import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.type.Decimal64SpecificationEffectiveStatementImpl; -import java.util.ArrayList; -import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.type.LengthEffectiveStatementImpl; -import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.type.PatternEffectiveStatementImpl; -import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.type.RangeEffectiveStatementImpl; import com.google.common.base.Optional; import com.google.common.collect.ImmutableList; +import java.util.ArrayList; import java.util.Collections; import java.util.List; import org.opendaylight.yangtools.yang.common.QName; @@ -25,6 +18,7 @@ import org.opendaylight.yangtools.yang.model.api.Status; import org.opendaylight.yangtools.yang.model.api.TypeDefinition; import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode; import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement; +import org.opendaylight.yangtools.yang.model.api.stmt.TypeStatement; import org.opendaylight.yangtools.yang.model.api.stmt.TypedefStatement; import org.opendaylight.yangtools.yang.model.api.type.LengthConstraint; import org.opendaylight.yangtools.yang.model.api.type.PatternConstraint; @@ -33,13 +27,17 @@ import org.opendaylight.yangtools.yang.model.util.ExtendedType; import org.opendaylight.yangtools.yang.model.util.ExtendedType.Builder; import org.opendaylight.yangtools.yang.parser.spi.TypeNamespace; import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext; +import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContextUtils; import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.TypeUtils; import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.Utils; +import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.type.Decimal64SpecificationEffectiveStatementImpl; +import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.type.LengthEffectiveStatementImpl; +import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.type.PatternEffectiveStatementImpl; +import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.type.RangeEffectiveStatementImpl; import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.type.TypeDefinitionEffectiveBuilder; -public class TypeDefEffectiveStatementImpl extends - EffectiveStatementBase implements - TypeDefinition>, TypeDefinitionEffectiveBuilder { +public class TypeDefEffectiveStatementImpl extends EffectiveStatementBase + implements TypeDefinition>, TypeDefinitionEffectiveBuilder { private final QName qName; private final SchemaPath path; @@ -61,8 +59,7 @@ public class TypeDefEffectiveStatementImpl extends private ExtendedType extendedType = null; - public TypeDefEffectiveStatementImpl( - StmtContext ctx) { + public TypeDefEffectiveStatementImpl(final StmtContext ctx) { super(ctx); qName = ctx.getStatementArgument(); @@ -109,8 +106,7 @@ public class TypeDefEffectiveStatementImpl extends } } - private TypeDefinition parseBaseTypeFromCtx( - final StmtContext ctx) { + private TypeDefinition parseBaseTypeFromCtx(final StmtContext ctx) { TypeDefinition baseType; @@ -135,58 +131,44 @@ public class TypeDefEffectiveStatementImpl extends } } else { StmtContext> baseTypeCtx = ctx - .getParentContext().getFromNamespace(TypeNamespace.class, - baseTypeQName); - baseType = (TypeDefEffectiveStatementImpl) baseTypeCtx - .buildEffective(); + .getParentContext().getFromNamespace(TypeNamespace.class, baseTypeQName); + baseType = (TypeDefEffectiveStatementImpl) baseTypeCtx.buildEffective(); } return baseType; } - protected Integer initFractionDigits( - EffectiveStatementBase typeEffectiveStmt) { + protected Integer initFractionDigits(final EffectiveStatementBase typeEffectiveStmt) { final FractionDigitsEffectiveStatementImpl fractionDigitsEffStmt = typeEffectiveStmt .firstEffective(FractionDigitsEffectiveStatementImpl.class); - return fractionDigitsEffStmt != null ? fractionDigitsEffStmt.argument() - : null; + return fractionDigitsEffStmt != null ? fractionDigitsEffStmt.argument() : null; } - protected List initRanges( - EffectiveStatementBase typeEffectiveStmt) { + protected List initRanges(final EffectiveStatementBase typeEffectiveStmt) { final RangeEffectiveStatementImpl rangeConstraints = typeEffectiveStmt .firstEffective(RangeEffectiveStatementImpl.class); - return rangeConstraints != null ? rangeConstraints.argument() - : Collections. emptyList(); + return rangeConstraints != null ? rangeConstraints.argument(): Collections. emptyList(); } - protected List initLengths( - EffectiveStatementBase typeEffectiveStmt) { + protected List initLengths(final EffectiveStatementBase typeEffectiveStmt) { final LengthEffectiveStatementImpl lengthConstraints = typeEffectiveStmt .firstEffective(LengthEffectiveStatementImpl.class); - return lengthConstraints != null ? lengthConstraints.argument() - : Collections. emptyList(); + return lengthConstraints != null ? lengthConstraints.argument(): Collections. emptyList(); } - protected List initPatterns( - EffectiveStatementBase typeEffectiveStmt) { + protected List initPatterns(final EffectiveStatementBase typeEffectiveStmt) { final List patternConstraints = new ArrayList<>(); - for (final EffectiveStatement effectiveStatement : typeEffectiveStmt - .effectiveSubstatements()) { + for (final EffectiveStatement effectiveStatement : typeEffectiveStmt.effectiveSubstatements()) { if (effectiveStatement instanceof PatternEffectiveStatementImpl) { - final PatternConstraint pattern = ((PatternEffectiveStatementImpl) effectiveStatement) - .argument(); - + final PatternConstraint pattern = ((PatternEffectiveStatementImpl) effectiveStatement).argument(); if (pattern != null) { patternConstraints.add(pattern); } } } - return !patternConstraints.isEmpty() ? ImmutableList - .copyOf(patternConstraints) : Collections - . emptyList(); + return ImmutableList.copyOf(patternConstraints); } @Override diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/UnitsEffectiveStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/UnitsEffectiveStatementImpl.java index 7ab0ac0971..4ac90946e3 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/UnitsEffectiveStatementImpl.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/UnitsEffectiveStatementImpl.java @@ -10,12 +10,8 @@ package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective; import org.opendaylight.yangtools.yang.model.api.stmt.UnitsStatement; import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext; -public class UnitsEffectiveStatementImpl extends - EffectiveStatementBase { - - public UnitsEffectiveStatementImpl( - StmtContext ctx) { +public class UnitsEffectiveStatementImpl extends EffectiveStatementBase { + public UnitsEffectiveStatementImpl(final StmtContext ctx) { super(ctx); } - } diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/UnknownEffectiveStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/UnknownEffectiveStatementImpl.java index 7822169ab0..2027a1b9cc 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/UnknownEffectiveStatementImpl.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/UnknownEffectiveStatementImpl.java @@ -36,10 +36,10 @@ public class UnknownEffectiveStatementImpl extends EffectiveStatementBase unknownNodes = new ArrayList<>(); private QName nodeType; - private String nodeParameter; + private final String nodeParameter; public UnknownEffectiveStatementImpl(final StmtContext, ?> ctx) { super(ctx); @@ -169,32 +169,16 @@ public class UnknownEffectiveStatementImpl extends EffectiveStatementBase implements UsesNode { private SchemaPath groupingPath; private boolean addedByUses; - ImmutableMap refines; - ImmutableSet augmentations; - ImmutableList unknownNodes; + private ImmutableMap refines; + private ImmutableSet augmentations; + private ImmutableList unknownNodes; - public UsesEffectiveStatementImpl(StmtContext> ctx) { + public UsesEffectiveStatementImpl(final StmtContext> ctx) { super(ctx); initGroupingPath(ctx); @@ -48,7 +48,7 @@ public class UsesEffectiveStatementImpl extends EffectiveStatementBase> ctx) { + private void initGroupingPath(final StmtContext> ctx) { StmtContext> grpCtx = ctx.getFromNamespace( GroupingNamespace.class, ctx.getStatementArgument()); this.groupingPath = Utils.getSchemaPath(grpCtx); @@ -83,7 +83,7 @@ public class UsesEffectiveStatementImpl extends EffectiveStatementBase> ctx) { + final StmtContext> ctx) { List copyTypesFromOriginal = ctx.getCopyHistory(); if(copyTypesFromOriginal.contains(TypeOfCopy.ADDED_BY_USES)) { @@ -145,21 +145,7 @@ public class UsesEffectiveStatementImpl extends EffectiveStatementBase { - - public ValueEffectiveStatementImpl(StmtContext ctx) { + public ValueEffectiveStatementImpl(final StmtContext ctx) { super(ctx); } } \ No newline at end of file diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/WhenEffectiveStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/WhenEffectiveStatementImpl.java index 45a1142ce1..76f9b692ea 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/WhenEffectiveStatementImpl.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/WhenEffectiveStatementImpl.java @@ -11,13 +11,8 @@ import org.opendaylight.yangtools.yang.model.api.RevisionAwareXPath; import org.opendaylight.yangtools.yang.model.api.stmt.WhenStatement; import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext; -public class WhenEffectiveStatementImpl extends - EffectiveStatementBase { - - public WhenEffectiveStatementImpl( - StmtContext ctx) { +public class WhenEffectiveStatementImpl extends EffectiveStatementBase { + public WhenEffectiveStatementImpl(final StmtContext ctx) { super(ctx); - } - } \ No newline at end of file diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/YangVersionEffectiveStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/YangVersionEffectiveStatementImpl.java index 32479687a1..34e38b4ea4 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/YangVersionEffectiveStatementImpl.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/YangVersionEffectiveStatementImpl.java @@ -10,13 +10,8 @@ package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective; import org.opendaylight.yangtools.yang.model.api.stmt.YangVersionStatement; import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext; -public class YangVersionEffectiveStatementImpl extends - EffectiveStatementBase { - - public YangVersionEffectiveStatementImpl( - StmtContext ctx) { +public class YangVersionEffectiveStatementImpl extends EffectiveStatementBase { + public YangVersionEffectiveStatementImpl(final StmtContext ctx) { super(ctx); - } - } \ No newline at end of file diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/YinElementEffectiveStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/YinElementEffectiveStatementImpl.java index 600b0c5998..f2d640c3db 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/YinElementEffectiveStatementImpl.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/YinElementEffectiveStatementImpl.java @@ -10,12 +10,8 @@ package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective; import org.opendaylight.yangtools.yang.model.api.stmt.YinElementStatement; import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext; -public class YinElementEffectiveStatementImpl extends - EffectiveStatementBase { - - public YinElementEffectiveStatementImpl( - StmtContext ctx) { +public class YinElementEffectiveStatementImpl extends EffectiveStatementBase { + public YinElementEffectiveStatementImpl(final StmtContext ctx) { super(ctx); } - } diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/BinaryEffectiveStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/BinaryEffectiveStatementImpl.java index e20dd839c5..7382a411a9 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/BinaryEffectiveStatementImpl.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/BinaryEffectiveStatementImpl.java @@ -23,9 +23,8 @@ import org.opendaylight.yangtools.yang.model.api.type.LengthConstraint; import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext; import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.EffectiveStatementBase; -public class BinaryEffectiveStatementImpl extends - EffectiveStatementBase implements - BinaryTypeDefinition { +public class BinaryEffectiveStatementImpl extends EffectiveStatementBase + implements BinaryTypeDefinition { private static final String DESCRIPTION = "The binary built-in type represents any binary data, i.e., a sequence of octets."; private static final String REFERENCE = "https://tools.ietf.org/html/rfc6020#section-9.8"; @@ -41,8 +40,8 @@ public class BinaryEffectiveStatementImpl extends final StmtContext> ctx) { super(ctx); - final LengthConstraint lengthConstraint = new LengthConstraintEffectiveImpl( - 0, Long.MAX_VALUE, OPTIONAL_EMPTY, OPTIONAL_EMPTY); + final LengthConstraint lengthConstraint = + new LengthConstraintEffectiveImpl(0, Long.MAX_VALUE, OPTIONAL_EMPTY, OPTIONAL_EMPTY); lengthConstraints = Collections.singletonList(lengthConstraint); } diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/BitEffectiveStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/BitEffectiveStatementImpl.java index fec0ef919e..a471895f92 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/BitEffectiveStatementImpl.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/BitEffectiveStatementImpl.java @@ -12,19 +12,19 @@ import java.util.ArrayList; import java.util.List; import java.util.Objects; import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement; import org.opendaylight.yangtools.yang.model.api.SchemaPath; import org.opendaylight.yangtools.yang.model.api.Status; +import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode; +import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement; import org.opendaylight.yangtools.yang.model.api.stmt.BitStatement; import org.opendaylight.yangtools.yang.model.api.type.BitsTypeDefinition; -import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode; import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext; +import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.Utils; import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.DescriptionEffectiveStatementImpl; import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.EffectiveStatementBase; import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.PositionEffectiveStatementImpl; import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.ReferenceEffectiveStatementImpl; import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.StatusEffectiveStatementImpl; -import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.Utils; public class BitEffectiveStatementImpl extends EffectiveStatementBase implements BitsTypeDefinition.Bit { @@ -35,9 +35,9 @@ public class BitEffectiveStatementImpl extends EffectiveStatementBase unknownSchemaNodes; + private final List unknownSchemaNodes; - public BitEffectiveStatementImpl(StmtContext ctx) { + public BitEffectiveStatementImpl(final StmtContext ctx) { super(ctx); List unknownSchemaNodesInit = new ArrayList<>(); @@ -130,21 +130,7 @@ public class BitEffectiveStatementImpl extends EffectiveStatementBase implements BitsTypeDefinition, TypeDefinitionEffectiveBuilder { @@ -39,7 +39,7 @@ public class BitsSpecificationEffectiveStatementImpl extends private final SchemaPath path; private final List bits; - public BitsSpecificationEffectiveStatementImpl(StmtContext> ctx) { + public BitsSpecificationEffectiveStatementImpl(final StmtContext> ctx) { super(ctx); List bitsInit = new ArrayList<>(); @@ -127,21 +127,7 @@ public class BitsSpecificationEffectiveStatementImpl extends return false; } BitsSpecificationEffectiveStatementImpl other = (BitsSpecificationEffectiveStatementImpl) obj; - if (bits == null) { - if (other.bits != null) { - return false; - } - } else if (!bits.equals(other.bits)) { - return false; - } - if (path == null) { - if (other.path != null) { - return false; - } - } else if (!path.equals(other.path)) { - return false; - } - return true; + return Objects.equals(bits, other.bits) && Objects.equals(path, other.path); } @Override diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/BooleanEffectiveStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/BooleanEffectiveStatementImpl.java index bf55043c73..ddf52a5e08 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/BooleanEffectiveStatementImpl.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/BooleanEffectiveStatementImpl.java @@ -8,9 +8,6 @@ package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.type; -import org.opendaylight.yangtools.yang.model.api.stmt.TypeStatement; - -import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.EffectiveStatementBase; import java.util.Collections; import java.util.List; import org.opendaylight.yangtools.yang.common.QName; @@ -19,27 +16,26 @@ import org.opendaylight.yangtools.yang.model.api.SchemaPath; import org.opendaylight.yangtools.yang.model.api.Status; import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode; import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement; +import org.opendaylight.yangtools.yang.model.api.stmt.TypeStatement; import org.opendaylight.yangtools.yang.model.api.type.BooleanTypeDefinition; import org.opendaylight.yangtools.yang.model.util.BaseTypes; import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext; import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.TypeUtils; +import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.EffectiveStatementBase; -public class BooleanEffectiveStatementImpl - extends EffectiveStatementBase implements - BooleanTypeDefinition { +public class BooleanEffectiveStatementImpl extends EffectiveStatementBase + implements BooleanTypeDefinition { public static final String LOCAL_NAME = TypeUtils.BOOLEAN; - private static final QName QNAME = QName.create( - YangConstants.RFC6020_YANG_MODULE, LOCAL_NAME); + private static final QName QNAME = QName.create(YangConstants.RFC6020_YANG_MODULE, LOCAL_NAME); private static final SchemaPath PATH = SchemaPath.create(true, QNAME); private static final String DESCRIPTION = "The boolean built-in type represents a boolean value."; private static final String REFERENCE = "https://tools.ietf.org/html/rfc6020#section-9.5"; private static final String UNITS = ""; public BooleanEffectiveStatementImpl( - StmtContext> ctx) { + final StmtContext> ctx) { super(ctx); - } @Override diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/Decimal64SpecificationEffectiveStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/Decimal64SpecificationEffectiveStatementImpl.java index 5a879baf58..18fb22ced1 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/Decimal64SpecificationEffectiveStatementImpl.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/Decimal64SpecificationEffectiveStatementImpl.java @@ -69,6 +69,7 @@ public class Decimal64SpecificationEffectiveStatementImpl extends private ExtendedType extendedType; private final boolean isExtended; + private Decimal64 decimal64Instance = null; public Decimal64SpecificationEffectiveStatementImpl( final StmtContext> ctx) { @@ -205,28 +206,17 @@ public class Decimal64SpecificationEffectiveStatementImpl extends return false; } Decimal64SpecificationEffectiveStatementImpl other = (Decimal64SpecificationEffectiveStatementImpl) obj; - if (path == null) { - if (other.path != null) { - return false; - } - } else if (!path.equals(other.path)) { - return false; - } - return true; + return Objects.equals(path, other.path); } @Override public String toString() { return Decimal64SpecificationEffectiveStatementImpl.class .getSimpleName() - + "[qName=" - + QNAME - + ", fractionDigits=" - + fractionDigits + "]"; + + "[qName=" + QNAME + + ", fractionDigits=" + fractionDigits + "]"; } - private Decimal64 decimal64Instance = null; - @Override public TypeDefinition buildType() { @@ -234,7 +224,7 @@ public class Decimal64SpecificationEffectiveStatementImpl extends decimal64Instance = Decimal64.create(path, fractionDigits); } - if(!isExtended) { + if (!isExtended) { return decimal64Instance; } @@ -242,8 +232,8 @@ public class Decimal64SpecificationEffectiveStatementImpl extends return extendedType; } - Builder extendedTypeBuilder = ExtendedType.builder(path.getLastComponent(), decimal64Instance, Optional.absent(), - Optional.absent(), path); + Builder extendedTypeBuilder = ExtendedType.builder(path.getLastComponent(), decimal64Instance, + Optional.absent(), Optional.absent(), path); extendedTypeBuilder.fractionDigits(fractionDigits); extendedTypeBuilder.ranges(rangeConstraints); diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/EmptyEffectiveStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/EmptyEffectiveStatementImpl.java index e586780051..0c8d5c8288 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/EmptyEffectiveStatementImpl.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/EmptyEffectiveStatementImpl.java @@ -8,9 +8,6 @@ package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.type; -import org.opendaylight.yangtools.yang.model.api.stmt.TypeStatement; -import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.EffectiveStatementBase; - import java.util.Collections; import java.util.List; import org.opendaylight.yangtools.yang.common.QName; @@ -19,25 +16,24 @@ import org.opendaylight.yangtools.yang.model.api.SchemaPath; import org.opendaylight.yangtools.yang.model.api.Status; import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode; import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement; +import org.opendaylight.yangtools.yang.model.api.stmt.TypeStatement; import org.opendaylight.yangtools.yang.model.api.type.EmptyTypeDefinition; import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext; import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.TypeUtils; +import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.EffectiveStatementBase; -public class EmptyEffectiveStatementImpl extends - EffectiveStatementBase implements - EmptyTypeDefinition { +public class EmptyEffectiveStatementImpl extends EffectiveStatementBase + implements EmptyTypeDefinition { public static final String LOCAL_NAME = TypeUtils.EMPTY; - private static final QName QNAME = QName.create( - YangConstants.RFC6020_YANG_MODULE, LOCAL_NAME); + private static final QName QNAME = QName.create(YangConstants.RFC6020_YANG_MODULE, LOCAL_NAME); private static final SchemaPath PATH = SchemaPath.create(true, QNAME); private static final String DESCRIPTION = "The empty built-in type represents a leaf that does not have any value, it conveys information by its presence or absence."; private static final String REFERENCE = "https://tools.ietf.org/html/rfc6020#page-131"; public EmptyEffectiveStatementImpl( - StmtContext> ctx) { + final StmtContext> ctx) { super(ctx); - } @Override diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/EnumEffectiveStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/EnumEffectiveStatementImpl.java index 478004f25e..a3d5feddbc 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/EnumEffectiveStatementImpl.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/EnumEffectiveStatementImpl.java @@ -9,14 +9,13 @@ package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.type; import java.util.Collections; import java.util.List; - import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.model.api.SchemaPath; import org.opendaylight.yangtools.yang.model.api.Status; import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode; import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement; import org.opendaylight.yangtools.yang.model.api.stmt.EnumStatement; -import org.opendaylight.yangtools.yang.model.api.type.EnumTypeDefinition; +import org.opendaylight.yangtools.yang.model.api.type.EnumTypeDefinition.EnumPair; import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext; import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.Utils; import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.DescriptionEffectiveStatementImpl; @@ -25,17 +24,15 @@ import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.ReferenceEf import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.StatusEffectiveStatementImpl; import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.ValueEffectiveStatementImpl; -public class EnumEffectiveStatementImpl extends EffectiveStatementBase implements - EnumTypeDefinition.EnumPair { - - private QName qName; - private SchemaPath path; +public class EnumEffectiveStatementImpl extends EffectiveStatementBase implements EnumPair { + private final QName qName; + private final SchemaPath path; private String description; private String reference; private Status status; private Integer value; - public EnumEffectiveStatementImpl(StmtContext ctx) { + public EnumEffectiveStatementImpl(final StmtContext ctx) { super(ctx); qName = ctx.getStatementArgument(); diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/EnumSpecificationEffectiveStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/EnumSpecificationEffectiveStatementImpl.java index fca2532227..a9dfd93e16 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/EnumSpecificationEffectiveStatementImpl.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/EnumSpecificationEffectiveStatementImpl.java @@ -132,25 +132,13 @@ public class EnumSpecificationEffectiveStatementImpl extends return false; } EnumSpecificationEffectiveStatementImpl other = (EnumSpecificationEffectiveStatementImpl) obj; - if (defaultEnum == null) { - if (other.defaultEnum != null) { - return false; - } - } else if (!defaultEnum.equals(other.defaultEnum)) { + if (!Objects.equals(defaultEnum, other.defaultEnum)) { return false; } - if (enums == null) { - if (other.enums != null) { - return false; - } - } else if (!enums.equals(other.enums)) { + if (!Objects.equals(enums, other.enums)) { return false; } - if (path == null) { - if (other.path != null) { - return false; - } - } else if (!path.equals(other.path)) { + if (!Objects.equals(path, other.path)) { return false; } return true; @@ -181,7 +169,7 @@ public class EnumSpecificationEffectiveStatementImpl extends @Override public TypeDefinition buildType() { - if(enumerationTypeInstance !=null) { + if (enumerationTypeInstance !=null) { return enumerationTypeInstance; } diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/Int16EffectiveStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/Int16EffectiveStatementImpl.java index 124112de8c..08bfea3cd7 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/Int16EffectiveStatementImpl.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/Int16EffectiveStatementImpl.java @@ -30,6 +30,6 @@ public class Int16EffectiveStatementImpl extends IntegerEffectiveImplBase { @Override public String toString() { - return "type " + qName; + return "type " + getQName(); } } diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/Int32EffectiveStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/Int32EffectiveStatementImpl.java index 4d2e445479..2bdc778530 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/Int32EffectiveStatementImpl.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/Int32EffectiveStatementImpl.java @@ -30,6 +30,6 @@ public class Int32EffectiveStatementImpl extends IntegerEffectiveImplBase { @Override public String toString() { - return "type " + qName; + return "type " + getQName(); } } diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/Int64EffectiveStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/Int64EffectiveStatementImpl.java index e3a365e317..5b94bcb032 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/Int64EffectiveStatementImpl.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/Int64EffectiveStatementImpl.java @@ -30,6 +30,6 @@ public class Int64EffectiveStatementImpl extends IntegerEffectiveImplBase { @Override public String toString() { - return "type " + qName; + return "type " + getQName(); } } diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/Int8EffectiveStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/Int8EffectiveStatementImpl.java index 9f90fa111b..e3d3f620b8 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/Int8EffectiveStatementImpl.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/Int8EffectiveStatementImpl.java @@ -30,6 +30,6 @@ public class Int8EffectiveStatementImpl extends IntegerEffectiveImplBase { @Override public String toString() { - return "type " + qName; + return "type " + getQName(); } } diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/IntegerEffectiveImplBase.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/IntegerEffectiveImplBase.java index 885b7a14d3..c1c6a07301 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/IntegerEffectiveImplBase.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/IntegerEffectiveImplBase.java @@ -8,34 +8,33 @@ package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.type; -import org.opendaylight.yangtools.yang.model.api.stmt.TypeStatement; - import com.google.common.base.Optional; import java.util.Collections; import java.util.List; import java.util.Objects; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.common.YangConstants; -import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement; import org.opendaylight.yangtools.yang.model.api.SchemaPath; import org.opendaylight.yangtools.yang.model.api.Status; +import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode; +import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement; +import org.opendaylight.yangtools.yang.model.api.stmt.TypeStatement; import org.opendaylight.yangtools.yang.model.api.type.IntegerTypeDefinition; import org.opendaylight.yangtools.yang.model.api.type.RangeConstraint; -import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode; import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext; -import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.EffectiveStatementBase; import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.Utils; +import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.EffectiveStatementBase; abstract class IntegerEffectiveImplBase extends EffectiveStatementBase implements IntegerTypeDefinition { private static final String REFERENCE_INT = "https://tools.ietf.org/html/rfc6020#section-9.2"; - protected QName qName; - private SchemaPath path; - private String units = ""; + private final QName qName; + private final SchemaPath path; + private final String units = ""; private final String description; - private List rangeStatements; + private final List rangeStatements; protected IntegerEffectiveImplBase(final StmtContext> ctx, final String localName, final Number minRange, final Number maxRange, final String description) { @@ -127,39 +126,19 @@ abstract class IntegerEffectiveImplBase extends return false; } IntegerEffectiveImplBase other = (IntegerEffectiveImplBase) obj; - if (description == null) { - if (other.description != null) { - return false; - } - } else if (!description.equals(other.description)) { + if (!Objects.equals(description, other.description)) { return false; } - if (qName == null) { - if (other.qName != null) { - return false; - } - } else if (!qName.equals(other.qName)) { + if (!Objects.equals(qName, other.qName)) { return false; } - if (path == null) { - if (other.path != null) { - return false; - } - } else if (!path.equals(other.path)) { + if (!Objects.equals(path, other.path)) { return false; } - if (rangeStatements == null) { - if (other.rangeStatements != null) { - return false; - } - } else if (!rangeStatements.equals(other.rangeStatements)) { + if (!Objects.equals(rangeStatements, other.rangeStatements)) { return false; } - if (units == null) { - if (other.units != null) { - return false; - } - } else if (!units.equals(other.units)) { + if (!Objects.equals(units, other.units)) { return false; } return true; diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/LeafrefSpecificationEffectiveStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/LeafrefSpecificationEffectiveStatementImpl.java index 24bdf82414..6b9d11e286 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/LeafrefSpecificationEffectiveStatementImpl.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/LeafrefSpecificationEffectiveStatementImpl.java @@ -12,18 +12,18 @@ import java.util.List; import java.util.Objects; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.common.YangConstants; -import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement; import org.opendaylight.yangtools.yang.model.api.RevisionAwareXPath; import org.opendaylight.yangtools.yang.model.api.SchemaPath; import org.opendaylight.yangtools.yang.model.api.Status; +import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode; +import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement; import org.opendaylight.yangtools.yang.model.api.stmt.TypeStatement; import org.opendaylight.yangtools.yang.model.api.type.LeafrefTypeDefinition; -import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode; import org.opendaylight.yangtools.yang.model.util.Leafref; import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext; +import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.Utils; import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.EffectiveStatementBase; import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.PathEffectiveStatementImpl; -import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.Utils; public class LeafrefSpecificationEffectiveStatementImpl extends EffectiveStatementBase implements LeafrefTypeDefinition, TypeDefinitionEffectiveBuilder { @@ -35,10 +35,11 @@ public class LeafrefSpecificationEffectiveStatementImpl extends private static final String REFERENCE = "https://tools.ietf.org/html/rfc6020#section-9.9"; private static final String UNITS = ""; - private RevisionAwareXPath xpath; private final SchemaPath path; + private RevisionAwareXPath xpath; + private Leafref leafrefInstance = null; - public LeafrefSpecificationEffectiveStatementImpl(StmtContext> ctx) { + public LeafrefSpecificationEffectiveStatementImpl(final StmtContext> ctx) { super(ctx); path = Utils.getSchemaPath(ctx.getParentContext()).createChild(QNAME); @@ -120,14 +121,7 @@ public class LeafrefSpecificationEffectiveStatementImpl extends return false; } LeafrefSpecificationEffectiveStatementImpl other = (LeafrefSpecificationEffectiveStatementImpl) obj; - if (xpath == null) { - if (other.xpath != null) { - return false; - } - } else if (!xpath.equals(other.xpath)) { - return false; - } - return true; + return Objects.equals(xpath, other.xpath); } @Override @@ -141,8 +135,6 @@ public class LeafrefSpecificationEffectiveStatementImpl extends return builder.toString(); } - private Leafref leafrefInstance = null; - @Override public Leafref buildType() { diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/LengthConstraintEffectiveImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/LengthConstraintEffectiveImpl.java index 2912bddcf2..32ca55e446 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/LengthConstraintEffectiveImpl.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/LengthConstraintEffectiveImpl.java @@ -92,25 +92,13 @@ public class LengthConstraintEffectiveImpl implements LengthConstraint { return false; } final LengthConstraintEffectiveImpl other = (LengthConstraintEffectiveImpl) obj; - if (description == null) { - if (other.description != null) { - return false; - } - } else if (!description.equals(other.description)) { + if (!Objects.equals(description, other.description)) { return false; } - if (errorAppTag == null) { - if (other.errorAppTag != null) { - return false; - } - } else if (!errorAppTag.equals(other.errorAppTag)) { + if (!Objects.equals(errorAppTag, other.errorAppTag)) { return false; } - if (errorMessage == null) { - if (other.errorMessage != null) { - return false; - } - } else if (!errorMessage.equals(other.errorMessage)) { + if (!Objects.equals(errorMessage, other.errorMessage)) { return false; } if (!Objects.equals(max, other.max)) { @@ -119,11 +107,7 @@ public class LengthConstraintEffectiveImpl implements LengthConstraint { if (!Objects.equals(min, other.min)) { return false; } - if (reference == null) { - if (other.reference != null) { - return false; - } - } else if (!reference.equals(other.reference)) { + if (!Objects.equals(reference, other.reference)) { return false; } return true; diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/LengthEffectiveStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/LengthEffectiveStatementImpl.java index e26d69600b..e876ac3363 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/LengthEffectiveStatementImpl.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/LengthEffectiveStatementImpl.java @@ -8,17 +8,13 @@ package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.type; import java.util.List; - import org.opendaylight.yangtools.yang.model.api.stmt.LengthStatement; import org.opendaylight.yangtools.yang.model.api.type.LengthConstraint; import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext; import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.EffectiveStatementBase; public class LengthEffectiveStatementImpl extends EffectiveStatementBase, LengthStatement> { - - public LengthEffectiveStatementImpl(StmtContext, LengthStatement, ?> ctx) { + public LengthEffectiveStatementImpl(final StmtContext, LengthStatement, ?> ctx) { super(ctx); - } - } \ No newline at end of file diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/PatternConstraintEffectiveImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/PatternConstraintEffectiveImpl.java index 1b8bbc9126..184ebc401b 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/PatternConstraintEffectiveImpl.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/PatternConstraintEffectiveImpl.java @@ -83,39 +83,19 @@ public class PatternConstraintEffectiveImpl implements PatternConstraint { return false; } final PatternConstraintEffectiveImpl other = (PatternConstraintEffectiveImpl) obj; - if (description == null) { - if (other.description != null) { - return false; - } - } else if (!description.equals(other.description)) { + if (!Objects.equals(description, other.description)) { return false; } - if (errorAppTag == null) { - if (other.errorAppTag != null) { - return false; - } - } else if (!errorAppTag.equals(other.errorAppTag)) { + if (!Objects.equals(errorAppTag, other.errorAppTag)) { return false; } - if (errorMessage == null) { - if (other.errorMessage != null) { - return false; - } - } else if (!errorMessage.equals(other.errorMessage)) { + if (!Objects.equals(errorMessage, other.errorMessage)) { return false; } - if (reference == null) { - if (other.reference != null) { - return false; - } - } else if (!reference.equals(other.reference)) { + if (!Objects.equals(reference, other.reference)) { return false; } - if (regEx == null) { - if (other.regEx != null) { - return false; - } - } else if (!regEx.equals(other.regEx)) { + if (!Objects.equals(regEx, other.regEx)) { return false; } return true; diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/PatternEffectiveStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/PatternEffectiveStatementImpl.java index 81f7d2a4d3..c58c185218 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/PatternEffectiveStatementImpl.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/PatternEffectiveStatementImpl.java @@ -13,9 +13,7 @@ import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext; import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.EffectiveStatementBase; public class PatternEffectiveStatementImpl extends EffectiveStatementBase { - - public PatternEffectiveStatementImpl(StmtContext ctx) { + public PatternEffectiveStatementImpl(final StmtContext ctx) { super(ctx); - } } \ No newline at end of file diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/RangeConstraintEffectiveImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/RangeConstraintEffectiveImpl.java index c2c98686b4..4308ecb07b 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/RangeConstraintEffectiveImpl.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/RangeConstraintEffectiveImpl.java @@ -93,32 +93,16 @@ public class RangeConstraintEffectiveImpl implements RangeConstraint { return false; } final RangeConstraintEffectiveImpl other = (RangeConstraintEffectiveImpl) obj; - if (description == null) { - if (other.description != null) { - return false; - } - } else if (!description.equals(other.description)) { + if (!Objects.equals(description, other.description)) { return false; } - if (max == null) { - if (other.max != null) { - return false; - } - } else if (!max.equals(other.max)) { + if (!Objects.equals(max, other.max)) { return false; } - if (min == null) { - if (other.min != null) { - return false; - } - } else if (!min.equals(other.min)) { + if (!Objects.equals(min, other.min)) { return false; } - if (reference == null) { - if (other.reference != null) { - return false; - } - } else if (!reference.equals(other.reference)) { + if (!Objects.equals(reference, other.reference)) { return false; } return true; diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/RangeEffectiveStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/RangeEffectiveStatementImpl.java index 0c88187c41..4e97546667 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/RangeEffectiveStatementImpl.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/RangeEffectiveStatementImpl.java @@ -8,15 +8,13 @@ package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.type; import java.util.List; - import org.opendaylight.yangtools.yang.model.api.stmt.RangeStatement; import org.opendaylight.yangtools.yang.model.api.type.RangeConstraint; import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext; import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.EffectiveStatementBase; public class RangeEffectiveStatementImpl extends EffectiveStatementBase, RangeStatement> { - - public RangeEffectiveStatementImpl(StmtContext, RangeStatement, ?> ctx) { + public RangeEffectiveStatementImpl(final StmtContext, RangeStatement, ?> ctx) { super(ctx); } } diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/StringEffectiveStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/StringEffectiveStatementImpl.java index 6a7207a6a6..06edda620f 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/StringEffectiveStatementImpl.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/StringEffectiveStatementImpl.java @@ -132,18 +132,10 @@ public class StringEffectiveStatementImpl extends EffectiveStatementBase { - - public StringRestrictionsEffectiveStatementImpl(StmtContext ctx) { +public class StringRestrictionsEffectiveStatementImpl extends EffectiveStatementBase { + public StringRestrictionsEffectiveStatementImpl(final StmtContext ctx) { super(ctx); } } diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/UInt16EffectiveStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/UInt16EffectiveStatementImpl.java index c411d4b2df..ba3cd16bc7 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/UInt16EffectiveStatementImpl.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/UInt16EffectiveStatementImpl.java @@ -29,6 +29,6 @@ public class UInt16EffectiveStatementImpl extends UnsignedIntegerEffectiveImplBa @Override public String toString() { - return "type " + qName; + return "type " + getQName(); } } diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/UInt32EffectiveStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/UInt32EffectiveStatementImpl.java index 2e051fc17d..ef1c69b078 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/UInt32EffectiveStatementImpl.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/UInt32EffectiveStatementImpl.java @@ -29,6 +29,6 @@ public class UInt32EffectiveStatementImpl extends UnsignedIntegerEffectiveImplBa @Override public String toString() { - return "type " + qName; + return "type " + getQName(); } } diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/UInt64EffectiveStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/UInt64EffectiveStatementImpl.java index 3f18f8bc48..4a07e45ba8 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/UInt64EffectiveStatementImpl.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/UInt64EffectiveStatementImpl.java @@ -9,7 +9,6 @@ package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.type; import java.math.BigInteger; - import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement; import org.opendaylight.yangtools.yang.model.api.stmt.TypeStatement; import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext; @@ -31,6 +30,6 @@ public class UInt64EffectiveStatementImpl extends UnsignedIntegerEffectiveImplBa @Override public String toString() { - return "type " + qName; + return "type " + getQName(); } } diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/UInt8EffectiveStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/UInt8EffectiveStatementImpl.java index 04f5d3c3c9..53197fbb4b 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/UInt8EffectiveStatementImpl.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/UInt8EffectiveStatementImpl.java @@ -29,6 +29,6 @@ public class UInt8EffectiveStatementImpl extends UnsignedIntegerEffectiveImplBas @Override public String toString() { - return "type " + qName; + return "type " + getQName(); } } diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/UnsignedIntegerEffectiveImplBase.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/UnsignedIntegerEffectiveImplBase.java index e00fbbdadd..12b9b35bdb 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/UnsignedIntegerEffectiveImplBase.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/type/UnsignedIntegerEffectiveImplBase.java @@ -14,16 +14,16 @@ import java.util.List; import java.util.Objects; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.common.YangConstants; -import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement; import org.opendaylight.yangtools.yang.model.api.SchemaPath; import org.opendaylight.yangtools.yang.model.api.Status; +import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode; +import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement; import org.opendaylight.yangtools.yang.model.api.stmt.TypeStatement; import org.opendaylight.yangtools.yang.model.api.type.RangeConstraint; import org.opendaylight.yangtools.yang.model.api.type.UnsignedIntegerTypeDefinition; -import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode; import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext; -import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.EffectiveStatementBase; import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.Utils; +import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.EffectiveStatementBase; abstract class UnsignedIntegerEffectiveImplBase extends EffectiveStatementBase implements UnsignedIntegerTypeDefinition { @@ -31,11 +31,11 @@ abstract class UnsignedIntegerEffectiveImplBase extends private static final String REFERENCE_INT = "https://tools.ietf.org/html/rfc6020#section-9.2"; protected static final Number MIN_RANGE = 0; - protected QName qName; - private SchemaPath path; - private String units = ""; + private final QName qName; + private final SchemaPath path; + private final String units = ""; private final String description; - private List rangeStatements; + private final List rangeStatements; protected UnsignedIntegerEffectiveImplBase(final StmtContext> ctx, final String localName, final Number maxRange, final String description) { @@ -127,39 +127,19 @@ abstract class UnsignedIntegerEffectiveImplBase extends return false; } UnsignedIntegerEffectiveImplBase other = (UnsignedIntegerEffectiveImplBase) obj; - if (description == null) { - if (other.description != null) { - return false; - } - } else if (!description.equals(other.description)) { + if (!Objects.equals(description, other.description)) { return false; } - if (qName == null) { - if (other.qName != null) { - return false; - } - } else if (!qName.equals(other.qName)) { + if (!Objects.equals(qName, other.qName)) { return false; } - if (path == null) { - if (other.path != null) { - return false; - } - } else if (!path.equals(other.path)) { + if (!Objects.equals(path, other.path)) { return false; } - if (rangeStatements == null) { - if (other.rangeStatements != null) { - return false; - } - } else if (!rangeStatements.equals(other.rangeStatements)) { + if (!Objects.equals(rangeStatements, other.rangeStatements)) { return false; } - if (units == null) { - if (other.units != null) { - return false; - } - } else if (!units.equals(other.units)) { + if (!Objects.equals(units, other.units)) { return false; } return true;