Example usage for com.google.common.collect Range hasLowerBound

List of usage examples for com.google.common.collect Range hasLowerBound

Introduction

In this page you can find the example usage for com.google.common.collect Range hasLowerBound.

Prototype

public boolean hasLowerBound() 

Source Link

Document

Returns true if this range has a lower endpoint.

Usage

From source file:org.noroomattheinn.timeseries.CachedTimeSeries.java

private boolean useInMemoryInternal(Range<Long> period) {
    long firstInMemory = inMemory.firstTime();
    long firstPersistent = persistent.firstTime();

    if (firstInMemory <= firstPersistent)
        return true;
    if (period.hasLowerBound() && firstInMemory <= period.lowerEndpoint())
        return true;
    return false;
}

From source file:org.pascani.dsl.dbmapper.databases.CSVExport.java

private Map<String, String> handle(ChangeEvent e, String collection) {
    Map<String, String> data = null;
    TaggedValue<Serializable> taggedValue = TaggedValue.instanceFrom(e.value(), Serializable.class);
    if (taggedValue.value() instanceof Number || taggedValue.value() instanceof Boolean
            || taggedValue.value() instanceof String) {
        data = toData(collection, e, taggedValue.value(), taggedValue.tags());
    } else if (taggedValue.value() instanceof Range<?>) {
        Range<?> range = (Range<?>) taggedValue.value();
        Class<?> clazz = range.hasLowerBound() ? range.lowerEndpoint().getClass()
                : range.upperEndpoint().getClass();
        if (Number.class.isAssignableFrom(clazz)) {
            data = toData(collection, e, taggedValue.value(), taggedValue.tags());
        } else {//  w w w  .jav  a2  s .  co  m
            System.out.println("Not supported type " + clazz.getCanonicalName());
        }
    } else {
        System.out.println("Not supported type " + taggedValue.value().getClass().getCanonicalName());
    }
    return data;
}

From source file:com.google.eclipse.protobuf.validation.ProtobufJavaValidator.java

private String rangeToString(Range<Long> range) {
    if (range.hasLowerBound() && range.hasUpperBound() && range.lowerEndpoint() == range.upperEndpoint()) {
        return String.valueOf(range.lowerEndpoint());
    }//from  ww w  .j  a  va 2  s  .c o  m

    String upper = range.hasUpperBound() ? String.valueOf(range.upperEndpoint()) : indexRanges.getMaxKeyword();
    return String.format("%d to %s", range.lowerEndpoint(), upper);
}

From source file:li.klass.fhem.activities.graph.ChartingActivity.java

private void setRangeFor(Optional<Range<Double>> axisRange,
        com.github.mikephil.charting.components.YAxis axis) {
    if (axisRange.isPresent()) {
        Range<Double> range = axisRange.get();
        if (range.hasLowerBound()) {
            axis.setAxisMinValue(range.lowerEndpoint().floatValue());
        }//from w w w.  j  a va2s .c  o  m
        if (range.hasUpperBound()) {
            axis.setAxisMinValue(range.upperEndpoint().floatValue());
        }
    }
}

From source file:com.pingcap.tikv.predicates.ScanBuilder.java

private List<KeyRange> buildTableScanKeyRange(TiTableInfo table, List<IndexRange> indexRanges) {
    requireNonNull(table, "Table cannot be null to encoding keyRange");
    requireNonNull(indexRanges, "indexRanges cannot be null to encoding keyRange");

    List<KeyRange> ranges = new ArrayList<>(indexRanges.size());
    for (IndexRange ir : indexRanges) {
        ByteString startKey;//from   w  w w .java2s .co m
        ByteString endKey;
        if (ir.hasAccessPoints()) {
            checkArgument(!ir.hasRange(), "Table scan must have one and only one access condition / point");

            Object v = ir.getAccessPoints().get(0);
            checkArgument(v instanceof Long, "Table scan key range must be long value");
            DataType type = ir.getTypes().get(0);
            checkArgument(type instanceof IntegerType, "Table scan key range must be long value");
            startKey = TableCodec.encodeRowKeyWithHandle(table.getId(), (long) v);
            endKey = ByteString.copyFrom(KeyUtils.prefixNext(startKey.toByteArray()));
        } else if (ir.hasRange()) {
            checkArgument(!ir.hasAccessPoints(),
                    "Table scan must have one and only one access condition / point");
            Range r = ir.getRange();
            DataType type = ir.getRangeType();
            checkArgument(type instanceof IntegerType, "Table scan key range must be long value");

            if (!r.hasLowerBound()) {
                // -INF
                // TODO: Domain and encoding should be further encapsulated
                startKey = TableCodec.encodeRowKeyWithHandle(table.getId(), Long.MIN_VALUE);
            } else {
                // Comparision with null should be filtered since it yields unknown always
                Object lb = r.lowerEndpoint();
                checkArgument(lb instanceof Long, "Table scan key range must be long value");
                long lVal = (long) lb;
                if (r.lowerBoundType().equals(BoundType.OPEN)) {
                    // TODO: Need push back?
                    if (lVal != Long.MAX_VALUE) {
                        lVal++;
                    }
                }
                startKey = TableCodec.encodeRowKeyWithHandle(table.getId(), lVal);
            }

            if (!r.hasUpperBound()) {
                // INF
                endKey = TableCodec.encodeRowKeyWithHandle(table.getId(), Long.MAX_VALUE);
            } else {
                Object ub = r.upperEndpoint();
                checkArgument(ub instanceof Long, "Table scan key range must be long value");
                long lVal = (long) ub;
                if (r.upperBoundType().equals(BoundType.CLOSED)) {
                    if (lVal != Long.MAX_VALUE) {
                        lVal++;
                    }
                }
                endKey = TableCodec.encodeRowKeyWithHandle(table.getId(), lVal);
            }
        } else {
            throw new TiClientInternalException("Empty access conditions");
        }

        ranges.add(KeyRange.newBuilder().setStart(startKey).setEnd(endKey).build());
    }

    if (ranges.isEmpty()) {
        ByteString startKey = TableCodec.encodeRowKeyWithHandle(table.getId(), Long.MIN_VALUE);
        ByteString endKey = TableCodec.encodeRowKeyWithHandle(table.getId(), Long.MAX_VALUE);
        ranges.add(KeyRange.newBuilder().setStart(startKey).setEnd(endKey).build());
    }

    return ranges;
}

From source file:org.pshdl.model.validation.builtin.BuiltInValidator.java

private static void checkType(HDLPackage unit, Set<Problem> problems,
        Map<HDLQualifiedName, HDLEvaluationContext> hContext) {
    final HDLVariableDeclaration[] hvds = unit.getAllObjectsOf(HDLVariableDeclaration.class, true);
    for (final HDLVariableDeclaration hvd : hvds) {
        final Optional<? extends HDLType> type = hvd.resolveType();
        if (type.isPresent()) {
            final HDLType hdlType = type.get();
            if (hdlType instanceof HDLPrimitive) {
                final HDLPrimitive primType = (HDLPrimitive) hdlType;
                switch (primType.getType()) {
                case BIT:
                case INTEGER:
                case NATURAL:
                    break;
                case STRING:
                    if (primType.getWidth() != null) {
                        problems.add(new Problem(TYPE_INVALID_PRIMITIVE, hvd, "Strings can not have a width"));
                    }//from   ww w  . ja va 2 s.c o m
                    break;
                case BOOL:
                    if (primType.getWidth() != null) {
                        problems.add(new Problem(TYPE_INVALID_PRIMITIVE, hvd, "Booleans can not have a width"));
                    }
                    break;
                case BITVECTOR:
                case INT:
                case UINT:
                    final Optional<Range<BigInteger>> rangeOpt = RangeExtension.rangeOf(primType.getWidth());
                    if (rangeOpt.isPresent()) {
                        final Range<BigInteger> range = rangeOpt.get();
                        if (!range.hasLowerBound()) {
                            problems.add(new Problem(ErrorCode.TYPE_NEGATIVE_WIDTH, hvd));
                        } else {
                            final BigInteger le = range.lowerEndpoint();
                            if (le.compareTo(BigInteger.ZERO) < 0) {
                                if (range.hasUpperBound()
                                        && (range.upperEndpoint().compareTo(BigInteger.ZERO) < 0)) {
                                    problems.add(new Problem(ErrorCode.TYPE_NEGATIVE_WIDTH, hvd));
                                } else {
                                    problems.add(new Problem(ErrorCode.TYPE_POSSIBLY_NEGATIVE_WIDTH, hvd));
                                }
                            } else if (le.equals(BigInteger.ZERO) && range.hasUpperBound()
                                    && range.upperEndpoint().equals(BigInteger.ZERO)) {
                                problems.add(new Problem(ErrorCode.TYPE_ZERO_WIDTH, hvd));
                            } else if (le.equals(BigInteger.ZERO)) {
                                problems.add(new Problem(ErrorCode.TYPE_POSSIBLY_ZERO_WIDTH, hvd));
                            }
                        }
                    }
                    break;
                }
            }
        }
    }

    final HDLOpExpression[] ops = unit.getAllObjectsOf(HDLOpExpression.class, true);
    for (final HDLOpExpression ope : ops) {
        if (skipExp(ope)) {
            continue;
        }
        checkOpExpression(problems, ope, ope);
    }
    final HDLManip[] manips = unit.getAllObjectsOf(HDLManip.class, true);
    for (final HDLManip manip : manips) {
        final Optional<? extends HDLType> targetType = TypeExtension.typeOf(manip.getTarget());
        if (targetType.isPresent()) {
            final HDLType tt = targetType.get();
            switch (manip.getType()) {
            case ARITH_NEG:
                if (tt instanceof HDLPrimitive) {
                    final HDLPrimitive primitive = (HDLPrimitive) tt;
                    if (!primitive.isNumber()) {
                        problems.add(new Problem(UNSUPPORTED_TYPE_FOR_OP, manip,
                                "Can not use arithmetic negate on a non-number"));
                    }
                } else {
                    problems.add(new Problem(UNSUPPORTED_TYPE_FOR_OP, manip,
                            "Can not use arithmetic negate on a non-number"));
                }
                break;
            case BIT_NEG:
                if (manip.getTarget().getClassType() == HDLClass.HDLLiteral) {
                    problems.add(new Problem(UNSUPPORTED_TYPE_FOR_OP, manip,
                            "Can not use binary negate on literals as they have no width"));
                }
                if (tt instanceof HDLPrimitive) {
                    final HDLPrimitive primitive = (HDLPrimitive) tt;
                    if (!primitive.isBits()) {
                        problems.add(new Problem(UNSUPPORTED_TYPE_FOR_OP, manip,
                                "Can not use binary negate on a non-bits"));
                    }
                } else {
                    problems.add(new Problem(UNSUPPORTED_TYPE_FOR_OP, manip,
                            "Can not use binary negate on a non-bits"));
                }
                break;
            case LOGIC_NEG:
                if (tt instanceof HDLPrimitive) {
                    final HDLPrimitive primitive = (HDLPrimitive) tt;
                    if ((primitive.getType() != HDLPrimitiveType.BOOL)
                            && (primitive.getType() != HDLPrimitiveType.BIT)) {
                        problems.add(new Problem(BOOL_NEGATE_NUMERIC_NOT_SUPPORTED, manip,
                                "Can not use logic negate on a non boolean/bit"));
                    }
                } else {
                    problems.add(new Problem(UNSUPPORTED_TYPE_FOR_OP, manip,
                            "Can not use logic negate on a non boolean"));
                }
                break;
            case CAST:
                final HDLType castTo = manip.getCastTo();
                if (castTo instanceof HDLInterface) {
                    if (!(tt instanceof HDLInterface)) {
                        problems.add(new Problem(UNSUPPORTED_TYPE_FOR_OP, manip,
                                "Can not cast from interface to non interface type:" + castTo));
                    }
                }
                if (castTo instanceof HDLEnum) {
                    problems.add(
                            new Problem(UNSUPPORTED_TYPE_FOR_OP, manip, "Enums can not be casted to anything"));
                }
                if (castTo instanceof HDLPrimitive) {
                    if (!(tt instanceof HDLPrimitive)) {
                        problems.add(new Problem(UNSUPPORTED_TYPE_FOR_OP, manip,
                                "Can not cast from primitve to non primitive type:" + castTo));
                    }
                }
                break;
            }
        }
    }
}

From source file:org.noroomattheinn.timeseries.PersistentTS.java

@Override
public final synchronized void streamRows(Range<Long> period, RowCollector collector) {
    double accumulator[] = new double[schema.nColumns];
    if (period == null)
        period = Range.all();/*  w  ww .j  a  v  a2s. c om*/
    long fromTime = period.hasLowerBound() ? period.lowerEndpoint() : 0L;
    long toTime = period.hasUpperBound() ? period.upperEndpoint() : Long.MAX_VALUE;
    long prevTime = 0;
    BufferedReader rdr = null;
    try {
        rdr = repo.getReader();
        String line;
        while ((line = rdr.readLine()) != null) {
            if (line.startsWith("#")) {
                continue;
            }
            String[] tokens = line.split("\t");

            // The first entry on the line is the time in delta format
            Long time = longValue(tokens[0]);
            if (time == null) {
                continue;
            } // Invalid format, ignore this line
            time = time < 0 ? -time : time + prevTime;
            prevTime = time; // Keep a running tally of the current time

            time = inflate(time);
            if (time < fromTime)
                continue; // Out of range, ignore & move on
            if (time > toTime)
                break; // Out of range, ignore & stop

            Row row = new Row(time, 0L, schema.nColumns);

            // The second element is a bitvector corresponding to which
            // columns have values on this line
            Long bitVector = longValue("0x" + tokens[1]);
            if (bitVector == null) {
                continue;
            } // Invalid format, Ignore this line
            row.bitVector = bitVector;

            // The remaining entries are readings. There is one reading for
            // each 1 bit in the bitvector. The positions in the bitvector
            // correspond to the columns in the order initially specified
            long bit = 1;
            int tokenIndex = 2;
            for (int i = 0; i < schema.nColumns; i++) {
                row.values[i] = accumulator[i]; // Start off with the previous value
                if (row.includes(bit)) {
                    String valString = tokens[tokenIndex++];
                    switch (valString) {
                    case "*":
                        break;
                    case "!":
                        row.clear(bit);
                        break;
                    default:
                        Double val = doubleValue(valString);
                        if (val == null) {
                            row.clear(bit);
                        } else {
                            accumulator[i] = row.values[i] = val.doubleValue();
                        }
                        break;
                    }
                } else {
                    row.values[i] = accumulator[i];
                }
                bit = bit << 1;
            }
            if (!collector.collect(row))
                break;
        }
    } catch (IOException ex) {
        logger.severe("Error loading from repository" + ex);
    }
    if (rdr != null)
        try {
            rdr.close();
        } catch (IOException e) {
            logger.warning("Failure closing reader: " + e);
        }
}

From source file:com.pingcap.tikv.predicates.ScanBuilder.java

private List<KeyRange> buildIndexScanKeyRange(TiTableInfo table, TiIndexInfo index,
        List<IndexRange> indexRanges) {
    requireNonNull(table, "Table cannot be null to encoding keyRange");
    requireNonNull(index, "Index cannot be null to encoding keyRange");
    requireNonNull(index, "indexRanges cannot be null to encoding keyRange");

    List<KeyRange> ranges = new ArrayList<>(indexRanges.size());

    for (IndexRange ir : indexRanges) {
        CodecDataOutput cdo = new CodecDataOutput();
        List<Object> values = ir.getAccessPoints();
        List<DataType> types = ir.getTypes();
        for (int i = 0; i < values.size(); i++) {
            Object v = values.get(i);
            DataType t = types.get(i);//from  w w  w  .  j a v a  2s  .c o  m
            t.encode(cdo, DataType.EncodeType.KEY, v);
        }

        byte[] pointsData = cdo.toBytes();

        cdo.reset();
        Range r = ir.getRange();
        byte[] lPointKey;
        byte[] uPointKey;

        byte[] lKey;
        byte[] uKey;
        if (r == null) {
            lPointKey = pointsData;
            uPointKey = KeyUtils.prefixNext(lPointKey.clone());

            lKey = new byte[0];
            uKey = new byte[0];
        } else {
            lPointKey = pointsData;
            uPointKey = pointsData;

            DataType type = ir.getRangeType();
            if (!r.hasLowerBound()) {
                // -INF
                type.encodeMinValue(cdo);
                lKey = cdo.toBytes();
            } else {
                Object lb = r.lowerEndpoint();
                type.encode(cdo, DataType.EncodeType.KEY, lb);
                lKey = cdo.toBytes();
                if (r.lowerBoundType().equals(BoundType.OPEN)) {
                    lKey = KeyUtils.prefixNext(lKey);
                }
            }

            cdo.reset();
            if (!r.hasUpperBound()) {
                // INF
                type.encodeMaxValue(cdo);
                uKey = cdo.toBytes();
            } else {
                Object ub = r.upperEndpoint();
                type.encode(cdo, DataType.EncodeType.KEY, ub);
                uKey = cdo.toBytes();
                if (r.upperBoundType().equals(BoundType.CLOSED)) {
                    uKey = KeyUtils.prefixNext(lKey);
                }
            }

            cdo.reset();
        }
        TableCodec.writeIndexSeekKey(cdo, table.getId(), index.getId(), lPointKey, lKey);

        ByteString lbsKey = ByteString.copyFrom(cdo.toBytes());

        cdo.reset();
        TableCodec.writeIndexSeekKey(cdo, table.getId(), index.getId(), uPointKey, uKey);
        ByteString ubsKey = ByteString.copyFrom(cdo.toBytes());

        ranges.add(KeyRange.newBuilder().setStart(lbsKey).setEnd(ubsKey).build());
    }

    if (ranges.isEmpty()) {
        ranges.add(INDEX_FULL_RANGE);
    }
    return ranges;
}

From source file:org.apache.kylin.storage.hbase.ii.coprocessor.endpoint.IIEndpoint.java

private Scan prepareScan(IIProtos.IIRequest request, HRegion region) throws IOException {
    Scan scan = new Scan();

    scan.addColumn(IIDesc.HBASE_FAMILY_BYTES, IIDesc.HBASE_QUALIFIER_BYTES);
    scan.addColumn(IIDesc.HBASE_FAMILY_BYTES, IIDesc.HBASE_DICTIONARY_BYTES);

    if (request.hasTsRange()) {
        Range<Long> tsRange = (Range<Long>) SerializationUtils
                .deserialize(HBaseZeroCopyByteString.zeroCopyGetBytes(request.getTsRange()));
        byte[] regionStartKey = region.getStartKey();
        if (!ArrayUtils.isEmpty(regionStartKey)) {
            shard = BytesUtil.readUnsigned(regionStartKey, 0, IIKeyValueCodec.SHARD_LEN);
        } else {//from  w ww.j a  v a 2  s  .co m
            shard = 0;
        }
        logger.info("Start key of the region is: " + BytesUtil.toReadableText(regionStartKey)
                + ", making shard to be :" + shard);

        if (tsRange.hasLowerBound()) {
            //differentiate GT and GTE seems not very beneficial
            Preconditions.checkArgument(shard != -1, "Shard is -1!");
            long tsStart = tsRange.lowerEndpoint();
            logger.info("ts start is " + tsStart);

            byte[] idealStartKey = new byte[IIKeyValueCodec.SHARD_LEN + IIKeyValueCodec.TIMEPART_LEN];
            BytesUtil.writeUnsigned(shard, idealStartKey, 0, IIKeyValueCodec.SHARD_LEN);
            BytesUtil.writeLong(tsStart, idealStartKey, IIKeyValueCodec.SHARD_LEN,
                    IIKeyValueCodec.TIMEPART_LEN);
            logger.info("ideaStartKey is(readable) :" + BytesUtil.toReadableText(idealStartKey));
            Result result = region.getClosestRowBefore(idealStartKey, IIDesc.HBASE_FAMILY_BYTES);
            if (result != null) {
                byte[] actualStartKey = Arrays.copyOf(result.getRow(),
                        IIKeyValueCodec.SHARD_LEN + IIKeyValueCodec.TIMEPART_LEN);
                scan.setStartRow(actualStartKey);
                logger.info("The start key is set to " + BytesUtil.toReadableText(actualStartKey));
            } else {
                logger.info("There is no key before ideaStartKey so ignore tsStart");
            }
        }

        if (tsRange.hasUpperBound()) {
            //differentiate LT and LTE seems not very beneficial
            Preconditions.checkArgument(shard != -1, "Shard is -1");
            long tsEnd = tsRange.upperEndpoint();
            logger.info("ts end is " + tsEnd);

            byte[] actualEndKey = new byte[IIKeyValueCodec.SHARD_LEN + IIKeyValueCodec.TIMEPART_LEN];
            BytesUtil.writeUnsigned(shard, actualEndKey, 0, IIKeyValueCodec.SHARD_LEN);
            BytesUtil.writeLong(tsEnd + 1, actualEndKey, IIKeyValueCodec.SHARD_LEN,
                    IIKeyValueCodec.TIMEPART_LEN);//notice +1 here
            scan.setStopRow(actualEndKey);
            logger.info("The stop key is set to " + BytesUtil.toReadableText(actualEndKey));
        }
    }

    return scan;
}

From source file:org.pshdl.model.extensions.RangeExtension.java

protected Optional<Range<BigInteger>> _determineRange(final HDLBitOp obj, final HDLEvaluationContext context) {
    HDLExpression _left = obj.getLeft();
    final Optional<Range<BigInteger>> leftRange = this.determineRange(_left, context);
    boolean _isPresent = leftRange.isPresent();
    boolean _not = (!_isPresent);
    if (_not) {//from ww w.  j  av  a2s . c om
        return Optional.<Range<BigInteger>>absent();
    }
    final Range<BigInteger> lrVal = leftRange.get();
    boolean _or = false;
    boolean _hasLowerBound = lrVal.hasLowerBound();
    boolean _not_1 = (!_hasLowerBound);
    if (_not_1) {
        _or = true;
    } else {
        boolean _hasUpperBound = lrVal.hasUpperBound();
        boolean _not_2 = (!_hasUpperBound);
        _or = _not_2;
    }
    if (_or) {
        return Optional.<Range<BigInteger>>absent();
    }
    HDLExpression _right = obj.getRight();
    final Optional<Range<BigInteger>> rightRange = this.determineRange(_right, context);
    boolean _isPresent_1 = rightRange.isPresent();
    boolean _not_3 = (!_isPresent_1);
    if (_not_3) {
        return Optional.<Range<BigInteger>>absent();
    }
    final Range<BigInteger> rrVal = rightRange.get();
    boolean _or_1 = false;
    boolean _hasLowerBound_1 = rrVal.hasLowerBound();
    boolean _not_4 = (!_hasLowerBound_1);
    if (_not_4) {
        _or_1 = true;
    } else {
        boolean _hasUpperBound_1 = rrVal.hasUpperBound();
        boolean _not_5 = (!_hasUpperBound_1);
        _or_1 = _not_5;
    }
    if (_or_1) {
        return Optional.<Range<BigInteger>>absent();
    }
    HDLBitOp.HDLBitOpType _type = obj.getType();
    final HDLBitOp.HDLBitOpType type = _type;
    boolean _matched = false;
    if (!_matched) {
        boolean _or_2 = false;
        boolean _equals = Objects.equal(type, HDLBitOp.HDLBitOpType.OR);
        if (_equals) {
            _or_2 = true;
        } else {
            boolean _equals_1 = Objects.equal(type, HDLBitOp.HDLBitOpType.XOR);
            _or_2 = _equals_1;
        }
        if (_or_2) {
            _matched = true;
            obj.<IHDLObject>addMeta(ProblemDescription.SOURCE, obj);
            obj.<ProblemDescription>addMeta(ProblemDescription.DESCRIPTION,
                    ProblemDescription.BIT_NOT_SUPPORTED_FOR_RANGES);
            BigInteger _upperEndpoint = lrVal.upperEndpoint();
            int _bitLength = _upperEndpoint.bitLength();
            BigInteger _shiftLeft = BigInteger.ONE.shiftLeft(_bitLength);
            BigInteger _subtract = _shiftLeft.subtract(BigInteger.ONE);
            Range<BigInteger> _createRange = RangeTool.<BigInteger>createRange(BigInteger.ZERO, _subtract);
            return Optional.<Range<BigInteger>>of(_createRange);
        }
    }
    if (!_matched) {
        if (Objects.equal(type, HDLBitOp.HDLBitOpType.AND)) {
            _matched = true;
            obj.<IHDLObject>addMeta(ProblemDescription.SOURCE, obj);
            obj.<ProblemDescription>addMeta(ProblemDescription.DESCRIPTION,
                    ProblemDescription.BIT_NOT_SUPPORTED_FOR_RANGES);
            BigInteger _upperEndpoint_1 = lrVal.upperEndpoint();
            BigInteger _upperEndpoint_2 = rrVal.upperEndpoint();
            int _bitLength_1 = _upperEndpoint_2.bitLength();
            BigInteger _shiftLeft_1 = BigInteger.ONE.shiftLeft(_bitLength_1);
            BigInteger _subtract_1 = _shiftLeft_1.subtract(BigInteger.ONE);
            BigInteger _min = _upperEndpoint_1.min(_subtract_1);
            Range<BigInteger> _createRange_1 = RangeTool.<BigInteger>createRange(BigInteger.ZERO, _min);
            return Optional.<Range<BigInteger>>of(_createRange_1);
        }
    }
    if (!_matched) {
        boolean _or_3 = false;
        boolean _equals_2 = Objects.equal(type, HDLBitOp.HDLBitOpType.LOGI_AND);
        if (_equals_2) {
            _or_3 = true;
        } else {
            boolean _equals_3 = Objects.equal(type, HDLBitOp.HDLBitOpType.LOGI_OR);
            _or_3 = _equals_3;
        }
        if (_or_3) {
            _matched = true;
            obj.<IHDLObject>addMeta(ProblemDescription.SOURCE, obj);
            obj.<ProblemDescription>addMeta(ProblemDescription.DESCRIPTION,
                    ProblemDescription.BOOLEAN_NOT_SUPPORTED_FOR_RANGES);
            Range<BigInteger> _createRange_2 = RangeTool.<BigInteger>createRange(BigInteger.ZERO,
                    BigInteger.ONE);
            return Optional.<Range<BigInteger>>of(_createRange_2);
        }
    }
    throw new RuntimeException("Incorrectly implemented obj op");
}