code: public static <T> Collector<T, ?, Optional<T>> first() {
          return new CancellableCollectorImpl<>(() -> new Box<T>(none()), (box, t) -> {
              if (box.a == NONE)
                  box.a = t;
          }, (box1, box2) -> box1.a == NONE ? box2 : box1, box -> box.a == NONE ? Optional.empty() : Optional.of(box.a),
                  box -> box.a != NONE, NO_CHARACTERISTICS);
      }
docs: Returns a {@code Collector} which collects only the first stream element
  if any.
  
  <p>
  This method returns a
  <a href="package-summary.html#ShortCircuitReduction">short-circuiting
  collector</a>.
  
  <p>
  The operation performed by the returned collector is equivalent to
  {@code stream.findFirst()}. This collector is mostly useful as a
  downstream collector.
  
  @param <T> the type of the input elements
  @return a collector which returns an {@link Optional} which describes the
  first element of the stream. For empty stream an empty
  {@code Optional} is returned.