T - is the generic type of the Datatype owning this segment.V - is the generic type of the segment value.public abstract class AbstractDatatypeSegmentDescriptor<T,V> extends Object implements DatatypeSegmentDescriptor<T,V>
DatatypeSegmentDescriptor.| Modifier and Type | Field and Description |
|---|---|
private String |
name |
private boolean |
optional |
private Class<V> |
type |
DEFAULT_NAME| Constructor and Description |
|---|
AbstractDatatypeSegmentDescriptor(String name,
Class<V> type)
The constructor.
|
AbstractDatatypeSegmentDescriptor(String name,
Class<V> type,
boolean optional)
The constructor.
|
| Modifier and Type | Method and Description |
|---|---|
protected abstract V |
doGetSegment(T datatype)
Called from
getSegment(Object) after validation (null-check). |
String |
getName() |
V |
getSegment(T datatype)
Gets the value of the segment described by this object.
|
Class<V> |
getType() |
boolean |
isOptional() |
String |
toString() |
private final boolean optional
isOptional()public AbstractDatatypeSegmentDescriptor(String name, Class<V> type)
public V getSegment(T datatype)
getSegment in interface DatatypeSegmentDescriptor<T,V>datatype - is the Datatype to disassemble.protected abstract V doGetSegment(T datatype)
getSegment(Object) after validation (null-check).datatype - is the datatype instance. May not be null.segment value.public String getName()
getName in interface DatatypeSegmentDescriptor<T,V>SimpleDatatype typically just DatatypeSegmentDescriptor.DEFAULT_NAME but
significant for composite datatypes where the name is used as field names when the datatype is
serialized to XML, JSON, a Map or whatever.public boolean isOptional()
isOptional in interface DatatypeSegmentDescriptor<T,V>true if this segment is optional and can be omitted, false otherwise.
Serialization is suggested to omit optional segments if their value is null.
Further, creation shall accept less arguments if any
number of optional arguments are skipped what requires that
segment descriptors are ordered such that
optional segments are at the end of the list.Copyright © 2001–2015 mmm-Team. All rights reserved.