private static final TopLevelListKey TOP_FOO_KEY = new TopLevelListKey("foo");
private static final InstanceIdentifier<TopLevelList> BA_TOP_LEVEL_LIST = InstanceIdentifier.builder(Top.class)
- .child(TopLevelList.class, TOP_FOO_KEY).toInstance();
+ .child(TopLevelList.class, TOP_FOO_KEY).build();
private static final InstanceIdentifier<TreeLeafOnlyAugment> BA_TREE_LEAF_ONLY = BA_TOP_LEVEL_LIST
.augmentation(TreeLeafOnlyAugment.class);
private static final InstanceIdentifier<TreeComplexUsesAugment> BA_TREE_COMPLEX_USES = BA_TOP_LEVEL_LIST
private static final TopLevelListKey TOP_FOO_KEY = new TopLevelListKey("foo");
private static final InstanceIdentifier<TopLevelList> BA_TOP_LEVEL_LIST = InstanceIdentifier.builder(Top.class)
- .child(TopLevelList.class, TOP_FOO_KEY).toInstance();
+ .child(TopLevelList.class, TOP_FOO_KEY).build();
private static final InstanceIdentifier<TreeLeafOnlyAugment> BA_TREE_LEAF_ONLY = BA_TOP_LEVEL_LIST
.augmentation(TreeLeafOnlyAugment.class);
private static final InstanceIdentifier<TreeComplexUsesAugment> BA_TREE_COMPLEX_USES = BA_TOP_LEVEL_LIST
private static final TopLevelListKey TOP_FOO_KEY = new TopLevelListKey("foo");
private static final InstanceIdentifier<TopLevelList> BA_TOP_LEVEL_LIST = InstanceIdentifier.builder(Top.class)
- .child(TopLevelList.class, TOP_FOO_KEY).toInstance();
+ .child(TopLevelList.class, TOP_FOO_KEY).build();
private static final InstanceIdentifier<TreeLeafOnlyAugment> BA_TREE_LEAF_ONLY = BA_TOP_LEVEL_LIST
.augmentation(TreeLeafOnlyAugment.class);
private static final InstanceIdentifier<TreeComplexUsesAugment> BA_TREE_COMPLEX_USES = BA_TOP_LEVEL_LIST
private static final TopLevelListKey TOP_FOO_KEY = new TopLevelListKey("foo");
private static final InstanceIdentifier<TopLevelList> BA_TOP_LEVEL_LIST = InstanceIdentifier
- .builder(Top.class).child(TopLevelList.class, TOP_FOO_KEY).toInstance();
+ .builder(Top.class).child(TopLevelList.class, TOP_FOO_KEY).build();
private static final InstanceIdentifier<TreeLeafOnlyAugment> BA_TREE_LEAF_ONLY =
BA_TOP_LEVEL_LIST.augmentation(TreeLeafOnlyAugment.class);
private static final InstanceIdentifier<TreeComplexUsesAugment> BA_TREE_COMPLEX_USES =
private static final TopLevelListKey TOP_FOO_KEY = new TopLevelListKey("foo");
private static final InstanceIdentifier<TopLevelList> BA_TOP_LEVEL_LIST = InstanceIdentifier.builder(Top.class)
- .child(TopLevelList.class, TOP_FOO_KEY).toInstance();
+ .child(TopLevelList.class, TOP_FOO_KEY).build();
private static final InstanceIdentifier<TreeLeafOnlyAugment> BA_TREE_LEAF_ONLY = BA_TOP_LEVEL_LIST
.augmentation(TreeLeafOnlyAugment.class);
private static final InstanceIdentifier<TreeComplexUsesAugment> BA_TREE_COMPLEX_USES = BA_TOP_LEVEL_LIST
private static final TopLevelListKey TOP_FOO_KEY = new TopLevelListKey("foo");
private static final InstanceIdentifier<TreeComplexLeaves> BA_TOP_LEVEL_LIST = InstanceIdentifier.builder(Top.class)
- .child(TopLevelList.class, TOP_FOO_KEY).augmentation(TreeComplexLeaves.class).toInstance();
+ .child(TopLevelList.class, TOP_FOO_KEY).augmentation(TreeComplexLeaves.class).build();
private BindingNormalizedNodeCodecRegistry registry;
private static final QName SIMPLE_VALUE_QNAME = QName.create(TreeComplexUsesAugment.QNAME, "simple-value");
private static final InstanceIdentifier<TopLevelList> BA_TOP_LEVEL_LIST = InstanceIdentifier
- .builder(Top.class).child(TopLevelList.class, TOP_LEVEL_LIST_FOO_KEY).toInstance();
+ .builder(Top.class).child(TopLevelList.class, TOP_LEVEL_LIST_FOO_KEY).build();
private static final InstanceIdentifier<TreeLeafOnlyAugment> BA_TREE_LEAF_ONLY =
BA_TOP_LEVEL_LIST.augmentation(TreeLeafOnlyAugment.class);
private static final InstanceIdentifier<TreeComplexUsesAugment> BA_TREE_COMPLEX_USES =
def CharSequence tree(Module module) '''
«strong(module.name)»
- «module.childNodes.treeSet(YangInstanceIdentifier.builder.toInstance())»
+ «module.childNodes.treeSet(YangInstanceIdentifier.builder.build())»
'''
private def dispatch CharSequence tree(ChoiceNode node,YangInstanceIdentifier path) '''
«IF !childNodes.nullOrEmpty»
<h2>Child nodes</h2>
- «childNodes.printChildren(3,YangInstanceIdentifier.builder().toInstance())»
+ «childNodes.printChildren(3,YangInstanceIdentifier.builder().build())»
«ENDIF»
'''
/**
* Builder object which produces a product.
- *
+ *
* @param <P> Product of builder
- *
+ *
* @author Tony Tkacik <ttkacik@cisco.com>
*/
public interface Builder<P> extends Mutable {
-
+
/**
* Returns instance of the product.
- *
+ *
* Multiple calls to this method are not required to return
* same instance if the state of the builder was changed.
- *
+ *
* @return Newly-built instance
*/
- P toInstance();
+ P build();
+
}
}
@Override
- public CompositeObjectRegistration<T> toInstance() {
+ public CompositeObjectRegistration<T> build() {
return new CompositeObjectRegistration<>(instance, registrations);
}
+
+ /*
+ * @deprecated Use #build() instead.
+ */
+ @Deprecated
+ public CompositeObjectRegistration<T> toInstance() {
+ return build();
+ }
}
}
public interface ProductAwareBuilder<P> extends Builder<P> {
/**
* Return the hash code of the product. This has to be equivalent
- * of calling {@link #toInstance()}.{@link Object#hashCode()}.
+ * of calling {@link #build()}.{@link Object#hashCode()}.
*
* @return the hash code of the product.
*/
/**
* Check whether an instance of the product that would be created
* by the builder is equal to an existing instance. This has to
- * be equivalent of calling {@link #toInstance()}.{@link Object#equals(Object)}.
+ * be equivalent of calling {@link #build()}.{@link Object#equals(Object)}.
*
* @param product Product instance
* @return Return true if the product is equal to the would-be
@Override
public <B extends ProductAwareBuilder<P>, P> P getProduct(final B builder) {
- return builder.toInstance();
+ return builder.build();
}
}
}
@Override
+ public Integer build() {
+ return currentHash;
+ }
+
+ @Deprecated
public Integer toInstance() {
return currentHash;
}
@Test
public void testAllMethodsOfHashCodeBuilder() {
final HashCodeBuilder<String> hashCodeBuilder = new HashCodeBuilder<>();
- assertEquals("Default hash code should be '1'.", 1, hashCodeBuilder.toInstance().intValue());
+ assertEquals("Default hash code should be '1'.", 1, hashCodeBuilder.build().intValue());
int nextHashCode = HashCodeBuilder.nextHashCode(1, "test");
assertEquals("Next hash code should be '3556529'.", 3556529, nextHashCode);
hashCodeBuilder.addArgument("another test");
- assertEquals("Updated internal hash code should be '700442706'.", -700442706, hashCodeBuilder.toInstance().intValue());
+ assertEquals("Updated internal hash code should be '700442706'.", -700442706, hashCodeBuilder.build().intValue());
}
}
private static final NodeId SOURCE_NODE_ID = new NodeId("node:id");
private static final TpId SOURCE_TP_ID = new TpId("source:tp");
private static final InstanceIdentifier<NetworkTopology> NETWORK_TOPOLOGY_PATH = InstanceIdentifier.builder(
- NetworkTopology.class).toInstance();
+ NetworkTopology.class).build();
private NetworkTopology networkModel;
private Link linkModel;
@Test
public void testXmlDataToDataObjectLinuxCase() {
final InstanceIdentifier<Topology> instanceIdentifier = InstanceIdentifier.builder(NetworkTopology.class)
- .child(Topology.class, new TopologyKey(new TopologyId("example-pcep-topology"))).toInstance();
+ .child(Topology.class, new TopologyKey(new TopologyId("example-pcep-topology"))).build();
final InputStream is = this.getClass().getClassLoader().getResourceAsStream("topology-bug1196-linux.xml");
final DataSchemaNode dataSchema = RestconfUtils.toRestconfIdentifier(instanceIdentifier, this.mappingService,
this.mappingService.getSchemaContext()).getValue();
@Test
public void testXmlDataToDataObjectUnixCase() {
final InstanceIdentifier<Topology> instanceIdentifier = InstanceIdentifier.builder(NetworkTopology.class)
- .child(Topology.class, new TopologyKey(new TopologyId("example-pcep-topology"))).toInstance();
+ .child(Topology.class, new TopologyKey(new TopologyId("example-pcep-topology"))).build();
final InputStream is = this.getClass().getClassLoader().getResourceAsStream("topology-bug1196-unix.xml");
final DataSchemaNode dataSchema = RestconfUtils.toRestconfIdentifier(instanceIdentifier, this.mappingService,
this.mappingService.getSchemaContext()).getValue();
@Test
public void testToDataObjectMappingWithNestedAugmentations() {
- InstanceIdentifier<Factory> factoryId = InstanceIdentifier.builder(Factory.class).toInstance();
+ InstanceIdentifier<Factory> factoryId = InstanceIdentifier.builder(Factory.class).build();
InputStream is = this.getClass().getClassLoader().getResourceAsStream("topology-bug527.xml");
DataSchemaNode dataSchema = RestconfUtils.toRestconfIdentifier(factoryId, mappingService,
mappingService.getSchemaContext()).getValue();
@Test
public void firstTest() { // test static state collisions with the other test
final InstanceIdentifier<Topology> instanceIdentifier = InstanceIdentifier.builder(NetworkTopology.class)
- .child(Topology.class, new TopologyKey(new TopologyId("example-pcep-topology"))).toInstance();
+ .child(Topology.class, new TopologyKey(new TopologyId("example-pcep-topology"))).build();
final InputStream is = this.getClass().getClassLoader().getResourceAsStream("topology-bug1196-linux.xml");
RestconfUtils.toRestconfIdentifier(instanceIdentifier, this.mappingService,
this.mappingService.getSchemaContext()).getValue();
}
Preconditions.checkArgument(a != null, "pathArguments may not be empty");
- return trustedCreate(a, pathArguments, hashBuilder.toInstance(), wildcard);
+ return trustedCreate(a, pathArguments, hashBuilder.build(), wildcard);
}
/**
* @return
*/
InstanceIdentifier<T> build();
+
+ /*
+ * @deprecated use #build()
+ */
+ @Deprecated
+ InstanceIdentifier<T> toInstance();
}
private void writeObject(final java.io.ObjectOutputStream out) throws IOException {
@Override
public int hashCode() {
- return hashBuilder.toInstance();
+ return hashBuilder.build();
}
@SuppressWarnings("unchecked")
}
@SuppressWarnings("unchecked")
- final InstanceIdentifier<T> ret = (InstanceIdentifier<T>) InstanceIdentifier.trustedCreate(arg, pathArguments, hashBuilder.toInstance(), wildcard);
+ final InstanceIdentifier<T> ret = (InstanceIdentifier<T>) InstanceIdentifier.trustedCreate(arg, pathArguments, hashBuilder.build(), wildcard);
return ret;
}
- @Override
+ /*
+ * @deprecated Use #build() instead.
+ */
+ @Deprecated
public InstanceIdentifier<T> toInstance() {
return build();
}
@Test
public void constructWithPredicates() {
- InstanceIdentifier<Nodes> nodes = InstanceIdentifier.builder(Nodes.class).toInstance();
+ InstanceIdentifier<Nodes> nodes = InstanceIdentifier.builder(Nodes.class).build();
assertNotNull(nodes);
assertEquals(Nodes.class, nodes.getTargetType());
- InstanceIdentifier<Node> node = nodes.builder().child(Node.class).toInstance();
+ InstanceIdentifier<Node> node = nodes.builder().child(Node.class).build();
assertNotNull(node);
assertEquals(Node.class, node.getTargetType());
@Test
public void fluentConstruction() {
- InstanceIdentifier<Nodes> nodes = InstanceIdentifier.builder(Nodes.class).toInstance();
- InstanceIdentifier<Node> node = InstanceIdentifier.builder(Nodes.class).child(Node.class,new NodeKey(10)).toInstance();
+ InstanceIdentifier<Nodes> nodes = InstanceIdentifier.builder(Nodes.class).build();
+ InstanceIdentifier<Node> node = InstanceIdentifier.builder(Nodes.class).child(Node.class,new NodeKey(10)).build();
assertNotNull(node);
assertEquals(Node.class, node.getTargetType());
InstanceIdentifier<FooChild> fooChild = InstanceIdentifier.builder(Nodes.class).child(InstantiatedFoo.class).child(FooChild.class).build();
InstanceIdentifier<Node> nodeTen = InstanceIdentifier.builder(Nodes.class) //
- .child(Node.class,new NodeKey(10)).toInstance();
+ .child(Node.class,new NodeKey(10)).build();
InstanceIdentifier<Node> nodeOne = InstanceIdentifier.builder(Nodes.class) //
- .child(Node.class,new NodeKey(1)).toInstance();
- InstanceIdentifier<Nodes> nodes = InstanceIdentifier.builder(Nodes.class).toInstance();
+ .child(Node.class,new NodeKey(1)).build();
+ InstanceIdentifier<Nodes> nodes = InstanceIdentifier.builder(Nodes.class).build();
assertFalse(fooChild.contains(nodeTen));
assertFalse(nodeTen.contains(nodes));
@Test
public void containsWildcarded() {
- InstanceIdentifier<Nodes> nodes = InstanceIdentifier.builder(Nodes.class).toInstance();
+ InstanceIdentifier<Nodes> nodes = InstanceIdentifier.builder(Nodes.class).build();
InstanceIdentifier<Node> wildcarded = InstanceIdentifier.builder(Nodes.class).child(Node.class).build();
InstanceIdentifier<NodeChild> wildcardedChildren = InstanceIdentifier.builder(Nodes.class) //
.child(Node.class) //
InstanceIdentifier<Node> nodeTen = InstanceIdentifier.builder(Nodes.class) //
- .child(Node.class,new NodeKey(10)).toInstance();
+ .child(Node.class,new NodeKey(10)).build();
InstanceIdentifier<Node> nodeOne = InstanceIdentifier.builder(Nodes.class) //
- .child(Node.class,new NodeKey(1)).toInstance();
+ .child(Node.class,new NodeKey(1)).build();
assertFalse(nodeTen.isWildcarded());
assertFalse(nodeOne.isWildcarded());
InstanceIdentifier<NodeChild> nodeTenChildWildcarded = InstanceIdentifier.builder(Nodes.class) //
- .child(Node.class,new NodeKey(10)).child(NodeChild.class).toInstance();
+ .child(Node.class,new NodeKey(10)).child(NodeChild.class).build();
assertTrue(nodeTenChildWildcarded.isWildcarded());
InstanceIdentifier<NodeChild> nodeTenChild = InstanceIdentifier.builder(Nodes.class) //
- .child(Node.class,new NodeKey(10)).child(NodeChild.class, new NodeChildKey(10)).toInstance();
+ .child(Node.class,new NodeKey(10)).child(NodeChild.class, new NodeChildKey(10)).build();
InstanceIdentifier<NodeChild> nodeOneChild = InstanceIdentifier.builder(Nodes.class) //
- .child(Node.class,new NodeKey(1)).child(NodeChild.class, new NodeChildKey(1)).toInstance();
+ .child(Node.class,new NodeKey(1)).child(NodeChild.class, new NodeChildKey(1)).build();
assertFalse(nodeTenChildWildcarded.containsWildcarded(nodeOneChild));
public void setup() {
MockitoAnnotations.initMocks(this);
- path = InstanceIdentifier.builder(Nodes.class).toInstance();
+ path = InstanceIdentifier.builder(Nodes.class).build();
ImmutableMap map = ImmutableMap.<InstanceIdentifier<? extends DataObject>,
DataObject>builder().put(path, mockedDataObject).build();
hash.addArgument(a);
}
- return new YangInstanceIdentifier(path, hash.toInstance());
+ return new YangInstanceIdentifier(path, hash.build());
}
public static final YangInstanceIdentifier create(final Iterable<? extends PathArgument> path) {
* @return {@link YangInstanceIdentifier}
*/
YangInstanceIdentifier build();
+
+ /*
+ * @deprecated use #build()
+ */
+ @Deprecated
+ YangInstanceIdentifier toInstance();
}
/**
return this;
}
- @Override
@Deprecated
public YangInstanceIdentifier toInstance() {
return build();
@Override
public YangInstanceIdentifier build() {
- return new YangInstanceIdentifier(ImmutableList.copyOf(path), hash.toInstance());
+ return new YangInstanceIdentifier(ImmutableList.copyOf(path), hash.build());
}
}
SimpleNode<?> anyxmlInData = NodeFactory.createImmutableSimpleNode(
QName.create("ns:complex:json", "2014-08-11", "anyxml-in-data"), null, "foo");
return ImmutableCompositeNode.builder().add(anyxmlInData)
- .setQName(QName.create("ns:complex:json", "2014-08-11", "lf12-any")).toInstance();
+ .setQName(QName.create("ns:complex:json", "2014-08-11", "lf12-any")).build();
}
private static CompositeNode prepareLf13Value() {
SimpleNode<?> anyxmlInData = NodeFactory.createImmutableSimpleNode(
QName.create("ns:complex:json", "2014-08-11", "anyxml-in-data"), null, "foo");
return ImmutableCompositeNode.builder().add(anyxmlInData)
- .setQName(QName.create("ns:complex:json", "2014-08-11", "lf13-any")).toInstance();
+ .setQName(QName.create("ns:complex:json", "2014-08-11", "lf13-any")).build();
}
public static NormalizedNode<?, ?> leafNodeInContainer() {
CompositeNodeBuilder<ImmutableCompositeNode> compNodeBuilder = ImmutableCompositeNode.builder();
compNodeBuilder.setQName(node.getNodeType());
compNodeBuilder.addAll(super.serialize(schema, node));
- return Collections.<Node<?>> singletonList(compNodeBuilder.toInstance());
+ return Collections.<Node<?>> singletonList(compNodeBuilder.build());
}
@Override
CompositeNodeBuilder<ImmutableCompositeNode> compNodeBuilder = ImmutableCompositeNode.builder();
compNodeBuilder.setQName(node.getNodeType());
compNodeBuilder.addAll(super.serialize(schema, node));
- return Collections.<Node<?>> singletonList(compNodeBuilder.toInstance());
+ return Collections.<Node<?>> singletonList(compNodeBuilder.build());
}
@Override
contBuilder.setQName(QName.create(MODULE_BASE, "cont"));
// cont1
- contBuilder.add(ImmutableCompositeNode.builder().setQName(QName.create(MODULE_BASE, "cont1")).toInstance());
+ contBuilder.add(ImmutableCompositeNode.builder().setQName(QName.create(MODULE_BASE, "cont1")).build());
// cont2
CompositeNodeBuilder<ImmutableCompositeNode> cont2 = ImmutableCompositeNode.builder().setQName(
QName.create(MODULE_BASE, "cont2"));
cont2.add(createMutableSimpleNode(QName.create(MODULE_BASE, "lf21"), null, "value in cont2/lf21", null, null));
- contBuilder.add(cont2.toInstance());
+ contBuilder.add(cont2.build());
// lst1
- contBuilder.add(ImmutableCompositeNode.builder().setQName(QName.create(MODULE_BASE, "lst1")).toInstance());
+ contBuilder.add(ImmutableCompositeNode.builder().setQName(QName.create(MODULE_BASE, "lst1")).build());
// lst2
CompositeNodeBuilder<ImmutableCompositeNode> lst2_1Builder = ImmutableCompositeNode.builder().setQName(
QName.create(MODULE_BASE, "lst2"));
lst2_1Builder.add(createMutableSimpleNode(QName.create(MODULE_BASE, "lf21"), null, "some value21", null, null));
- contBuilder.add(lst2_1Builder.toInstance());
+ contBuilder.add(lst2_1Builder.build());
CompositeNodeBuilder<ImmutableCompositeNode> lst2_2Builder = ImmutableCompositeNode.builder().setQName(
QName.create(MODULE_BASE, "lst2"));
lst2_2Builder.add(createMutableSimpleNode(QName.create(MODULE_BASE, "lf22"), null, "some value22", null, null));
- contBuilder.add(lst2_2Builder.toInstance());
+ contBuilder.add(lst2_2Builder.build());
// lflst1
contBuilder.add(createMutableSimpleNode(QName.create(MODULE_BASE, "lflst1"), null, "lflst1_1", null, null));
QName.create(MODULE_AUGMENT, "cont3"));
cont3Builder.add(createMutableSimpleNode(QName.create(MODULE_AUGMENT, "lf31"), null,
"value in leaf in augment", null, null));
- contBuilder.add(cont3Builder.toInstance());
+ contBuilder.add(cont3Builder.build());
// anxml-composite
CompositeNodeBuilder<ImmutableCompositeNode> anxmlCompositeBuilder = ImmutableCompositeNode.builder().setQName(
QName.create(MODULE_BASE, "anxml-composite"));
anxmlCompositeBuilder.add(NodeFactory.createImmutableSimpleNode(QName.create(MODULE_BASE, "anxml-cont"), null,
null));
- contBuilder.add(anxmlCompositeBuilder.toInstance());
+ contBuilder.add(anxmlCompositeBuilder.build());
// anxml-simple
contBuilder.add(NodeFactory.createImmutableSimpleNode(QName.create(MODULE_BASE, "anxml-simple"), null,43));
- return contBuilder.toInstance();
+ return contBuilder.build();
}
/**
.setQName(QName.create("simple:container:yang", "2013-11-12", "anxml-composite"))
.add(NodeFactory.createImmutableSimpleNode(
QName.create("simple:container:yang", "2013-11-12", "anxml-cont"), null, null))
- .toInstance()).build());
+ .build()).build());
containerBuilder
.withChild(Builders
}
@Override
+ public ImmutableCompositeNode build() {
+ return ImmutableCompositeNode.create(this.getQName(), this.getAttributes(), this.getChildNodes());
+ }
+
+ @Deprecated
public ImmutableCompositeNode toInstance() {
return ImmutableCompositeNode.create(this.getQName(), this.getAttributes(), this.getChildNodes());
}
import org.opendaylight.yangtools.concepts.Builder;
import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.data.api.CompositeNode;
import org.opendaylight.yangtools.yang.data.api.Node;
public interface NodeBuilder<P extends Node<?>, T extends NodeBuilder<P, T>> extends Builder<P> {
T setQName(QName name);
-
+
QName getQName();
T setAttribute(QName attrName, String attrValue);
T setAttribute(String attrName, String attrValue);
+ /*
+ * @deprecated use #build()
+ */
+ @Deprecated
+ P toInstance();
+
}
* @see org.opendaylight.yangtools.yang.parser.builder.impl.IConstraintsBuilder#build()
*/
@Override
- public ConstraintDefinition toInstance() {
+ public ConstraintDefinition build() {
if (instance != null) {
return instance;
}
}
}
+ /*
+ * @deprecated Use #build() instead.
+ */
+ @Override
+ @Deprecated
+ public ConstraintDefinition toInstance() {
+ return build();
+ }
+
}