Code Review
/
yangtools.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Compute YangInstanceIdentifier.hashCode() lazily
[yangtools.git]
/
data
/
yang-data-api
/
src
/
main
/
java
/
org
/
opendaylight
/
yangtools
/
yang
/
data
/
api
/
StackedYangInstanceIdentifier.java
diff --git
a/data/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/StackedYangInstanceIdentifier.java
b/data/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/StackedYangInstanceIdentifier.java
index 955ef2543eebe13c6682b91c4bc85d20b537a15d..b2cc4497da9eb7d41d6be587c1d022706f8a0964 100644
(file)
--- a/
data/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/StackedYangInstanceIdentifier.java
+++ b/
data/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/StackedYangInstanceIdentifier.java
@@
-9,6
+9,7
@@
package org.opendaylight.yangtools.yang.data.api;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Verify.verify;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Verify.verify;
+import static com.google.common.base.Verify.verifyNotNull;
import static java.util.Objects.requireNonNull;
import com.google.common.collect.Iterables;
import static java.util.Objects.requireNonNull;
import com.google.common.collect.Iterables;
@@
-22,6
+23,7
@@
import java.security.PrivilegedAction;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.jdt.annotation.NonNull;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.jdt.annotation.NonNull;
+import org.opendaylight.yangtools.util.HashCodeBuilder;
final class StackedYangInstanceIdentifier extends YangInstanceIdentifier implements Cloneable {
private static final long serialVersionUID = 1L;
final class StackedYangInstanceIdentifier extends YangInstanceIdentifier implements Cloneable {
private static final long serialVersionUID = 1L;
@@
-49,9
+51,7
@@
final class StackedYangInstanceIdentifier extends YangInstanceIdentifier impleme
private transient volatile StackedPathArguments pathArguments;
private transient volatile StackedReversePathArguments reversePathArguments;
private transient volatile StackedPathArguments pathArguments;
private transient volatile StackedReversePathArguments reversePathArguments;
- StackedYangInstanceIdentifier(final YangInstanceIdentifier parent, final PathArgument pathArgument,
- final int hash) {
- super(hash);
+ StackedYangInstanceIdentifier(final YangInstanceIdentifier parent, final PathArgument pathArgument) {
this.parent = requireNonNull(parent);
this.pathArgument = requireNonNull(pathArgument);
}
this.parent = requireNonNull(parent);
this.pathArgument = requireNonNull(pathArgument);
}
@@
-101,7
+101,7
@@
final class StackedYangInstanceIdentifier extends YangInstanceIdentifier impleme
final int toWalk = ourDepth - depth;
YangInstanceIdentifier result = this;
for (int i = 0; i < toWalk; ++i) {
final int toWalk = ourDepth - depth;
YangInstanceIdentifier result = this;
for (int i = 0; i < toWalk; ++i) {
- result =
result.getParent(
);
+ result =
verifyNotNull(result.getParent()
);
}
return result;
}
return result;
@@
-125,8
+125,7
@@
final class StackedYangInstanceIdentifier extends YangInstanceIdentifier impleme
current = stacked.getParent();
} while (current.tryPathArguments() == null);
current = stacked.getParent();
} while (current.tryPathArguments() == null);
- ret = new StackedPathArguments(current, Lists.reverse(stack));
- pathArguments = ret;
+ pathArguments = ret = new StackedPathArguments(current, Lists.reverse(stack));
}
return ret;
}
return ret;
@@
-163,6
+162,11
@@
final class StackedYangInstanceIdentifier extends YangInstanceIdentifier impleme
return YangInstanceIdentifier.create(Iterables.skip(getPathArguments(), skipFromRoot));
}
return YangInstanceIdentifier.create(Iterables.skip(getPathArguments(), skipFromRoot));
}
+ @Override
+ int computeHashCode() {
+ return HashCodeBuilder.nextHashCode(parent.hashCode(), pathArgument);
+ }
+
@Override
boolean pathArgumentsEqual(final YangInstanceIdentifier other) {
if (other instanceof StackedYangInstanceIdentifier) {
@Override
boolean pathArgumentsEqual(final YangInstanceIdentifier other) {
if (other instanceof StackedYangInstanceIdentifier) {
@@
-190,7
+194,7
@@
final class StackedYangInstanceIdentifier extends YangInstanceIdentifier impleme
if (parent instanceof FixedYangInstanceIdentifier) {
p = (FixedYangInstanceIdentifier) parent;
} else {
if (parent instanceof FixedYangInstanceIdentifier) {
p = (FixedYangInstanceIdentifier) parent;
} else {
- p = FixedYangInstanceIdentifier.
create(parent.getPathArguments(), parent.hashCode
());
+ p = FixedYangInstanceIdentifier.
of(parent.getPathArguments
());
}
outputStream.writeObject(p);
}
}
outputStream.writeObject(p);
}