Interface ReplicaCollection<C extends ReplicaCollection<C>>

All Superinterfaces:
Iterable<Replica>
All Known Subinterfaces:
ReplicaCollection.Builder<C>
All Known Implementing Classes:
AbstractReplicaCollection, Endpoints, EndpointsForRange, EndpointsForRange.Builder, EndpointsForToken, EndpointsForToken.Builder, RangesAtEndpoint, RangesAtEndpoint.Builder

public interface ReplicaCollection<C extends ReplicaCollection<C>> extends Iterable<Replica>
A collection like class for Replica objects. Represents both a well defined order on the contained Replica objects, and efficient methods for accessing the contained Replicas, directly and as a projection onto their endpoints and ranges.
  • Method Details

    • endpoints

      Set<InetAddressAndPort> endpoints()
      Returns:
      a Set of the endpoints of the contained Replicas. Iteration order is maintained where there is a 1:1 relationship between endpoint and Replica Typically this collection offers O(1) access methods, and this is true for all but ReplicaList.
    • get

      Replica get(int i)
      Parameters:
      i - a value in the range [0..size())
      Returns:
      the i'th Replica, in our iteration order
    • size

      int size()
      Returns:
      the number of Replica contained
    • isEmpty

      boolean isEmpty()
      Returns:
      true iff size() == 0
    • contains

      boolean contains(Replica replica)
      Returns:
      true iff a Replica in this collection is equal to the provided Replica. Typically this method is expected to take O(1) time, and this is true for all but ReplicaList.
    • count

      int count(Predicate<? super Replica> predicate)
      Returns:
      the number of replicas that match the predicate
    • filter

      C filter(Predicate<? super Replica> predicate)
      Returns:
      a *eagerly constructed* copy of this collection containing the Replica that match the provided predicate. An effort will be made to either return ourself, or a subList, where possible. It is guaranteed that no changes to any upstream Builder will affect the state of the result.
    • filter

      C filter(Predicate<? super Replica> predicate, int maxSize)
      Returns:
      a *eagerly constructed* copy of this collection containing the Replica that match the provided predicate. An effort will be made to either return ourself, or a subList, where possible. It is guaranteed that no changes to any upstream Builder will affect the state of the result. Only the first maxSize items will be returned.
    • filterLazily

      Iterable<Replica> filterLazily(Predicate<? super Replica> predicate)
      Returns:
      a *lazily constructed* Iterable over this collection, containing the Replica that match the provided predicate.
    • filterLazily

      Iterable<Replica> filterLazily(Predicate<? super Replica> predicate, int maxSize)
      Returns:
      a *lazily constructed* Iterable over this collection, containing the Replica that match the provided predicate. Only the first maxSize matching items will be returned.
    • subList

      C subList(int start, int end)
      Returns:
      an *eagerly constructed* copy of this collection containing the Replica at positions [start..end); An effort will be made to either return ourself, or a subList, where possible. It is guaranteed that no changes to any upstream Builder will affect the state of the result.
    • sorted

      C sorted(Comparator<? super Replica> comparator)
      Returns:
      an *eagerly constructed* copy of this collection containing the Replica re-ordered according to this comparator It is guaranteed that no changes to any upstream Builder will affect the state of the result.
    • iterator

      Iterator<Replica> iterator()
      Specified by:
      iterator in interface Iterable<C extends ReplicaCollection<C>>
    • stream

      Stream<Replica> stream()
    • equals

      boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      String toString()
      Overrides:
      toString in class Object