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,Axolotl,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,GlowSquid,Goat,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,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,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
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 DataTransactionResultcopyFrom(ValueContainer that) Performs an absolute copy of allValue.Mutables andValueContainers to thisDataHolder.Mutablesuch that any overlappingValue.Mutables are offered for replacement.copyFrom(ValueContainer that, MergeFunction function) Performs an absolute copy of allValue.Mutables andValueContainers to thisDataHolder.Mutablesuch that any overlappingValue.Mutables are offered for replacement.default <E> DataTransactionResultOffers the givenvalueas defined by the providedKeysuch that aDataTransactionResultis returned for any successful, rejected, and replacedValues from thisDataHolder.Mutable.default <E> DataTransactionResultOffers the givenvalueas defined by the providedKeysuch that aDataTransactionResultis returned for any successful, rejected, and replacedValues from thisDataHolder.Mutable.Offers the givenvalueas defined by the providedKeysuch that aDataTransactionResultis returned for any successful, rejected, and replacedValues from thisDataHolder.Mutable.Offers the givenValueas defined by the providedKeysuch that aDataTransactionResultis returned for any successful, rejected, and replacedValues from thisDataHolder.Mutable.default <E> DataTransactionResultofferAll(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> DataTransactionResultofferSingle(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 DataTransactionResultAttempts to remove the data associated with the providedKey.Attempts to remove the data associated with the providedKey.default DataTransactionResultAttempts to remove the providedValue.default <E> DataTransactionResultremoveAll(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> DataTransactionResultdefault <E> DataTransactionResultremoveSingle(Supplier<? extends Key<? extends CollectionValue<E, ?>>> key, E element) removeSingle(Key<? extends CollectionValue<E, ?>> key, E element) default <E> DataTransactionResultApplies a transformation on the providedValuesuch that the return value ofFunction.apply(Object)will become the end resulting value set into thisDataHolder.Mutable.default <E> DataTransactionResultApplies a transformation on the providedValuesuch that the return value ofFunction.apply(Object)will become the end resulting value set into thisDataHolder.Mutable.default <E> DataTransactionResultOffers the givenvalueas defined by the providedKeysuch that aDataTransactionResultis returned for any successfulValues from thisDataHolder.Mutable.Offers the givenvalueas defined by the providedKeysuch that aDataTransactionResultis returned for any successfulValues from thisDataHolder.Mutable.default <E> DataTransactionResultOffers the givenvalueas defined by the providedKeysuch that aDataTransactionResultis returned for any successfulValues from thisDataHolder.Mutable.undo(DataTransactionResult result) Attempts to "revert" aDataTransactionResultsuch 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 providedValuesuch 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 theKeyed data is compatible, but not necessarily present. Writing aFunctionto 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 providedValuesuch 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 theKeyed data is compatible, but not necessarily present. Writing aFunctionto 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 givenvalueas defined by the providedKeysuch that aDataTransactionResultis returned for any successful, rejected, and replacedValues 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 givenvalueas defined by the providedKeysuch that aDataTransactionResultis returned for any successful, rejected, and replacedValues 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 givenvalueas defined by the providedKeysuch that aDataTransactionResultis returned for any successful, rejected, and replacedValues 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 givenValueas defined by the providedKeysuch that aDataTransactionResultis returned for any successful, rejected, and replacedValues 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 givenvalueas defined by the providedKeysuch that aDataTransactionResultis returned for any successfulValues 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 givenvalueas defined by the providedKeysuch that aDataTransactionResultis returned for any successfulValues 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 givenvalueas defined by the providedKeysuch that aDataTransactionResultis returned for any successfulValues 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" aDataTransactionResultsuch 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.Mutables andValueContainers to thisDataHolder.Mutablesuch that any overlappingValue.Mutables are offered for replacement. The result is provided as aDataTransactionResult.- Parameters:
that- The otherDataHolder.Mutableto copy values from- Returns:
- The transaction result
-
copyFrom
Performs an absolute copy of allValue.Mutables andValueContainers to thisDataHolder.Mutablesuch that any overlappingValue.Mutables are offered for replacement. The result is provided as aDataTransactionResult.- Parameters:
that- The otherDataHolder.Mutableto copy values fromfunction- The function to resolve merge conflicts- Returns:
- The transaction result
-