src/java.sql/share/classes/java/sql/ShardingKeyBuilder.java
author darcy
Thu, 01 Nov 2018 20:37:45 -0700
changeset 52380 6b31efbf833e
parent 47216 71c04702a3d5
permissions -rw-r--r--
6304578: (reflect) toGenericString fails to print bounds of type variables on generic methods Reviewed-by: vromero, plevart, briangoetz, mcimadamore
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
34338
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
     1
/*
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
     2
 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
     4
 *
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    10
 *
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    15
 * accompanied this code).
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    16
 *
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    20
 *
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    23
 * questions.
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    24
 */
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    25
package java.sql;
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    26
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    27
/**
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    28
 * A builder created from a {@code DataSource}  or {@code XADataSource} object,
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    29
 * used to create a {@link ShardingKey} with sub-keys of supported data types.
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    30
 * Implementations must
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    31
 * support JDBCType.VARCHAR and  may also support additional data types.
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    32
 * <p>
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    33
 * The following example illustrates the use of {@code ShardingKeyBuilder} to
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    34
 * create a {@link ShardingKey}:
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    35
 * <pre>
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    36
 * {@code
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    37
 *
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    38
 *     DataSource ds = new MyDataSource();
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    39
 *     ShardingKey shardingKey = ds.createShardingKeyBuilder()
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    40
 *                           .subkey("abc", JDBCType.VARCHAR)
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    41
 *                           .subkey(94002, JDBCType.INTEGER)
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    42
 *                           .build();
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    43
 * }
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    44
 * </pre>
44256
12050b22e372 8176721: @since value errors java.sql module
mli
parents: 34338
diff changeset
    45
 *
12050b22e372 8176721: @since value errors java.sql module
mli
parents: 34338
diff changeset
    46
 * @since 9
34338
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    47
 */
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    48
public interface ShardingKeyBuilder {
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    49
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    50
    /**
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    51
     * This method will be called to add a subkey into a Sharding Key object being
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    52
     * built. The order in which subkey method is called is important as it
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    53
     * indicates the order of placement of the subkey within the Sharding Key.
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    54
     *
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    55
     * @param subkey contains the object that needs to be part of shard sub key
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    56
     * @param subkeyType sub-key data type of type java.sql.SQLType
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    57
     * @return this builder object
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    58
     */
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    59
    ShardingKeyBuilder subkey(Object subkey, SQLType subkeyType);
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    60
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    61
    /**
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    62
     * Returns an instance of the object defined by this builder.
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    63
     *
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    64
     * @return The built object
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    65
     * @throws java.sql.SQLException If an error occurs building the object
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    66
     */
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    67
    ShardingKey build() throws SQLException;
67d0e5867568 8085984: Add JDBC Sharding API
lancea
parents:
diff changeset
    68
}