T
- The type of DataSerializablepublic abstract class AbstractDataBuilder<T extends DataSerializable> extends Object implements DataBuilder<T>
DataBuilder
that pre-defines all of
the necessary "content update" implementation required for content
versioning. Note that the builder itself is versioned to ensure that
content versioning is appropriately handled. It is highly recommended to
extend this class to implement DataManipulatorBuilder
and implement
DataContentUpdater
s as necessary for future upgradeability of
custom content.Modifier | Constructor and Description |
---|---|
protected |
AbstractDataBuilder(Class<T> requiredClass,
int supportedVersion) |
Modifier and Type | Method and Description |
---|---|
Optional<T> |
build(DataView container)
Attempts to build the provided
DataSerializable from the given
DataView . |
protected abstract Optional<T> |
buildContent(DataView container)
Builds the currently
supportedVersion variant of the intended
DataSerializable , such that all content upgrades have already
been handled by build(DataView) . |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
from, reset
protected abstract Optional<T> buildContent(DataView container) throws InvalidDataException
supportedVersion
variant of the intended
DataSerializable
, such that all content upgrades have already
been handled by build(DataView)
. This otherwise follows the
same contract as DataBuilder.build(DataView)
.container
- The container with data to build fromInvalidDataException
- If there's issues of invalid data formats
or invalid datapublic final Optional<T> build(DataView container) throws InvalidDataException
DataBuilder
DataSerializable
from the given
DataView
. If the DataView
is invalid or
missing necessary information to complete building the
DataSerializable
, Optional.empty()
may be returned.build
in interface DataBuilder<T extends DataSerializable>
container
- The container containing all necessary dataDataSerializable
, if successfulInvalidDataException
- In the event that the builder is unable to
properly construct the data serializable from the data view