val List<QName> nodeNames = nodeSp.path
val List<QName> nodeNewNames = new ArrayList(nodeNames)
nodeNewNames.remove(nodeNewNames.size - 1)
- val SchemaPath nodeNewSp = new SchemaPath(nodeNewNames, nodeSp.absolute)
+ val SchemaPath nodeNewSp = SchemaPath.create(nodeNewNames, nodeSp.absolute)
parentNode = findDataSchemaNode(schemaContext, nodeNewSp)
var SchemaNode parent
val List<QName> names = sp.path
val List<QName> newNames = new ArrayList(names)
newNames.remove(newNames.size - 1)
- val SchemaPath newSp = new SchemaPath(newNames, sp.absolute)
+ val SchemaPath newSp = SchemaPath.create(newNames, sp.absolute)
parent = findDataSchemaNode(schemaContext, newSp)
}
var GeneratedTypeBuilder childOfType = findChildNodeByPath(parent.path)
val List<QName> nodeNames = nodeSp.path
val List<QName> nodeNewNames = new ArrayList(nodeNames)
nodeNewNames.remove(nodeNewNames.size - 1)
- val SchemaPath nodeNewSp = new SchemaPath(nodeNewNames, nodeSp.absolute)
+ val SchemaPath nodeNewSp = SchemaPath.create(nodeNewNames, nodeSp.absolute)
parent = findDataSchemaNode(schemaContext, nodeNewSp)
var GeneratedTypeBuilder childOfType = null;
for (final PathArgument a : getPathArguments()) {
if (type.equals(a.getType())) {
@SuppressWarnings("unchecked")
- final InstanceIdentifier<I> ret = (InstanceIdentifier<I>) create(Iterables.limit(getPathArguments(), i));
+ final InstanceIdentifier<I> ret = (InstanceIdentifier<I>) internalCreate(Iterables.limit(getPathArguments(), i));
return ret;
}
}
/**
- * Create an instance identifier for a very specific object type.
+ * Create an instance identifier for a very specific object type. This method
+ * implements {@link #create(Iterable)} semantics, except it is used by internal
+ * callers, which have assured that the argument is an immutable Iterable.
*
- * Example
- * <pre>
- * List<PathArgument> path = Arrays.asList(new Item(Nodes.class))
- * new InstanceIdentifier(path);
- * </pre>
*
* @param pathArguments The path to a specific node in the data tree
* @return InstanceIdentifier instance
* @throws IllegalArgumentException if pathArguments is empty or
* contains a null element.
*/
- public static InstanceIdentifier<?> create(final Iterable<? extends PathArgument> pathArguments) {
+ private static InstanceIdentifier<?> internalCreate(final Iterable<PathArgument> pathArguments) {
final Iterator<? extends PathArgument> it = Preconditions.checkNotNull(pathArguments, "pathArguments may not be null").iterator();
final HashCodeBuilder<PathArgument> hashBuilder = new HashCodeBuilder<>();
boolean wildcard = false;
}
Preconditions.checkArgument(a != null, "pathArguments may not be empty");
- final Iterable<PathArgument> immutableArguments;
+ return trustedCreate(a, pathArguments, hashBuilder.toInstance(), wildcard);
+ }
+
+ /**
+ * Create an instance identifier for a very specific object type.
+ *
+ * Example
+ * <pre>
+ * List<PathArgument> path = Arrays.asList(new Item(Nodes.class))
+ * new InstanceIdentifier(path);
+ * </pre>
+ *
+ * @param pathArguments The path to a specific node in the data tree
+ * @return InstanceIdentifier instance
+ * @throws IllegalArgumentException if pathArguments is empty or
+ * contains a null element.
+ */
+ public static InstanceIdentifier<?> create(final Iterable<? extends PathArgument> pathArguments) {
if (pathArguments instanceof ImmutableCollection<?>) {
- immutableArguments = (Iterable<PathArgument>) pathArguments;
+ @SuppressWarnings("unchecked")
+ final Iterable<PathArgument> immutableArguments = (Iterable<PathArgument>) pathArguments;
+ return internalCreate(immutableArguments);
} else {
- immutableArguments = ImmutableList.copyOf(pathArguments);
+ return internalCreate(ImmutableList.copyOf(pathArguments));
}
-
- return trustedCreate(a, immutableArguments, hashBuilder.toInstance(), wildcard);
}
/**
@Override
public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((type == null) ? 0 : type.hashCode());
- return result;
+ return type.hashCode();
}
@Override
return false;
}
final AbstractPathArgument<?> other = (AbstractPathArgument<?>) obj;
- if (type == null) {
- if (other.type != null) {
- return false;
- }
- } else if (!type.equals(other.type)) {
- return false;
- }
- return true;
+ return type.equals(other.type);
}
}
@Override
public boolean equals(final Object obj) {
- return super.equals(obj) && obj.hashCode() == hashCode() && key.equals(((IdentifiableItem<?, ?>) obj).getKey());
+ return super.equals(obj) && key.equals(((IdentifiableItem<?, ?>) obj).getKey());
}
@Override
public int hashCode() {
- return key.hashCode();
+ return super.hashCode() * 31 + key.hashCode();
}
@Override