Package org.apache.sis.feature.builder
Class AssociationRoleBuilder
java.lang.Object
org.apache.sis.feature.builder.TypeBuilder
org.apache.sis.feature.builder.PropertyTypeBuilder
org.apache.sis.feature.builder.AssociationRoleBuilder
- All Implemented Interfaces:
Localized
Describes one association from the
FeatureType
to be built by an FeatureTypeBuilder
to another
FeatureType
. A different instance of AssociationRoleBuilder
exists for each feature association
to describe. Those instances are created preferably by FeatureTypeBuilder.addAssociation(FeatureType)
,
or in case of cyclic reference by FeatureTypeBuilder.addAssociation(GenericName)
.- Since:
- 0.8
- Version:
- 0.8
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate DefaultAssociationRole
The association created by this builder, ornull
if not yet created.private final DefaultFeatureType
The target feature type, ornull
if unknown.private final org.opengis.util.GenericName
Name of the target feature type (never null).Fields inherited from class org.apache.sis.feature.builder.PropertyTypeBuilder
maximumOccurs, minimumOccurs
-
Constructor Summary
ConstructorsConstructorDescriptionAssociationRoleBuilder
(FeatureTypeBuilder owner, DefaultAssociationRole template) Creates a newFeatureAssociationRole
builder initialized to the values of an existing association.AssociationRoleBuilder
(FeatureTypeBuilder owner, DefaultFeatureType type, org.opengis.util.GenericName typeName) Creates a newAssociationRole
builder for values of the given type. -
Method Summary
Modifier and TypeMethodDescriptionbuild()
Builds the association role from the information specified to this builder.(package private) final void
If theFeatureAssociationRole
created by the last call tobuild()
has been cached, clears that cache.(package private) final String
Returns a default name to use if the user did not specified a name.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.setMaximumOccurs
(int occurs) Sets the maximum number of associations.setMinimumOccurs
(int occurs) Sets the minimum number of associations.setName
(CharSequence localPart) Sets theFeatureAssociationRole
name as a simple string (local name).setName
(CharSequence... components) Sets theFeatureAssociationRole
name as a string in the given scope.setName
(org.opengis.util.GenericName name) Sets theFeatureAssociationRole
name as a generic name.(package private) final void
toStringInternal
(StringBuilder buffer) Appends a text inside the value returned byTypeBuilder.toString()
, before the closing bracket.Methods inherited from class org.apache.sis.feature.builder.PropertyTypeBuilder
createGenericName, createLocalName, dispose, getMaximumOccurs, getMinimumOccurs, isIdentifier, owner, remove
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
-
Field Details
-
type
The target feature type, ornull
if unknown. -
typeName
private final org.opengis.util.GenericName typeNameName of the target feature type (never null). -
property
The association 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
-
AssociationRoleBuilder
AssociationRoleBuilder(FeatureTypeBuilder owner, DefaultFeatureType type, org.opengis.util.GenericName typeName) Creates a newAssociationRole
builder for values of the given type. Thetype
argument can be null if unknown, buttypeName
is mandatory.- Parameters:
owner
- the builder of theFeatureType
for which to add this property.
-
AssociationRoleBuilder
AssociationRoleBuilder(FeatureTypeBuilder owner, DefaultAssociationRole template) Creates a newFeatureAssociationRole
builder initialized to the values of an existing association.- Parameters:
owner
- the builder of theFeatureType
for which to add this property.
-
-
Method Details
-
clearCache
final void clearCache()If theFeatureAssociationRole
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.- Overrides:
clearCache
in classPropertyTypeBuilder
- See Also:
-
toStringInternal
Appends a text inside the value returned byTypeBuilder.toString()
, before the closing bracket.- Overrides:
toStringInternal
in classTypeBuilder
-
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 theFeatureAssociationRole
name as a generic name. If another name was defined before this method call, that previous value will be discarded.- Overrides:
setName
in classPropertyTypeBuilder
- Parameters:
name
- the generic name (cannot benull
).- Returns:
this
for allowing method calls chaining.- See Also:
-
setName
Sets theFeatureAssociationRole
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 classPropertyTypeBuilder
- Parameters:
localPart
- the local part of the generic name as aString
orInternationalString
.- Returns:
this
for allowing method calls chaining.- See Also:
-
setName
Sets theFeatureAssociationRole
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 calls to theAbstractFeature.getProperty(String)
method. The other elements before the last one are optional and can be used for resolving ambiguity. They will be visible as the name path.Example: a call toIn addition to the path specified by thesetName("A", "B", "C")
will create a "A:B:C" name. An association built with this name can be obtained from a feature by a call tofeature.getProperty("C")
if there is no ambiguity, or otherwise by a call tofeature.getProperty("B:C")
(if non-ambiguous) orfeature.getProperty("A:B:C")
.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 classPropertyTypeBuilder
- Parameters:
components
- the name components as an array ofString
orInternationalString
instances.- Returns:
this
for allowing method calls chaining.- See Also:
-
setMinimumOccurs
Sets the minimum number of associations. If the given number is greater than the maximal number of associations, than the maximum is also set to that value.- Overrides:
setMinimumOccurs
in classPropertyTypeBuilder
- Parameters:
occurs
- the new minimum number of associations.- Returns:
this
for allowing method calls chaining.- See Also:
-
setMaximumOccurs
Sets the maximum number of associations. If the given number is less than the minimal number of associations, than the minimum is also set to that value.Integer.MAX_VALUE
means that there is no maximum.- Overrides:
setMaximumOccurs
in classPropertyTypeBuilder
- Parameters:
occurs
- the new maximum number of associations.- Returns:
this
for allowing method calls chaining.- See Also:
-
setDefinition
Sets a concise definition of the element.- Overrides:
setDefinition
in classPropertyTypeBuilder
- 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 classPropertyTypeBuilder
- 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 classPropertyTypeBuilder
- 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 classPropertyTypeBuilder
- Parameters:
deprecated
- whether this type is deprecated.- Returns:
this
for allowing method calls chaining.- See Also:
-
build
Builds the association role from the information specified to this builder. If a role has already been built and this builder state has not changed since the role creation, then the previously createdFeatureAssociationRole
instance is returned.Warning: In a future SIS version, the return type may be changed to theorg.opengis.feature.FeatureAssociationRole
interface. This change is pending GeoAPI revision.- Specified by:
build
in classPropertyTypeBuilder
- Returns:
- the association role.
-