Class View<T>

java.lang.Object
dev.twilite.game.stream.View<T>
All Implemented Interfaces:
Iterable<T>
Direct Known Subclasses:
BaseItemView, ComponentView, GrandExchangeOfferView, ServerView, UnitView

public class View<T> extends Object implements Iterable<T>
Lazy filtered view over game API objects.
  • Constructor Details

    • View

      public View(Supplier<Stream<T>> source)
      Creates a view backed by a stream supplier.
  • Method Details

    • filter

      public View<T> filter(Predicate<T> filter)
      Returns a new view with an additional filter.
    • not

      public View<T> not()
      Returns a new view with the most recent filter negated.
    • or

      public View<T> or(Predicate<T> filter)
      Returns a new view with the supplied filter OR'ed with the most recent filter.
    • first

      public Optional<T> first()
      Returns the first matching element.
    • toList

      public List<T> toList()
      Materializes the current view into a list.
    • map

      public <R> Stream<R> map(Function<T,R> mapper)
      Maps matching elements into another stream.
    • mapToInt

      public IntStream mapToInt(ToIntFunction<T> mapper)
      Maps matching elements into an int stream.
    • count

      public int count()
      Counts matching elements.
    • exists

      public boolean exists()
      Returns whether the view contains at least one element.
    • stream

      public Stream<T> stream()
      Opens a stream of matching elements.
    • iterator

      public Iterator<T> iterator()
      Iterates over matching elements.
      Specified by:
      iterator in interface Iterable<T>