|
34 | 34 | import org.neo4j.driver.v1.util.Function;
|
35 | 35 | import org.neo4j.driver.v1.util.Functions;
|
36 | 36 |
|
37 |
| -// todo: unit tests |
38 | 37 | public class InternalStatementResultCursor implements StatementResultCursor
|
39 | 38 | {
|
40 |
| - // todo: maybe smth better than these two string constants? |
41 |
| - private static final String BLOCKING_NAME = "result"; |
42 |
| - private static final String ASYNC_NAME = "cursor"; |
43 |
| - |
44 |
| - private final String name; |
45 | 39 | private final RunResponseHandler runResponseHandler;
|
46 | 40 | private final PullAllResponseHandler pullAllHandler;
|
47 | 41 |
|
48 |
| - private InternalStatementResultCursor( String name, RunResponseHandler runResponseHandler, |
49 |
| - PullAllResponseHandler pullAllHandler ) |
| 42 | + public InternalStatementResultCursor( RunResponseHandler runResponseHandler, PullAllResponseHandler pullAllHandler ) |
50 | 43 | {
|
51 |
| - this.name = name; |
52 | 44 | this.runResponseHandler = runResponseHandler;
|
53 | 45 | this.pullAllHandler = pullAllHandler;
|
54 | 46 | }
|
55 | 47 |
|
56 |
| - public static InternalStatementResultCursor forBlockingRun( RunResponseHandler runResponseHandler, |
57 |
| - PullAllResponseHandler pullAllHandler ) |
58 |
| - { |
59 |
| - return new InternalStatementResultCursor( BLOCKING_NAME, runResponseHandler, pullAllHandler ); |
60 |
| - } |
61 |
| - |
62 |
| - public static InternalStatementResultCursor forAsyncRun( RunResponseHandler runResponseHandler, |
63 |
| - PullAllResponseHandler pullAllHandler ) |
64 |
| - { |
65 |
| - return new InternalStatementResultCursor( ASYNC_NAME, runResponseHandler, pullAllHandler ); |
66 |
| - } |
67 |
| - |
68 | 48 | @Override
|
69 | 49 | public List<String> keys()
|
70 | 50 | {
|
@@ -97,14 +77,14 @@ public CompletionStage<Record> singleAsync()
|
97 | 77 | if ( firstRecord == null )
|
98 | 78 | {
|
99 | 79 | throw new NoSuchRecordException(
|
100 |
| - "Cannot retrieve a single record, because this " + name + " is empty." ); |
| 80 | + "Cannot retrieve a single record, because this result is empty." ); |
101 | 81 | }
|
102 | 82 | return nextAsync().thenApply( secondRecord ->
|
103 | 83 | {
|
104 | 84 | if ( secondRecord != null )
|
105 | 85 | {
|
106 | 86 | throw new NoSuchRecordException(
|
107 |
| - "Expected a " + name + " with a single record, but this " + name + " " + |
| 87 | + "Expected a result with a single record, but this result " + |
108 | 88 | "contains at least one more. Ensure your query returns only " +
|
109 | 89 | "one record." );
|
110 | 90 | }
|
|
0 commit comments