Package org.spongepowered.api.data
Interface DataHolder.Mutable
-
- All Superinterfaces:
DataHolder
,ValueContainer
- All Known Subinterfaces:
Aerial
,Ageable
,Agent
,Ambient
,Animal
,Aquatic
,Archetype<S,E>
,AreaEffectCloud
,ArmorStand
,Arrow
,ArrowEntity
,Banner
,Barrel
,Bat
,Beacon
,Bed
,Bee
,Beehive
,Bell
,BlastFurnace
,Blaze
,BlockEntity
,BlockEntityArchetype
,BlockOccupiedMinecart
,Boat
,Boss
,BrewingStand
,Campfire
,CarrierBlockEntity
,CarrierMinecart<M>
,Cat
,CaveSpider
,Chest
,ChestMinecart
,Chicken
,ClientPlayer
,Cod
,CommandBlock
,CommandBlockMinecart
,Comparator
,ComplexLiving<T>
,ComplexLivingPart<P>
,Conduit
,Cow
,Creature
,Creeper
,DamagingProjectile
,DaylightDetector
,DirectionRelativeDataHolder.Mutable
,Dispenser
,Dolphin
,Donkey
,DragonFireball
,Dropper
,Drowned
,Egg
,ElderGuardian
,EnchantmentTable
,EndCrystal
,EnderChest
,EnderDragon
,EnderDragonPart
,Enderman
,Endermite
,EnderPearl
,EndGateway
,EndPortal
,Entity
,EntityArchetype
,EntityTargetingProjectile
,Evoker
,EvokerFangs
,ExperienceBottle
,ExperienceOrb
,Explosive
,ExplosiveFireball
,EyeOfEnder
,FallingBlock
,FireballEntity
,FireworkRocket
,Fish
,FishingBobber
,FluidStack
,Fox
,Furnace
,FurnaceBlockEntity
,FurnaceMinecart
,FusedExplosive
,Ghast
,Giant
,Golem
,Guardian
,Hanging
,Hoglin
,Hopper
,HopperMinecart
,Horse
,HorseLike
,Hostile
,Human
,Humanoid
,Husk
,Illager
,Illusioner
,IronGolem
,Item
,ItemFrame
,ItemStack
,Jigsaw
,Jukebox
,LeashKnot
,Lectern
,LightningBolt
,Living
,Llama
,LlamaLike
,LlamaSpit
,LocalPlayer
,MagmaCube
,MapInfo
,Merchant
,Minecart
,MinecartLike
,MobSpawner
,Monster
,Mooshroom
,Mule
,NameableBlockEntity
,NameableCarrierBlockEntity
,Ocelot
,PackHorse
,Painting
,Panda
,Parrot
,Patroller
,Phantom
,Pig
,Piglin
,PiglinBrute
,PiglinLike
,Pillager
,Piston
,Player
,PolarBear
,Potion
,PrimedTNT
,Projectile
,Pufferfish
,Rabbit
,Raider
,Ranger
,Ravager
,RemotePlayer
,Salmon
,SchoolingFish
,SerializableDataHolder.Mutable
,ServerLocation
,ServerPlayer
,Sheep
,Shulker
,ShulkerBox
,ShulkerBullet
,Sign
,Silverfish
,Sittable
,Skeleton
,SkeletonHorse
,SkeletonLike
,Skull
,Slime
,SmallFireball
,Smoker
,Snowball
,SnowGolem
,Spawner
,SpawnerMinecart
,SpectralArrow
,Spellcaster
,Spider
,Squid
,Stray
,Strider
,StructureBlock
,TameableAnimal
,TameableHorse
,TNTMinecart
,Trader
,TraderLlama
,TrappedChest
,Trident
,TropicalFish
,Turtle
,User
,Vehicle
,Vex
,Villager
,Vindicator
,WanderingTrader
,WeatherEffect
,Witch
,Wither
,WitherSkeleton
,WitherSkull
,Wolf
,Zoglin
,Zombie
,ZombieHorse
,ZombieLike
,ZombieVillager
,ZombifiedPiglin
- Enclosing interface:
- DataHolder
public static interface DataHolder.Mutable extends DataHolder
Represents a data holder that allows its data to be modified.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.spongepowered.api.data.DataHolder
DataHolder.Immutable<I extends DataHolder.Immutable<I>>, DataHolder.Mutable
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default DataTransactionResult
copyFrom(ValueContainer that)
Performs an absolute copy of allValue.Mutable
s andValueContainer
s to thisDataHolder.Mutable
such that any overlappingValue.Mutable
s are offered for replacement.DataTransactionResult
copyFrom(ValueContainer that, MergeFunction function)
Performs an absolute copy of allValue.Mutable
s andValueContainer
s to thisDataHolder.Mutable
such that any overlappingValue.Mutable
s are offered for replacement.default <E> DataTransactionResult
offer(Supplier<? extends Key<? extends Value<E>>> key, E value)
Offers the givenvalue
as defined by the providedKey
such that aDataTransactionResult
is returned for any successful, rejected, and replacedValue
s from thisDataHolder.Mutable
.default <E> DataTransactionResult
offer(Supplier<? extends Key<? extends Value<E>>> key, Supplier<? extends E> value)
Offers the givenvalue
as defined by the providedKey
such that aDataTransactionResult
is returned for any successful, rejected, and replacedValue
s from thisDataHolder.Mutable
.<E> DataTransactionResult
offer(Key<? extends Value<E>> key, E value)
Offers the givenvalue
as defined by the providedKey
such that aDataTransactionResult
is returned for any successful, rejected, and replacedValue
s from thisDataHolder.Mutable
.DataTransactionResult
offer(Value<?> value)
Offers the givenValue
as defined by the providedKey
such that aDataTransactionResult
is returned for any successful, rejected, and replacedValue
s from thisDataHolder.Mutable
.default <E> DataTransactionResult
offerAll(Supplier<? extends Key<? extends CollectionValue<E,?>>> key, Collection<? extends E> elements)
default <K,V>
DataTransactionResultofferAll(Supplier<? extends Key<? extends MapValue<K,V>>> key, Map<? extends K,? extends V> map)
<E> DataTransactionResult
offerAll(Key<? extends CollectionValue<E,?>> key, Collection<? extends E> elements)
<K,V>
DataTransactionResultofferAll(Key<? extends MapValue<K,V>> key, Map<? extends K,? extends V> map)
DataTransactionResult
offerAll(CollectionValue<?,?> value)
DataTransactionResult
offerAll(MapValue<?,?> value)
default <E> DataTransactionResult
offerSingle(Supplier<? extends Key<? extends CollectionValue<E,?>>> key, E element)
default <K,V>
DataTransactionResultofferSingle(Supplier<? extends Key<? extends MapValue<K,V>>> key, K valueKey, V value)
<E> DataTransactionResult
offerSingle(Key<? extends CollectionValue<E,?>> key, E element)
<K,V>
DataTransactionResultofferSingle(Key<? extends MapValue<K,V>> key, K valueKey, V value)
default DataTransactionResult
remove(Supplier<? extends Key<?>> key)
Attempts to remove the data associated with the providedKey
.DataTransactionResult
remove(Key<?> key)
Attempts to remove the data associated with the providedKey
.default DataTransactionResult
remove(Value<?> value)
Attempts to remove the providedValue
.default <E> DataTransactionResult
removeAll(Supplier<? extends Key<? extends CollectionValue<E,?>>> key, Collection<? extends E> elements)
default <K,V>
DataTransactionResultremoveAll(Supplier<? extends Key<? extends MapValue<K,V>>> key, Map<? extends K,? extends V> map)
<E> DataTransactionResult
removeAll(Key<? extends CollectionValue<E,?>> key, Collection<? extends E> elements)
<K,V>
DataTransactionResultremoveAll(Key<? extends MapValue<K,V>> key, Map<? extends K,? extends V> map)
DataTransactionResult
removeAll(CollectionValue<?,?> value)
DataTransactionResult
removeAll(MapValue<?,?> value)
default <K> DataTransactionResult
removeKey(Supplier<? extends Key<? extends MapValue<K,?>>> key, K mapKey)
<K> DataTransactionResult
removeKey(Key<? extends MapValue<K,?>> key, K mapKey)
default <E> DataTransactionResult
removeSingle(Supplier<? extends Key<? extends CollectionValue<E,?>>> key, E element)
<E> DataTransactionResult
removeSingle(Key<? extends CollectionValue<E,?>> key, E element)
default <E> DataTransactionResult
transform(Supplier<? extends Key<? extends Value<E>>> key, Function<E,E> function)
Applies a transformation on the providedValue
such that the return value ofFunction.apply(Object)
will become the end resulting value set into thisDataHolder.Mutable
.default <E> DataTransactionResult
transform(Key<? extends Value<E>> key, Function<E,E> function)
Applies a transformation on the providedValue
such that the return value ofFunction.apply(Object)
will become the end resulting value set into thisDataHolder.Mutable
.default <E> DataTransactionResult
tryOffer(Supplier<? extends Key<? extends Value<E>>> key, E value)
Offers the givenvalue
as defined by the providedKey
such that aDataTransactionResult
is returned for any successfulValue
s from thisDataHolder.Mutable
.<E> DataTransactionResult
tryOffer(Key<? extends Value<E>> key, E value)
Offers the givenvalue
as defined by the providedKey
such that aDataTransactionResult
is returned for any successfulValue
s from thisDataHolder.Mutable
.default <E> DataTransactionResult
tryOffer(Value<E> value)
Offers the givenvalue
as defined by the providedKey
such that aDataTransactionResult
is returned for any successfulValue
s from thisDataHolder.Mutable
.DataTransactionResult
undo(DataTransactionResult result)
Attempts to "revert" aDataTransactionResult
such that any of theDataTransactionResult.replacedData()
are offered back, and anyDataTransactionResult.successfulData()
are removed if they were not the same types as any exising in the replaced values.
-
-
-
Method Detail
-
transform
default <E> DataTransactionResult transform(Key<? extends Value<E>> key, Function<E,E> function)
Applies a transformation on the providedValue
such that the return value ofFunction.apply(Object)
will become the end resulting value set into thisDataHolder.Mutable
. It is not necessary that the input is actually present, in which case theKey
ed data is compatible, but not necessarily present. Writing aFunction
to properly handle the potential for a null input is required for this method to execute without exception.- Type Parameters:
E
- The type of value- Parameters:
key
- The key linked tofunction
- The function to manipulate the value- Returns:
- The end resulting value
-
transform
default <E> DataTransactionResult transform(Supplier<? extends Key<? extends Value<E>>> key, Function<E,E> function)
Applies a transformation on the providedValue
such that the return value ofFunction.apply(Object)
will become the end resulting value set into thisDataHolder.Mutable
. It is not necessary that the input is actually present, in which case theKey
ed data is compatible, but not necessarily present. Writing aFunction
to properly handle the potential for a null input is required for this method to execute without exception.- Type Parameters:
E
- The type of value- Parameters:
key
- The key linked tofunction
- The function to manipulate the value- Returns:
- The end resulting value
-
offer
<E> DataTransactionResult offer(Key<? extends Value<E>> key, E value)
Offers the givenvalue
as defined by the providedKey
such that aDataTransactionResult
is returned for any successful, rejected, and replacedValue
s from thisDataHolder.Mutable
.- Type Parameters:
E
- The type of value- Parameters:
key
- The key to the value to setvalue
- The value to set- Returns:
- The transaction result
-
offer
default <E> DataTransactionResult offer(Supplier<? extends Key<? extends Value<E>>> key, E value)
Offers the givenvalue
as defined by the providedKey
such that aDataTransactionResult
is returned for any successful, rejected, and replacedValue
s from thisDataHolder.Mutable
.- Type Parameters:
E
- The type of value- Parameters:
key
- The key to the value to setvalue
- The value to set- Returns:
- The transaction result
-
offer
default <E> DataTransactionResult offer(Supplier<? extends Key<? extends Value<E>>> key, Supplier<? extends E> value)
Offers the givenvalue
as defined by the providedKey
such that aDataTransactionResult
is returned for any successful, rejected, and replacedValue
s from thisDataHolder.Mutable
.- Type Parameters:
E
- The type of value- Parameters:
key
- The key to the value to setvalue
- The value to set- Returns:
- The transaction result
-
offer
DataTransactionResult offer(Value<?> value)
Offers the givenValue
as defined by the providedKey
such that aDataTransactionResult
is returned for any successful, rejected, and replacedValue
s from thisDataHolder.Mutable
.- Parameters:
value
- The value to set- Returns:
- The transaction result
-
offerSingle
<E> DataTransactionResult offerSingle(Key<? extends CollectionValue<E,?>> key, E element)
-
offerSingle
default <E> DataTransactionResult offerSingle(Supplier<? extends Key<? extends CollectionValue<E,?>>> key, E element)
-
offerSingle
<K,V> DataTransactionResult offerSingle(Key<? extends MapValue<K,V>> key, K valueKey, V value)
-
offerSingle
default <K,V> DataTransactionResult offerSingle(Supplier<? extends Key<? extends MapValue<K,V>>> key, K valueKey, V value)
-
offerAll
<K,V> DataTransactionResult offerAll(Key<? extends MapValue<K,V>> key, Map<? extends K,? extends V> map)
-
offerAll
default <K,V> DataTransactionResult offerAll(Supplier<? extends Key<? extends MapValue<K,V>>> key, Map<? extends K,? extends V> map)
-
offerAll
DataTransactionResult offerAll(MapValue<?,?> value)
-
offerAll
DataTransactionResult offerAll(CollectionValue<?,?> value)
-
offerAll
<E> DataTransactionResult offerAll(Key<? extends CollectionValue<E,?>> key, Collection<? extends E> elements)
-
offerAll
default <E> DataTransactionResult offerAll(Supplier<? extends Key<? extends CollectionValue<E,?>>> key, Collection<? extends E> elements)
-
removeSingle
<E> DataTransactionResult removeSingle(Key<? extends CollectionValue<E,?>> key, E element)
-
removeSingle
default <E> DataTransactionResult removeSingle(Supplier<? extends Key<? extends CollectionValue<E,?>>> key, E element)
-
removeKey
<K> DataTransactionResult removeKey(Key<? extends MapValue<K,?>> key, K mapKey)
-
removeKey
default <K> DataTransactionResult removeKey(Supplier<? extends Key<? extends MapValue<K,?>>> key, K mapKey)
-
removeAll
DataTransactionResult removeAll(CollectionValue<?,?> value)
-
removeAll
<E> DataTransactionResult removeAll(Key<? extends CollectionValue<E,?>> key, Collection<? extends E> elements)
-
removeAll
default <E> DataTransactionResult removeAll(Supplier<? extends Key<? extends CollectionValue<E,?>>> key, Collection<? extends E> elements)
-
removeAll
DataTransactionResult removeAll(MapValue<?,?> value)
-
removeAll
<K,V> DataTransactionResult removeAll(Key<? extends MapValue<K,V>> key, Map<? extends K,? extends V> map)
-
removeAll
default <K,V> DataTransactionResult removeAll(Supplier<? extends Key<? extends MapValue<K,V>>> key, Map<? extends K,? extends V> map)
-
tryOffer
<E> DataTransactionResult tryOffer(Key<? extends Value<E>> key, E value)
Offers the givenvalue
as defined by the providedKey
such that aDataTransactionResult
is returned for any successfulValue
s from thisDataHolder.Mutable
. Intentionally, however, this differs fromoffer(Key, Object)
as it will intentionally throw an exception if the result was a failure.- Type Parameters:
E
- The type of value- Parameters:
key
- The key to the value to setvalue
- The value to set- Returns:
- The transaction result
- Throws:
IllegalArgumentException
- If the result is a failure likely due to incompatibility
-
tryOffer
default <E> DataTransactionResult tryOffer(Supplier<? extends Key<? extends Value<E>>> key, E value)
Offers the givenvalue
as defined by the providedKey
such that aDataTransactionResult
is returned for any successfulValue
s from thisDataHolder.Mutable
. Intentionally, however, this differs fromoffer(Key, Object)
as it will intentionally throw an exception if the result was a failure.- Type Parameters:
E
- The type of value- Parameters:
key
- The key to the value to setvalue
- The value to set- Returns:
- The transaction result
- Throws:
IllegalArgumentException
- If the result is a failure likely due to incompatibility
-
tryOffer
default <E> DataTransactionResult tryOffer(Value<E> value) throws IllegalArgumentException
Offers the givenvalue
as defined by the providedKey
such that aDataTransactionResult
is returned for any successfulValue
s from thisDataHolder.Mutable
. Intentionally, however, this differs fromoffer(Key, Object)
as it will intentionally throw an exception if the result was a failure.- Type Parameters:
E
- The type of value- Parameters:
value
- The value to set- Returns:
- The transaction result
- Throws:
IllegalArgumentException
- If the result is a failure likely due to incompatibility
-
remove
default DataTransactionResult remove(Value<?> value)
Attempts to remove the providedValue
. All values that were successfully removed will be provided inDataTransactionResult.replacedData()
. If the data can not be removed, the result will be an expectedDataTransactionResult.Type.FAILURE
.- Parameters:
value
- The value to remove- Returns:
- The transaction result
-
remove
DataTransactionResult remove(Key<?> key)
Attempts to remove the data associated with the providedKey
. All values that were successfully removed will be provided inDataTransactionResult.replacedData()
. If the data can not be removed, the result will be an expectedDataTransactionResult.Type.FAILURE
.- Parameters:
key
- The key of the data- Returns:
- The transaction result
-
remove
default DataTransactionResult remove(Supplier<? extends Key<?>> key)
Attempts to remove the data associated with the providedKey
. All values that were successfully removed will be provided inDataTransactionResult.replacedData()
. If the data can not be removed, the result will be an expectedDataTransactionResult.Type.FAILURE
.- Parameters:
key
- The key of the data- Returns:
- The transaction result
-
undo
DataTransactionResult undo(DataTransactionResult result)
Attempts to "revert" aDataTransactionResult
such that any of theDataTransactionResult.replacedData()
are offered back, and anyDataTransactionResult.successfulData()
are removed if they were not the same types as any exising in the replaced values.- Parameters:
result
- The result to undo- Returns:
- The result of the undo
-
copyFrom
default DataTransactionResult copyFrom(ValueContainer that)
Performs an absolute copy of allValue.Mutable
s andValueContainer
s to thisDataHolder.Mutable
such that any overlappingValue.Mutable
s are offered for replacement. The result is provided as aDataTransactionResult
.- Parameters:
that
- The otherDataHolder.Mutable
to copy values from- Returns:
- The transaction result
-
copyFrom
DataTransactionResult copyFrom(ValueContainer that, MergeFunction function)
Performs an absolute copy of allValue.Mutable
s andValueContainer
s to thisDataHolder.Mutable
such that any overlappingValue.Mutable
s are offered for replacement. The result is provided as aDataTransactionResult
.- Parameters:
that
- The otherDataHolder.Mutable
to copy values fromfunction
- The function to resolve merge conflicts- Returns:
- The transaction result
-
-