/// <summary> /// Indicates whether some other object is "equal to" this OptionalInt. The /// other object is considered equal if: /// <ul> /// <li>it is also an {@code OptionalInt} and; /// <li>both instances have no value present or; /// <li>the present values are "equal to" each other via {@code ==}. /// </ul> /// </summary> /// <param name="obj"> an object to be tested for equality </param> /// <returns> {code true} if the other object is "equal to" this object /// otherwise {@code false} </returns> public override bool Equals(Object obj) { if (this == obj) { return(true); } if (!(obj is OptionalInt)) { return(false); } OptionalInt other = (OptionalInt)obj; return((IsPresent && other.IsPresent) ? Value == other.Value : IsPresent == other.IsPresent); }
/// <summary> /// Constructs a {@code TerminalOp} for streams of ints. /// </summary> /// <param name="mustFindFirst"> whether the {@code TerminalOp} must produce the /// first element in the encounter order </param> /// <returns> a {@code TerminalOp} implementing the find operation </returns> public static TerminalOp <Integer, OptionalInt> MakeInt(bool mustFindFirst) { return(new FindOp <>(mustFindFirst, StreamShape.INT_VALUE, OptionalInt.Empty(), OptionalInt::isPresent, FindSink.OfInt::new)); }