Class GnmiNodeBuilder
- java.lang.Object
-
- org.opendaylight.yang.gen.v1.urn.lighty.gnmi.topology.rev210316.GnmiNodeBuilder
-
@Generated("mdsal-binding-generator") public class GnmiNodeBuilder extends Object
Class that buildsGnmiNodeinstances. Overall design of the class is that of a fluent interface, where method chaining is used.In general, this class is supposed to be used like this template:
GnmiNode createGnmiNode(int fooXyzzy, int barBaz) { return new GnmiNodeBuilder() .setFoo(new FooBuilder().setXyzzy(fooXyzzy).build()) .setBar(new BarBuilder().setBaz(barBaz).build()) .build(); }This pattern is supported by the immutable nature of GnmiNode, as instances can be freely passed around without worrying about synchronization issues.
As a side note: method chaining results in:
- very efficient Java bytecode, as the method invocation result, in this case the Builder reference, is
on the stack, so further method invocations just need to fill method arguments for the next method
invocation, which is terminated by
build(), which is then returned from the method - better understanding by humans, as the scope of mutable state (the builder) is kept to a minimum and is very localized
- better optimization opportunities, as the object scope is minimized in terms of invocation (rather than method) stack, making escape analysis a lot easier. Given enough compiler (JIT/AOT) prowess, the cost of th builder object can be completely eliminated
- See Also:
GnmiNode
- very efficient Java bytecode, as the method invocation result, in this case the Builder reference, is
on the stack, so further method invocations just need to fill method arguments for the next method
invocation, which is terminated by
-
-
Constructor Summary
Constructors Constructor Description GnmiNodeBuilder()Construct an empty builder.GnmiNodeBuilder(GnmiConnectionParameters arg)Construct a new builder initialized from specifiedGnmiConnectionParameters.GnmiNodeBuilder(GnmiNode base)Construct a builder initialized with state from specifiedGnmiNode.GnmiNodeBuilder(GnmiNodeState arg)Construct a new builder initialized from specifiedGnmiNodeState.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description @NonNull GnmiNodebuild()A newGnmiNodeinstance.voidfieldsFrom(org.opendaylight.yangtools.yang.binding.DataObject arg)Set fields from given grouping argument.ConnectionParametersgetConnectionParameters()Return current value associated with the property corresponding toGnmiConnectionParameters.getConnectionParameters().ExtensionsParametersgetExtensionsParameters()Return current value associated with the property corresponding toGnmiConnectionParameters.getExtensionsParameters().NodeStategetNodeState()Return current value associated with the property corresponding toGnmiNodeState.getNodeState().GnmiNodeBuildersetConnectionParameters(ConnectionParameters value)Set the property corresponding toGnmiConnectionParameters.getConnectionParameters()to the specified value.GnmiNodeBuildersetExtensionsParameters(ExtensionsParameters value)Set the property corresponding toGnmiConnectionParameters.getExtensionsParameters()to the specified value.GnmiNodeBuildersetNodeState(NodeState value)Set the property corresponding toGnmiNodeState.getNodeState()to the specified value.
-
-
-
Constructor Detail
-
GnmiNodeBuilder
public GnmiNodeBuilder()
Construct an empty builder.
-
GnmiNodeBuilder
public GnmiNodeBuilder(GnmiConnectionParameters arg)
Construct a new builder initialized from specifiedGnmiConnectionParameters.- Parameters:
arg- GnmiConnectionParameters from which the builder should be initialized
-
GnmiNodeBuilder
public GnmiNodeBuilder(GnmiNodeState arg)
Construct a new builder initialized from specifiedGnmiNodeState.- Parameters:
arg- GnmiNodeState from which the builder should be initialized
-
-
Method Detail
-
fieldsFrom
public void fieldsFrom(org.opendaylight.yangtools.yang.binding.DataObject arg)
Set fields from given grouping argument. Valid argument is instance of one of following types:- Parameters:
arg- grouping object- Throws:
IllegalArgumentException- if given argument is none of valid types or has property with incompatible value
-
getConnectionParameters
public ConnectionParameters getConnectionParameters()
Return current value associated with the property corresponding toGnmiConnectionParameters.getConnectionParameters().- Returns:
- current value
-
getExtensionsParameters
public ExtensionsParameters getExtensionsParameters()
Return current value associated with the property corresponding toGnmiConnectionParameters.getExtensionsParameters().- Returns:
- current value
-
getNodeState
public NodeState getNodeState()
Return current value associated with the property corresponding toGnmiNodeState.getNodeState().- Returns:
- current value
-
setConnectionParameters
public GnmiNodeBuilder setConnectionParameters(ConnectionParameters value)
Set the property corresponding toGnmiConnectionParameters.getConnectionParameters()to the specified value.- Parameters:
value- desired value- Returns:
- this builder
-
setExtensionsParameters
public GnmiNodeBuilder setExtensionsParameters(ExtensionsParameters value)
Set the property corresponding toGnmiConnectionParameters.getExtensionsParameters()to the specified value.- Parameters:
value- desired value- Returns:
- this builder
-
setNodeState
public GnmiNodeBuilder setNodeState(NodeState value)
Set the property corresponding toGnmiNodeState.getNodeState()to the specified value.- Parameters:
value- desired value- Returns:
- this builder
-
-