Class CharacteristicTypeBuilder<V>
- Type Parameters:
V
- the class of characteristic values.
- All Implemented Interfaces:
Localized
AttributeType
will will be built by a FeatureTypeBuilder
.
Characteristics can describe additional information useful for interpreting an attribute value, like
the units of measurement and uncertainties of a numerical value, or the coordinate reference system
(CRS) of a geometry.
In many cases, all instances of the same AttributeType
have the same characteristics.
For example, all values of the "temperature" attribute typically have the same units of measurement.
Such common value can be specified as the characteristic default value.
- Since:
- 0.8
- Version:
- 0.8
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate DefaultAttributeType
<V> The characteristic created by this builder, ornull
if not yet created.private V
The default value for the attribute, ornull
if none.private AttributeTypeBuilder
<?> The attribute type builder instance that created thisCharacteristicTypeBuilder
builder.The class of characteristic values. -
Constructor Summary
ConstructorsModifierConstructorDescription(package private)
CharacteristicTypeBuilder
(AttributeTypeBuilder<?> owner, Class<V> valueClass) Creates a new characteristic builder for values of the given class.(package private)
CharacteristicTypeBuilder
(AttributeTypeBuilder<?> owner, DefaultAttributeType<V> template) Creates a new characteristic builder initialized to the values of an existing attribute.private
CharacteristicTypeBuilder
(CharacteristicTypeBuilder<?> builder, Class<V> valueClass) Creates a new builder initialized to the values of the given builder but a different type. -
Method Summary
Modifier and TypeMethodDescriptionbuild()
Builds the characteristic type from the information specified to this builder.(package private) final void
If theAttributeType<V>
created by the last call tobuild()
has been cached, clears that cache.(package private) final org.opengis.util.GenericName
createGenericName
(CharSequence... names) Creates a generic name in the feature namespace.(package private) final org.opengis.util.GenericName
createLocalName
(CharSequence name) Creates a local name in the feature namespace.(package private) final String
Returns a default name to use if the user did not specified a name.Returns the default value for the characteristic, ornull
if none.Returns the class of characteristic values.(package private) final void
owner
(AttributeTypeBuilder<?> newb) Sets a new owner.void
remove()
Removes this characteristics from theAttributeTypeBuilder
.(package private) final void
Sets the default value with check of the value class.setDefaultValue
(V value) Sets the default value for the characteristic.setDefinition
(CharSequence definition) Sets a concise definition of the element.setDeprecated
(boolean deprecated) Sets whether the type is deprecated.setDescription
(CharSequence description) Sets optional information beyond that required for concise definition of the element.setDesignation
(CharSequence designation) Sets a natural language designator for the element.setName
(CharSequence localPart) Sets the characteristic name as a simple string (local name).setName
(CharSequence... components) Sets the characteristic name as a string in the given scope.setName
(org.opengis.util.GenericName name) Sets the characteristic name as a generic name.<N> CharacteristicTypeBuilder
<N> setValueClass
(Class<N> type) Sets the class of characteristic values.Methods inherited from class org.apache.sis.feature.builder.TypeBuilder
appendStringTo, ensureAlive, ensureNonEmpty, ensureNonNull, errors, forName, getDefinition, getDescription, getDesignation, getDisplayName, getLocale, getName, identification, initialize, isDeprecated, reset, resources, toString, toStringInternal
-
Field Details
-
owner
The attribute type builder instance that created thisCharacteristicTypeBuilder
builder. This is set at construction time and considered as immutable until it is set tonull
. -
valueClass
The class of characteristic values. Cannot be changed after construction because this value determines the parameterized type<V>
. -
defaultValue
The default value for the attribute, ornull
if none. -
characteristic
The characteristic created by this builder, ornull
if not yet created. This field must be cleared every time that a setter method is invoked on this builder.
-
-
Constructor Details
-
CharacteristicTypeBuilder
private CharacteristicTypeBuilder(CharacteristicTypeBuilder<?> builder, Class<V> valueClass) throws UnconvertibleObjectException Creates a new builder initialized to the values of the given builder but a different type. This constructor is forsetValueClass(Class)
implementation only.- Throws:
UnconvertibleObjectException
- if the default value cannot be converted to the given class.
-
CharacteristicTypeBuilder
CharacteristicTypeBuilder(AttributeTypeBuilder<?> owner, Class<V> valueClass) Creates a new characteristic builder for values of the given class.- Parameters:
owner
- the builder of theAttributeType
for which to add this property.valueClass
- the class of characteristic values.
-
CharacteristicTypeBuilder
CharacteristicTypeBuilder(AttributeTypeBuilder<?> owner, DefaultAttributeType<V> template) Creates a new characteristic builder initialized to the values of an existing attribute.- Parameters:
owner
- the builder of theAttributeType
for which to add this property.
-
-
Method Details
-
clearCache
final void clearCache()If theAttributeType<V>
created by the last call tobuild()
has been cached, clears that cache. This method must be invoked every time that a setter method is invoked.- Specified by:
clearCache
in classTypeBuilder
- See Also:
-
getDefaultName
Returns a default name to use if the user did not specified a name. The first letter will be changed to lower case (unless the name looks like an acronym) for compliance with Java convention on property names.- Overrides:
getDefaultName
in classTypeBuilder
-
setName
Sets the characteristic name as a generic name. If another name was defined before this method call, that previous value will be discarded.- Overrides:
setName
in classTypeBuilder
- Parameters:
name
- the generic name (cannot benull
).- Returns:
this
for allowing method calls chaining.- See Also:
-
setName
Sets the characteristic name as a simple string (local name). The namespace will be the value specified by the last call toFeatureTypeBuilder.setNameSpace(CharSequence)
, but that namespace will not be visible in the string representation unless the fully qualified name is requested.This convenience method creates a
LocalName
instance from the givenCharSequence
, then delegates tosetName(GenericName)
.- Overrides:
setName
in classTypeBuilder
- Parameters:
localPart
- the local part of the generic name as aString
orInternationalString
.- Returns:
this
for allowing method calls chaining.- See Also:
-
setName
Sets the characteristic name as a string in the given scope. Thecomponents
array must contain at least one element. The last component (the tip) will be sufficient in many cases for getting values from the characteristics map. The other elements before the last one are optional and can be used for resolving ambiguity. They will be visible as the name path.In addition to the path specified by the
components
array, the name may also contain a namespace specified by the last call toFeatureTypeBuilder.setNameSpace(CharSequence)
. But contrarily to the specified components, the namespace will not be visible in the name string representation unless the fully qualified name is requested.This convenience method creates a
LocalName
orScopedName
instance depending on whether thenames
array contains exactly 1 element or more than 1 element, then delegates tosetName(GenericName)
.- Overrides:
setName
in classTypeBuilder
- Parameters:
components
- the name components as an array ofString
orInternationalString
instances.- Returns:
this
for allowing method calls chaining.- See Also:
-
createLocalName
Creates a local name in the feature namespace.- Specified by:
createLocalName
in classTypeBuilder
-
createGenericName
Creates a generic name in the feature namespace.- Specified by:
createGenericName
in classTypeBuilder
-
getValueClass
Returns the class of characteristic values.- Returns:
- the class of characteristic values.
- See Also:
-
setValueClass
public <N> CharacteristicTypeBuilder<N> setValueClass(Class<N> type) throws UnconvertibleObjectException Sets the class of characteristic values. Callers must use the builder returned by this method instead ofthis
builder after this method call, since the returned builder may be a new instance.- Type Parameters:
N
- the compile-time value of thetype
argument.- Parameters:
type
- the new class of characteristic values.- Returns:
- the characteristic builder — not necessarily this instance.
- Throws:
UnconvertibleObjectException
- if the default value cannot be converted to the given<N>
class.- See Also:
-
getDefaultValue
Returns the default value for the characteristic, ornull
if none.- Returns:
- the default characteristic value, or
null
if none. - See Also:
-
setDefaultValue
Sets the default value for the characteristic.- Parameters:
value
- characteristic default value, ornull
if none.- Returns:
this
for allowing method calls chaining.- See Also:
-
set
Sets the default value with check of the value class. -
setDefinition
Sets a concise definition of the element.- Overrides:
setDefinition
in classTypeBuilder
- Parameters:
definition
- a concise definition of the element, ornull
if none.- Returns:
this
for allowing method calls chaining.- See Also:
-
setDesignation
Sets a natural language designator for the element. This can be used as an alternative to the name in user interfaces.- Overrides:
setDesignation
in classTypeBuilder
- Parameters:
designation
- a natural language designator for the element, ornull
if none.- Returns:
this
for allowing method calls chaining.- See Also:
-
setDescription
Sets optional information beyond that required for concise definition of the element. The description may assist in understanding the feature scope and application. If the type is deprecated, then the description should give indication about the replacement (e.g. "superceded by …").- Overrides:
setDescription
in classTypeBuilder
- Parameters:
description
- information beyond that required for concise definition of the element, ornull
if none.- Returns:
this
for allowing method calls chaining.- See Also:
-
setDeprecated
Sets whether the type is deprecated. If the type is deprecated, then the description should be set to an indication about the replacement (e.g. "superceded by …").- Overrides:
setDeprecated
in classTypeBuilder
- Parameters:
deprecated
- whether this type is deprecated.- Returns:
this
for allowing method calls chaining.- See Also:
-
build
Builds the characteristic type from the information specified to this builder. If a type has already been built and this builder state has not changed since the type creation, then the previously createdAttributeType
instance is returned.Warning: In a future SIS version, the return type may be changed to theorg.opengis.feature.AttributeType
interface. This change is pending GeoAPI revision.- Specified by:
build
in classTypeBuilder
- Returns:
- the characteristic type.
-
owner
Sets a new owner. -
remove
public void remove()Removes this characteristics from theAttributeTypeBuilder
. After this method has been invoked, thisCharacteristicTypeBuilder
instance is no longer in the list returned byAttributeTypeBuilder.characteristics()
and attempts to invoke any setter method onthis
will cause anIllegalStateException
to be thrown.- Overrides:
remove
in classTypeBuilder
-