src/jdk.incubator.adba/share/classes/jdk/incubator/sql2/OutOperation.java
branchJDK-8188051-branch
changeset 56380 f06946e00a26
child 56797 fb523d4d9185
equal deleted inserted replaced
56373:1f76a5f8e999 56380:f06946e00a26
       
     1 /*
       
     2  * Copyright (c)  2017, Oracle and/or its affiliates. All rights reserved.
       
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       
     4  *
       
     5  * This code is free software; you can redistribute it and/or modify it
       
     6  * under the terms of the GNU General Public License version 2 only, as
       
     7  * published by the Free Software Foundation.  Oracle designates this
       
     8  * particular file as subject to the "Classpath" exception as provided
       
     9  * by Oracle in the LICENSE file that accompanied this code.
       
    10  *
       
    11  * This code is distributed in the hope that it will be useful, but WITHOUT
       
    12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
       
    13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
       
    14  * version 2 for more details (a copy is included in the LICENSE file that
       
    15  * accompanied this code).
       
    16  *
       
    17  * You should have received a copy of the GNU General Public License version
       
    18  * 2 along with this work; if not, write to the Free Software Foundation,
       
    19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
       
    20  *
       
    21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
       
    22  * or visit www.oracle.com if you need additional information or have any
       
    23  * questions.
       
    24  */
       
    25 
       
    26 package jdk.incubator.sql2;
       
    27 
       
    28 import java.time.Duration;
       
    29 import java.util.concurrent.CompletionStage;
       
    30 import java.util.function.Consumer;
       
    31 import java.util.function.Function;
       
    32 
       
    33 /**
       
    34  * An {@link ParameterizedOperation} for which the result is a set of out parameter 
       
    35  * values and/or function results. As the SQL is vendor specific, how parameters
       
    36  * are represented in the SQL is itself vendor specific. 
       
    37  * 
       
    38  * @param <T> the type of the result of this {@link Operation}
       
    39  */
       
    40 public interface OutOperation<T> extends ParameterizedOperation<T> {
       
    41   
       
    42   /**
       
    43    * Register an out parameter identified by the given id.
       
    44    * 
       
    45    * @param id the parameter identifier
       
    46    * @param type the SQL type of the value of the parameter
       
    47    * @return this {@link OutOperation}
       
    48    * @throws IllegalArgumentException if id is not a parameter marker in the SQL
       
    49    * @throws IllegalStateException if this method has been called previously on
       
    50    * this {@link Operation} with the same id or this {@link OutOperation} has been submitted
       
    51    */
       
    52   public OutOperation<T> outParameter(String id, SqlType type);
       
    53   
       
    54   /**
       
    55    * Provide a processor that will handle the result of executing the SQL.
       
    56    * 
       
    57    * @param processor the {@link Function} that will be called to process the result of
       
    58    * this {@link OutOperation}
       
    59    * @return this {@link OutOperation}
       
    60    * @throws IllegalStateException if this method has been called previously on
       
    61    * this {@link Operation} or this {@link Operation} has been submitted.
       
    62    */
       
    63   public OutOperation<T> apply(Function<Result.OutParameterMap, ? extends T> processor);
       
    64 
       
    65   // Covariant overrides
       
    66   
       
    67   @Override
       
    68   public OutOperation<T> onError(Consumer<Throwable> handler);
       
    69   
       
    70   @Override
       
    71   public OutOperation<T> set(String id, Object value);
       
    72 
       
    73   @Override
       
    74   public OutOperation<T> set(String id, Object value, SqlType type);
       
    75 
       
    76   @Override
       
    77   public OutOperation<T> set(String id, CompletionStage<?> source);
       
    78 
       
    79   @Override
       
    80   public OutOperation<T> set(String id, CompletionStage<?> source, SqlType type);
       
    81 
       
    82   @Override
       
    83   public OutOperation<T> timeout(Duration minTime);
       
    84 
       
    85 }