Package org.openmuc.jeebus.spine.impl
Class EntityBuilder
- java.lang.Object
-
- org.openmuc.jeebus.spine.impl.EntityBuilder
-
public class EntityBuilder extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description EntityBuilder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description EntityBuilderaddEntity()Creates a new EntityBuilder instance.FeatureBuilderaddFeature()Creates a new FeatureBuilder instance.voidaddFeature(Feature feature)voidaddFeature(AddableFeature feature)EntityBuilderaddUseCase(UseCase useCase)org.openmuc.jeebus.spine.xsd.v1.EntityAddressTypeapplyAndGetStaticAddress()Convenience method for callingapplyToDevice()and getting the address of the newEntity.DeviceBuilderapplyToDevice()Builds this entity and adds it to the parent device.EntityBuilderapplyToEntity()Builds this entity and adds it to the parent entity.Entitybuild()Builds the SPINE entity.longgetLastAddedFeatureId()EntityBuildersetDescription(java.lang.String description)EntityBuildersetLabel(java.lang.String label)EntityBuildersetType(org.openmuc.jeebus.spine.xsd.v1.EntityTypeEnumType entityType)
-
-
-
Method Detail
-
setType
public EntityBuilder setType(org.openmuc.jeebus.spine.xsd.v1.EntityTypeEnumType entityType)
- Parameters:
entityType- the type of the SPINE entity- Returns:
- the updated
EntityBuilder
-
addEntity
public EntityBuilder addEntity()
Creates a new EntityBuilder instance. The sub-entity can then be fluently added to this entity withapplyToEntity()- Returns:
- a new EntityBuilder instance
-
addFeature
public FeatureBuilder addFeature()
Creates a new FeatureBuilder instance. The feature can then be fluently added to this entity withFeatureBuilder.apply().- Returns:
- a new FeatureBuilder instance
-
addFeature
public void addFeature(AddableFeature feature)
-
addFeature
public void addFeature(Feature feature)
-
setDescription
public EntityBuilder setDescription(java.lang.String description)
- Parameters:
description- a string describing the new SPINE entity- Returns:
- the updated
EntityBuilder
-
setLabel
public EntityBuilder setLabel(java.lang.String label)
- Parameters:
label- a human-readable alias of the new SPINE entity- Returns:
- the updated
EntityBuilder
-
applyToEntity
public EntityBuilder applyToEntity()
Builds this entity and adds it to the parent entity.
If this EntityBuilder was not created from another EntityBuilder this throwsUnsupportedOperationException.
If mandatory information was not set (setType(EntityTypeEnumType)) this operation throws anIncompleteBuildException.- Returns:
- the updated parent
EntityBuilder
-
applyAndGetStaticAddress
public org.openmuc.jeebus.spine.xsd.v1.EntityAddressType applyAndGetStaticAddress()
Convenience method for callingapplyToDevice()and getting the address of the newEntity.- Returns:
- the complete static {link
EntityAddressType} of the newEntity
-
applyToDevice
public DeviceBuilder applyToDevice()
Builds this entity and adds it to the parent device.
If this EntityBuilder was not created from a DeviceBuilder this throwsUnsupportedOperationException.
If mandatory information was not set (setType(EntityTypeEnumType)) this operation throws anIncompleteBuildException.- Returns:
- the updated parent
DeviceBuilder
-
addUseCase
public EntityBuilder addUseCase(UseCase useCase)
-
getLastAddedFeatureId
public long getLastAddedFeatureId()
-
build
public Entity build() throws IncompleteBuildException
Builds the SPINE entity. The new entity can then be added to a SPINE device or entity at runtime withEntityParent.addEntity(Entity)orEntityParent.addEntity(Entity)
If mandatory information was not set (setType(EntityTypeEnumType)) this operation throws andIncompleteBuildException.- Returns:
- the built SPINE entity
- Throws:
IncompleteBuildException- when the entity type was not set
-
-