/*
* Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
package org.opendaylight.yangtools.yang.data.api;
-import com.google.common.collect.ImmutableList;
+import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
import java.util.ArrayList;
import java.util.List;
this.hash = new HashCodeBuilder<>(hash);
}
- @Override
- public InstanceIdentifierBuilder node(final QName nodeType) {
- final PathArgument arg = new NodeIdentifier(nodeType);
+ private InstanceIdentifierBuilder addArgument(final PathArgument arg) {
path.add(arg);
hash.addArgument(arg);
return this;
}
@Override
- public InstanceIdentifierBuilder nodeWithKey(final QName nodeType, final QName key, final Object value) {
- final PathArgument arg = new NodeIdentifierWithPredicates(nodeType, key, value);
- path.add(arg);
- hash.addArgument(arg);
- return this;
+ public InstanceIdentifierBuilder node(final PathArgument arg) {
+ return addArgument(Preconditions.checkNotNull(arg));
}
@Override
- public InstanceIdentifierBuilder nodeWithKey(final QName nodeType, final Map<QName, Object> keyValues) {
- final PathArgument arg = new NodeIdentifierWithPredicates(nodeType, keyValues);
- path.add(arg);
- hash.addArgument(arg);
- return this;
+ public InstanceIdentifierBuilder node(final QName nodeType) {
+ return addArgument(new NodeIdentifier(nodeType));
+ }
+
+ @Override
+ public InstanceIdentifierBuilder nodeWithKey(final QName nodeType, final QName key, final Object value) {
+ return addArgument(new NodeIdentifierWithPredicates(nodeType, key, value));
}
@Override
- @Deprecated
- public YangInstanceIdentifier toInstance() {
- return build();
+ public InstanceIdentifierBuilder nodeWithKey(final QName nodeType, final Map<QName, Object> keyValues) {
+ return addArgument(new NodeIdentifierWithPredicates(nodeType, keyValues));
}
@Override
public YangInstanceIdentifier build() {
- return new YangInstanceIdentifier(ImmutableList.copyOf(path), hash.build());
+ return FixedYangInstanceIdentifier.create(path, hash.build());
}
-}
\ No newline at end of file
+}