Package org.spongepowered.api.data.value
Interface CollectionValue<E,C extends Collection<E>>
- Type Parameters:
E- The type of elementC- The type of collection
- All Known Subinterfaces:
CollectionValue.Immutable<E,,C, I, M> CollectionValue.Mutable<E,,C, M, I> ListValue<E>,ListValue.Immutable<E>,ListValue.Mutable<E>,SetValue<E>,SetValue.Immutable<E>,SetValue.Mutable<E>,WeightedCollectionValue<E>,WeightedCollectionValue.Immutable<E>,WeightedCollectionValue.Mutable<E>
A
Collection based Value type. Since some collections
are complex, or can be empty, this exposes
some of the common methods found in Collection and it itself
is Iterable. This is the base class for the common collections,
like ListValue and SetValue.-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceCollectionValue.Immutable<E,C extends Collection<E>, I extends CollectionValue.Immutable<E, C, I, M>, M extends CollectionValue.Mutable<E, C, M, I>> static interfaceCollectionValue.Mutable<E,C extends Collection<E>, M extends CollectionValue.Mutable<E, C, M, I>, I extends CollectionValue.Immutable<E, C, I, M>> Represents aValue.Mutablethat is backed by aCollectionof elements.Nested classes/interfaces inherited from interface org.spongepowered.api.data.value.Value
Value.Factory -
Method Summary
Modifier and TypeMethodDescriptionall()Creates a newCollectionof the proper typeCwith all elements copied to the new collection.CollectionValue.Immutable<E,C, ?, ?> Retrieves an immutable form of this value.CollectionValue.Mutable<E,C, ?, ?> Retrieves a mutable form of this value.CollectionValue.Mutable<E,C, ?, ?> Retrieves a copy in the mutable form of this value.booleanChecks if the givenEelement is contained within the backedCollection.booleancontainsAll(Iterable<E> iterable) Checks if all of the given elements in the providedIterableare contained within the backedCollection.booleanisEmpty()Checks if the backedCollectionis empty.intsize()Gets the size of the underlying collection of elements.Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
-
Method Details
-
size
int size()Gets the size of the underlying collection of elements.- Returns:
- The size
-
isEmpty
boolean isEmpty()Checks if the backedCollectionis empty.- Returns:
- True if the collection is empty
- See Also:
-
contains
Checks if the givenEelement is contained within the backedCollection.- Parameters:
element- The element to check- Returns:
- True if the element is contained in this collection
-
containsAll
Checks if all of the given elements in the providedIterableare contained within the backedCollection.- Parameters:
iterable- The iterable elements- Returns:
- True if all elements are contained within the backed collection
-
all
C all()Creates a newCollectionof the proper typeCwith all elements copied to the new collection. Any modifications to the new collection are not reflected to thisCollectionValue.Mutable. Likewise, no modifications to thisCollectionValue.Mutableare reflected to the returnedCollection.- Returns:
- A new collection with all elements copied
-
asMutable
CollectionValue.Mutable<E,C, asMutable()?, ?> Description copied from interface:ValueRetrieves 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. -
asMutableCopy
CollectionValue.Mutable<E,C, asMutableCopy()?, ?> Description copied from interface:ValueRetrieves a copy in the mutable form of this value. The new is created with the same key and values.- Specified by:
asMutableCopyin interfaceValue<E>- Returns:
- A mutable value
-
asImmutable
CollectionValue.Immutable<E,C, asImmutable()?, ?> Description copied from interface:ValueRetrieves 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.- Specified by:
asImmutablein interfaceValue<E>- Returns:
- An immutable value
-