Package org.spongepowered.api.data.value
Interface Value<E>
- 
- Type Parameters:
- E- The type of element wrapped by this value
 - All Known Subinterfaces:
- CollectionValue<E,C>,- CollectionValue.Immutable<E,C,I,M>,- CollectionValue.Mutable<E,C,M,I>,- ListValue<E>,- ListValue.Immutable<E>,- ListValue.Mutable<E>,- MapValue<K,V>,- MapValue.Immutable<K,V>,- MapValue.Mutable<K,V>,- SetValue<E>,- SetValue.Immutable<E>,- SetValue.Mutable<E>,- Value.Immutable<E>,- Value.Mutable<E>,- WeightedCollectionValue<E>,- WeightedCollectionValue.Immutable<E>,- WeightedCollectionValue.Mutable<E>
 
 public interface Value<E>The abstract base interface for all of the "Value API". In short, aValueis a "wrapper" around an actual value from aValueContainer. The actual value may come from various sources of theValueContainer, but usually it's a generic dynamic system for being able to fetch values from object fields without having to know the type ofClassof theValueContainer, the getters and setters for that particular value. The driving force behind this is that instead of having a traditional hierarchical structure of data that is possible to be retrieved from anEntity,Living, etc., all that is required is
 where the container is simply acontainer.supports(Keys.HEALTH) ? container.get(Keys.HEALTH).get() : 0ValueContainer, nothing more, nothing less.The advantage of this is that now, these various known and unknown Value.Mutables can be retrieved by simple java generics:ValueContainer.getValue(Key). While having aValue.Mutablefor something so primitive as the current health of aLivingentity, the power is wielded when aValue.Mutablecan be offered up to multipleValueContainers without worrying about whether it's supported or not, or getting the right cast information.
- 
- 
Nested Class SummaryNested Classes Modifier and Type Interface Description static interfaceValue.Factorystatic interfaceValue.Immutable<E>Represents an immutable representation of aValuewhere any modifications of the underlying value result in a new instance of anValue.Immutableand/or theValueContainerif theValueContainertoo is immutable.static interfaceValue.Mutable<E>Represents a type ofValuethat is mutable.
 - 
Method SummaryAll Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description Value.Immutable<E>asImmutable()Retrieves an immutable form of this value.Value.Mutable<E>asMutable()Retrieves a mutable form of this value.Value.Mutable<E>asMutableCopy()Retrieves a copy in the mutable form of this value.static <V extends Value<E>,E>
 VgenericImmutableOf(Key<V> key, E element)static <V extends Value<E>,E>
 VgenericMutableOf(Key<V> key, E element)Eget()Gets the held value.static <E> ListValue.Immutable<E>immutableOf(java.util.function.Supplier<? extends Key<? extends ListValue<E>>> key, java.util.List<E> element)static <K,V>
 MapValue.Immutable<K,V>immutableOf(java.util.function.Supplier<? extends Key<? extends MapValue<K,V>>> key, java.util.Map<K,V> element)static <E> SetValue.Immutable<E>immutableOf(java.util.function.Supplier<? extends Key<? extends SetValue<E>>> key, java.util.Set<E> element)static <E> Value.Immutable<E>immutableOf(java.util.function.Supplier<? extends Key<? extends Value<E>>> key, E element)static <E> WeightedCollectionValue.Immutable<E>immutableOf(java.util.function.Supplier<? extends Key<? extends WeightedCollectionValue<E>>> key, WeightedTable<E> element)Constructs an immutableWeightedCollectionValueof the appropriate type based on the givenKeyand the element.static <E> ListValue.Immutable<E>immutableOf(Key<? extends ListValue<E>> key, java.util.List<E> element)static <K,V>
 MapValue.Immutable<K,V>immutableOf(Key<? extends MapValue<K,V>> key, java.util.Map<K,V> element)static <E> SetValue.Immutable<E>immutableOf(Key<? extends SetValue<E>> key, java.util.Set<E> element)static <E> Value.Immutable<E>immutableOf(Key<? extends Value<E>> key, E element)static <E> WeightedCollectionValue.Immutable<E>immutableOf(Key<? extends WeightedCollectionValue<E>> key, WeightedTable<E> element)Constructs an immutableWeightedCollectionValueof the appropriate type based on the givenKeyand the element.Key<? extends Value<E>>key()Gets the key for thisValue.static <E> ListValue.Mutable<E>mutableOf(java.util.function.Supplier<? extends Key<? extends ListValue<E>>> key, java.util.List<E> element)static <K,V>
 MapValue.Mutable<K,V>mutableOf(java.util.function.Supplier<? extends Key<? extends MapValue<K,V>>> key, java.util.Map<K,V> element)static <E> SetValue.Mutable<E>mutableOf(java.util.function.Supplier<? extends Key<? extends SetValue<E>>> key, java.util.Set<E> element)static <E> Value.Mutable<E>mutableOf(java.util.function.Supplier<? extends Key<? extends Value<E>>> key, E element)static <E> WeightedCollectionValue.Mutable<E>mutableOf(java.util.function.Supplier<? extends Key<? extends WeightedCollectionValue<E>>> key, WeightedTable<E> element)Constructs a mutableWeightedCollectionValueof the appropriate type based on the givenKeyand the element.static <E> ListValue.Mutable<E>mutableOf(Key<? extends ListValue<E>> key, java.util.List<E> element)static <K,V>
 MapValue.Mutable<K,V>mutableOf(Key<? extends MapValue<K,V>> key, java.util.Map<K,V> element)static <E> SetValue.Mutable<E>mutableOf(Key<? extends SetValue<E>> key, java.util.Set<E> element)static <E> Value.Mutable<E>mutableOf(Key<? extends Value<E>> key, E element)static <E> WeightedCollectionValue.Mutable<E>mutableOf(Key<? extends WeightedCollectionValue<E>> key, WeightedTable<E> element)Constructs a mutableWeightedCollectionValueof the appropriate type based on the givenKeyand the element.
 
- 
- 
- 
Method Detail- 
mutableOfstatic <E> Value.Mutable<E> mutableOf(Key<? extends Value<E>> key, E element) - Type Parameters:
- E- The element type
- Parameters:
- key- The key
- element- The element
- Returns:
- The constructed mutable value
 
 - 
mutableOfstatic <E> Value.Mutable<E> mutableOf(java.util.function.Supplier<? extends Key<? extends Value<E>>> key, E element) - Type Parameters:
- E- The element type
- Parameters:
- key- The key
- element- The element
- Returns:
- The constructed mutable value
 
 - 
immutableOfstatic <E> Value.Immutable<E> immutableOf(Key<? extends Value<E>> key, E element) - Type Parameters:
- E- The element type
- Parameters:
- key- The key
- element- The element
- Returns:
- The constructed immutable value
 
 - 
immutableOfstatic <E> Value.Immutable<E> immutableOf(java.util.function.Supplier<? extends Key<? extends Value<E>>> key, E element) - Type Parameters:
- E- The element type
- Parameters:
- key- The key
- element- The element
- Returns:
- The constructed immutable value
 
 - 
mutableOfstatic <E> ListValue.Mutable<E> mutableOf(Key<? extends ListValue<E>> key, java.util.List<E> element) - Type Parameters:
- E- The element type
- Parameters:
- key- The key
- element- The element
- Returns:
- The constructed mutable value
 
 - 
mutableOfstatic <E> ListValue.Mutable<E> mutableOf(java.util.function.Supplier<? extends Key<? extends ListValue<E>>> key, java.util.List<E> element) - Type Parameters:
- E- The element type
- Parameters:
- key- The key
- element- The element
- Returns:
- The constructed mutable value
 
 - 
immutableOfstatic <E> ListValue.Immutable<E> immutableOf(Key<? extends ListValue<E>> key, java.util.List<E> element) - Type Parameters:
- E- The element type
- Parameters:
- key- The key
- element- The element
- Returns:
- The constructed immutable value
 
 - 
immutableOfstatic <E> ListValue.Immutable<E> immutableOf(java.util.function.Supplier<? extends Key<? extends ListValue<E>>> key, java.util.List<E> element) - Type Parameters:
- E- The element type
- Parameters:
- key- The key
- element- The element
- Returns:
- The constructed immutable value
 
 - 
mutableOfstatic <E> SetValue.Mutable<E> mutableOf(Key<? extends SetValue<E>> key, java.util.Set<E> element) - Type Parameters:
- E- The element type
- Parameters:
- key- The key
- element- The element
- Returns:
- The constructed mutable value
 
 - 
mutableOfstatic <E> SetValue.Mutable<E> mutableOf(java.util.function.Supplier<? extends Key<? extends SetValue<E>>> key, java.util.Set<E> element) - Type Parameters:
- E- The element type
- Parameters:
- key- The key
- element- The element
- Returns:
- The constructed mutable value
 
 - 
immutableOfstatic <E> SetValue.Immutable<E> immutableOf(Key<? extends SetValue<E>> key, java.util.Set<E> element) - Type Parameters:
- E- The element type
- Parameters:
- key- The key
- element- The element
- Returns:
- The constructed immutable value
 
 - 
immutableOfstatic <E> SetValue.Immutable<E> immutableOf(java.util.function.Supplier<? extends Key<? extends SetValue<E>>> key, java.util.Set<E> element) - Type Parameters:
- E- The element type
- Parameters:
- key- The key
- element- The element
- Returns:
- The constructed immutable value
 
 - 
mutableOfstatic <K,V> MapValue.Mutable<K,V> mutableOf(Key<? extends MapValue<K,V>> key, java.util.Map<K,V> element) - Type Parameters:
- K- The map key type
- V- The map value type
- Parameters:
- key- The key
- element- The element
- Returns:
- The constructed mutable value
 
 - 
mutableOfstatic <K,V> MapValue.Mutable<K,V> mutableOf(java.util.function.Supplier<? extends Key<? extends MapValue<K,V>>> key, java.util.Map<K,V> element) - Type Parameters:
- K- The map key type
- V- The map value type
- Parameters:
- key- The key
- element- The element
- Returns:
- The constructed mutable value
 
 - 
immutableOfstatic <K,V> MapValue.Immutable<K,V> immutableOf(Key<? extends MapValue<K,V>> key, java.util.Map<K,V> element) - Type Parameters:
- K- The map key type
- V- The map value type
- Parameters:
- key- The key
- element- The element
- Returns:
- The constructed immutable value
 
 - 
immutableOfstatic <K,V> MapValue.Immutable<K,V> immutableOf(java.util.function.Supplier<? extends Key<? extends MapValue<K,V>>> key, java.util.Map<K,V> element) - Type Parameters:
- K- The map key type
- V- The map value type
- Parameters:
- key- The key
- element- The element
- Returns:
- The constructed immutable value
 
 - 
mutableOfstatic <E> WeightedCollectionValue.Mutable<E> mutableOf(Key<? extends WeightedCollectionValue<E>> key, WeightedTable<E> element) Constructs a mutableWeightedCollectionValueof the appropriate type based on the givenKeyand the element.- Type Parameters:
- E- The element type
- Parameters:
- key- The key
- element- The element
- Returns:
- The constructed mutable value
 
 - 
mutableOfstatic <E> WeightedCollectionValue.Mutable<E> mutableOf(java.util.function.Supplier<? extends Key<? extends WeightedCollectionValue<E>>> key, WeightedTable<E> element) Constructs a mutableWeightedCollectionValueof the appropriate type based on the givenKeyand the element.- Type Parameters:
- E- The element type
- Parameters:
- key- The key
- element- The element
- Returns:
- The constructed mutable value
 
 - 
immutableOfstatic <E> WeightedCollectionValue.Immutable<E> immutableOf(Key<? extends WeightedCollectionValue<E>> key, WeightedTable<E> element) Constructs an immutableWeightedCollectionValueof the appropriate type based on the givenKeyand the element.- Type Parameters:
- E- The element type
- Parameters:
- key- The key
- element- The element
- Returns:
- The constructed immutable value
 
 - 
immutableOfstatic <E> WeightedCollectionValue.Immutable<E> immutableOf(java.util.function.Supplier<? extends Key<? extends WeightedCollectionValue<E>>> key, WeightedTable<E> element) Constructs an immutableWeightedCollectionValueof the appropriate type based on the givenKeyand the element.- Type Parameters:
- E- The element type
- Parameters:
- key- The key
- element- The element
- Returns:
- The constructed immutable value
 
 - 
genericMutableOfstatic <V extends Value<E>,E> V genericMutableOf(Key<V> key, E element) Constructs aValueof the appropriate type based on the givenKeyand the element. The returnedValueis guaranteedValue.Mutable, this means that callingasMutable()will return itself.- Type Parameters:
- V- The value type
- E- The element type
- Parameters:
- key- The key
- element- The element
- Returns:
- The constructed mutable value
 
 - 
genericImmutableOfstatic <V extends Value<E>,E> V genericImmutableOf(Key<V> key, E element) Constructs aValueof the appropriate type based on the givenKeyand the element. The returnedValueis guaranteedValue.Immutable, this means that callingasImmutable()will return itself.- Type Parameters:
- V- The value type
- E- The element type
- Parameters:
- key- The key
- element- The element
- Returns:
- The constructed immutable value
 
 - 
getE get() Gets the held value.- Returns:
- The held value
 
 - 
asMutableValue.Mutable<E> asMutable() Retrieves a mutable form of this value. Due to the vague nature of the value itself, some cases can already provide aValue.Mutableinstance where this would simply return itself. In other cases, where the retrieved value is anValue.Immutableinstance, a new mutable value is created with the same key and values.- Returns:
- A mutable value
 
 - 
asMutableCopyValue.Mutable<E> asMutableCopy() Retrieves a copy in the mutable form of this value. The new is created with the same key and values.- Returns:
- A mutable value
 
 - 
asImmutableValue.Immutable<E> asImmutable() Retrieves an immutable form of this value. Due to the vague nature of the value itself, some cases can already provide aValue.Immutableinstance where this would simply return itself. In other cases, where the retrieved value is aValue.Mutableinstance, a new immutable value is created with the same key and values.- Returns:
- An immutable value
 
 
- 
 
-