public static Object indexKeyFor(Object obj) throws TypeMismatchException {
    if (obj == null) {
      return null;
    }

    if (obj instanceof Byte) {
      return ((Byte) obj).intValue();
    }

    if (obj instanceof Short) {
      return ((Short) obj).intValue();
    }

    // Ketan : Added later. Indexes should be created
    // if the IndexedExpr implements Comparable interface.
    if (obj instanceof Comparable) {
      if (obj instanceof Enum) {
        obj = new PdxInstanceEnum((Enum<?>) obj);
      }

      return obj;
    }

    throw new TypeMismatchException(String.format("Indexes are not supported for type ' %s '",
        obj.getClass().getName()));
  }
Given an arbitrary object, return the value that should be used as the key for a particular
index.

@param obj the object to evaluate.
@return the value that should be used as the key for an index.
@throws TypeMismatchException if the object type is not supported to be used as an index.
geode-core/src/main/java/org/apache/geode/cache/query/internal/types/TypeUtils.java