Example usage for org.apache.commons.lang3.mutable MutableBoolean compareTo

List of usage examples for org.apache.commons.lang3.mutable MutableBoolean compareTo

Introduction

In this page you can find the example usage for org.apache.commons.lang3.mutable MutableBoolean compareTo.

Prototype

@Override
public int compareTo(final MutableBoolean other) 

Source Link

Document

Compares this mutable to another in ascending order.

Usage

From source file:asterix.parser.classad.Operation.java

public static void compareBools(int op, Value v1, Value v2, Value result) throws HyracksDataException {
    MutableBoolean b1 = new MutableBoolean();
    MutableBoolean b2 = new MutableBoolean();
    boolean compResult = false;
    v1.isBooleanValue(b1);//from  w w w . jav a 2  s.  c om
    v2.isBooleanValue(b2);

    switch (op) {
    case OpKind_LESS_THAN_OP:
        compResult = (b1.compareTo(b2) < 0);
        break;
    case OpKind_LESS_OR_EQUAL_OP:
        compResult = (b1.compareTo(b2) <= 0);
        break;
    case OpKind_EQUAL_OP:
        compResult = (b1.booleanValue() == b2.booleanValue());
        break;
    case OpKind_META_EQUAL_OP:
        compResult = (b1.booleanValue() == b2.booleanValue());
        break;
    case OpKind_NOT_EQUAL_OP:
        compResult = (b1.booleanValue() != b2.booleanValue());
        break;
    case OpKind_META_NOT_EQUAL_OP:
        compResult = (b1.booleanValue() != b2.booleanValue());
        break;
    case OpKind_GREATER_THAN_OP:
        compResult = (b1.compareTo(b2) > 0);
        break;
    case OpKind_GREATER_OR_EQUAL_OP:
        compResult = (b1.compareTo(b2) >= 0);
        break;
    default:
        // should not get here
        throw new HyracksDataException("Should not get here");
    }
    result.setBooleanValue(compResult);
}

From source file:org.apache.asterix.external.classad.Operation.java

public static void compareBools(int op, Value v1, Value v2, Value result, ClassAdObjectPool objectPool)
        throws HyracksDataException {
    MutableBoolean b1 = objectPool.boolPool.get();
    MutableBoolean b2 = objectPool.boolPool.get();
    boolean compResult = false;
    v1.isBooleanValue(b1);//from w ww. j  a  va 2 s .  c o m
    v2.isBooleanValue(b2);

    switch (op) {
    case OpKind_LESS_THAN_OP:
        compResult = (b1.compareTo(b2) < 0);
        break;
    case OpKind_LESS_OR_EQUAL_OP:
        compResult = (b1.compareTo(b2) <= 0);
        break;
    case OpKind_EQUAL_OP:
        compResult = (b1.booleanValue() == b2.booleanValue());
        break;
    case OpKind_META_EQUAL_OP:
        compResult = (b1.booleanValue() == b2.booleanValue());
        break;
    case OpKind_NOT_EQUAL_OP:
        compResult = (b1.booleanValue() != b2.booleanValue());
        break;
    case OpKind_META_NOT_EQUAL_OP:
        compResult = (b1.booleanValue() != b2.booleanValue());
        break;
    case OpKind_GREATER_THAN_OP:
        compResult = (b1.compareTo(b2) > 0);
        break;
    case OpKind_GREATER_OR_EQUAL_OP:
        compResult = (b1.compareTo(b2) >= 0);
        break;
    default:
        // should not get here
        throw new HyracksDataException("Should not get here");
    }
    result.setBooleanValue(compResult);
}