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 Details

    • MappedCollection

      public MappedCollection(@NotNull @NotNull Collection<O> original, @NotNull @NotNull Function<O,R> mapper)
      Creates an instance of a MappedCollection record class.
      Parameters:
      original - the value for the original record component
      mapper - the value for the mapper 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 interface Collection<O>
    • isEmpty

      public boolean isEmpty()
      Specified by:
      isEmpty in interface Collection<O>
    • contains

      public boolean contains(Object o)
      Specified by:
      contains in interface Collection<O>
    • iterator

      @NotNull public @NotNull Iterator<R> iterator()
      Specified by:
      iterator in interface Collection<O>
      Specified by:
      iterator in interface Iterable<O>
    • toArray

      @NotNull public @NotNull Object @NotNull [] toArray()
      Specified by:
      toArray in interface Collection<O>
    • toArray

      @NotNull public <T> @NotNull T @NotNull [] toArray(@NotNull @NotNull T @NotNull [] a)
      Specified by:
      toArray in interface Collection<O>
    • containsAll

      public boolean containsAll(@NotNull @NotNull Collection<?> c)
      Specified by:
      containsAll in interface Collection<O>
    • add

      public boolean add(R t)
      Specified by:
      add in interface Collection<O>
    • remove

      public boolean remove(Object o)
      Specified by:
      remove in interface Collection<O>
    • addAll

      public boolean addAll(@NotNull @NotNull Collection<? extends R> c)
      Specified by:
      addAll in interface Collection<O>
    • removeAll

      public boolean removeAll(@NotNull @NotNull Collection<?> c)
      Specified by:
      removeAll in interface Collection<O>
    • retainAll

      public boolean retainAll(@NotNull @NotNull Collection<?> c)
      Specified by:
      retainAll in interface Collection<O>
    • clear

      public void clear()
      Specified by:
      clear in interface Collection<O>
    • toString

      public final String 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.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • 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 interface Collection<O>
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 with Objects::equals(Object,Object).
      Specified by:
      equals in interface Collection<O>
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • original

      @NotNull public @NotNull Collection<O> original()
      Returns the value of the original record component.
      Returns:
      the value of the original record component
    • mapper

      @NotNull public @NotNull Function<O,R> mapper()
      Returns the value of the mapper record component.
      Returns:
      the value of the mapper record component