Package org.spongepowered.api.data.value
Interface ValueContainer
- All Known Subinterfaces:
AcceleratingProjectile
,Aerial
,Ageable
,Agent
,Allay
,Ambient
,Angerable
,Animal
,Aquatic
,Archetype<S,
,E> AreaEffectCloud
,Armadillo
,ArmorStand
,Arrow
,ArrowLike
,Attackable
,Axolotl
,Banner
,Barrel
,Bat
,Beacon
,Bed
,Bee
,Beehive
,Bell
,Biome
,BlastFurnace
,Blaze
,BlockDisplay
,BlockEntity
,BlockEntityArchetype
,BlockEntityInventory<T>
,BlockOccupiedMinecart
,BlockSnapshot
,BlockState
,BlockType
,Boat
,Bogged
,Boss
,Breedable
,Breeze
,BreezeWindCharge
,BrewingStand
,Camel
,Campfire
,CarriedInventory<C>
,CarrierBlockEntity
,CarrierMinecart<M>
,Cat
,CaveSpider
,Chargeable
,Chest
,ChestBoat
,ChestMinecart
,Chicken
,ClientPlayer
,ClientWorldProperties
,Cod
,CommandBlock
,CommandBlockMinecart
,Comparator
,ComplexLiving<T>
,ComplexLivingPart<P>
,Conduit
,Container
,CopyableDataHolder
,CopyableValueContainer
,Cow
,Crafter
,CraftingGridInventory
,CraftingInventory
,CraftingOutput
,Creaking
,CreakingHeart
,Creeper
,DataHolder
,DataHolder.Immutable<I>
,DataHolder.Mutable
,DataManipulator
,DataManipulator.Immutable
,DataManipulator.Mutable
,DaylightDetector
,DecoratedPot
,DirectionRelativeDataHolder
,DirectionRelativeDataHolder.Immutable<I>
,DirectionRelativeDataHolder.Mutable
,Dispenser
,DisplayEntity
,Dolphin
,Donkey
,DragonFireball
,Dropper
,Drowned
,Egg
,ElderGuardian
,EmptyInventory
,EnchantmentTable
,EndCrystal
,EnderChest
,EnderDragon
,EnderDragonPart
,Enderman
,Endermite
,EnderPearl
,EndGateway
,EndPortal
,Entity
,EntityArchetype
,EntitySnapshot
,EquipmentInventory
,EquipmentSlot
,Evoker
,EvokerFangs
,ExperienceBottle
,ExperienceOrb
,Explosive
,ExplosiveFireball
,EyeOfEnder
,FallingBlock
,FilteringSlot
,FireworkRocket
,Fish
,FishingBobber
,FluidStack
,FluidStackSnapshot
,FluidState
,FluidType
,Fox
,Frog
,FuelSlot
,Furnace
,FurnaceBlockEntity
,FurnaceMinecart
,FusedExplosive
,Ghast
,Giant
,GlowItemFrame
,GlowSquid
,Goat
,Golem
,GridInventory
,Guardian
,Hanging
,Hoglin
,Hopper
,HopperMinecart
,Horse
,HorseLike
,Hostile
,Hotbar
,Human
,Humanoid
,Husk
,IgnitingProjectile
,Illager
,Illusioner
,InputSlot
,Interaction
,Inventory
,Inventory2D
,InventoryColumn
,InventoryRow
,IronGolem
,Item
,ItemDisplay
,ItemFrame
,ItemRepresentable
,ItemStack
,ItemStackLike
,ItemStackSnapshot
,ItemType
,Jigsaw
,Jukebox
,Leashable
,LeashKnot
,Lectern
,LightningBolt
,Living
,Llama
,LlamaSpit
,LocalPlayer
,LocatableBlock
,LocatableSnapshot<T>
,MagmaCube
,MapInfo
,Marker
,Merchant
,Minecart
,MinecartLike
,MobSpawner
,Monster
,Mooshroom
,Mule
,NameableBlockEntity
,NameableCarrierBlockEntity
,Ocelot
,OminousItemSpawner
,OutputSlot
,Ownable
,PackHorse
,Painting
,Panda
,Parrot
,PathfinderAgent
,Patroller
,PersistentInventory
,Phantom
,Pig
,Piglin
,PiglinBrute
,PiglinLike
,Pillager
,Piston
,Player
,PlayerInventory
,PolarBear
,Potion
,PotionSlot
,PrimaryPlayerInventory
,PrimedTNT
,Projectile
,Pufferfish
,Rabbit
,Raft
,Raider
,RangedAgent
,Ranger
,Ravager
,RecipeInput
,RecipeInput.Crafting
,RecipeInput.Single
,RecipeInput.Smithing
,RemotePlayer
,Saddleable
,Salmon
,SchoolingFish
,SculkSensor
,SerializableDataHolder
,SerializableDataHolder.Immutable<I>
,SerializableDataHolder.Mutable
,ServerLocation
,ServerPlayer
,ServerWorldProperties
,Sheep
,Shulker
,ShulkerBox
,ShulkerBullet
,SidedSlot
,Sign
,Sign.SignText
,Silverfish
,Sittable
,Skeleton
,SkeletonHorse
,SkeletonLike
,Skull
,Slime
,Slot
,SmallFireball
,Smoker
,Sniffer
,Snowball
,SnowGolem
,Spawner
,SpawnerMinecart
,SpectralArrow
,Spellcaster
,Spider
,Squid
,State<S>
,Stray
,Strider
,StructureBlock
,Tadpole
,TameableAnimal
,Targeting
,TextDisplay
,ThrowableItemProjectile
,TNTMinecart
,TraderLlama
,TrappedChest
,TrialSpawner
,Trident
,TropicalFish
,Turtle
,User
,UserInventory
,Vehicle
,Vex
,ViewableInventory
,ViewableInventory.Custom
,Villager
,VillagerLike
,Vindicator
,WanderingTrader
,Warden
,WindCharge
,WindChargeLike
,Witch
,Wither
,WitherSkeleton
,WitherSkull
,Wolf
,WorldChunk
,WorldProperties
,WorldTemplate
,WorldType
,WorldTypeDataFetcher
,WorldTypeTemplate
,Zoglin
,Zombie
,ZombieHorse
,ZombieVillager
,ZombifiedPiglin
public interface ValueContainer
A value holder is a holder of a particular set of
Value
s. While
there exists a DataHolder
and DataManipulator
,
the emphasis of ValueContainer
is that it only contains "data". It
is not known whether a ValueHolder
is mutable or immutable.
Being that a ValueHolder
is literally a container of
Value
s, it itself does not contain the underlying values of
data. A ValueContainer
may not always be parented by another
ValueContainer
, such as the case for DataManipulator
s and
DataHolder.Mutable
s, it is recommended to knowingly understand the
fundamental differences between them.
-
Method Summary
Modifier and TypeMethodDescription<E> Optional
<E> default OptionalDouble
default OptionalInt
getKeys()
Gets all applicableKey
s for thisValueContainer
.default OptionalLong
default <E> E
Attempts to get the underlying value if available.default <E> @Nullable E
Attempts to get the underlying value if available and supported.Set
<Value.Immutable<?>> Gets all applicableValue
s associated with thisValueContainer
.default <E> E
default <E,
V extends Value<E>>
VrequireValue
(Key<V> key) boolean
Checks if the givenKey
is supported by thisValueContainer
.default boolean
Checks if the providedValue
is supported.
-
Method Details
-
get
Attempts to get the underlying value backed by aValue
linked to the providedKey
. If theKey
is not supported,Optional.empty()
is returned. It is important to check for support of aKey
by either callingsupports(Value)
orsupports(Key)
.- Type Parameters:
E
- The type of value- Parameters:
key
- The key to retrieve the value for- Returns:
- The value, if available
-
getInt
Attempts to get the underlying int value backed by aValue
linked to the providedKey
. If theKey
is not supported,Optional.empty()
is returned. It is important to check for support of aKey
by either callingsupports(Value)
orsupports(Key)
.- Parameters:
key
- The key to retrieve the value for- Returns:
- The value, if available
-
getDouble
Attempts to get the underlying double value backed by aValue
linked to the providedKey
. If theKey
is not supported,Optional.empty()
is returned. It is important to check for support of aKey
by either callingsupports(Value)
orsupports(Key)
.- Parameters:
key
- The key to retrieve the value for- Returns:
- The value, if available
-
getLong
Attempts to get the underlying long value backed by aValue
linked to the providedKey
. If theKey
is not supported,Optional.empty()
is returned. It is important to check for support of aKey
by either callingsupports(Value)
orsupports(Key)
.- Parameters:
key
- The key to retrieve the value for- Returns:
- The value, if available
-
require
Attempts to get the underlying value backed by aValue
linked to the providedKey
.If the
Key
is not supported or available,NoSuchElementException
will be thrown.- Type Parameters:
E
- The type of value- Parameters:
key
- The key- Returns:
- The value
- Throws:
NoSuchElementException
- If the value is not supported or present
-
getOrNull
Attempts to get the underlying value if available and supported. If theValue
is not supported whatsoever by thisValueContainer
, an exception is thrown. -
getOrElse
Attempts to get the underlying value if available. If the value is not set, the givendefaultValue
is returned, if theValue
is even supported.- Type Parameters:
E
- The type of value- Parameters:
key
- The key backing theValue
defaultValue
- The value to default to if not set- Returns:
- The value, or default if not set
-
getValue
- Type Parameters:
E
- The type of the return typeV
- The type of value- Parameters:
key
- The key linked to theValue
- Returns:
- The value, if available
-
requireValue
Attempts to get the underlying value backed by aValue
linked to the providedKey
.If the
Key
is not supported or available,NoSuchElementException
will be thrown.- Type Parameters:
E
- The type of element wrapped by the valueV
- The type of value- Parameters:
key
- The key- Returns:
- The value
- Throws:
NoSuchElementException
- If the value is not supported or present
-
supports
Checks if the givenKey
is supported by thisValueContainer
.- Parameters:
key
- The key to check- Returns:
- True if the key and value backed by the key is supported
-
supports
Checks if the providedValue
is supported.- Parameters:
value
- The base value to check- Returns:
- True if the base value is supported
-
getKeys
Gets all applicableKey
s for thisValueContainer
. Changes can not be made to the set to alter theValueContainer
, nor can theValue
s be changed with the providedSet
.- Returns:
- An immutable set of known
Key
s
-
getValues
Set<Value.Immutable<?>> getValues()Gets all applicableValue
s associated with thisValueContainer
. As the data backed by the values are copied, any modifications to theValue
s will not be reflected onto thisValueContainer
.- Returns:
- An immutable set of copied values
-