Interface ReadOnlyCollection<E>

Type Parameters:
E - the element type
All Superinterfaces:
Iterable<E>
All Known Subinterfaces:
ImmutableCollection<E>, ImmutableList<E>, ImmutableNavigableSet<E>, ImmutableSequencedCollection<E>, ImmutableSequencedSet<E>, ImmutableSet<E>, ImmutableSortedSet<E>, Option<T>, ReadOnlyList<E>, ReadOnlyNavigableSet<E>, ReadOnlySequencedCollection<E>, ReadOnlySequencedSet<E>, ReadOnlySet<E>, ReadOnlySortedSet<E>
All Known Implementing Classes:
org.jhotdraw8.icollection.impl.champ.AbstractMutableChampSet, AbstractReadOnlyCollection, AbstractReadOnlyList, AbstractReadOnlySet, ChampSet, ChampVectorSet, CollectionFacade, ImmutableSetFacade, MutableChampSet, MutableChampVectorSet, MutableListFacade, MutableRedBlackSet, MutableSetFacade, MutableVectorList, NavigableSetFacade, Option.None, Option.Some, ReadOnlyCollectionFacade, ReadOnlyListFacade, ReadOnlyNavigableSetFacade, ReadOnlySequencedCollectionFacade, ReadOnlySequencedSetFacade, ReadOnlySetFacade, ReadOnlySortedSetFacade, RedBlackSet, SequencedCollectionFacade, SequencedSetFacade, SetFacade, VectorList

public interface ReadOnlyCollection<E> extends Iterable<E>
A read-only interface to a collection.

A collection represents a group of objects, known as its elements.

This interface does not guarantee 'read-only', it actually guarantees 'readable'. We use the prefix 'ReadOnly' because this is the naming convention in JavaFX for interfaces that provide read methods but no write methods.

  • Method Details

    • size

      int size()
      Returns the size of the collection.
      Returns:
      the size
    • isEmpty

      default boolean isEmpty()
      Returns true if the collection is empty.
      Returns:
      true if empty
    • toArray

      default Object @NonNull [] toArray()
    • toArray

      default <T> @NonNull T @NonNull [] toArray(@NonNull T @NonNull [] a)
      Converts the collection to an array.
      Type Parameters:
      T - the element type
      Parameters:
      a - a template array
      Returns:
      an array
    • stream

      default Stream<E> stream()
      Returns a stream.
      Returns:
      a stream
    • contains

      boolean contains(Object o)
      Returns true if this collection contains the specified object.
      Parameters:
      o - an object
      Returns:
      true if this collection contains the specified object
    • iterator

      @NonNull Iterator<E> iterator()
      Returns an iterator over the elements in this collection.
      Specified by:
      iterator in interface Iterable<E>
      Returns:
      an iterator
    • containsAll

      default boolean containsAll(@NonNull Iterable<?> c)
      Returns true if this collection contains all elements of that collection.
      Parameters:
      c - another collection
      Returns:
      true if this collection contains all of c
    • asCollection

      default @NonNull Collection<E> asCollection()
      Wraps this collection in the Collection interface - without copying.
      Returns:
      the wrapped collection
    • iterableToString

      static <E> @NonNull String iterableToString(@NonNull Iterable<E> c)
      Returns a string representation of the provided iterable. The string representation consists of a list of the iterable's elements in the order they are returned, enclosed in square brackets ("[]"). Adjacent elements are separated by the characters ", " (comma and space). Elements are converted to strings as by String.valueOf(Object).
      Type Parameters:
      E - the element type
      Parameters:
      c - an iterable
      Returns:
      a string representation of the iterable
    • characteristics

      default int characteristics()
      Returns the Spliterator characteristics of this collection.

      The default implementation returns Spliterator.SIZED.

      Returns:
      the characteristics