T - is the generic type of the described Datatype.public abstract class AbstractDatatypeDescriptor<T> extends Object implements DatatypeDescriptor<T>
DatatypeDescriptor.| Modifier and Type | Field and Description |
|---|---|
private Class<T> |
datatype |
private int |
requiredSegmentCount
The number of
segments that are required. |
private List<DatatypeSegmentDescriptor<T,?>> |
segmentDescriptorList |
| Constructor and Description |
|---|
AbstractDatatypeDescriptor(Class<T> datatype,
DatatypeSegmentDescriptor<T,?>... segmentDescriptors)
The constructor.
|
| Modifier and Type | Method and Description |
|---|---|
T |
create(Object... segments)
|
protected abstract T |
doCreate(Object... segments)
Called from
create(Object...) after input validation has been performed. |
Class<T> |
getDatatype() |
Object |
getSegment(T datatypeInstance,
int index)
Gets a single segment of the given
Datatype. |
List<DatatypeSegmentDescriptor<T,?>> |
getSegmentDescriptors()
|
String |
toString() |
private final Class<T> datatype
getDatatype()private final List<DatatypeSegmentDescriptor<T,?>> segmentDescriptorList
getSegmentDescriptors()private final int requiredSegmentCount
segments that are required.@SafeVarargs public AbstractDatatypeDescriptor(Class<T> datatype, DatatypeSegmentDescriptor<T,?>... segmentDescriptors)
datatype - - see getDatatype().segmentDescriptors - - see getSegmentDescriptors().public Class<T> getDatatype()
getDatatype in interface DatatypeDescriptor<T>Class reflecting the Datatype described by this object.public List<DatatypeSegmentDescriptor<T,?>> getSegmentDescriptors()
List of DatatypeSegmentDescriptors the described datatype
is composed of. LocalDate is composed out of three segments all of the
type Integer: year, month, and day.getSegmentDescriptors in interface DatatypeDescriptor<T>List of DatatypeSegmentDescriptors.public Object getSegment(T datatypeInstance, int index)
Datatype.getSegment in interface DatatypeDescriptor<T>datatypeInstance - is the Datatype instance to disassemble.index - is the index of the segment to retrieve. Has to correspond to the list
index of segment descriptors.DatatypeSegmentDescriptor.getType().DatatypeDescriptor.getSegmentDescriptors()public T create(Object... segments)
create in interface DatatypeDescriptor<T>segments - are the segment values in the order given by
DatatypeDescriptor.getSegmentDescriptors(). Optional segments
may be omitted (from the end of the list). The type of each segment has to match the corresponding
segment type.protected abstract T doCreate(Object... segments)
create(Object...) after input validation has been performed. Implement this method and do not
worry about null values, wrong array size, etc.segments - are the segment values.Copyright © 2001–2015 mmm-Team. All rights reserved.