private void ensureSameType(MsgPackToken x, MsgPackToken y) { // transform number types for comparison if (x.getType() == MsgPackType.INTEGER && y.getType() == MsgPackType.FLOAT) { x.setType(MsgPackType.FLOAT); x.setValue((double) x.getIntegerValue()); } else if (x.getType() == MsgPackType.FLOAT && y.getType() == MsgPackType.INTEGER) { y.setType(MsgPackType.FLOAT); y.setValue((double) y.getIntegerValue()); } else if (x.getType() != y.getType()) { throw new JsonConditionException( String.format( "Cannot compare values of different types: %s and %s", x.getType(), y.getType())); } }
private void ensureSameType(MsgPackToken x, MsgPackToken y) { // transform number types for comparison if (x.getType() == MsgPackType.INTEGER && y.getType() == MsgPackType.FLOAT) { x.setType(MsgPackType.FLOAT); x.setValue((double) x.getIntegerValue()); } else if (x.getType() == MsgPackType.FLOAT && y.getType() == MsgPackType.INTEGER) { y.setType(MsgPackType.FLOAT); y.setValue((double) y.getIntegerValue()); } else if (x.getType() != y.getType()) { throw new JsonConditionException( String.format( "Cannot compare values of different types: %s and %s", x.getType(), y.getType())); } }
case INTEGER: token.setType(MsgPackType.INTEGER); token.setValue(readInteger()); break; case FLOAT: token.setType(MsgPackType.FLOAT); token.setValue(readFloat()); break; case BOOLEAN: token.setType(MsgPackType.BOOLEAN); token.setValue(readBoolean()); break; case MAP: token.setType(MsgPackType.BINARY); final int binaryLength = readBinaryLength(); token.setValue(buffer, offset, binaryLength); skipBytes(binaryLength); break; token.setType(MsgPackType.STRING); final int stringLength = readStringLength(); token.setValue(buffer, offset, stringLength); skipBytes(stringLength); break;
case INTEGER: token.setType(MsgPackType.INTEGER); token.setValue(readInteger()); break; case FLOAT: token.setType(MsgPackType.FLOAT); token.setValue(readFloat()); break; case BOOLEAN: token.setType(MsgPackType.BOOLEAN); token.setValue(readBoolean()); break; case MAP: token.setType(MsgPackType.BINARY); final int binaryLength = readBinaryLength(); token.setValue(buffer, offset, binaryLength); skipBytes(binaryLength); break; token.setType(MsgPackType.STRING); final int stringLength = readStringLength(); token.setValue(buffer, offset, stringLength); skipBytes(stringLength); break;