public static final class Feature.Builder extends Object implements AutoCloseable
Feature
object.
Make sure to
dataType()
before calling value()
id()
and dataType()
before finishing the Feature
using build()
Otherwise a java.lang.IllegalStateException will be thrown.
Constructor and Description |
---|
Builder(Feature.Builder other) |
Modifier and Type | Method and Description |
---|---|
Feature |
build()
Build the feature using the settings configured.
|
void |
close() |
Feature.Builder |
dataType(DataType dataType)
Configures the dataType of the feature being built.
|
protected void |
finalize() |
Feature.Builder |
id(long id)
Configures the id of the feature being built.
|
Feature.Builder |
resetId()
Resets the id.
|
Feature.Builder |
resetValue(DataPropertyPath propertyPath)
Resets the value associated with the given property.
|
<T> Feature.Builder |
value(DataPropertyPath propertyPath,
T value)
Sets the value associated with the given property.
|
public Builder(@NotNull Feature.Builder other)
public void close()
close
in interface AutoCloseable
@NotNull public Feature build() throws IllegalStateException
After this method is invoked once, this builder can no longer be used.
IllegalStateException
- if the id or dataType are not configured@NotNull public Feature.Builder id(long id)
A feature id should be unique across a model.
This method is not mandatory, though Features in a model must have an id. It is allowed to temporarily have features without id, for example during Feature
creation. As soon as such a temporary Feature
is added
to a model, it must be assigned
an id
though.
When no id is set, Feature#getId
will throw an exception.
id
- the id@NotNull public Feature.Builder resetId()
Calling this method will cause the built Feature
to have no id, thus throwing an exception when calling Feature#getId
.
Features in a model must have an id. It is allowed to temporarily have features without id, for example during Feature
creation. As soon as such a temporary Feature
is added
to a model, it must be assigned
an id
though.
Note that for a newly created Feature.Builder
using the Feature#newBuilder()
method, the id will be empty by default. This method is less useful in that case. It is mainly useful when using the Feature#asBuilder()
method.
@NotNull public Feature.Builder dataType(@NotNull DataType dataType)
dataType
- the data type@NotNull public <T> Feature.Builder value(@NotNull DataPropertyPath propertyPath, @NotNull T value) throws IllegalArgumentException
featureBuilder.value(booleanPropertyPath, booleanValue);
featureBuilder.value(intPropertyPath, intValue);
featureBuilder.value(longPropertyPath, longValue);
featureBuilder.value(floatPropertyPath, floatValue);
featureBuilder.value(doublePropertyPath, doubleValue);
featureBuilder.value(stringPropertyPath, stringValue);
featureBuilder.value(geometryPropertyPath, geometry);
T
- the supported types are java.lang.Boolean
, java.lang.Integer
, java.lang.Long
, java.lang.Float
, java.lang.Double
, java.lang.String
and Geometry
propertyPath
- the property for which to set the valuevalue
- the valueIllegalArgumentException
- when the dataType has not been configured yet, the property is not of a known type, or if it doesn't exist in the DataType
.@NotNull public Feature.Builder resetValue(@NotNull DataPropertyPath propertyPath) throws IllegalArgumentException
Calling this method will cause the built Feature
to return an empty optional for the given property.
Note that for a newly created Feature.Builder
using the Feature#newBuilder()
method, all values will be empty by default. This method is less useful in that case. It is mainly useful when using the Feature#asBuilder()
method.
propertyPath
- the property for which to reset the valueIllegalArgumentException
- when the dataType has not been configured yet, the property is not of a known type, or if it doesn't exist in the DataType
.