@@ -194,13 +194,16 @@ public Optional<T> get() {
194194 return hasValue ? Optional .of (value ) : null ;
195195 }
196196
197- static final TerminalOp <?, ?> OP_FIND_FIRST = new FindOp <>(true ,
198- StreamShape .REFERENCE , Optional .empty (),
199- Optional ::isPresent , FindSink .OfRef ::new );
200-
201- static final TerminalOp <?, ?> OP_FIND_ANY = new FindOp <>(false ,
202- StreamShape .REFERENCE , Optional .empty (),
203- Optional ::isPresent , FindSink .OfRef ::new );
197+ static final TerminalOp <?, ?> OP_FIND_FIRST , OP_FIND_ANY ;
198+ static {
199+ Predicate <Optional <Object >> isPresent = Optional ::isPresent ;
200+ Supplier <TerminalSink <Object , Optional <Object >>> newSink
201+ = FindSink .OfRef ::new ;
202+ OP_FIND_FIRST = new FindOp <>(true , StreamShape .REFERENCE ,
203+ Optional .empty (), isPresent , newSink );
204+ OP_FIND_ANY = new FindOp <>(false , StreamShape .REFERENCE ,
205+ Optional .empty (), isPresent , newSink );
206+ }
204207 }
205208
206209 /** Specialization of {@code FindSink} for int streams */
@@ -217,12 +220,16 @@ public OptionalInt get() {
217220 return hasValue ? OptionalInt .of (value ) : null ;
218221 }
219222
220- static final TerminalOp <Integer , OptionalInt > OP_FIND_FIRST = new FindOp <>(true ,
221- StreamShape .INT_VALUE , OptionalInt .empty (),
222- OptionalInt ::isPresent , FindSink .OfInt ::new );
223- static final TerminalOp <Integer , OptionalInt > OP_FIND_ANY = new FindOp <>(false ,
224- StreamShape .INT_VALUE , OptionalInt .empty (),
225- OptionalInt ::isPresent , FindSink .OfInt ::new );
223+ static final TerminalOp <Integer , OptionalInt > OP_FIND_FIRST , OP_FIND_ANY ;
224+ static {
225+ Predicate <OptionalInt > isPresent = OptionalInt ::isPresent ;
226+ Supplier <TerminalSink <Integer , OptionalInt >> newSink
227+ = FindSink .OfInt ::new ;
228+ OP_FIND_FIRST = new FindOp <>(true , StreamShape .INT_VALUE ,
229+ OptionalInt .empty (), isPresent , newSink );
230+ OP_FIND_ANY = new FindOp <>(false , StreamShape .INT_VALUE ,
231+ OptionalInt .empty (), isPresent , newSink );
232+ }
226233 }
227234
228235 /** Specialization of {@code FindSink} for long streams */
@@ -239,12 +246,16 @@ public OptionalLong get() {
239246 return hasValue ? OptionalLong .of (value ) : null ;
240247 }
241248
242- static final TerminalOp <Long , OptionalLong > OP_FIND_FIRST = new FindOp <>(true ,
243- StreamShape .LONG_VALUE , OptionalLong .empty (),
244- OptionalLong ::isPresent , FindSink .OfLong ::new );
245- static final TerminalOp <Long , OptionalLong > OP_FIND_ANY = new FindOp <>(false ,
246- StreamShape .LONG_VALUE , OptionalLong .empty (),
247- OptionalLong ::isPresent , FindSink .OfLong ::new );
249+ static final TerminalOp <Long , OptionalLong > OP_FIND_FIRST , OP_FIND_ANY ;
250+ static {
251+ Predicate <OptionalLong > isPresent = OptionalLong ::isPresent ;
252+ Supplier <TerminalSink <Long , OptionalLong >> newSink
253+ = FindSink .OfLong ::new ;
254+ OP_FIND_FIRST = new FindOp <>(true , StreamShape .LONG_VALUE ,
255+ OptionalLong .empty (), isPresent , newSink );
256+ OP_FIND_ANY = new FindOp <>(false , StreamShape .LONG_VALUE ,
257+ OptionalLong .empty (), isPresent , newSink );
258+ }
248259 }
249260
250261 /** Specialization of {@code FindSink} for double streams */
@@ -261,12 +272,16 @@ public OptionalDouble get() {
261272 return hasValue ? OptionalDouble .of (value ) : null ;
262273 }
263274
264- static final TerminalOp <Double , OptionalDouble > OP_FIND_FIRST = new FindOp <>(true ,
265- StreamShape .DOUBLE_VALUE , OptionalDouble .empty (),
266- OptionalDouble ::isPresent , FindSink .OfDouble ::new );
267- static final TerminalOp <Double , OptionalDouble > OP_FIND_ANY = new FindOp <>(false ,
268- StreamShape .DOUBLE_VALUE , OptionalDouble .empty (),
269- OptionalDouble ::isPresent , FindSink .OfDouble ::new );
275+ static final TerminalOp <Double , OptionalDouble > OP_FIND_FIRST , OP_FIND_ANY ;
276+ static {
277+ Predicate <OptionalDouble > isPresent = OptionalDouble ::isPresent ;
278+ Supplier <TerminalSink <Double , OptionalDouble >> newSink
279+ = FindSink .OfDouble ::new ;
280+ OP_FIND_FIRST = new FindOp <>(true , StreamShape .DOUBLE_VALUE ,
281+ OptionalDouble .empty (), isPresent , newSink );
282+ OP_FIND_ANY = new FindOp <>(false , StreamShape .DOUBLE_VALUE ,
283+ OptionalDouble .empty (), isPresent , newSink );
284+ }
270285 }
271286 }
272287
0 commit comments