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> (@NotNull Collection<O> original, @NotNull Function<O,R> mapper)
extends Record
implements Collection<R>
-
Constructor Summary
ConstructorsConstructorDescriptionMappedCollection(@NotNull Collection<O> original, @NotNull Function<O, R> mapper) Creates an instance of aMappedCollectionrecord class. -
Method Summary
Modifier and TypeMethodDescriptionbooleanbooleanaddAll(@NotNull Collection<? extends R> c) voidclear()booleanbooleancontainsAll(@NotNull 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.@NotNull Collection<O> original()Returns the value of theoriginalrecord component.static <O extends AtomicReference<R>,R>
MappedCollection<O, R> plainReferences(@NotNull Collection<O> original) booleanbooleanremoveAll(@NotNull Collection<?> c) booleanretainAll(@NotNull Collection<?> c) intsize()@NotNull Object @NotNull []toArray()<T> T @NotNull []toArray(T @NotNull [] a) final StringtoString()Returns a string representation of this record class.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, spliterator, stream, toArray
-
Constructor Details
-
MappedCollection
public MappedCollection(@NotNull @NotNull Collection<O> original, @NotNull @NotNull Function<O, R> mapper) 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(@NotNull @NotNull 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
@NotNull public <T> T @NotNull [] toArray(@NotNull T @NotNull [] 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
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
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
Returns the value of themapperrecord component.- Returns:
- the value of the
mapperrecord component
-