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>, 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, 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 Summary

    Modifier and Type
    Method
    Description
    default Collection<E>
    Wraps this collection in the Collection interface - without copying.
    default int
    Returns the Spliterator characteristics of this collection.
    boolean
    Returns true if this collection contains the specified object.
    default boolean
    Returns true if this collection contains all elements of that collection.
    default boolean
    Returns true if the collection is empty.
    static <E> String
    Returns a string representation of the provided iterable.
    Returns an iterator over the elements in this collection.
    int
    Returns the size of the collection.
    default Stream<E>
    Returns a stream.
    default Object[]
     
    default <T> T[]
    toArray(T[] a)
    Converts the collection to an array.

    Methods inherited from interface java.lang.Iterable

    forEach, spliterator
  • 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[] toArray()
    • toArray

      default <T> T[] toArray(T[] 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

      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(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 Collection<E> asCollection()
      Wraps this collection in the Collection interface - without copying.
      Returns:
      the wrapped collection
    • iterableToString

      static <E> String iterableToString(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 in this interface returns Spliterator.SIZED.

      Returns:
      the characteristics