Browse files

Merge pull request #566 from woolfel/master

Added support for ReversedType
  • Loading branch information...
2 parents da71030 + 6578590 commit 695e950e4086db47316926d87ecb5e45cd55314e @zznate zznate committed Nov 26, 2012
Showing with 123 additions and 120 deletions.
  1. +123 −120 core/src/main/java/me/prettyprint/hector/api/ddl/ComparatorType.java
View
243 core/src/main/java/me/prettyprint/hector/api/ddl/ComparatorType.java
@@ -1,120 +1,123 @@
-package me.prettyprint.hector.api.ddl;
-
-import java.util.Map;
-
-import com.google.common.collect.ImmutableMap;
-
-/**
- * @author peter
- * @author Mikhail Mazursky
- */
-public final class ComparatorType {
-
- public static final ComparatorType ASCIITYPE = new ComparatorType(
- "org.apache.cassandra.db.marshal.AsciiType");
- public static final ComparatorType BOOLEANTYPE = new ComparatorType(
- "org.apache.cassandra.db.marshal.BooleanType");
- public static final ComparatorType BYTESTYPE = new ComparatorType(
- "org.apache.cassandra.db.marshal.BytesType");
- public static final ComparatorType DATETYPE = new ComparatorType(
- "org.apache.cassandra.db.marshal.DateType");
- public static final ComparatorType DECIMALTYPE = new ComparatorType(
- "org.apache.cassandra.db.marshal.DecimalType");
- public static final ComparatorType FLOATTYPE = new ComparatorType(
- "org.apache.cassandra.db.marshal.FloatType");
- public static final ComparatorType INTEGERTYPE = new ComparatorType(
- "org.apache.cassandra.db.marshal.IntegerType");
- public static final ComparatorType INT32TYPE = new ComparatorType(
- "org.apache.cassandra.db.marshal.Int32Type");
- public static final ComparatorType LEXICALUUIDTYPE = new ComparatorType(
- "org.apache.cassandra.db.marshal.LexicalUUIDType");
- public static final ComparatorType LOCALBYPARTITIONERTYPE = new ComparatorType(
- "org.apache.cassandra.db.marshal.LocalByPartionerType");
- public static final ComparatorType LONGTYPE = new ComparatorType(
- "org.apache.cassandra.db.marshal.LongType");
- public static final ComparatorType TIMEUUIDTYPE = new ComparatorType(
- "org.apache.cassandra.db.marshal.TimeUUIDType");
- public static final ComparatorType UTF8TYPE = new ComparatorType(
- "org.apache.cassandra.db.marshal.UTF8Type");
- public static final ComparatorType COMPOSITETYPE = new ComparatorType(
- "org.apache.cassandra.db.marshal.CompositeType");
- public static final ComparatorType DYNAMICCOMPOSITETYPE = new ComparatorType(
- "org.apache.cassandra.db.marshal.DynamicCompositeType");
- public static final ComparatorType UUIDTYPE = new ComparatorType(
- "org.apache.cassandra.db.marshal.UUIDType");
- public static final ComparatorType COUNTERTYPE = new ComparatorType(
- "org.apache.cassandra.db.marshal.CounterColumnType");
-
- private static final Map<String, ComparatorType> valuesMap;
-
- static {
- ComparatorType[] types = { ASCIITYPE, BOOLEANTYPE, BYTESTYPE, DATETYPE,
- DECIMALTYPE, FLOATTYPE, INTEGERTYPE, INT32TYPE,
- LEXICALUUIDTYPE, LOCALBYPARTITIONERTYPE, LONGTYPE, TIMEUUIDTYPE,
- UTF8TYPE, COMPOSITETYPE, DYNAMICCOMPOSITETYPE, UUIDTYPE, COUNTERTYPE };
-
- ImmutableMap.Builder<String, ComparatorType> builder =
- new ImmutableMap.Builder<String, ComparatorType>();
-
- for (ComparatorType type : types){
- builder.put(type.getClassName(), type).put(type.getTypeName(), type);
- }
-
- valuesMap = builder.build();
- }
-
- private final String className;
- private final String typeName;
-
- private ComparatorType(String className) {
- this.className = className;
- if (className.startsWith("org.apache.cassandra.db.marshal.")) {
- typeName = className.substring("org.apache.cassandra.db.marshal."
- .length());
- } else {
- typeName = className;
- }
- }
-
- public String getClassName() {
- return className;
- }
-
- public String getTypeName() {
- return typeName;
- }
-
- public static ComparatorType getByClassName(String className) {
- if (className == null) {
- return null;
- }
- ComparatorType type = valuesMap.get(className);
- if (type == null) {
- return new ComparatorType(className);
- }
- return type;
- }
-
- @Override
- public int hashCode() {
- return className.hashCode();
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- ComparatorType other = (ComparatorType) obj;
- if (!className.equals(other.className)) {
- return false;
- }
- return true;
- }
-}
+package me.prettyprint.hector.api.ddl;
+
+import java.util.Map;
+
+import com.google.common.collect.ImmutableMap;
+
+/**
+ * @author peter
+ * @author Mikhail Mazursky
+ */
+public final class ComparatorType {
+
+ public static final ComparatorType ASCIITYPE = new ComparatorType(
+ "org.apache.cassandra.db.marshal.AsciiType");
+ public static final ComparatorType BOOLEANTYPE = new ComparatorType(
+ "org.apache.cassandra.db.marshal.BooleanType");
+ public static final ComparatorType BYTESTYPE = new ComparatorType(
+ "org.apache.cassandra.db.marshal.BytesType");
+ public static final ComparatorType DATETYPE = new ComparatorType(
+ "org.apache.cassandra.db.marshal.DateType");
+ public static final ComparatorType DECIMALTYPE = new ComparatorType(
+ "org.apache.cassandra.db.marshal.DecimalType");
+ public static final ComparatorType FLOATTYPE = new ComparatorType(
+ "org.apache.cassandra.db.marshal.FloatType");
+ public static final ComparatorType INTEGERTYPE = new ComparatorType(
+ "org.apache.cassandra.db.marshal.IntegerType");
+ public static final ComparatorType INT32TYPE = new ComparatorType(
+ "org.apache.cassandra.db.marshal.Int32Type");
+ public static final ComparatorType LEXICALUUIDTYPE = new ComparatorType(
+ "org.apache.cassandra.db.marshal.LexicalUUIDType");
+ public static final ComparatorType LOCALBYPARTITIONERTYPE = new ComparatorType(
+ "org.apache.cassandra.db.marshal.LocalByPartionerType");
+ public static final ComparatorType LONGTYPE = new ComparatorType(
+ "org.apache.cassandra.db.marshal.LongType");
+ public static final ComparatorType TIMEUUIDTYPE = new ComparatorType(
+ "org.apache.cassandra.db.marshal.TimeUUIDType");
+ public static final ComparatorType UTF8TYPE = new ComparatorType(
+ "org.apache.cassandra.db.marshal.UTF8Type");
+ public static final ComparatorType COMPOSITETYPE = new ComparatorType(
+ "org.apache.cassandra.db.marshal.CompositeType");
+ public static final ComparatorType DYNAMICCOMPOSITETYPE = new ComparatorType(
+ "org.apache.cassandra.db.marshal.DynamicCompositeType");
+ public static final ComparatorType UUIDTYPE = new ComparatorType(
+ "org.apache.cassandra.db.marshal.UUIDType");
+ public static final ComparatorType COUNTERTYPE = new ComparatorType(
+ "org.apache.cassandra.db.marshal.CounterColumnType");
+ public static final ComparatorType REVERSEDTYPE = new ComparatorType(
+ "org.apache.cassandra.db.marshal.ReversedType");
+
+ private static final Map<String, ComparatorType> valuesMap;
+
+ static {
+ ComparatorType[] types = { ASCIITYPE, BOOLEANTYPE, BYTESTYPE, DATETYPE,
+ DECIMALTYPE, FLOATTYPE, INTEGERTYPE, INT32TYPE,
+ LEXICALUUIDTYPE, LOCALBYPARTITIONERTYPE, LONGTYPE, TIMEUUIDTYPE,
+ UTF8TYPE, COMPOSITETYPE, DYNAMICCOMPOSITETYPE, UUIDTYPE, COUNTERTYPE,
+ REVERSEDTYPE};
+
+ ImmutableMap.Builder<String, ComparatorType> builder =
+ new ImmutableMap.Builder<String, ComparatorType>();
+
+ for (ComparatorType type : types){
+ builder.put(type.getClassName(), type).put(type.getTypeName(), type);
+ }
+
+ valuesMap = builder.build();
+ }
+
+ private final String className;
+ private final String typeName;
+
+ private ComparatorType(String className) {
+ this.className = className;
+ if (className.startsWith("org.apache.cassandra.db.marshal.")) {
+ typeName = className.substring("org.apache.cassandra.db.marshal."
+ .length());
+ } else {
+ typeName = className;
+ }
+ }
+
+ public String getClassName() {
+ return className;
+ }
+
+ public String getTypeName() {
+ return typeName;
+ }
+
+ public static ComparatorType getByClassName(String className) {
+ if (className == null) {
+ return null;
+ }
+ ComparatorType type = valuesMap.get(className);
+ if (type == null) {
+ return new ComparatorType(className);
+ }
+ return type;
+ }
+
+ @Override
+ public int hashCode() {
+ return className.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ ComparatorType other = (ComparatorType) obj;
+ if (!className.equals(other.className)) {
+ return false;
+ }
+ return true;
+ }
+}

0 comments on commit 695e950

Please sign in to comment.