Path: blob/master/src/java.sql/share/classes/java/sql/ShardingKeyBuilder.java
41153 views
/*1* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/24package java.sql;2526/**27* A builder created from a {@code DataSource} or {@code XADataSource} object,28* used to create a {@link ShardingKey} with sub-keys of supported data types.29* Implementations must30* support JDBCType.VARCHAR and may also support additional data types.31* <p>32* The following example illustrates the use of {@code ShardingKeyBuilder} to33* create a {@link ShardingKey}:34* <pre>35* {@code36*37* DataSource ds = new MyDataSource();38* ShardingKey shardingKey = ds.createShardingKeyBuilder()39* .subkey("abc", JDBCType.VARCHAR)40* .subkey(94002, JDBCType.INTEGER)41* .build();42* }43* </pre>44*45* @since 946*/47public interface ShardingKeyBuilder {4849/**50* This method will be called to add a subkey into a Sharding Key object being51* built. The order in which subkey method is called is important as it52* indicates the order of placement of the subkey within the Sharding Key.53*54* @param subkey contains the object that needs to be part of shard sub key55* @param subkeyType sub-key data type of type java.sql.SQLType56* @return this builder object57*/58ShardingKeyBuilder subkey(Object subkey, SQLType subkeyType);5960/**61* Returns an instance of the object defined by this builder.62*63* @return The built object64* @throws java.sql.SQLException If an error occurs building the object65*/66ShardingKey build() throws SQLException;67}686970