Class EntityBuilder
- java.lang.Object
-
- org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.clustering.entity.owners.rev150804.entity.owners.entity.type.EntityBuilder
-
- All Implemented Interfaces:
org.opendaylight.yangtools.concepts.Builder<Entity>,org.opendaylight.yangtools.concepts.CheckedBuilder<Entity,IllegalArgumentException>,org.opendaylight.yangtools.concepts.Mutable,org.opendaylight.yangtools.concepts.MutationBehaviour<org.opendaylight.yangtools.concepts.Mutable>
public class EntityBuilder extends Object implements org.opendaylight.yangtools.concepts.Builder<Entity>
Class that buildsEntityBuilderinstances. 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:
EntityBuilder createTarget(int fooXyzzy, int barBaz) { return new EntityBuilderBuilder() .setFoo(new FooBuilder().setXyzzy(fooXyzzy).build()) .setBar(new BarBuilder().setBaz(barBaz).build()) .build(); }This pattern is supported by the immutable nature of EntityBuilder, 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 oportunities, 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:
EntityBuilder,Builder
-
-
Constructor Summary
Constructors Constructor Description EntityBuilder()EntityBuilder(Entity base)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description EntityBuilderaddAugmentation(Class<? extends org.opendaylight.yangtools.yang.binding.Augmentation<Entity>> augmentationType, org.opendaylight.yangtools.yang.binding.Augmentation<Entity> augmentationValue)<E$$ extends org.opendaylight.yangtools.yang.binding.Augmentation<Entity>>
E$$augmentation(Class<E$$> augmentationType)Entitybuild()List<Candidate>getCandidate()org.opendaylight.yangtools.yang.binding.InstanceIdentifier<?>getId()StringgetOwner()EntityKeykey()EntityBuilderremoveAugmentation(Class<? extends org.opendaylight.yangtools.yang.binding.Augmentation<Entity>> augmentationType)EntityBuildersetCandidate(List<Candidate> values)EntityBuildersetId(org.opendaylight.yangtools.yang.binding.InstanceIdentifier<?> value)EntityBuildersetOwner(String value)EntityBuilderwithKey(EntityKey key)
-
-
-
Constructor Detail
-
EntityBuilder
public EntityBuilder()
-
EntityBuilder
public EntityBuilder(Entity base)
-
-
Method Detail
-
key
public EntityKey key()
-
getId
public org.opendaylight.yangtools.yang.binding.InstanceIdentifier<?> getId()
-
getOwner
public String getOwner()
-
augmentation
public <E$$ extends org.opendaylight.yangtools.yang.binding.Augmentation<Entity>> E$$ augmentation(Class<E$$> augmentationType)
-
withKey
public EntityBuilder withKey(EntityKey key)
-
setCandidate
public EntityBuilder setCandidate(List<Candidate> values)
-
setId
public EntityBuilder setId(org.opendaylight.yangtools.yang.binding.InstanceIdentifier<?> value)
-
setOwner
public EntityBuilder setOwner(String value)
-
addAugmentation
public EntityBuilder addAugmentation(Class<? extends org.opendaylight.yangtools.yang.binding.Augmentation<Entity>> augmentationType, org.opendaylight.yangtools.yang.binding.Augmentation<Entity> augmentationValue)
-
removeAugmentation
public EntityBuilder removeAugmentation(Class<? extends org.opendaylight.yangtools.yang.binding.Augmentation<Entity>> augmentationType)
-
build
public Entity build()
- Specified by:
buildin interfaceorg.opendaylight.yangtools.concepts.Builder<Entity>- Specified by:
buildin interfaceorg.opendaylight.yangtools.concepts.CheckedBuilder<Entity,IllegalArgumentException>
-
-