X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=yang%2Fyang-parser-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fyangtools%2Fyang%2Fparser%2Fstmt%2Frfc6020%2Feffective%2FNotificationEffectiveStatementImpl.java;h=67e46139c857b7ecda7fe63f6895ddbfaf626dcd;hb=0d77417cb1aab5cacac7503052eb0ca8faacc01e;hp=8b2ec246cb9172a3f53e4167fdd7d9dbcf92db53;hpb=30c67c4d780e897d972d60bb79d546b512516f90;p=yangtools.git 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 8b2ec246cb..67e46139c8 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 @@ -7,47 +7,40 @@ */ package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableSet; import java.util.Collection; import java.util.HashSet; import java.util.LinkedList; -import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.Utils; -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 com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableSet; import java.util.List; +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.NotificationDefinition; 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.NotificationStatement; +import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext; -public class NotificationEffectiveStatementImpl - extends - AbstractEffectiveDocumentedDataNodeContainer - implements NotificationDefinition { +public class NotificationEffectiveStatementImpl extends + AbstractEffectiveDocumentedDataNodeContainer implements NotificationDefinition { private final QName qname; private final SchemaPath path; - ImmutableSet augmentations; - ImmutableList unknownNodes; + private final Set augmentations; + private final List unknownNodes; public NotificationEffectiveStatementImpl( - StmtContext> ctx) { + final StmtContext> ctx) { super(ctx); this.qname = ctx.getStatementArgument(); - this.path = Utils.getSchemaPath(ctx); + this.path = ctx.getSchemaPath().get(); - initSubstatementCollections(); - } - - private void initSubstatementCollections() { + // initSubstatementCollections Collection> effectiveSubstatements = effectiveSubstatements(); - List unknownNodesInit = new LinkedList<>(); Set augmentationsInit = new HashSet<>(); - for (EffectiveStatement effectiveStatement : effectiveSubstatements) { if (effectiveStatement instanceof UnknownSchemaNode) { UnknownSchemaNode unknownNode = (UnknownSchemaNode) effectiveStatement; @@ -58,7 +51,6 @@ public class NotificationEffectiveStatementImpl augmentationsInit.add(augmentationSchema); } } - this.unknownNodes = ImmutableList.copyOf(unknownNodesInit); this.augmentations = ImmutableSet.copyOf(augmentationsInit); } @@ -87,8 +79,8 @@ public class NotificationEffectiveStatementImpl public int hashCode() { final int prime = 31; int result = 1; - result = prime * result + ((qname == null) ? 0 : qname.hashCode()); - result = prime * result + ((path == null) ? 0 : path.hashCode()); + result = prime * result + Objects.hashCode(qname); + result = prime * result + Objects.hashCode(path); return result; } @@ -104,29 +96,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(); } -} \ No newline at end of file +}