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
ConstructorDescriptionMappedCollection
(@NotNull Collection<O> original, @NotNull Function<O, R> mapper) Creates an instance of aMappedCollection
record class. -
Method Summary
Modifier and TypeMethodDescriptionboolean
boolean
addAll
(@NotNull Collection<? extends R> c) void
clear()
boolean
boolean
containsAll
(@NotNull Collection<?> c) final boolean
Indicates whether some other object is "equal to" this one.final int
hashCode()
Returns a hash code value for this object.boolean
isEmpty()
iterator()
mapper()
Returns the value of themapper
record component.@NotNull Collection
<O> original()
Returns the value of theoriginal
record component.static <O extends AtomicReference<R>,
R>
MappedCollection<O, R> plainReferences
(@NotNull Collection<O> original) boolean
boolean
removeAll
(@NotNull Collection<?> c) boolean
retainAll
(@NotNull Collection<?> c) int
size()
@NotNull Object @NotNull []
toArray()
<T> T @NotNull []
toArray
(T @NotNull [] a) final String
toString()
Returns a string representation of this record class.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods 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 aMappedCollection
record class.- Parameters:
original
- the value for theoriginal
record componentmapper
- the value for themapper
record 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:
size
in interfaceCollection<O>
-
isEmpty
public boolean isEmpty()- Specified by:
isEmpty
in interfaceCollection<O>
-
contains
- Specified by:
contains
in interfaceCollection<O>
-
iterator
-
toArray
- Specified by:
toArray
in interfaceCollection<O>
-
toArray
@NotNull public <T> T @NotNull [] toArray(@NotNull T @NotNull [] a) - Specified by:
toArray
in interfaceCollection<O>
-
containsAll
- Specified by:
containsAll
in interfaceCollection<O>
-
add
- Specified by:
add
in interfaceCollection<O>
-
remove
- Specified by:
remove
in interfaceCollection<O>
-
addAll
- Specified by:
addAll
in interfaceCollection<O>
-
removeAll
- Specified by:
removeAll
in interfaceCollection<O>
-
retainAll
- Specified by:
retainAll
in interfaceCollection<O>
-
clear
public void clear()- Specified by:
clear
in 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:
hashCode
in interfaceCollection<O>
- Specified by:
hashCode
in 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:
equals
in interfaceCollection<O>
- Specified by:
equals
in classRecord
- Parameters:
o
- the object with which to compare- Returns:
true
if this object is the same as theo
argument;false
otherwise.
-
original
Returns the value of theoriginal
record component.- Returns:
- the value of the
original
record component
-
mapper
Returns the value of themapper
record component.- Returns:
- the value of the
mapper
record component
-