public interface DataHolder extends DataSerializable, CompositeValueStore<DataHolder,DataManipulator<?,?>>
Modifier and Type | Method and Description |
---|---|
Collection<Property<?,?>> |
getProperties()
Gets an immutable collection of all known
Property s pertaining to
this DataHolder . |
<T extends Property<?,?>> |
getProperty(Class<T> propertyClass)
Attempts to retrieve a specific
Property type of this
DataHolder . |
void |
setRawData(DataContainer container)
Attempts to set all data of this
DataHolder according to the
DataContainer 's held information. |
boolean |
validateRawData(DataContainer container)
Validates the container with known data required to set the raw data to
this
DataHolder . |
toContainer
<T extends Property<?,?>> Optional<T> getProperty(Class<T> propertyClass)
Property
type of this
DataHolder
. If the property is not applicable,
Optional.absent()
is returned.
Property
s can define various immutable information about a
DataHolder
that is dependent on the instance of the holder.
As Property
s cannot be changed, the DataHolder
can
not change the information about it's own properties either.
T
- The type of propertypropertyClass
- The property classCollection<Property<?,?>> getProperties()
Property
s pertaining to
this DataHolder
.
Property
s can not be changed such that the property is attached
to the instance of the residing DataHolder
.
Property
sboolean validateRawData(DataContainer container)
DataHolder
. If the container is incomplete or contains
invalid data, false
is returned.
This validation should be checked prior to calling
setRawData(DataContainer)
to avoid exceptions.
container
- The raw data to validatevoid setRawData(DataContainer container) throws InvalidDataException
DataHolder
according to the
DataContainer
's held information. Using this to modify known
DataManipulator
is unsupported and if the data is invalid, an
InvalidDataException
is thrown.
This setter is used to provide setting custom data that is not
represented by the Data API, including forge mods and other
unknown data. Attempts at validating known DataManipulator
s
contained in the data container are made with the assumption that all
necessary data exists.
container
- A container containing all raw data to set on this
data holderInvalidDataException
- If the container is missing or has invalid
data that this holder will refuse