-
Notifications
You must be signed in to change notification settings - Fork 31
/
AutoCloseFactory.java
72 lines (65 loc) · 3.19 KB
/
AutoCloseFactory.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*
* JPAstreamer - Express JPA queries with Java Streams
* Copyright (c) 2020-2022, Speedment, Inc. All Rights Reserved.
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* See: https://github.com/speedment/jpa-streamer/blob/master/LICENSE
*/
package com.speedment.jpastreamer.autoclose;
import java.util.stream.*;
public interface AutoCloseFactory {
/**
* Creates and returns a new wrapped Stream that will call its {@link Stream#close()} method
* automatically after a terminating operation has been called.
* <p>
* N.B. The {@link BaseStream#iterator()} {@link BaseStream#spliterator()} methods will throw
* an {@link UnsupportedOperationException} because otherwise the AutoClose
* property cannot be guaranteed. This can be unlocked by setting the
* system property "jpastreamer.allowiteratorandspliterator" to {@code true}.
*
* @param <T> Stream type
* @author Per Minborg
*/
<T> Stream<T> createAutoCloseStream(Stream<T> stream);
/**
* Creates and returns a new wrapped IntStream that will call its {@link BaseStream#close()}
* method automatically after a terminating operation has been called.
* <p>
* N.B. The {@link BaseStream#iterator()} {@link BaseStream#spliterator()} methods will throw
* an {@link UnsupportedOperationException} because otherwise the AutoClose
* property cannot be guaranteed. This can be unlocked by setting the
* system property "jpastreamer.allowiteratorandspliterator" to {@code true}.
*
* @author Per Minborg
*/
IntStream createAutoCloseIntStream(IntStream intStream);
/**
* Creates and returns a new wrapped LongStream that will call its {@link BaseStream#close()}
* method automatically after a terminating operation has been called.
* <p>
* N.B. The {@link BaseStream#iterator()} {@link BaseStream#spliterator()} methods will throw
* an {@link UnsupportedOperationException} because otherwise the AutoClose
* property cannot be guaranteed. This can be unlocked by setting the
* system property "jpastreamer.allowiteratorandspliterator" to {@code true}.
*
* @author Per Minborg
*/
LongStream createAutoCloseLongStream(LongStream longStream);
/**
* Creates and returns a new wrapped DoubleStream that will call its {@link BaseStream#close()}
* method automatically after a terminating operation has been called.
* <p>
* N.B. The {@link BaseStream#iterator()} {@link BaseStream#spliterator()} methods will throw
* an {@link UnsupportedOperationException} because otherwise the AutoClose
* property cannot be guaranteed. This can be unlocked by setting the
* system property "jpastreamer.allowiteratorandspliterator" to {@code true}.
*
* @author Per Minborg
*/
DoubleStream createAutoCloseDoubleStream(DoubleStream doubleStream);
}