private BytesRef convertNumber(Number number) {
        if (Integer.class.isInstance(number) || Byte.class.isInstance(number) || Short.class.isInstance(number)) {
            BytesRef bytes = new BytesRef(NumericUtils.BUF_SIZE_INT);
            NumericUtils.intToPrefixCoded(number.intValue(), 0, bytes);
            return bytes;
        } else if (Double.class.isInstance(number) || BigDecimal.class.isInstance(number)) {
            BytesRef bytes = new BytesRef(NumericUtils.BUF_SIZE_LONG);
            long l = NumericUtils.doubleToSortableLong(number.doubleValue());
            NumericUtils.longToPrefixCoded(l, 0, bytes);
            return bytes;
        } else if (Long.class.isInstance(number) || BigInteger.class.isInstance(number)) {
            BytesRef bytes = new BytesRef(NumericUtils.BUF_SIZE_LONG);
            NumericUtils.longToPrefixCoded(number.longValue(), 0, bytes);
            return bytes;
        } else if (Float.class.isInstance(number)) {
            BytesRef bytes = new BytesRef(NumericUtils.BUF_SIZE_INT);
            int i = NumericUtils.floatToSortableInt(number.floatValue());
            NumericUtils.intToPrefixCoded(i, 0, bytes);
            return bytes;
        } else {
            throw new IllegalArgumentException("Unsupported numeric type "
                    + number.getClass().getName());
        }
    }
If the query is a BooleanQuery and it contains a single Occur.MUST_NOT
clause it will be returned as is. Otherwise it will be wrapped in a
BooleanClause with the given Occur.
querydsl-lucene4/src/main/java/com/querydsl/lucene4/LuceneSerializer.java