Package org.spongepowered.api.state
Interface State<S extends State<S>>
-
- All Superinterfaces:
CopyableDataHolder,DataHolder,DataHolder.Immutable<S>,DataSerializable,SerializableDataHolder,SerializableDataHolder.Immutable<S>,ValueContainer
- All Known Subinterfaces:
BlockState,FluidState
public interface State<S extends State<S>> extends SerializableDataHolder.Immutable<S>
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceState.Builder<S extends State<S>,B extends State.Builder<S,B>>-
Nested classes/interfaces inherited from interface org.spongepowered.api.data.DataHolder
DataHolder.Immutable<I extends DataHolder.Immutable<I>>, DataHolder.Mutable
-
Nested classes/interfaces inherited from interface org.spongepowered.api.data.SerializableDataHolder
SerializableDataHolder.Immutable<I extends SerializableDataHolder.Immutable<I>>, SerializableDataHolder.Mutable
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default <T extends Comparable<T>>
Optional<S>cycleStateProperty(Supplier<? extends StateProperty<T>> stateProperty)Cycles to the next possible value of theStatePropertyand returns the newState.<T extends Comparable<T>>
Optional<S>cycleStateProperty(StateProperty<T> stateProperty)Cycles to the next possible value of theStatePropertyand returns the newState.default <T extends Cycleable<T>>
Optional<S>cycleValue(Supplier<? extends Key<? extends Value<T>>> key)<T extends Cycleable<T>>
Optional<S>cycleValue(Key<? extends Value<T>> key)Optional<StateProperty<?>>findStateProperty(String name)Collection<StateProperty<?>>stateProperties()default <T extends Comparable<T>>
Optional<T>stateProperty(Supplier<? extends StateProperty<T>> stateProperty)Gets theComparablevalue for the specificStatePropertysuch that if theStatedoes not support theStateProperty,Optional.empty()is returned.<T extends Comparable<T>>
Optional<T>stateProperty(StateProperty<T> stateProperty)Gets theComparablevalue for the specificStatePropertysuch that if theStatedoes not support theStateProperty,Optional.empty()is returned.Map<StateProperty<?>,?>statePropertyMap()Gets an immutable or unmodifiableMapof the knownStatePropertys to their current values for thisState.Collection<?>statePropertyValues()StringtoString()default <T extends Comparable<T>,V extends T>
Optional<S>withStateProperty(Supplier<? extends StateProperty<T>> stateProperty, V value)Gets theStatewith the appropriate value for the givenStateProperty.<T extends Comparable<T>,V extends T>
Optional<S>withStateProperty(StateProperty<T> stateProperty, V value)Gets theStatewith the appropriate value for the givenStateProperty.-
Methods inherited from interface org.spongepowered.api.data.DataHolder.Immutable
mergeWith, mergeWith, transform, transform, with, with, with, without, without, without
-
Methods inherited from interface org.spongepowered.api.data.persistence.DataSerializable
contentVersion, toContainer
-
Methods inherited from interface org.spongepowered.api.data.SerializableDataHolder
validateRawData
-
Methods inherited from interface org.spongepowered.api.data.SerializableDataHolder.Immutable
copy, withRawData
-
-
-
-
Method Detail
-
stateProperty
<T extends Comparable<T>> Optional<T> stateProperty(StateProperty<T> stateProperty)
Gets theComparablevalue for the specificStatePropertysuch that if theStatedoes not support theStateProperty,Optional.empty()is returned.- Type Parameters:
T- The generic type of state property- Parameters:
stateProperty- The state property- Returns:
- The comparable value, if available and compatible
-
stateProperty
default <T extends Comparable<T>> Optional<T> stateProperty(Supplier<? extends StateProperty<T>> stateProperty)
Gets theComparablevalue for the specificStatePropertysuch that if theStatedoes not support theStateProperty,Optional.empty()is returned.- Type Parameters:
T- The generic type of state property- Parameters:
stateProperty- The state property- Returns:
- The comparable value, if available and compatible
-
findStateProperty
Optional<StateProperty<?>> findStateProperty(String name)
Attempts to retrieve theStatePropertyinstance associated with thisStatesStateContainerby name. If there is noStatePropertyavailable,Optional.empty()is returned.- Parameters:
name- The state property name- Returns:
- The state property, if available
-
withStateProperty
<T extends Comparable<T>,V extends T> Optional<S> withStateProperty(StateProperty<T> stateProperty, V value)
Gets theStatewith the appropriate value for the givenStateProperty. If theStatePropertyis not supported,Optional.empty()is returned. If the object is not either an instance contained inStateProperty.possibleValues()or an instanceObject.toString(),Optional.empty()may be returned.- Type Parameters:
T- The type of cycleable valueV- The type of extended value- Parameters:
stateProperty- The state propertyvalue- The value- Returns:
- The state, if the state property and value are supported
-
withStateProperty
default <T extends Comparable<T>,V extends T> Optional<S> withStateProperty(Supplier<? extends StateProperty<T>> stateProperty, V value)
Gets theStatewith the appropriate value for the givenStateProperty. If theStatePropertyis not supported,Optional.empty()is returned. If the object is not either an instance contained inStateProperty.possibleValues()or an instanceObject.toString(),Optional.empty()may be returned.- Type Parameters:
T- The type of cycleable valueV- The type of extended value- Parameters:
stateProperty- The state propertyvalue- The value- Returns:
- The state, if the state property and value are supported
-
cycleStateProperty
<T extends Comparable<T>> Optional<S> cycleStateProperty(StateProperty<T> stateProperty)
Cycles to the next possible value of theStatePropertyand returns the newState. ReturnsOptional.empty()if the state property or the value isn't supported.- Type Parameters:
T- The type of cycleable value- Parameters:
stateProperty- The state property- Returns:
- The cycled state if successful
-
cycleStateProperty
default <T extends Comparable<T>> Optional<S> cycleStateProperty(Supplier<? extends StateProperty<T>> stateProperty)
Cycles to the next possible value of theStatePropertyand returns the newState. ReturnsOptional.empty()if the state property or the value isn't supported.- Type Parameters:
T- The type of cycleable value- Parameters:
stateProperty- The state property- Returns:
- The cycled state if successful
-
cycleValue
<T extends Cycleable<T>> Optional<S> cycleValue(Key<? extends Value<T>> key)
Cycles to the next possible value of theKeyand returns the newState. ReturnsOptional.empty()if the key or the value isn't supported.- Type Parameters:
T- The type of cycleable value- Parameters:
key- The key- Returns:
- The cycled state if successful
-
cycleValue
default <T extends Cycleable<T>> Optional<S> cycleValue(Supplier<? extends Key<? extends Value<T>>> key)
Cycles to the next possible value of theKeyand returns the newState. ReturnsOptional.empty()if the key or the value isn't supported.- Type Parameters:
T- The type of cycleable value- Parameters:
key- The key- Returns:
- The cycled state if successful
-
stateProperties
Collection<StateProperty<?>> stateProperties()
- Returns:
- An immutable collection of all applicable state properties
-
statePropertyValues
Collection<?> statePropertyValues()
- Returns:
- An immutable collection of all the values for all applicable properties
-
statePropertyMap
Map<StateProperty<?>,?> statePropertyMap()
Gets an immutable or unmodifiableMapof the knownStatePropertys to their current values for thisState.- Returns:
- The immutable map of state properties to their values representing this state
-
-