Package io.datarouter.model.databean
Interface Databean<PK extends PrimaryKey<PK>,D extends Databean<PK,D>>
- All Superinterfaces:
Comparable<Databean<?,?>>
- All Known Subinterfaces:
IndexEntry<IK,IE,PK,D>,KeyIndexEntry<IK,IE,PK,D>,MultiIndexEntry<IK,IE,PK,D>,MultiKeyIndexEntry<IK,IE,PK,D>,UniqueIndexEntry<IK,IE,PK,D>,UniqueKeyIndexEntry<IK,IE,PK,D>
- All Known Implementing Classes:
BaseDatabean,BaseMultiIndexEntry,BaseUniqueKeyIndexEntry,FieldlessIndexEntry
public interface Databean<PK extends PrimaryKey<PK>,D extends Databean<PK,D>> extends Comparable<Databean<?,?>>
A Databean is an atomic unit of serialization corresponding to a MySQL row or a Memcached item. Generally, all fields
of the databean are read from the datastore together even if some are not wanted, and they are written to the
datastore together even if some are not updated.
Every Databean has a single PrimaryKey which determines its uniqueness and ordering among other databeans of the same
type. This is determined by the hashCode(), equals(), and compareTo() methods in the PrimaryKey and should generally
not be modified.
While Databeans consist of more code than JDO or JPA style databeans, they add many rich features such as: a strongly
typed PrimaryKey, equality, ordering, automatic schema updating, the ability to define multiple Fielders for
different storage formats, and the ability to serialize to arbitrary formats like JSON, Memcached, a file, or
HBase. Databeans are often the foundation of a project, and comprise a minority of the code so the trade-off is
usually worthwhile.
-
Method Summary
Modifier and Type Method Description StringgetDatabeanName()PKgetKey()StringgetKeyFieldName()List<Field<?>>getKeyFields()Supplier<PK>getKeySupplier()
-
Method Details
-
getDatabeanName
String getDatabeanName() -
getKeySupplier
-
getKeyFieldName
String getKeyFieldName() -
getKey
PK getKey() -
getKeyFields
-