Package org.spongepowered.api.data.value
Interface CollectionValue<E,C extends java.util.Collection<E>>
-
- Type Parameters:
E
- The type of elementC
- The type of collection
- All Superinterfaces:
java.lang.Iterable<E>
,Value<C>
- 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>
public interface CollectionValue<E,C extends java.util.Collection<E>> extends Value<C>, java.lang.Iterable<E>
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
CollectionValue.Immutable<E,C extends java.util.Collection<E>,I extends CollectionValue.Immutable<E,C,I,M>,M extends CollectionValue.Mutable<E,C,M,I>>
static interface
CollectionValue.Mutable<E,C extends java.util.Collection<E>,M extends CollectionValue.Mutable<E,C,M,I>,I extends CollectionValue.Immutable<E,C,I,M>>
Represents aValue.Mutable
that is backed by aCollection
of elements.-
Nested classes/interfaces inherited from interface org.spongepowered.api.data.value.Value
Value.Factory
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description C
all()
Creates a newCollection
of the proper typeC
with all elements copied to the new collection.CollectionValue.Immutable<E,C,?,?>
asImmutable()
Retrieves an immutable form of this value.CollectionValue.Mutable<E,C,?,?>
asMutable()
Retrieves a mutable form of this value.CollectionValue.Mutable<E,C,?,?>
asMutableCopy()
Retrieves a copy in the mutable form of this value.boolean
contains(E element)
Checks if the givenE
element is contained within the backedCollection
.boolean
containsAll(java.lang.Iterable<E> iterable)
Checks if all of the given elements in the providedIterable
are contained within the backedCollection
.boolean
isEmpty()
Checks if the backedCollection
is empty.int
size()
Gets the size of the underlying collection of elements.
-
-
-
Method Detail
-
size
int size()
Gets the size of the underlying collection of elements.- Returns:
- The size
-
isEmpty
boolean isEmpty()
Checks if the backedCollection
is empty.- Returns:
- True if the collection is empty
- See Also:
Collection.isEmpty()
-
contains
boolean contains(E element)
Checks if the givenE
element is contained within the backedCollection
.- Parameters:
element
- The element to check- Returns:
- True if the element is contained in this collection
-
containsAll
boolean containsAll(java.lang.Iterable<E> iterable)
Checks if all of the given elements in the providedIterable
are 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 newCollection
of the proper typeC
with all elements copied to the new collection. Any modifications to the new collection are not reflected to thisCollectionValue.Mutable
. Likewise, no modifications to thisCollectionValue.Mutable
are reflected to the returnedCollection
.- Returns:
- A new collection with all elements copied
-
asMutable
CollectionValue.Mutable<E,C,?,?> asMutable()
Description copied from interface:Value
Retrieves a mutable form of this value. Due to the vague nature of the value itself, some cases can already provide aValue.Mutable
instance where this would simply return itself. In other cases, where the retrieved value is anValue.Immutable
instance, a new mutable value is created with the same key and values.
-
asMutableCopy
CollectionValue.Mutable<E,C,?,?> asMutableCopy()
Description copied from interface:Value
Retrieves a copy in the mutable form of this value. The new is created with the same key and values.- Specified by:
asMutableCopy
in interfaceValue<E>
- Returns:
- A mutable value
-
asImmutable
CollectionValue.Immutable<E,C,?,?> asImmutable()
Description copied from interface:Value
Retrieves an immutable form of this value. Due to the vague nature of the value itself, some cases can already provide aValue.Immutable
instance where this would simply return itself. In other cases, where the retrieved value is aValue.Mutable
instance, a new immutable value is created with the same key and values.- Specified by:
asImmutable
in interfaceValue<E>
- Returns:
- An immutable value
-
-