310 public final S parallel() { 311 sourceStage.parallel = true; 312 return (S) this; 313 } 314 315 @Override 316 public void close() { 317 linkedOrConsumed = true; 318 sourceSupplier = null; 319 sourceSpliterator = null; 320 if (sourceStage.sourceCloseAction != null) { 321 Runnable closeAction = sourceStage.sourceCloseAction; 322 sourceStage.sourceCloseAction = null; 323 closeAction.run(); 324 } 325 } 326 327 @Override 328 @SuppressWarnings("unchecked") 329 public S onClose(Runnable closeHandler) { 330 Objects.requireNonNull(closeHandler); 331 Runnable existingHandler = sourceStage.sourceCloseAction; 332 sourceStage.sourceCloseAction = 333 (existingHandler == null) 334 ? closeHandler 335 : Streams.composeWithExceptions(existingHandler, closeHandler); 336 return (S) this; 337 } 338 339 // Primitive specialization use co-variant overrides, hence is not final 340 @Override 341 @SuppressWarnings("unchecked") 342 public Spliterator<E_OUT> spliterator() { 343 if (linkedOrConsumed) 344 throw new IllegalStateException(MSG_STREAM_LINKED); 345 linkedOrConsumed = true; 346 347 if (this == sourceStage) { 348 if (sourceStage.sourceSpliterator != null) { 349 @SuppressWarnings("unchecked") | 310 public final S parallel() { 311 sourceStage.parallel = true; 312 return (S) this; 313 } 314 315 @Override 316 public void close() { 317 linkedOrConsumed = true; 318 sourceSupplier = null; 319 sourceSpliterator = null; 320 if (sourceStage.sourceCloseAction != null) { 321 Runnable closeAction = sourceStage.sourceCloseAction; 322 sourceStage.sourceCloseAction = null; 323 closeAction.run(); 324 } 325 } 326 327 @Override 328 @SuppressWarnings("unchecked") 329 public S onClose(Runnable closeHandler) { 330 if (linkedOrConsumed) 331 throw new IllegalStateException(MSG_STREAM_LINKED); 332 Objects.requireNonNull(closeHandler); 333 Runnable existingHandler = sourceStage.sourceCloseAction; 334 sourceStage.sourceCloseAction = 335 (existingHandler == null) 336 ? closeHandler 337 : Streams.composeWithExceptions(existingHandler, closeHandler); 338 return (S) this; 339 } 340 341 // Primitive specialization use co-variant overrides, hence is not final 342 @Override 343 @SuppressWarnings("unchecked") 344 public Spliterator<E_OUT> spliterator() { 345 if (linkedOrConsumed) 346 throw new IllegalStateException(MSG_STREAM_LINKED); 347 linkedOrConsumed = true; 348 349 if (this == sourceStage) { 350 if (sourceStage.sourceSpliterator != null) { 351 @SuppressWarnings("unchecked") |