java.lang.Object
com.renomad.minum.database.DbData<T>
- Direct Known Subclasses:
Inmate
An abstract data type meant to be used with the database
The Minum database is very plain - data is stored in a strongly-typed Java data collection in memory, and also written to disk.
Each database is responsible for one type of data. For example, you might create a database for Person information, such as name, age, and favorite ice cream flavor. To do so, you would design a class representing the Person, which would include those properties.
Users must supply an implementation of the serialize() and
deserialize(String) methods.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract Tdeserialize(String serializedText) Deserialize the string into a strongly-typed object.protected abstract longgetIndex()Each piece of data is made unique by having its own index valueprotected abstract StringSerializes this object into a string representation.protected abstract voidsetIndex(long index)
-
Constructor Details
-
DbData
public DbData()
-
-
Method Details
-
serialize
Serializes this object into a string representation.An example:
public String serialize() { return serializeHelper(index, a, b); }- Returns:
- this type serialized to a string - use
SerializationUtils.serializeHelper(Object[]) - See Also:
-
deserialize
Deserialize the string into a strongly-typed object. See helper methodSerializationUtils.deserializeHelper(String)to split a serialized string into tokens for rebuilding the object. See alsoserialize()An example:
public Foo deserialize(String serializedText) { final var tokens = deserializeHelper(serializedText); return new Foo( Integer.parseInt(tokens.get(0)), Integer.parseInt(tokens.get(1)), tokens.get(2) ); }- Parameters:
serializedText- the serialized string- Returns:
- this type deserialized from a string
- See Also:
-
getIndex
protected abstract long getIndex()Each piece of data is made unique by having its own index value -
setIndex
protected abstract void setIndex(long index)
-