public int compareTo()

in tablestore/src/main/java/com/alicloud/openservices/tablestore/model/PrimaryKeyValue.java [340:379]


    public int compareTo(PrimaryKeyValue target) {
        if (this.type == null) { // INF_MIN or INF_MAX or AUTO_INCR
            if (target.type == null && target.value.equals(this.value)) {
                return 0;
            }

            if (this.value.equals("INF_MIN")) {
                return -1;
            } else if (this.value.equals("INF_MAX")){
                return 1;
            } else {
                throw new IllegalArgumentException(this.value + " can't compare.");
            } 
        } else {
            if (target.type == null) {
                if (target.value.equals("INF_MIN")) {
                    return 1;
                } else {
                    return -1;
                }
            }

            if (this.type != target.type) {
                throw new IllegalArgumentException("The type of primary key to compare must be the same.");
            }

            switch (this.type) {
                case STRING:
                    return ((String) value).compareTo(target.asString());
                case INTEGER:
                    return ((Long) value).compareTo(target.asLong());
                case BINARY:
                    byte[] b1 = (byte[]) this.value;
                    byte[] b2 = (byte[]) target.value;
                    return Bytes.compareByteArrayInLexOrder(b1, 0, b1.length, b2, 0, b2.length);
                default:
                    throw new IllegalArgumentException("Unknown type: " + this.type);
            }
        }
    }