public interface Datatype extends Serializable
Serializable.equals and hashCode properly (two
different instances with the same value are equal and have the same
hash).string representation suitable for
sinks such as UI, loggers, etc. Also consider cases like a Datatype representing a password where
toString() should return something like "********" instead of the actual password to prevent
security accidents.string
(as needed).Datatype instance (see e.g.
BigDecimal.add(java.math.BigDecimal)).Comparable if a natural order is defined.Datatype a presentation layer can decide how to view and how to edit the value.
Therefore a structured data model should make use of custom datatypes in order to be expressive. String, Boolean, Number and its subclasses,
Currency, etc. They should always be accepted and supported as datatypes (even though
they obviously do NOT implement this interface). Date and Calendar are mutable and have very
confusing APIs. Therefore, use JSR-310 or jodatime instead. String or a Number but logically something
special it is worth to define it as a dedicated datatype class already for the purpose of having a central
javadoc to explain it. On the other side avoid to introduce technical datatypes like String32
for a String with a maximum length of 32 characters as this is not adding value in the sense of a
real Datatype. Fields as final to
ensure being immutable. However, we are supporting Google Web Toolkit (GWT) that has additional
requirements for serialization:
Fields are NOT final. See GWT issue 1054.Constructor.AbstractSimpleDatatype| Modifier and Type | Method and Description |
|---|---|
String |
toString()
|
String toString()
String representation of this Datatype. While the general contract
of Object.toString() is very weak and mainly used for debugging, the contract here is very
strong. The returned String has to be suitable for end-users and official output to any kind of
sink. NlsMessage for this purpose and implement
NlsObject if you want to support I18N/L10N.Copyright © 2001–2015 mmm-Team. All rights reserved.