Elffuss BraidHub

kikocis/java-driver public

Provide backward-compatible version of Cluster.Builder.withProtocolVersion.
Changeset81b76d1ea0600a326e86d566dc78fb976d172d9d4cbb643a51b53896c4185298
Authorolim7t <omichallat+github@gmail.com> · 2014-10-06 16:19 +02:00
Committerolim7t <omichallat+github@gmail.com> · 2014-10-06 16:20 +02:00
Parents5f007c700854

Browse the files at this changeset

1 file changed

modified driver-core/src/main/java/com/datastax/driver/core/Cluster.java +16 −3
@@ -654,15 +654,28 @@
654654 * to trigger auto-detection (see above) but this is the default (so you don't have
655655 * to call this method for that behavior).
656656 * @return this Builder.
657- *
658- * @throws IllegalArgumentException if {@code version} is neither 1, 2 or a
659- * negative value.
660657 */
661658 public Builder withProtocolVersion(ProtocolVersion version) {
662659 this.protocolVersion = version;
663660 return this;
664661 }
665662
663+ /**
664+ * The native protocol version to use, as a number.
665+ * <p>
666+ * This method is provided for backward-compatibility. Whenever possible,
667+ * {@link #withProtocolVersion(ProtocolVersion)} should be preferred.
668+ *
669+ * @param version the native protocol version as a number.
670+ * @return this Builder.
671+ * @throws DriverInternalError if the number does not correspond to any known native
672+ * protocol version.
673+ */
674+ public Builder withProtocolVersion(int version) {
675+ this.protocolVersion = ProtocolVersion.fromInt(version);
676+ return this;
677+ }
678+
666679 /**
667680 * Adds a contact point.
668681 * <p>