Interface DataStructureComponent<R extends ComponentRole,S extends ValueDomainSubset<S,D>,D extends ValueDomain>
-
- Type Parameters:
R
- theComponentRole
S
- theValueDomainSubset
D
- theValueDomain
- All Superinterfaces:
Serializable
- All Known Implementing Classes:
DataStructureComponentImpl
public interface DataStructureComponent<R extends ComponentRole,S extends ValueDomainSubset<S,D>,D extends ValueDomain> extends Serializable
The immutable representation of a component of a dataset.- Author:
- Valentino Pinna
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default <R2 extends ComponentRole>
DataStructureComponent<R2,S,D>as(Class<R2> role)
Narrows the role of thisDataStructureComponent
to the specified role if possible.default <S2 extends ValueDomainSubset<S2,D2>,D2 extends ValueDomain>
DataStructureComponent<R,S2,D2>as(S2 domain)
Narrows the domain of thisDataStructureComponent
to the specified domain if possible.static Comparator<DataStructureComponent<?,?,?>>
byName()
default ScalarValue<?,?,S,D>
cast(ScalarValue<?,?,?,?> value)
Casts a given value to the domain subset of thisDataStructureComponent
if possible.DataStructureComponent<ComponentRole.Measure,S,D>
createMeasureFrom()
Create a measure component with the same domain as this component and a default name.boolean
equals(Object obj)
S
getDomain()
default ScalarValueMetadata<S,D>
getMetadata()
default String
getName()
Class<R>
getRole()
Variable
getVariable()
int
hashCode()
default boolean
is(Class<? extends ComponentRole> role)
Checks if thisDataStructureComponent
has the specified role.DataStructureComponent<R,S,D>
rename(String name)
Creates a new component by renaming thisDataStructureComponent
.default DataStructureComponent<R,S,D>
rename(UnaryOperator<String> nameMapper)
Creates a new component by renaming thisDataStructureComponent
.
-
-
-
Method Detail
-
byName
static Comparator<DataStructureComponent<?,?,?>> byName()
-
getVariable
Variable getVariable()
- Returns:
- The dataset variable for this
DataStructureComponent
.
-
getDomain
S getDomain()
- Returns:
- The domain subset of this
DataStructureComponent
.
-
getMetadata
default ScalarValueMetadata<S,D> getMetadata()
- Returns:
- The scalar value metadata of this
DataStructureComponent
.
-
getRole
Class<R> getRole()
- Returns:
- The role of this
DataStructureComponent
.
-
getName
default String getName()
- Returns:
- The name of this
DataStructureComponent
.
-
rename
DataStructureComponent<R,S,D> rename(String name)
Creates a new component by renaming thisDataStructureComponent
.- Parameters:
name
- The name to assign to the new component- Returns:
- the new component.
-
rename
default DataStructureComponent<R,S,D> rename(UnaryOperator<String> nameMapper)
Creates a new component by renaming thisDataStructureComponent
.- Parameters:
nameMapper
- a functions that returns the new name given the name of thisDataStructureComponent
- Returns:
- the new component.
-
is
default boolean is(Class<? extends ComponentRole> role)
Checks if thisDataStructureComponent
has the specified role.- Parameters:
role
- the role- Returns:
- true if this
DataStructureComponent
has the specified role.
-
as
default <R2 extends ComponentRole> DataStructureComponent<R2,S,D> as(Class<R2> role)
Narrows the role of thisDataStructureComponent
to the specified role if possible.- Parameters:
role
- the role to narrow to- Returns:
- this component with the narrowed role.
- Throws:
ClassCastException
- if the role cannot be narrowed.
-
as
default <S2 extends ValueDomainSubset<S2,D2>,D2 extends ValueDomain> DataStructureComponent<R,S2,D2> as(S2 domain)
Narrows the domain of thisDataStructureComponent
to the specified domain if possible.- Parameters:
domain
- the domain to narrow to- Returns:
- this component with the narrowed domain.
- Throws:
ClassCastException
- if the domain cannot be narrowed.
-
cast
default ScalarValue<?,?,S,D> cast(ScalarValue<?,?,?,?> value)
Casts a given value to the domain subset of thisDataStructureComponent
if possible.- Parameters:
value
- the value to cast- Returns:
- the casted value.
- Throws:
VTLCastException
- if the value cannot be casted to the domain of this component.
-
createMeasureFrom
DataStructureComponent<ComponentRole.Measure,S,D> createMeasureFrom()
Create a measure component with the same domain as this component and a default name.- Returns:
- The new component
-
-