Class AttributesBuilder
java.lang.Object
org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.AttributesBuilder
Class that builds
Attributes
instances. 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:
Attributes createAttributes(int fooXyzzy, int barBaz) {
return new AttributesBuilder()
.setFoo(new FooBuilder().setXyzzy(fooXyzzy).build())
.setBar(new BarBuilder().setBaz(barBaz).build())
.build();
}
This pattern is supported by the immutable nature of Attributes, 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:
-
Constructor Summary
ConstructorDescriptionConstruct an empty builder.AttributesBuilder
(Attributes base) Construct a builder initialized with state from specifiedAttributes
.AttributesBuilder
(NextHop arg) Construct a new builder initialized from specifiedNextHop
. -
Method Summary
Modifier and TypeMethodDescriptionaddAugmentation
(org.opendaylight.yangtools.yang.binding.Augmentation<Attributes> augmentation) Add an augmentation to this builder's product.<E$$ extends org.opendaylight.yangtools.yang.binding.Augmentation<Attributes>>
E$$augmentation
(Class<E$$> augmentationType) Return the specified augmentation, if it is present in this builder.@NonNull Attributes
build()
A newAttributes
instance.static @NonNull Attributes
empty()
Get empty instance of Attributes.void
fieldsFrom
(org.opendaylight.yangtools.yang.binding.DataObject arg) Set fields from given grouping argument.Return current value associated with the property corresponding toAttributes.getAggregator()
.getAigp()
Return current value associated with the property corresponding toAttributes.getAigp()
.Return current value associated with the property corresponding toAttributes.getAsPath()
.Return current value associated with the property corresponding toAttributes.getAtomicAggregate()
.Return current value associated with the property corresponding toAttributes.getBgpPrefixSid()
.Return current value associated with the property corresponding toAttributes.getClusterId()
.Return current value associated with the property corresponding toNextHop.getCNextHop()
.Return current value associated with the property corresponding toAttributes.getCommunities()
.Return current value associated with the property corresponding toAttributes.getExtendedCommunities()
.Return current value associated with the property corresponding toAttributes.getLocalPref()
.Return current value associated with the property corresponding toAttributes.getMultiExitDisc()
.Return current value associated with the property corresponding toAttributes.getOrigin()
.Return current value associated with the property corresponding toAttributes.getOriginatorId()
.Return current value associated with the property corresponding toAttributes.getUnrecognizedAttributes()
.removeAugmentation
(Class<? extends org.opendaylight.yangtools.yang.binding.Augmentation<Attributes>> augmentationType) Remove an augmentation from this builder's product.setAggregator
(Aggregator value) Set the property corresponding toAttributes.getAggregator()
to the specified value.Set the property corresponding toAttributes.getAigp()
to the specified value.Set the property corresponding toAttributes.getAsPath()
to the specified value.Set the property corresponding toAttributes.getAtomicAggregate()
to the specified value.setBgpPrefixSid
(BgpPrefixSid value) Set the property corresponding toAttributes.getBgpPrefixSid()
to the specified value.setClusterId
(ClusterId value) Set the property corresponding toAttributes.getClusterId()
to the specified value.setCNextHop
(CNextHop value) Set the property corresponding toNextHop.getCNextHop()
to the specified value.setCommunities
(List<Communities> values) Set the property corresponding toAttributes.getCommunities()
to the specified value.Set the property corresponding toAttributes.getExtendedCommunities()
to the specified value.setLocalPref
(LocalPref value) Set the property corresponding toAttributes.getLocalPref()
to the specified value.setMultiExitDisc
(MultiExitDisc value) Set the property corresponding toAttributes.getMultiExitDisc()
to the specified value.Set the property corresponding toAttributes.getOrigin()
to the specified value.setOriginatorId
(OriginatorId value) Set the property corresponding toAttributes.getOriginatorId()
to the specified value.Set the property corresponding toAttributes.getUnrecognizedAttributes()
to the specified value.
-
Constructor Details
-
AttributesBuilder
public AttributesBuilder()Construct an empty builder. -
AttributesBuilder
Construct a new builder initialized from specifiedNextHop
.- Parameters:
arg
- NextHop from which the builder should be initialized
-
AttributesBuilder
Construct a builder initialized with state from specifiedAttributes
.- Parameters:
base
- Attributes from which the builder should be initialized
-
-
Method Details
-
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
-
empty
Get empty instance of Attributes.- Returns:
- An empty
Attributes
-
getAggregator
Return current value associated with the property corresponding toAttributes.getAggregator()
.- Returns:
- current value
-
getAigp
Return current value associated with the property corresponding toAttributes.getAigp()
.- Returns:
- current value
-
getAsPath
Return current value associated with the property corresponding toAttributes.getAsPath()
.- Returns:
- current value
-
getAtomicAggregate
Return current value associated with the property corresponding toAttributes.getAtomicAggregate()
.- Returns:
- current value
-
getBgpPrefixSid
Return current value associated with the property corresponding toAttributes.getBgpPrefixSid()
.- Returns:
- current value
-
getCNextHop
Return current value associated with the property corresponding toNextHop.getCNextHop()
.- Returns:
- current value
-
getClusterId
Return current value associated with the property corresponding toAttributes.getClusterId()
.- Returns:
- current value
-
getCommunities
Return current value associated with the property corresponding toAttributes.getCommunities()
.- Returns:
- current value
-
getExtendedCommunities
Return current value associated with the property corresponding toAttributes.getExtendedCommunities()
.- Returns:
- current value
-
getLocalPref
Return current value associated with the property corresponding toAttributes.getLocalPref()
.- Returns:
- current value
-
getMultiExitDisc
Return current value associated with the property corresponding toAttributes.getMultiExitDisc()
.- Returns:
- current value
-
getOrigin
Return current value associated with the property corresponding toAttributes.getOrigin()
.- Returns:
- current value
-
getOriginatorId
Return current value associated with the property corresponding toAttributes.getOriginatorId()
.- Returns:
- current value
-
getUnrecognizedAttributes
Return current value associated with the property corresponding toAttributes.getUnrecognizedAttributes()
.- Returns:
- current value
-
augmentation
public <E$$ extends org.opendaylight.yangtools.yang.binding.Augmentation<Attributes>> E$$ augmentation(Class<E$$> augmentationType) Return the specified augmentation, if it is present in this builder.- Type Parameters:
E$$
- augmentation type- Parameters:
augmentationType
- augmentation type class- Returns:
- Augmentation object from this builder, or
null
if not present - Throws:
NullPointerException
- ifaugmentType
isnull
-
setAggregator
Set the property corresponding toAttributes.getAggregator()
to the specified value.- Parameters:
value
- desired value- Returns:
- this builder
-
setAigp
Set the property corresponding toAttributes.getAigp()
to the specified value.- Parameters:
value
- desired value- Returns:
- this builder
-
setAsPath
Set the property corresponding toAttributes.getAsPath()
to the specified value.- Parameters:
value
- desired value- Returns:
- this builder
-
setAtomicAggregate
Set the property corresponding toAttributes.getAtomicAggregate()
to the specified value.- Parameters:
value
- desired value- Returns:
- this builder
-
setBgpPrefixSid
Set the property corresponding toAttributes.getBgpPrefixSid()
to the specified value.- Parameters:
value
- desired value- Returns:
- this builder
-
setCNextHop
Set the property corresponding toNextHop.getCNextHop()
to the specified value.- Parameters:
value
- desired value- Returns:
- this builder
-
setClusterId
Set the property corresponding toAttributes.getClusterId()
to the specified value.- Parameters:
value
- desired value- Returns:
- this builder
-
setCommunities
Set the property corresponding toAttributes.getCommunities()
to the specified value.- Parameters:
values
- desired value- Returns:
- this builder
-
setExtendedCommunities
Set the property corresponding toAttributes.getExtendedCommunities()
to the specified value.- Parameters:
values
- desired value- Returns:
- this builder
-
setLocalPref
Set the property corresponding toAttributes.getLocalPref()
to the specified value.- Parameters:
value
- desired value- Returns:
- this builder
-
setMultiExitDisc
Set the property corresponding toAttributes.getMultiExitDisc()
to the specified value.- Parameters:
value
- desired value- Returns:
- this builder
-
setOrigin
Set the property corresponding toAttributes.getOrigin()
to the specified value.- Parameters:
value
- desired value- Returns:
- this builder
-
setOriginatorId
Set the property corresponding toAttributes.getOriginatorId()
to the specified value.- Parameters:
value
- desired value- Returns:
- this builder
-
setUnrecognizedAttributes
public AttributesBuilder setUnrecognizedAttributes(Map<UnrecognizedAttributesKey, UnrecognizedAttributes> values) Set the property corresponding toAttributes.getUnrecognizedAttributes()
to the specified value.- Parameters:
values
- desired value- Returns:
- this builder
-
addAugmentation
public AttributesBuilder addAugmentation(org.opendaylight.yangtools.yang.binding.Augmentation<Attributes> augmentation) Add an augmentation to this builder's product.- Parameters:
augmentation
- augmentation to be added- Returns:
- this builder
- Throws:
NullPointerException
- ifaugmentation
is null
-
removeAugmentation
public AttributesBuilder removeAugmentation(Class<? extends org.opendaylight.yangtools.yang.binding.Augmentation<Attributes>> augmentationType) Remove an augmentation from this builder's product. If this builder does not track such an augmentation type, this method does nothing.- Parameters:
augmentationType
- augmentation type to be removed- Returns:
- this builder
-
build
A newAttributes
instance.- Returns:
- A new
Attributes
instance.
-