org.opendaylight.yang.gen.v1.module._2.rev140102.DummyRpc1Module2InputBuilder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of test-models Show documentation
Show all versions of test-models Show documentation
OpenDaylight NETCONF project test models
The newest version!
package org.opendaylight.yang.gen.v1.module._2.rev140102;
import java.lang.Class;
import java.lang.NullPointerException;
import java.lang.Object;
import java.lang.Override;
import java.lang.String;
import java.lang.SuppressWarnings;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import javax.annotation.processing.Generated;
import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.yangtools.binding.Augmentation;
import org.opendaylight.yangtools.binding.lib.AbstractAugmentable;
/**
* Class that builds {@link DummyRpc1Module2Input} 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:
*
*
* DummyRpc1Module2Input createDummyRpc1Module2Input(int fooXyzzy, int barBaz) {
* return new DummyRpc1Module2InputBuilder()
* .setFoo(new FooBuilder().setXyzzy(fooXyzzy).build())
* .setBar(new BarBuilder().setBaz(barBaz).build())
* .build();
* }
*
*
*
*
* This pattern is supported by the immutable nature of DummyRpc1Module2Input, 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 {@link #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 DummyRpc1Module2Input
*
*/
@Generated("mdsal-binding-generator")
public class DummyRpc1Module2InputBuilder {
Map>, Augmentation> augmentation = Map.of();
/**
* Construct an empty builder.
*/
public DummyRpc1Module2InputBuilder() {
// No-op
}
/**
* Construct a builder initialized with state from specified {@link DummyRpc1Module2Input}.
*
* @param base DummyRpc1Module2Input from which the builder should be initialized
*/
public DummyRpc1Module2InputBuilder(final DummyRpc1Module2Input base) {
final var aug = base.augmentations();
if (!aug.isEmpty()) {
this.augmentation = new HashMap<>(aug);
}
}
/**
* Return the specified augmentation, if it is present in this builder.
*
* @param augmentation type
* @param augmentationType augmentation type class
* @return Augmentation object from this builder, or {@code null} if not present
* @throws NullPointerException if {@code augmentType} is {@code null}
*/
@SuppressWarnings({ "unchecked", "checkstyle:methodTypeParameterName"})
public > E$$ augmentation(Class augmentationType) {
return (E$$) augmentation.get(Objects.requireNonNull(augmentationType));
}
/**
* Add an augmentation to this builder's product.
*
* @param augmentation augmentation to be added
* @return this builder
* @throws NullPointerException if {@code augmentation} is null
*/
public DummyRpc1Module2InputBuilder addAugmentation(Augmentation augmentation) {
if (!(this.augmentation instanceof HashMap)) {
this.augmentation = new HashMap<>();
}
this.augmentation.put(augmentation.implementedInterface(), augmentation);
return this;
}
/**
* Remove an augmentation from this builder's product. If this builder does not track such an augmentation
* type, this method does nothing.
*
* @param augmentationType augmentation type to be removed
* @return this builder
*/
public DummyRpc1Module2InputBuilder removeAugmentation(Class> augmentationType) {
if (this.augmentation instanceof HashMap) {
this.augmentation.remove(augmentationType);
}
return this;
}
/**
* A new {@link DummyRpc1Module2Input} instance.
*
* @return A new {@link DummyRpc1Module2Input} instance.
*/
public @NonNull DummyRpc1Module2Input build() {
return new DummyRpc1Module2InputImpl(this);
}
private static final class DummyRpc1Module2InputImpl
extends AbstractAugmentable
implements DummyRpc1Module2Input {
DummyRpc1Module2InputImpl(final DummyRpc1Module2InputBuilder base) {
super(base.augmentation);
}
private int hash = 0;
private volatile boolean hashValid = false;
@Override
public int hashCode() {
if (hashValid) {
return hash;
}
final int result = DummyRpc1Module2Input.bindingHashCode(this);
hash = result;
hashValid = true;
return result;
}
@Override
public boolean equals(Object obj) {
return DummyRpc1Module2Input.bindingEquals(this, obj);
}
@Override
public String toString() {
return DummyRpc1Module2Input.bindingToString(this);
}
}
}