Record Class MappedCollection<O,R>
java.lang.Object
java.lang.Record
net.minestom.server.utils.collection.MappedCollection<O,R>
- All Implemented Interfaces:
Iterable<R>, Collection<R>
@Internal
public record MappedCollection<O,R> (Collection<O> original, Function<O,R> mapper)
extends Record
implements Collection<R>
-
Constructor Summary
ConstructorsConstructorDescriptionMappedCollection(Collection<O> original, Function<O, R> mapper) Creates an instance of aMappedCollectionrecord class. -
Method Summary
Modifier and TypeMethodDescriptionbooleanbooleanaddAll(Collection<? extends R> c) voidclear()booleanbooleancontainsAll(Collection<?> c) final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.booleanisEmpty()iterator()mapper()Returns the value of themapperrecord component.original()Returns the value of theoriginalrecord component.static <O extends AtomicReference<R>, R>
MappedCollection<O, R> plainReferences(Collection<O> original) booleanbooleanremoveAll(Collection<?> c) booleanretainAll(Collection<?> c) intsize()Object[]toArray()<T> T[]toArray(T[] a) final StringtoString()Returns a string representation of this record class.Methods inherited from interface Collection
parallelStream, removeIf, spliterator, stream, toArray
-
Constructor Details
-
MappedCollection
Creates an instance of aMappedCollectionrecord class.- Parameters:
original- the value for theoriginalrecord componentmapper- the value for themapperrecord component
-
-
Method Details
-
plainReferences
public static <O extends AtomicReference<R>, R> MappedCollection<O,R> plainReferences(Collection<O> original) -
size
public int size()- Specified by:
sizein interfaceCollection<O>
-
isEmpty
public boolean isEmpty()- Specified by:
isEmptyin interfaceCollection<O>
-
contains
- Specified by:
containsin interfaceCollection<O>
-
iterator
-
toArray
- Specified by:
toArrayin interfaceCollection<O>
-
toArray
public <T> T[] toArray(T[] a) - Specified by:
toArrayin interfaceCollection<O>
-
containsAll
- Specified by:
containsAllin interfaceCollection<O>
-
add
- Specified by:
addin interfaceCollection<O>
-
remove
- Specified by:
removein interfaceCollection<O>
-
addAll
- Specified by:
addAllin interfaceCollection<O>
-
removeAll
- Specified by:
removeAllin interfaceCollection<O>
-
retainAll
- Specified by:
retainAllin interfaceCollection<O>
-
clear
public void clear()- Specified by:
clearin interfaceCollection<O>
-
toString
-
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components.- Specified by:
hashCodein interfaceCollection<O>- Specified by:
hashCodein classRecord- Returns:
- a hash code value for this object
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object).- Specified by:
equalsin interfaceCollection<O>- Specified by:
equalsin classRecord- Parameters:
o- the object with which to compare- Returns:
trueif this object is the same as theoargument;falseotherwise.
-
original
Returns the value of theoriginalrecord component.- Returns:
- the value of the
originalrecord component
-
mapper
-