Elffuss BraidHub

kikocis/java-driver public

Minor improvements to the javadocs of DataType and TypeCodec.
Changeset13df164b0d2d5c435f3d6d93ef73e760aaf34f4a58f0ce201513e40c0334749d
AuthorAlexandre Dutra <alexandre.dutra@datastax.com> · 2016-01-28 12:24 +01:00
CommitterAlexandre Dutra <alexandre.dutra@datastax.com> · 2016-01-28 12:54 +01:00
Parents0aa90c5ece06

Browse the files at this changeset

2 files changed

modified driver-core/src/main/java/com/datastax/driver/core/DataType.java +32 −1
@@ -496,7 +496,7 @@
496496 * @param typeClassName the server-side fully qualified class name for the type.
497497 * @return the custom type for {@code typeClassName}.
498498 */
499- public static DataType custom(String typeClassName) {
499+ public static DataType.CustomType custom(String typeClassName) {
500500 if (typeClassName == null)
501501 throw new NullPointerException();
502502 return new DataType.CustomType(Name.CUSTOM, typeClassName);
@@ -600,6 +600,10 @@
600600 return toString();
601601 }
602602
603+ /**
604+ * Instances of this class represent CQL native types,
605+ * also known as CQL primitive types.
606+ */
603607 public static class NativeType extends DataType {
604608
605609 private NativeType(DataType.Name name) {
@@ -633,6 +637,10 @@
633637 }
634638 }
635639
640+ /**
641+ * Instances of this class represent collection types, that is,
642+ * lists, sets or maps.
643+ */
636644 public static class CollectionType extends DataType {
637645
638646 private final List<DataType> typeArguments;
@@ -691,6 +699,18 @@
691699 }
692700 }
693701
702+ /**
703+ * A "custom" type is a type that cannot be expressed as a CQL type.
704+ * <p/>
705+ * Each custom type is merely identified by the fully qualified
706+ * {@link #getCustomTypeClassName() class name}
707+ * that represents this type server-side.
708+ * <p/>
709+ * The driver provides a minimal support for such types through
710+ * instances of this class.
711+ * <p/>
712+ * A codec for custom types can be obtained via {@link TypeCodec#custom(CustomType)}.
713+ */
694714 public static class CustomType extends DataType {
695715
696716 private final String customClassName;
@@ -705,6 +725,17 @@
705725 return false;
706726 }
707727
728+ /**
729+ * Returns the fully qualified name
730+ * of the subtype of
731+ * {@code org.apache.cassandra.db.marshal.AbstractType}
732+ * that represents this type server-side.
733+ *
734+ * @return the fully qualified name
735+ * of the subtype of
736+ * {@code org.apache.cassandra.db.marshal.AbstractType}
737+ * that represents this type server-side.
738+ */
708739 public String getCustomTypeClassName() {
709740 return customClassName;
710741 }
modified driver-core/src/main/java/com/datastax/driver/core/TypeCodec.java +12 −2
@@ -378,9 +378,19 @@
378378
379379 /**
380380 * Return a newly-created codec for the given CQL custom type.
381- * The returned codec maps the custom type into the Java type {@link ByteBuffer}.
382- * This method provides a (very lightweight) support for Cassandra
381+ * <p/>
382+ * The returned codec maps the custom type into the Java type {@link ByteBuffer},
383+ * thus providing a (very lightweight) support for Cassandra
383384 * types that do not have a CQL equivalent.
385+ * <p/>
386+ * Note that the returned codec assumes that CQL literals for the given custom
387+ * type are expressed in binary form as well, e.g. {@code 0xcafebabe}. If this is
388+ * not the case, <em>the returned codec might be unable to {@link #parse(String) parse}
389+ * and {@link #format(Object) format} literals for this type</em>.
390+ * This is notoriously true for types inheriting from
391+ * {@code org.apache.cassandra.db.marshal.AbstractCompositeType}, whose CQL literals
392+ * are actually expressed as quoted strings.
393+ * <p/>
384394 * This method does not cache returned instances and returns a newly-allocated object
385395 * at each invocation.
386396 *