-
- Type Parameters:
T
- The type of the result of thisOperation
- All Superinterfaces:
Operation<T>
,OutOperation<T>
,ParameterizedOperation<T>
,PrimitiveOperation<T>
public interface MultiOperation<T> extends OutOperation<T>
A multi-operation is anOperation
that returns one or more results in addition to the out result defined by theOperation
. Each result is processed by anOperation
. TheOperation
s can be created by callingrowOperation()
, orrowCountOperation()
if the kind of results is known. These results are processed in the order theOperation
s are submitted. Any results not processed by an explicitOperation
is processed by calling the appropriate handler specified byonRows(java.util.function.BiConsumer<java.lang.Integer, jdk.incubator.sql2.RowOperation<T>>)
oronCount(java.util.function.BiConsumer<java.lang.Integer, jdk.incubator.sql2.RowCountOperation<T>>)
. If any result is an error that error is processed by calling the handler specified byOperation.onError(java.util.function.Consumer<java.lang.Throwable>)
of the correspondingOperation
. If the appropriate handler is not specified that result is ignored, including errors. ISSUE: Should this have a collector?
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description MultiOperation<T>
apply(java.util.function.Function<Result.OutColumn,? extends T> processor)
Provide a processor that will handle the result of executing the SQL.MultiOperation<T>
onCount(java.util.function.BiConsumer<java.lang.Integer,RowCountOperation<T>> handler)
Provides a handler for trailing count results.MultiOperation<T>
onError(java.util.function.BiConsumer<java.lang.Integer,java.lang.Throwable> handler)
Provides an error handler for thisOperation
.MultiOperation<T>
onError(java.util.function.Consumer<java.lang.Throwable> handler)
This handler is called if the execution fails completely.MultiOperation<T>
onRows(java.util.function.BiConsumer<java.lang.Integer,RowOperation<T>> handler)
Provides a handler for trailing row sequence results.MultiOperation<T>
outParameter(java.lang.String id, SqlType type)
Register an out parameter identified by the given id.RowCountOperation<T>
rowCountOperation()
Returns aRowCountOperation
to process a count result.RowOperation<T>
rowOperation()
Returns aRowOperation
to process a row sequence result.RowPublisherOperation<T>
rowPublisherOperation()
Returns aRowPublisherOperation
to process a row sequence result.MultiOperation<T>
set(java.lang.String id, java.lang.Object value)
Set a parameter value.MultiOperation<T>
set(java.lang.String id, java.lang.Object value, SqlType type)
Set a parameter value.MultiOperation<T>
set(java.lang.String id, java.util.concurrent.CompletionStage<?> source)
Set a parameter value to be the future value of aCompletionStage
.MultiOperation<T>
set(java.lang.String id, java.util.concurrent.CompletionStage<?> source, SqlType type)
Set a parameter value to be the value of aCompletionStage
.MultiOperation<T>
timeout(java.time.Duration minTime)
The minimum time before thisOperation
might be canceled automatically.-
Methods inherited from interface jdk.incubator.sql2.PrimitiveOperation
submit
-
-
-
-
Method Detail
-
rowOperation
RowOperation<T> rowOperation()
Returns aRowOperation
to process a row sequence result. TheOperation
s are executed in the order they are submitted. If a result is of the wrong type for the next submittedOperation
theMultiOperation
is completed withIllegalStateException
.- Returns:
- a
RowOperation
that is part of thisMultiOperation
-
rowPublisherOperation
RowPublisherOperation<T> rowPublisherOperation()
Returns aRowPublisherOperation
to process a row sequence result. TheOperation
s are executed in the order they are submitted. If a result is of the wrong type for the next submittedOperation
theMultiOperation
is completed withIllegalStateException
.- Returns:
- a
RowPublisherOperation
that is part of thisMultiOperation
-
rowCountOperation
RowCountOperation<T> rowCountOperation()
Returns aRowCountOperation
to process a count result. TheOperation
s are executed in the order they are submitted. If a result is of the wrong type for the next submitted Operation theMultiOperation
is completed withIllegalStateException
.- Returns:
- a
RowCountOperation
that is part of thisMultiOperation
-
onCount
MultiOperation<T> onCount(java.util.function.BiConsumer<java.lang.Integer,RowCountOperation<T>> handler)
Provides a handler for trailing count results. The provided handler is called for each count result not processed by RowCountOperation. When called the first argument is the number of results that preceeded the current result. The second argument is aRowCountOperation
that will process the current result. ThisRowCountOperation
has not been configured in any way nor has it been submitted. The handler configures theRowCountOperation
and submits it. The count result is processed when theRowCountOperation
is submitted. If theRowCountOperation
is not submitted when the handler returns the count result is ignored. If this method is not called any trailing count results are ignored.- Parameters:
handler
- not null- Returns:
- this
MultiOperation
- Throws:
java.lang.IllegalStateException
- if this method was called previously
-
onRows
MultiOperation<T> onRows(java.util.function.BiConsumer<java.lang.Integer,RowOperation<T>> handler)
Provides a handler for trailing row sequence results. The provided handler is called for each row sequence result not processed by a RowOperation. When called the first argument is the number of results that preceeded the current result. The second argument is aRowOperation
that will process the current result. ThisRowOperation
has not been configured in any way nor has it been submitted. The handler configures theRowOperation
and submits it. The row sequence result is processed when theRowOperation
is submitted. If theRowOperation
is not submitted when the handler returns, the row sequence result is ignored. If this method is not called any trailing row sequence results are ignored. ISSUE: Should there be a version of this method that provides RowProcessorOperations? If so only one of that method or this one can be called.- Parameters:
handler
-- Returns:
- This
MultiOperation
- Throws:
java.lang.IllegalStateException
- if this method was called previously
-
onError
MultiOperation<T> onError(java.util.function.BiConsumer<java.lang.Integer,java.lang.Throwable> handler)
Provides an error handler for thisOperation
. The provided handler is called for each error that occurs. When called the first argument is the number of results, including errors, that preceeded the current error. The second argument is aThrowable
corresponding to the error. When the handler returns processing of theMultiOperation
results continues. Only one onError method may be called.- Parameters:
handler
- a BiConsumer that handles an error- Returns:
- this
MultiOperation
- Throws:
java.lang.IllegalStateException
- if this method oronError(java.util.function.Consumer)
was called previously
-
onError
MultiOperation<T> onError(java.util.function.Consumer<java.lang.Throwable> handler)
This handler is called if the execution fails completely. If the execution returns any individual results, even if any or all of those results are errors, this handler is not called. Provides an error handler for thisOperation
. If execution of thisOperation
results in an error, before theOperation
is completed, the handler is called with theThrowable
as the argument. The type of theThrowable
is implementation dependent.
-
apply
MultiOperation<T> apply(java.util.function.Function<Result.OutColumn,? extends T> processor)
Provide a processor that will handle the result of executing the SQL.- Specified by:
apply
in interfaceOutOperation<T>
- Parameters:
processor
- theFunction
that will be called to process the result of thisOutOperation
- Returns:
- this
MultiOperation
-
outParameter
MultiOperation<T> outParameter(java.lang.String id, SqlType type)
Register an out parameter identified by the given id.- Specified by:
outParameter
in interfaceOutOperation<T>
- Parameters:
id
- the parameter identifiertype
- the SQL type of the value of the parameter- Returns:
- this
MultiOperation
-
set
MultiOperation<T> set(java.lang.String id, java.lang.Object value, SqlType type)
Set a parameter value. The value is captured and should not be modified before theOperation
is completed.- Specified by:
set
in interfaceOutOperation<T>
- Specified by:
set
in interfaceParameterizedOperation<T>
- Parameters:
id
- the identifier of the parameter marker to be setvalue
- the value the parameter is to be set totype
- the SQL type of the value to send to the database- Returns:
- this
MultiOperation
-
set
MultiOperation<T> set(java.lang.String id, java.lang.Object value)
Set a parameter value. Use a default SQL type determined by the type of the value argument. The value is captured and should not be modified before theOperation
is completed.- Specified by:
set
in interfaceOutOperation<T>
- Specified by:
set
in interfaceParameterizedOperation<T>
- Parameters:
id
- the identifier of the parameter marker to be setvalue
- the value the parameter is to be set to- Returns:
- this
MultiOperation
-
set
MultiOperation<T> set(java.lang.String id, java.util.concurrent.CompletionStage<?> source, SqlType type)
Set a parameter value to be the value of aCompletionStage
. TheOperation
will not be executed until theCompletionStage
is completed. This method allows submittingOperation
s that depend on the result of previousOperation
s rather than requiring that the dependentOperation
be submitted only when the previousOperation
completes.- Specified by:
set
in interfaceOutOperation<T>
- Specified by:
set
in interfaceParameterizedOperation<T>
- Parameters:
id
- the identifier of the parameter marker to be setsource
- theCompletionStage
that provides the value the parameter is to be set totype
- the SQL type of the value to send to the database- Returns:
- this
MultiOperation
-
set
MultiOperation<T> set(java.lang.String id, java.util.concurrent.CompletionStage<?> source)
Set a parameter value to be the future value of aCompletionStage
. TheOperation
will not be executed until theCompletionStage
is completed. This method allows submittingOperation
s that depend on the result of previousOperation
s rather than requiring that the dependentOperation
be submitted only when the previousOperation
completes. Use a default SQL type determined by the type of the value of theCompletionStage
argument.- Specified by:
set
in interfaceOutOperation<T>
- Specified by:
set
in interfaceParameterizedOperation<T>
- Parameters:
id
- the identifier of the parameter marker to be setsource
- theCompletionStage
that provides the value the parameter is to be set to- Returns:
- this
MultiOperation
-
timeout
MultiOperation<T> timeout(java.time.Duration minTime)
The minimum time before thisOperation
might be canceled automatically. The default value is forever. The time is counted from the beginning of Operation execution. The Operation will not be canceled beforeminTime
after the beginning of execution. Some time at leastminTime
after the beginning of execution, an attempt will be made to cancel theOperation
if it has not yet completed. Implementations are encouraged to attempt to cancel within a reasonable time, though what is reasonable is implementation dependent.
-
-