E
- The type of extent containing this locationpublic final class Location<E extends Extent> extends Object implements DataHolder
Extent
.
This class is primarily a helper class to represent a location in a
particular Extent
. The methods provided are proxy methods to ones
on Extent
.
Each instance can be used to either represent a block or a location on a continuous coordinate system. Internally, positions are stored using doubles. When a block-related method is used, the components of the position are each rounded to an integer.
Locations are immutable. Methods that change the properties of the location create a new instance.
Constructor and Description |
---|
Location(E extent,
double x,
double y,
double z)
Create a new instance.
|
Location(E extent,
int x,
int y,
int z)
Create a new instance.
|
Location(E extent,
com.flowpowered.math.vector.Vector3d position)
Create a new instance.
|
Location(E extent,
com.flowpowered.math.vector.Vector3i blockPosition)
Create a new instance.
|
Modifier and Type | Method and Description |
---|---|
Location<E> |
add(double x,
double y,
double z)
Add vector components to the position on this instance, returning
a new Location instance.
|
Location<E> |
add(com.flowpowered.math.vector.Vector3d v)
Add another Vector3d to the position on this instance, returning
a new Location instance.
|
ScheduledBlockUpdate |
addScheduledUpdate(int priority,
int ticks)
Adds a new
ScheduledBlockUpdate to this block. |
DataHolder |
copy()
Creates a clone copy of this
ValueContainer as a new
ValueContainer such that all the BaseValue s are
safely duplicated to the new instance. |
DataTransactionResult |
copyFrom(DataHolder that)
Performs an absolute copy of all
Value s and
ValueContainer s to this CompositeValueStore such that
any overlapping Value s are offered for replacement. |
DataTransactionResult |
copyFrom(DataHolder that,
MergeFunction strategy)
Performs an absolute copy of all
Value s and
ValueContainer s to this CompositeValueStore such that
any overlapping Value s are offered for replacement. |
BlockSnapshot |
createSnapshot()
Get a snapshot of this block at the current point in time.
|
boolean |
digBlock()
Simulate the digging of the block as if a player had done so.
|
boolean |
digBlockWith(ItemStack itemStack)
Simulate the digging of the block with the given tool as if a player had
done so.
|
boolean |
equals(Object other) |
<T extends DataManipulator<?,?>> |
get(Class<T> containerClass)
|
<E> Optional<E> |
get(Key<? extends BaseValue<E>> key)
|
BiomeType |
getBiome()
Gets the block at this location.
|
com.flowpowered.math.vector.Vector2i |
getBiomePosition()
Gets the underlying biome position.
|
BlockState |
getBlock()
Get the
BlockState for this position. |
int |
getBlockDigTimeWith(ItemStack itemStack)
Gets the time it takes to dig this block the specified item in ticks.
|
com.flowpowered.math.vector.Vector3i |
getBlockPosition()
Get the underlying block position.
|
BlockType |
getBlockType()
Get the base type of block.
|
int |
getBlockX()
Get the floored X component of this instance's position.
|
int |
getBlockY()
Get the floored Y component of this instance's position.
|
int |
getBlockZ()
Get the floored Z component of this instance's position.
|
Collection<DataManipulator<?,?>> |
getContainers()
Gets an copied collection of all known
ValueContainer s
belonging to this CompositeValueStore . |
E |
getExtent()
Get the underlying extent.
|
Collection<Direction> |
getIndirectlyPoweredBlockFaces()
Get all faces of this block that are indirectly powered.
|
Set<Key<?>> |
getKeys()
Gets all applicable
Key s for this ValueContainer . |
<T extends DataManipulator<?,?>> |
getOrCreate(Class<T> containerClass)
|
<E> E |
getOrElse(Key<? extends BaseValue<E>> key,
E defaultValue)
Attempts to get the underlying value if available.
|
<E> E |
getOrNull(Key<? extends BaseValue<E>> key)
Attempts to get the underlying value if available and supported.
|
com.flowpowered.math.vector.Vector3d |
getPosition()
Get the underlying position.
|
Collection<Direction> |
getPoweredBlockFaces()
Get all the faces of this block that are directly powered.
|
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 . |
Location<E> |
getRelative(Direction direction)
Gets the location next to this one in the give direction.
|
Collection<ScheduledBlockUpdate> |
getScheduledUpdates()
Gets a list of
ScheduledBlockUpdate s on this block. |
Optional<TileEntity> |
getTileEntity()
Gets the associated
TileEntity on this block. |
<E,V extends BaseValue<E>> |
getValue(Key<V> key)
|
Set<ImmutableValue<?>> |
getValues()
Gets all applicable
BaseValue s associated with this
ValueContainer . |
double |
getX()
Get the X component of this instance's position.
|
double |
getY()
Get the Y component of this instance's position.
|
double |
getZ()
Get the Z component of this instance's position.
|
boolean |
hasBiome()
Returns true if this location has a biome at its
getBiomePosition() . |
boolean |
hasBlock()
Returns true if this location has a block at its
getBlockPosition() ()}. |
int |
hashCode() |
boolean |
hasTileEntity()
Checks for whether the block at this position contains tile entity data.
|
boolean |
inExtent(Extent extent)
Returns true if this location is in the given extent.
|
void |
interactBlock(Direction side)
Simulates the interaction with this object as if a player had done so.
|
void |
interactBlockWith(ItemStack itemStack,
Direction side)
Simulates the interaction with this object using the given item as if
the player had done so.
|
boolean |
isBlockFaceFlammable(Direction direction)
Test whether the given face of the block can catch fire.
|
boolean |
isBlockFaceIndirectlyPowered(Direction direction)
Test whether the face in the given direction is indirectly powered.
|
boolean |
isBlockFacePowered(Direction direction)
Test whether the face in the given direction is powered.
|
<E> DataTransactionResult |
offer(BaseValue<E> value)
Offers the given
BaseValue as defined by the provided
Key such that a DataTransactionResult is returned for
any successful, rejected, and replaced BaseValue s from this
CompositeValueStore . |
DataTransactionResult |
offer(DataManipulator<?,?> valueContainer)
Offers the given
ValueContainer such that all of the available
BaseValue s from the given ValueContainer are offered
to this CompositeValueStore . |
DataTransactionResult |
offer(DataManipulator<?,?> valueContainer,
MergeFunction function)
Offers the given
ValueContainer such that all of the available
BaseValue s from the given ValueContainer are offered
to this CompositeValueStore . |
DataTransactionResult |
offer(Iterable<DataManipulator<?,?>> valueHolders)
Offers all provided
ValueContainer s to this
CompositeValueStore much like CompositeValueStore.offer(ValueContainer)
except all in a single batch. |
DataTransactionResult |
offer(Iterable<DataManipulator<?,?>> values,
MergeFunction function)
Offers all provided
ValueContainer s to this
CompositeValueStore much like CompositeValueStore.offer(ValueContainer)
except all in a single batch. |
<E> DataTransactionResult |
offer(Key<? extends BaseValue<E>> key,
E value)
Offers the given
value as defined by the provided Key
such that a DataTransactionResult is returned for any
successful, rejected, and replaced BaseValue s from this
CompositeValueStore . |
DataTransactionResult |
remove(BaseValue<?> value)
Attempts to remove the provided
BaseValue . |
DataTransactionResult |
remove(Class<? extends DataManipulator<?,?>> containerClass)
Attempts to remove all
Value s associated with the class of the
provided ValueContainer class. |
DataTransactionResult |
remove(Key<?> key)
Attempts to remove the data associated with the provided
Key . |
void |
removeBlock()
Remove the block at this position by replacing it with
BlockTypes.AIR . |
void |
removeScheduledUpdate(ScheduledBlockUpdate update)
Removes a
ScheduledBlockUpdate from this block. |
void |
restoreSnapshot(BlockSnapshot snapshot,
boolean force,
boolean notifyNeighbors)
Replace the block at this position with a copy of the given snapshot.
|
void |
setBlock(BlockState state)
Replace the block at this position with a new state.
|
void |
setBlock(BlockState state,
boolean notifyNeighbors)
Replace the block at this position with a new state.
|
void |
setBlockType(BlockType type)
Replace the block type at this position by a new type.
|
void |
setBlockType(BlockType type,
boolean notifyNeighbors)
Replace the block type at this position by a new type.
|
Location<E> |
setExtent(E extent)
Create a new instance with a new extent.
|
Location<E> |
setPosition(com.flowpowered.math.vector.Vector3d position)
Create a new instance with a new position.
|
void |
setRawData(DataContainer container)
Attempts to set all data of this
DataHolder according to the
DataContainer 's held information. |
Location<E> |
sub(double x,
double y,
double z)
Subtract vector components to the position on this instance, returning
a new Location instance.
|
Location<E> |
sub(com.flowpowered.math.vector.Vector3d v)
Subtract another Vector3d to the position on this instance, returning
a new Location instance.
|
boolean |
supports(BaseValue<?> baseValue)
Checks if the provided
BaseValue is supported. |
boolean |
supports(Class<? extends DataManipulator<?,?>> holderClass)
|
boolean |
supports(Key<?> key)
Checks if the given
Key is supported by this
ValueContainer . |
DataContainer |
toContainer()
Serializes this object into a comprehensible
DataContainer . |
String |
toString() |
<E> DataTransactionResult |
transform(Key<? extends BaseValue<E>> key,
Function<E,E> function)
Applies a transformation on the provided
BaseValue such that
the return value of Function.apply(Object) will become the end
resulting value set into this CompositeValueStore . |
DataTransactionResult |
undo(DataTransactionResult result)
Attempts to "revert" a
DataTransactionResult such that any
of the DataTransactionResult.getReplacedData() are offered
back, and any DataTransactionResult.getSuccessfulData() are
removed if they were not the same types as any exising in the
replaced values. |
boolean |
validateRawData(DataContainer container)
Validates the container with known data required to set the raw data to
this
DataHolder . |
public Location(E extent, com.flowpowered.math.vector.Vector3d position)
extent
- The extentposition
- The positionpublic Location(E extent, double x, double y, double z)
extent
- The extentx
- The X-axis positiony
- The Y-axis positionz
- The Z-axis positionpublic Location(E extent, com.flowpowered.math.vector.Vector3i blockPosition)
extent
- The extentblockPosition
- The positionpublic Location(E extent, int x, int y, int z)
extent
- The extentx
- The X-axis positiony
- The Y-axis positionz
- The Z-axis positionpublic E getExtent()
Note: This can be null if the Extent
is unloaded and garbage
collected.
IllegalStateException
- If the Extent
is nullpublic com.flowpowered.math.vector.Vector3d getPosition()
public com.flowpowered.math.vector.Vector3i getBlockPosition()
public com.flowpowered.math.vector.Vector2i getBiomePosition()
public double getX()
public double getY()
public double getZ()
public int getBlockX()
public int getBlockY()
public int getBlockZ()
public boolean inExtent(Extent extent)
Object.equals(Object)
check.extent
- The extent to checkpublic boolean hasBiome()
getBiomePosition()
.public boolean hasBlock()
getBlockPosition()
()}.public Location<E> setExtent(E extent)
extent
- The new extentpublic Location<E> setPosition(com.flowpowered.math.vector.Vector3d position)
position
- The new positionpublic Location<E> sub(com.flowpowered.math.vector.Vector3d v)
v
- The vector to subtractpublic Location<E> sub(double x, double y, double z)
x
- The x componenty
- The y componentz
- The z componentpublic Location<E> add(com.flowpowered.math.vector.Vector3d v)
v
- The vector to addpublic Location<E> add(double x, double y, double z)
x
- The x componenty
- The y componentz
- The z componentpublic Location<E> getRelative(Direction direction)
direction
- The direction to look inpublic BiomeType getBiome()
public BlockType getBlockType()
The type does not include block data such as the contents of inventories.
public BlockState getBlock()
BlockState
for this position.public boolean hasTileEntity()
public Optional<TileEntity> getTileEntity()
TileEntity
on this block.public void setBlock(BlockState state)
This will remove any extended block data at the given position.
state
- The new block statepublic void setBlock(BlockState state, boolean notifyNeighbors)
This will remove any extended block data at the given position.
state
- The new block statenotifyNeighbors
- Whether or not you want to notify neighboring
blocks of this change. If true, this may cause blocks to change.public void setBlockType(BlockType type)
This will remove any extended block data at the given position.
type
- The new typepublic void setBlockType(BlockType type, boolean notifyNeighbors)
This will remove any extended block data at the given position.
type
- The new typenotifyNeighbors
- Whether or not you want to notify neighboring
blocks of this change. If true, this may cause blocks to change.public void restoreSnapshot(BlockSnapshot snapshot, boolean force, boolean notifyNeighbors)
Changing the snapshot afterwards will not affect the block that has been placed at this location.
snapshot
- The snapshotforce
- If true, forces block state to be set even if the
BlockType
does not match the snapshot one.notifyNeighbors
- Whether or not you want to notify neighboring
blocks of this change. If true, this may cause blocks to change.public void removeBlock()
BlockTypes.AIR
.
This will remove any extended block data at the given position.
public DataTransactionResult remove(Class<? extends DataManipulator<?,?>> containerClass)
CompositeValueStore
Value
s associated with the class of the
provided ValueContainer
class. All values that were successfully
removed will be provided in
DataTransactionResult.getReplacedData()
. If the data can not be
removed, the result will be an expected
DataTransactionResult.Type.FAILURE
.remove
in interface CompositeValueStore<DataHolder,DataManipulator<?,?>>
containerClass
- The container classpublic DataTransactionResult remove(BaseValue<?> value)
CompositeValueStore
BaseValue
. All values that were
successfully removed will be provided in
DataTransactionResult.getReplacedData()
. If the data can not be
removed, the result will be an expected
DataTransactionResult.Type.FAILURE
.remove
in interface CompositeValueStore<DataHolder,DataManipulator<?,?>>
value
- The value to removepublic DataTransactionResult remove(Key<?> key)
CompositeValueStore
Key
.
All values that were successfully removed will be provided in
DataTransactionResult.getReplacedData()
. If the data can not be
removed, the result will be an expected
DataTransactionResult.Type.FAILURE
.remove
in interface CompositeValueStore<DataHolder,DataManipulator<?,?>>
key
- The key of the datapublic void interactBlock(Direction side)
side
- The side of the block to interact withpublic void interactBlockWith(ItemStack itemStack, Direction side)
itemStack
- The itemside
- The side of the block to interact withpublic boolean digBlock()
public boolean digBlockWith(ItemStack itemStack)
itemStack
- The toolpublic int getBlockDigTimeWith(ItemStack itemStack)
itemStack
- The item to pretend-dig withpublic boolean isBlockFacePowered(Direction direction)
direction
- The directionpublic boolean isBlockFaceIndirectlyPowered(Direction direction)
direction
- The directionpublic Collection<Direction> getPoweredBlockFaces()
public Collection<Direction> getIndirectlyPoweredBlockFaces()
public boolean isBlockFaceFlammable(Direction direction)
direction
- The face of the block to checkpublic BlockSnapshot createSnapshot()
A snapshot is disconnected from the Extent
that it was taken
from so changes to the original block do not affect the snapshot.
public Collection<ScheduledBlockUpdate> getScheduledUpdates()
ScheduledBlockUpdate
s on this block.public ScheduledBlockUpdate addScheduledUpdate(int priority, int ticks)
ScheduledBlockUpdate
to this block.priority
- The priority of the scheduled updateticks
- The ticks until the scheduled update should be processedpublic void removeScheduledUpdate(ScheduledBlockUpdate update)
ScheduledBlockUpdate
from this block.update
- The ScheduledBlockUpdate to removepublic <T extends Property<?,?>> Optional<T> getProperty(Class<T> propertyClass)
DataHolder
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.
getProperty
in interface DataHolder
T
- The type of propertypropertyClass
- The property classpublic Collection<Property<?,?>> getProperties()
DataHolder
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
.
getProperties
in interface DataHolder
Property
spublic boolean validateRawData(DataContainer container)
DataHolder
DataHolder
. If the container is incomplete or contains
invalid data, false
is returned.
This validation should be checked prior to calling
DataHolder.setRawData(DataContainer)
to avoid exceptions.
validateRawData
in interface DataHolder
container
- The raw data to validatepublic void setRawData(DataContainer container) throws InvalidDataException
DataHolder
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.
setRawData
in interface DataHolder
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 refusepublic DataContainer toContainer()
DataSerializable
DataContainer
.toContainer
in interface DataSerializable
public <T extends DataManipulator<?,?>> Optional<T> get(Class<T> containerClass)
CompositeValueStore
ValueContainer
of type H
if the
ValueContainer
is compatible. Since the return type is an
Optional
, a short way of checking compatibility and presence
of the requested data is to mimic the following:
// MyCompositeValueStore extends CompositeValueStore<MyCompositeValueStore, DataManipulator<?>>
MyCompositeValueStore valueStore;
final Optional<DisplayNameData> displayOptional = valueStore.get(DisplayNameData.class);
if (displayOptional.isPresent()) {
// We know that we have a present DataManipulator and it's supported
System.out.println(displayOptional.get().displayName().get().toString());
}
This is the equivalent as performing the following:
MyCompositeValueStore valueStore;
if (valueStore.supports(DisplayNameData.class)) {
System.out.println(valueStore.getOrNull(DisplayNameData.class).displayName().get().toString());
}
The advantage of this returning an Optional
is that the
ValueContainer
may be unsupported, the required data missing
and ignoring the possibility of null
s, it is a guarantee that if
the Optional.isPresent()
is true
, the
ValueContainer
not only is supported, but there is already pre-
existing data for the ValueContainer
.
If it is necessary to ignore the Optional
,
Optional.orNull()
can be used to return a potentially
null
ValueContainer
.
get
in interface CompositeValueStore<DataHolder,DataManipulator<?,?>>
T
- The type of ValueContainer
containerClass
- The container classpublic <E> Optional<E> get(Key<? extends BaseValue<E>> key)
ValueContainer
BaseValue
linked to the provided Key
. If the Key
is not
supported, Optional.absent()
is returned. It is important
to check for support of a Key
by either calling
ValueContainer.supports(BaseValue)
or ValueContainer.supports(Key)
.get
in interface ValueContainer<DataHolder>
E
- The type of valuekey
- The key linking thepublic <T extends DataManipulator<?,?>> Optional<T> getOrCreate(Class<T> containerClass)
CompositeValueStore
ValueContainer
of type H
if the
ValueContainer
is compatible. If insufficient data is available
to provide a ValueContainer
with all Value
s preset, a
new instance of the ValueContainer
is returned with "default"
values. Since the return type is an Optional
, a short way of
checking compatibility and presence of the requested data is to mimic
the following:
// MyCompositeValueStore extends CompositeValueStore<MyCompositeValueStore, DataManipulator<?>>
MyCompositeValueStore valueStore;
final Optional<DisplayNameData> displayOptional = valueStore.getOrCreate(DisplayNameData.class);
if (displayOptional.isPresent()) {
// We know that we have a present DataManipulator and it's supported
System.out.println(displayOptional.get().displayName().get().toString());
}
This is the equivalent as performing the following:
MyCompositeValueStore valueStore;
if (valueStore.supports(DisplayNameData.class)) {
System.out.println(valueStore.get(DisplayNameData.class).get().displayName().get().toString());
}
The advantage of this returning an Optional
is that the
ValueContainer
may be unsupported, the required data missing
and ignoring the possibility of null
s, it is a guarantee that if
the Optional.isPresent()
is true
, the
ValueContainer
not only is supported, but some default values
can be generated to create the desired ValueContainer
.
If it is necessary to ignore the Optional
,
Optional.orNull()
can be used to return a potentially
null
ValueContainer
.
getOrCreate
in interface CompositeValueStore<DataHolder,DataManipulator<?,?>>
T
- The type of ValueContainer
containerClass
- The container class@Nullable public <E> E getOrNull(Key<? extends BaseValue<E>> key)
ValueContainer
BaseValue
is not supported whatsoever by this
ValueContainer
, an exception is thrown.getOrNull
in interface ValueContainer<DataHolder>
E
- The type of valuekey
- The Key
backing the BaseValue
public <E> E getOrElse(Key<? extends BaseValue<E>> key, E defaultValue)
ValueContainer
defaultValue
is returned, if the
BaseValue
is even supported.getOrElse
in interface ValueContainer<DataHolder>
E
- The type of valuekey
- The key backing the BaseValue
defaultValue
- The value to default to if not setpublic <E> DataTransactionResult offer(Key<? extends BaseValue<E>> key, E value)
CompositeValueStore
value
as defined by the provided Key
such that a DataTransactionResult
is returned for any
successful, rejected, and replaced BaseValue
s from this
CompositeValueStore
.offer
in interface CompositeValueStore<DataHolder,DataManipulator<?,?>>
E
- The type of valuekey
- The key to the value to setvalue
- The value to setpublic DataTransactionResult offer(Iterable<DataManipulator<?,?>> valueHolders)
CompositeValueStore
ValueContainer
s to this
CompositeValueStore
much like CompositeValueStore.offer(ValueContainer)
except all in a single batch. The end result of the values successfully
offered, rejected, and replaced are stored in the returned
DataTransactionResult
.offer
in interface CompositeValueStore<DataHolder,DataManipulator<?,?>>
valueHolders
- The values to setpublic DataTransactionResult offer(Iterable<DataManipulator<?,?>> values, MergeFunction function)
CompositeValueStore
ValueContainer
s to this
CompositeValueStore
much like CompositeValueStore.offer(ValueContainer)
except all in a single batch. The end result of the values successfully
offered, rejected, and replaced are stored in the returned
DataTransactionResult
. Any merge conflicts are resolved through
the MergeFunction
.offer
in interface CompositeValueStore<DataHolder,DataManipulator<?,?>>
values
- The values to setfunction
- The function to resolve the valuespublic <E> DataTransactionResult offer(BaseValue<E> value)
CompositeValueStore
BaseValue
as defined by the provided
Key
such that a DataTransactionResult
is returned for
any successful, rejected, and replaced BaseValue
s from this
CompositeValueStore
.offer
in interface CompositeValueStore<DataHolder,DataManipulator<?,?>>
E
- The type of the element wrapped by the valuevalue
- The value to setpublic DataTransactionResult offer(DataManipulator<?,?> valueContainer)
CompositeValueStore
ValueContainer
such that all of the available
BaseValue
s from the given ValueContainer
are offered
to this CompositeValueStore
. The end result of the values
successfully offered, rejected, and replaced are stored in the returned
DataTransactionResult
.offer
in interface CompositeValueStore<DataHolder,DataManipulator<?,?>>
valueContainer
- The value to setpublic DataTransactionResult offer(DataManipulator<?,?> valueContainer, MergeFunction function)
CompositeValueStore
ValueContainer
such that all of the available
BaseValue
s from the given ValueContainer
are offered
to this CompositeValueStore
. The end result of the values
successfully offered, rejected, and replaced are stored in the returned
DataTransactionResult
. Any overlaps of data are merged via
the MergeFunction
.offer
in interface CompositeValueStore<DataHolder,DataManipulator<?,?>>
valueContainer
- The value to setfunction
- The merge functionpublic DataTransactionResult undo(DataTransactionResult result)
CompositeValueStore
DataTransactionResult
such that any
of the DataTransactionResult.getReplacedData()
are offered
back, and any DataTransactionResult.getSuccessfulData()
are
removed if they were not the same types as any exising in the
replaced values.undo
in interface CompositeValueStore<DataHolder,DataManipulator<?,?>>
result
- The result to undopublic boolean supports(Class<? extends DataManipulator<?,?>> holderClass)
CompositeValueStore
supports
in interface CompositeValueStore<DataHolder,DataManipulator<?,?>>
holderClass
- The container classpublic boolean supports(Key<?> key)
ValueContainer
Key
is supported by this
ValueContainer
.supports
in interface ValueContainer<DataHolder>
key
- The key to checkpublic boolean supports(BaseValue<?> baseValue)
ValueContainer
BaseValue
is supported.supports
in interface ValueContainer<DataHolder>
baseValue
- The base value to checkpublic <E> DataTransactionResult transform(Key<? extends BaseValue<E>> key, Function<E,E> function)
CompositeValueStore
BaseValue
such that
the return value of Function.apply(Object)
will become the end
resulting value set into this CompositeValueStore
. It is not
necessary that the input is actually present, in which case the
Key
ed data is compatible, but not necessarily present. Writing
a Function
to properly handle the potential for a null input
is required for this method to execute without exception.transform
in interface CompositeValueStore<DataHolder,DataManipulator<?,?>>
E
- The type of valuekey
- The key linked tofunction
- The function to manipulate the valuepublic DataTransactionResult copyFrom(DataHolder that)
CompositeValueStore
Value
s and
ValueContainer
s to this CompositeValueStore
such that
any overlapping Value
s are offered for replacement. The
result is provided as a DataTransactionResult
.copyFrom
in interface CompositeValueStore<DataHolder,DataManipulator<?,?>>
that
- The other CompositeValueStore
to copy values frompublic DataTransactionResult copyFrom(DataHolder that, MergeFunction strategy)
CompositeValueStore
Value
s and
ValueContainer
s to this CompositeValueStore
such that
any overlapping Value
s are offered for replacement. The
result is provided as a DataTransactionResult
.copyFrom
in interface CompositeValueStore<DataHolder,DataManipulator<?,?>>
that
- The other CompositeValueStore
to copy values fromstrategy
- The function to resolve merge conflictspublic Collection<DataManipulator<?,?>> getContainers()
CompositeValueStore
ValueContainer
s
belonging to this CompositeValueStore
. An individual
ValueContainer
can be used for data processing for various
purposes.getContainers
in interface CompositeValueStore<DataHolder,DataManipulator<?,?>>
ValueContainer
s originating
from this value storepublic <E,V extends BaseValue<E>> Optional<V> getValue(Key<V> key)
ValueContainer
getValue
in interface ValueContainer<DataHolder>
E
- The type of the return typeV
- The type of valuekey
- The key linked to the BaseValue
public DataHolder copy()
ValueContainer
ValueContainer
as a new
ValueContainer
such that all the BaseValue
s are
safely duplicated to the new instance.copy
in interface ValueContainer<DataHolder>
public Set<Key<?>> getKeys()
ValueContainer
Key
s for this ValueContainer
.
Changes can not be made to the set to alter the ValueContainer
,
nor can the BaseValue
s be changed with the provided
ImmutableSet
.getKeys
in interface ValueContainer<DataHolder>
Key
spublic Set<ImmutableValue<?>> getValues()
ValueContainer
BaseValue
s associated with this
ValueContainer
. As the data backed by the values are copied,
any modifications to the BaseValue
s will not be reflected onto
this ValueContainer
.getValues
in interface ValueContainer<DataHolder>