Beispiel #1
0
 @Override
 public int compareTo(Datum datum) {
   switch (datum.type()) {
     case SHORT:
       if (val < datum.asShort()) {
         return -1;
       } else if (datum.asShort() < val) {
         return 1;
       } else {
         return 0;
       }
     case INT:
       if (val < datum.asInt()) {
         return -1;
       } else if (datum.asInt() < val) {
         return 1;
       } else {
         return 0;
       }
     case LONG:
       if (val < datum.asLong()) {
         return -1;
       } else if (datum.asLong() < val) {
         return 1;
       } else {
         return 0;
       }
     case FLOAT:
       if (val < datum.asFloat()) {
         return -1;
       } else if (datum.asFloat() < val) {
         return 1;
       } else {
         return 0;
       }
     case DOUBLE:
       if (val < datum.asDouble()) {
         return -1;
       } else if (datum.asDouble() < val) {
         return 1;
       } else {
         return 0;
       }
     default:
       throw new InvalidOperationException(datum.type());
   }
 }
Beispiel #2
0
 @Override
 public Datum modular(Datum datum) {
   switch (datum.type()) {
     case SHORT:
       return DatumFactory.createShort((short) (val % datum.asShort()));
     case INT:
       return DatumFactory.createInt(val % datum.asInt());
     case LONG:
       return DatumFactory.createLong(val % datum.asLong());
     case FLOAT:
       return DatumFactory.createFloat(val % datum.asFloat());
     case DOUBLE:
       return DatumFactory.createDouble(val % datum.asDouble());
     default:
       throw new InvalidOperationException(datum.type());
   }
 }
Beispiel #3
0
 @Override
 public BoolDatum equalsTo(Datum datum) {
   switch (datum.type()) {
     case SHORT:
       return DatumFactory.createBool(val == datum.asShort());
     case INT:
       return DatumFactory.createBool(val == datum.asInt());
     case LONG:
       return DatumFactory.createBool(val == datum.asLong());
     case FLOAT:
       return DatumFactory.createBool(val == datum.asFloat());
     case DOUBLE:
       return DatumFactory.createBool(val == datum.asDouble());
     default:
       throw new InvalidOperationException(datum.type());
   }
 }