Package org.spongepowered.api.data
Interface DataHolder.Mutable
- All Superinterfaces:
DataHolder
,ValueContainer
- All Known Subinterfaces:
Aerial
,Ageable
,Agent
,Allay
,Ambient
,Animal
,Aquatic
,Archetype<S,
,E> AreaEffectCloud
,ArmorStand
,Arrow
,ArrowEntity
,Axolotl
,Banner
,Barrel
,Bat
,Beacon
,Bed
,Bee
,Beehive
,Bell
,BlastFurnace
,Blaze
,BlockDisplay
,BlockEntity
,BlockEntityArchetype
,BlockOccupiedMinecart
,Boat
,Boss
,BrewingStand
,Camel
,Campfire
,CarrierBlockEntity
,CarrierMinecart<M>
,Cat
,CaveSpider
,Chest
,ChestBoat
,ChestMinecart
,Chicken
,ClientPlayer
,ClientWorldProperties
,Cod
,CommandBlock
,CommandBlockMinecart
,Comparator
,ComplexLiving<T>
,ComplexLivingPart<P>
,Conduit
,Cow
,Creature
,Creeper
,DamagingProjectile
,DaylightDetector
,DirectionRelativeDataHolder.Mutable
,Dispenser
,DisplayEntity
,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
,Frog
,Furnace
,FurnaceBlockEntity
,FurnaceMinecart
,FusedExplosive
,Ghast
,Giant
,GlowSquid
,Goat
,Golem
,Guardian
,Hanging
,Hoglin
,Hopper
,HopperMinecart
,Horse
,HorseLike
,Hostile
,Human
,Humanoid
,Husk
,Illager
,Illusioner
,Interaction
,IronGolem
,Item
,ItemDisplay
,ItemFrame
,ItemStack
,Jigsaw
,Jukebox
,LeashKnot
,Lectern
,LightningBolt
,Living
,Llama
,LlamaLike
,LlamaSpit
,LocalPlayer
,MagmaCube
,MapInfo
,Marker
,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
,SculkSensor
,SerializableDataHolder.Mutable
,ServerLocation
,ServerPlayer
,ServerWorldProperties
,Sheep
,Shulker
,ShulkerBox
,ShulkerBullet
,Sign
,Silverfish
,Sittable
,Skeleton
,SkeletonHorse
,SkeletonLike
,Skull
,Slime
,SmallFireball
,Smoker
,Sniffer
,Snowball
,SnowGolem
,Spawner
,SpawnerMinecart
,SpectralArrow
,Spellcaster
,Spider
,Squid
,Stray
,Strider
,StructureBlock
,Tadpole
,TameableAnimal
,TameableHorse
,TextDisplay
,TNTMinecart
,Trader
,TraderLlama
,TrappedChest
,Trident
,TropicalFish
,Turtle
,User
,Vehicle
,Vex
,ViewableInventory.Custom
,Villager
,Vindicator
,WanderingTrader
,Warden
,WeatherEffect
,Witch
,Wither
,WitherSkeleton
,WitherSkull
,Wolf
,WorldProperties
,Zoglin
,Zombie
,ZombieHorse
,ZombieLike
,ZombieVillager
,ZombifiedPiglin
- Enclosing interface:
- 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
Modifier and TypeMethodDescriptiondefault 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.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
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
Offers the givenvalue
as defined by the providedKey
such that aDataTransactionResult
is returned for any successful, rejected, and replacedValue
s from thisDataHolder.Mutable
.Offers the givenvalue
as defined by the providedKey
such that aDataTransactionResult
is returned for any successful, rejected, and replacedValue
s from thisDataHolder.Mutable
.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> DataTransactionResult offerAll
(Key<? extends CollectionValue<E, ?>> key, Collection<? extends E> elements) <K,
V> DataTransactionResult offerAll
(CollectionValue<?, ?> value) default <E> DataTransactionResult
offerSingle
(Supplier<? extends Key<? extends CollectionValue<E, ?>>> key, E element) default <K,
V> DataTransactionResult offerSingle
(Supplier<? extends Key<? extends MapValue<K, V>>> key, K valueKey, V value) offerSingle
(Key<? extends CollectionValue<E, ?>> key, E element) <K,
V> DataTransactionResult offerSingle
(Key<? extends MapValue<K, V>> key, K valueKey, V value) default DataTransactionResult
Attempts to remove the data associated with the providedKey
.Attempts to remove the data associated with the providedKey
.default DataTransactionResult
Attempts to remove the providedValue
.default <E> DataTransactionResult
removeAll
(Supplier<? extends Key<? extends CollectionValue<E, ?>>> key, Collection<? extends E> elements) default <K,
V> DataTransactionResult removeAll
(Key<? extends CollectionValue<E, ?>> key, Collection<? extends E> elements) <K,
V> DataTransactionResult removeAll
(CollectionValue<?, ?> value) default <K> DataTransactionResult
default <E> DataTransactionResult
removeSingle
(Supplier<? extends Key<? extends CollectionValue<E, ?>>> key, E element) removeSingle
(Key<? extends CollectionValue<E, ?>> key, E element) default <E> DataTransactionResult
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
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
Offers the givenvalue
as defined by the providedKey
such that aDataTransactionResult
is returned for any successfulValue
s from thisDataHolder.Mutable
.Offers the givenvalue
as defined by the providedKey
such that aDataTransactionResult
is returned for any successfulValue
s from thisDataHolder.Mutable
.default <E> DataTransactionResult
Offers the givenvalue
as defined by the providedKey
such that aDataTransactionResult
is returned for any successfulValue
s from thisDataHolder.Mutable
.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 Details
-
transform
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
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
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
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
-
offerSingle
default <E> DataTransactionResult offerSingle(Supplier<? extends Key<? extends CollectionValue<E, ?>>> key, E element) -
offerSingle
-
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
-
offerAll
-
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
-
removeSingle
default <E> DataTransactionResult removeSingle(Supplier<? extends Key<? extends CollectionValue<E, ?>>> key, E element) -
removeKey
-
removeKey
default <K> DataTransactionResult removeKey(Supplier<? extends Key<? extends MapValue<K, ?>>> key, K mapKey) -
removeAll
-
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
-
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
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
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
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
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
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
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
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
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
-