Class MessageBuilder
- java.lang.Object
-
- org.opendaylight.yang.gen.v1.http.openconfig.net.yang.messages.rev180813.messages.state.MessageBuilder
-
@Generated("mdsal-binding-generator") public class MessageBuilder extends Object
Class that buildsMessageinstances. 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:
Message createMessage(int fooXyzzy, int barBaz) { return new MessageBuilder() .setFoo(new FooBuilder().setXyzzy(fooXyzzy).build()) .setBar(new BarBuilder().setBaz(barBaz).build()) .build(); }This pattern is supported by the immutable nature of Message, 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:
Message
- 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 MessageBuilder()Construct an empty builder.MessageBuilder(Message base)Construct a builder initialized with state from specifiedMessage.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description MessageBuilderaddAugmentation(org.opendaylight.yangtools.yang.binding.Augmentation<Message> augmentation)Add an augmentation to this builder's product.<E$$ extends org.opendaylight.yangtools.yang.binding.Augmentation<Message>>
E$$augmentation(Class<E$$> augmentationType)Return the specified augmentation, if it is present in this builder.@NonNull Messagebuild()A newMessageinstance.StringgetAppName()Return current value associated with the property corresponding toMessage.getAppName().StringgetMsg()Return current value associated with the property corresponding toMessage.getMsg().StringgetMsgid()Return current value associated with the property corresponding toMessage.getMsgid().org.opendaylight.yangtools.yang.common.Uint8getPriority()Return current value associated with the property corresponding toMessage.getPriority().StringgetProcid()Return current value associated with the property corresponding toMessage.getProcid().MessageBuilderremoveAugmentation(Class<? extends org.opendaylight.yangtools.yang.binding.Augmentation<Message>> augmentationType)Remove an augmentation from this builder's product.MessageBuildersetAppName(String value)Set the property corresponding toMessage.getAppName()to the specified value.MessageBuildersetMsg(String value)Set the property corresponding toMessage.getMsg()to the specified value.MessageBuildersetMsgid(String value)Set the property corresponding toMessage.getMsgid()to the specified value.MessageBuildersetPriority(org.opendaylight.yangtools.yang.common.Uint8 value)Set the property corresponding toMessage.getPriority()to the specified value.MessageBuildersetProcid(String value)Set the property corresponding toMessage.getProcid()to the specified value.
-
-
-
Method Detail
-
getAppName
public String getAppName()
Return current value associated with the property corresponding toMessage.getAppName().- Returns:
- current value
-
getMsg
public String getMsg()
Return current value associated with the property corresponding toMessage.getMsg().- Returns:
- current value
-
getMsgid
public String getMsgid()
Return current value associated with the property corresponding toMessage.getMsgid().- Returns:
- current value
-
getPriority
public org.opendaylight.yangtools.yang.common.Uint8 getPriority()
Return current value associated with the property corresponding toMessage.getPriority().- Returns:
- current value
-
getProcid
public String getProcid()
Return current value associated with the property corresponding toMessage.getProcid().- Returns:
- current value
-
augmentation
public <E$$ extends org.opendaylight.yangtools.yang.binding.Augmentation<Message>> 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
nullif not present - Throws:
NullPointerException- ifaugmentTypeisnull
-
setAppName
public MessageBuilder setAppName(String value)
Set the property corresponding toMessage.getAppName()to the specified value.- Parameters:
value- desired value- Returns:
- this builder
-
setMsg
public MessageBuilder setMsg(String value)
Set the property corresponding toMessage.getMsg()to the specified value.- Parameters:
value- desired value- Returns:
- this builder
-
setMsgid
public MessageBuilder setMsgid(String value)
Set the property corresponding toMessage.getMsgid()to the specified value.- Parameters:
value- desired value- Returns:
- this builder
-
setPriority
public MessageBuilder setPriority(org.opendaylight.yangtools.yang.common.Uint8 value)
Set the property corresponding toMessage.getPriority()to the specified value.- Parameters:
value- desired value- Returns:
- this builder
-
setProcid
public MessageBuilder setProcid(String value)
Set the property corresponding toMessage.getProcid()to the specified value.- Parameters:
value- desired value- Returns:
- this builder
-
addAugmentation
public MessageBuilder addAugmentation(org.opendaylight.yangtools.yang.binding.Augmentation<Message> augmentation)
Add an augmentation to this builder's product.- Parameters:
augmentation- augmentation to be added- Returns:
- this builder
- Throws:
NullPointerException- ifaugmentationis null
-
removeAugmentation
public MessageBuilder removeAugmentation(Class<? extends org.opendaylight.yangtools.yang.binding.Augmentation<Message>> 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
-
-