code: public static <T> Collector<T, ?, Optional<T>> onlyOne() {
          return new CancellableCollectorImpl<T, Box<Optional<T>>, Optional<T>>(Box::new, (box,
                  t) -> box.a = box.a == null ? Optional.of(t) : Optional.empty(), (box1, box2) -> box1.a == null ? box2
                          : box2.a == null ? box1 : new Box<>(Optional.empty()), box -> box.a == null ? Optional.empty()
                                  : box.a, box -> box.a != null && !box.a.isPresent(), UNORDERED_CHARACTERISTICS);
      }
docs: Returns a {@code Collector} which collects the stream element if stream
  contains exactly one element.
  
  <p>
  This method returns a
  <a href="package-summary.html#ShortCircuitReduction">short-circuiting
  collector</a>.
  
  @param <T> the type of the input elements
  @return a collector which returns an {@link Optional} describing the only
  element of the stream. For empty stream or stream containing more
  than one element an empty {@code Optional} is returned.
  @since 0.4.0