*/
package org.opendaylight.yangtools.yang.data.impl.schema.nodes;
-import com.google.common.base.MoreObjects;
import com.google.common.base.MoreObjects.ToStringHelper;
-import com.google.common.base.Preconditions;
+import org.opendaylight.yangtools.concepts.AbstractIdentifiable;
import org.opendaylight.yangtools.concepts.Immutable;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-public abstract class AbstractImmutableNormalizedNode<K extends PathArgument,V> implements NormalizedNode<K, V>,
- Immutable {
- private final K nodeIdentifier;
-
+public abstract class AbstractImmutableNormalizedNode<K extends PathArgument, V> extends AbstractIdentifiable<K>
+ implements NormalizedNode<K, V>, Immutable {
protected AbstractImmutableNormalizedNode(final K nodeIdentifier) {
- this.nodeIdentifier = Preconditions.checkNotNull(nodeIdentifier, "nodeIdentifier");
+ super(nodeIdentifier);
}
@Override
}
@Override
- public final K getIdentifier() {
- return nodeIdentifier;
- }
-
- @Override
- public final String toString() {
- return addToStringAttributes(MoreObjects.toStringHelper(this)).toString();
- }
-
protected ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) {
- return toStringHelper.add("nodeIdentifier", nodeIdentifier).add("value", getValue());
+ return super.addToStringAttributes(toStringHelper).add("value", getValue());
}
protected abstract boolean valueEquals(AbstractImmutableNormalizedNode<?, ?> other);
if (this == obj) {
return true;
}
- if (obj == null) {
- return false;
- }
- if (this.getClass() != obj.getClass()) {
+ if (obj == null || this.getClass() != obj.getClass()) {
return false;
}
final AbstractImmutableNormalizedNode<?, ?> other = (AbstractImmutableNormalizedNode<?, ?>)obj;
- if (!nodeIdentifier.equals(other.nodeIdentifier)) {
- return false;
- }
-
- return valueEquals(other);
+ return getIdentifier().equals(other.getIdentifier()) && valueEquals(other);
}
@Override
public final int hashCode() {
- int result = nodeIdentifier.hashCode();
- result = 31 * result + valueHashCode();
- return result;
+ return 31 * getIdentifier().hashCode() + valueHashCode();
}
}