*/
package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext.TypeOfCopy;
+
import java.util.Collection;
import java.util.LinkedList;
import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.Utils;
this.path = Utils.getSchemaPath(ctx);
initSubstatementCollections();
+ initCopyType(ctx);
+ }
+
+ private void initCopyType(
+ StmtContext<QName, AnyxmlStatement, EffectiveStatement<QName, AnyxmlStatement>> ctx) {
+
+ TypeOfCopy typeOfCopy = ctx.getTypeOfCopy();
+ switch (typeOfCopy) {
+ case ADDED_BY_AUGMENTATION:
+ augmenting = true;
+ original = (AnyXmlSchemaNode) ctx.getOriginalCtx().buildEffective();
+ break;
+ case ADDED_BY_USES:
+ addedByUses = true;
+ original = (AnyXmlSchemaNode) ctx.getOriginalCtx().buildEffective();
+ break;
+ default:
+ break;
+ }
}
private void initSubstatementCollections() {
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 (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
+
+ if (!checkObject(obj)) {
+ return false;
}
+
AnyXmlEffectiveStatementImpl other = (AnyXmlEffectiveStatementImpl) obj;
- if (qname == null) {
- if (other.qname != null) {
- return false;
- }
- } else if (!qname.equals(other.qname)) {
+
+ if (!checkQname(other)) {
return false;
}
- if (path == null) {
- if (other.path != null) {
- return false;
- }
- } else if (!path.equals(other.path)) {
+
+ if (!checkPath(other)) {
return false;
}
+
return true;
}
return sb.toString();
}
-}
\ No newline at end of file
+}