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

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

Introduction

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

Prototype

public static <C extends Comparable<?>> Range<C> closed(C lower, C upper) 

Source Link

Document

Returns a range that contains all values greater than or equal to lower and less than or equal to upper .

Usage

From source file:jetbrains.jetpad.hybrid.HybridSynchronizer.java

private CellTrait createTargetTrait() {
    return new CellTrait() {
        @Override/*  www .j  a va 2s  . com*/
        public Object get(Cell cell, CellTraitPropertySpec<?> spec) {
            if (spec == HYBRID_SYNCHRONIZER) {
                return HybridSynchronizer.this;
            }
            if (spec == CellStateHandler.PROPERTY) {
                return getCellStateHandler();
            }

            return super.get(cell, spec);
        }

        @Override
        public void onKeyPressed(Cell cell, KeyEvent event) {
            Cell focusedCell = cell.cellContainer().get().focusedCell.get();
            if (myTargetList.contains(focusedCell)) {
                Cell currentCell = cell.cellContainer().get().focusedCell.get();
                if (!hasSelection()) {
                    if (event.is(KeyStrokeSpecs.SELECT_UP) && currentCell != null) {
                        mySelectionSupport.select(currentCell, currentCell);
                        event.consume();
                    }
                } else {
                    Range<Integer> currentRange = selection();
                    if (event.is(KeyStrokeSpecs.SELECT_UP)) {
                        ParseNode parseNode = myTokenListEditor.parseNode();
                        if (parseNode != null) {
                            if (!currentRange.equals(parseNode.range())) {
                                ParseNode node = ParseNodes.findForRange(parseNode, currentRange);
                                ParseNode parentNode = ParseNodes.nonSameRangeParent(node);
                                if (parentNode != null) {
                                    select(parentNode.range());
                                    event.consume();
                                }
                            }
                        } else {
                            if (!currentRange.equals(Range.closed(0, tokens().size()))) {
                                select(Range.closed(0, tokens().size()));
                                event.consume();
                            }
                        }
                    }

                    if (event.is(KeyStrokeSpecs.SELECT_DOWN)) {
                        ParseNode parseNode = myTokenListEditor.parseNode();
                        if (parseNode != null) {
                            ParseNode node = ParseNodes.findForRange(parseNode, currentRange);
                            ParseNode childNode = ParseNodes.nonSameRangeChild(node,
                                    myTargetList.indexOf(mySelectionSupport.currentCell()));
                            if (childNode != null) {
                                select(childNode.range());
                                event.consume();
                                return;
                            }
                        }

                        if (!mySelectionSupport.isCurrentCompletelySelected()) {
                            mySelectionSupport.clearSelection();
                            event.consume();
                        }
                    }
                }
            }
            super.onKeyPressed(cell, event);
        }

        @Override
        public void onCopy(Cell cell, CopyCutEvent event) {
            if (canCopy()) {
                event.consume(copy());
                return;
            }
            super.onCopy(cell, event);
        }

        @Override
        public void onCut(Cell cell, CopyCutEvent event) {
            if (canCut()) {
                event.consume(cut());
                return;
            }
            super.onCut(cell, event);
        }

        @Override
        public void onPaste(Cell cell, PasteEvent event) {
            if (canPaste(event.getContent())) {
                paste(event.getContent());
                event.consume();
                return;
            }
            super.onPaste(cell, event);
        }

        private boolean canPaste(ClipboardContent content) {
            return content.isSupported(TOKENS_CONTENT);
        }

        private void paste(ClipboardContent content) {
            List<Token> tokens = content.get(TOKENS_CONTENT);
            Cell currentCell = mySelectionSupport.currentCell();

            int targetIndex;
            if (currentCell != null) {
                int currentCellIndex = myTargetList.indexOf(currentCell);
                targetIndex = Positions.isHomePosition(currentCell) ? currentCellIndex : currentCellIndex + 1;
            } else {
                targetIndex = 0;
            }

            myTokenListEditor.tokens.addAll(targetIndex, tokens);
            myTokenListEditor.updateToPrintedTokens();
            tokenOperations().select(targetIndex + tokens.size() - 1, LAST).run();
        }

        private boolean canCopy() {
            return hasSelection();
        }

        private ClipboardContent copy() {
            final Range<Integer> selection = selection();
            final List<Token> tokens = new ArrayList<>(
                    tokens().subList(selection.lowerEndpoint(), selection.upperEndpoint()));
            return new ClipboardContent() {
                @Override
                public boolean isSupported(ContentKind<?> kind) {
                    return kind == TOKENS_CONTENT;
                }

                @Override
                public <T> T get(ContentKind<T> kind) {
                    if (kind == TOKENS_CONTENT) {
                        return (T) Collections.unmodifiableList(tokens);
                    }
                    return null;
                }
            };
        }

        private boolean canCut() {
            return hasSelection();
        }

        private ClipboardContent cut() {
            ClipboardContent result = copy();
            clearSelection();
            return result;
        }
    };
}

From source file:jetbrains.jetpad.hybrid.BaseHybridSynchronizer.java

private CellTrait createTargetTrait() {
    return new CellTrait() {
        @Override//from w  ww.  ja v  a2  s .com
        public Object get(Cell cell, CellTraitPropertySpec<?> spec) {
            if (spec == HYBRID_SYNCHRONIZER) {
                return BaseHybridSynchronizer.this;
            }
            if (spec == CellStateHandler.PROPERTY) {
                return getCellStateHandler();
            }

            return super.get(cell, spec);
        }

        @Override
        public void onKeyPressed(Cell cell, KeyEvent event) {
            Cell focusedCell = cell.getContainer().focusedCell.get();
            if (myTargetList.contains(focusedCell)) {
                Cell currentCell = cell.getContainer().focusedCell.get();
                if (!hasSelection()) {
                    if (event.is(KeyStrokeSpecs.SELECT_UP) && currentCell != null) {
                        mySelectionSupport.select(currentCell, currentCell);
                        event.consume();
                    }
                } else {
                    Range<Integer> currentRange = selection();
                    if (event.is(KeyStrokeSpecs.SELECT_UP)) {
                        ParseNode parseNode = myTokenListEditor.getParseNode();
                        if (parseNode != null) {
                            if (!currentRange.equals(parseNode.getRange())) {
                                ParseNode node = ParseNodes.findForRange(parseNode, currentRange);
                                ParseNode parentNode = ParseNodes.nonSameRangeParent(node);
                                if (parentNode != null) {
                                    select(parentNode.getRange());
                                    event.consume();
                                }
                            }
                        } else {
                            if (!currentRange.equals(Range.closed(0, tokens().size()))) {
                                select(Range.closed(0, tokens().size()));
                                event.consume();
                            }
                        }
                    }

                    if (event.is(KeyStrokeSpecs.SELECT_DOWN)) {
                        ParseNode parseNode = myTokenListEditor.getParseNode();
                        if (parseNode != null) {
                            ParseNode node = ParseNodes.findForRange(parseNode, currentRange);
                            ParseNode childNode = ParseNodes.nonSameRangeChild(node,
                                    myTargetList.indexOf(mySelectionSupport.currentCell()));
                            if (childNode != null) {
                                select(childNode.getRange());
                                event.consume();
                                return;
                            }
                        }

                        if (!mySelectionSupport.isCurrentCompletelySelected()) {
                            mySelectionSupport.clearSelection();
                            event.consume();
                        }
                    }
                }
            }
            super.onKeyPressed(cell, event);
        }

        @Override
        public void onCopy(Cell cell, CopyCutEvent event) {
            if (canCopy()) {
                event.consume(copy());
                return;
            }
            super.onCopy(cell, event);
        }

        @Override
        public void onCut(Cell cell, CopyCutEvent event) {
            if (canCut()) {
                ClipboardContent content = cut();
                myTokensEditPostProcessor.afterTokensEdit(tokens(), property().get());
                event.consume(content);
                return;
            }
            super.onCut(cell, event);
        }

        @Override
        public void onPaste(Cell cell, PasteEvent event) {
            if (canPaste(event.getContent())) {
                paste(event.getContent());
                myTokensEditPostProcessor.afterTokensEdit(tokens(), property().get());
                event.consume();
                return;
            }
            super.onPaste(cell, event);
        }

        private boolean canPaste(ClipboardContent content) {
            return content.isSupported(TOKENS_CONTENT);
        }

        private void paste(ClipboardContent content) {
            List<Token> tokens = content.get(TOKENS_CONTENT);
            Cell currentCell = mySelectionSupport.currentCell();

            int targetIndex;
            if (currentCell != null) {
                int currentCellIndex = myTargetList.indexOf(currentCell);
                boolean home = Positions.isHomePosition(currentCell);
                boolean end = Positions.isEndPosition(currentCell);
                if (home && end) {
                    // One-char token which allows editing at only one side
                    if (currentCell instanceof TextTokenCell && ((TextTokenCell) currentCell).noSpaceToLeft()) {
                        targetIndex = currentCellIndex + 1;
                    } else {
                        targetIndex = currentCellIndex;
                    }
                } else if (home) {
                    targetIndex = currentCellIndex;
                } else {
                    targetIndex = currentCellIndex + 1;
                }
            } else {
                targetIndex = 0;
            }

            myTokenListEditor.tokens.addAll(targetIndex, tokens);
            myTokenListEditor.updateToPrintedTokens();
            tokenOperations().select(targetIndex + tokens.size() - 1, LAST).run();
        }

        private boolean canCopy() {
            return hasSelection();
        }

        private ClipboardContent copy() {
            final Range<Integer> selection = selection();
            final List<Token> copiedTokens = new ArrayList<>(
                    selection.upperEndpoint() - selection.lowerEndpoint());
            for (Token token : tokens().subList(selection.lowerEndpoint(), selection.upperEndpoint())) {
                copiedTokens.add(token.copy());
            }
            return new ClipboardContent() {
                @Override
                public boolean isSupported(ContentKind<?> kind) {
                    return kind == TOKENS_CONTENT;
                }

                @Override
                public <T> T get(ContentKind<T> kind) {
                    if (kind == TOKENS_CONTENT) {
                        List<Token> result = new ArrayList<>(copiedTokens.size());
                        for (Token token : copiedTokens) {
                            result.add(token.copy());
                        }
                        return (T) Collections.unmodifiableList(result);
                    }
                    return null;
                }

                @Override
                public String toString() {
                    try {
                        return TokenUtil.getText(copiedTokens);
                    } catch (UnsupportedOperationException e) {
                        return super.toString();
                    }
                }
            };
        }

        private boolean canCut() {
            return hasSelection();
        }

        private ClipboardContent cut() {
            ClipboardContent result = copy();
            clearSelection();
            return result;
        }
    };
}

From source file:com.google.googlejavaformat.java.JavaInput.java

/**
 * Input constructor./*from  ww w  .ja v  a  2  s  .co m*/
 *
 * @param text the input text
 * @throws FormatterException if the input cannot be parsed
 */
public JavaInput(String text) throws FormatterException {
    this.text = checkNotNull(text);
    setLines(ImmutableList.copyOf(Newlines.lineIterator(text)));
    ImmutableList<Tok> toks = buildToks(text);
    positionToColumnMap = makePositionToColumnMap(toks);
    tokens = buildTokens(toks);
    ImmutableRangeMap.Builder<Integer, Token> tokenLocations = ImmutableRangeMap.builder();
    for (Token token : tokens) {
        Input.Tok end = JavaOutput.endTok(token);
        int upper = end.getPosition();
        if (!end.getText().isEmpty()) {
            upper += end.length() - 1;
        }
        tokenLocations.put(Range.closed(JavaOutput.startTok(token).getPosition(), upper), token);
    }
    positionTokenMap = tokenLocations.build();

    // adjust kN for EOF
    kToToken = new Token[kN + 1];
    for (Token token : tokens) {
        for (Input.Tok tok : token.getToksBefore()) {
            if (tok.getIndex() < 0) {
                continue;
            }
            kToToken[tok.getIndex()] = token;
        }
        kToToken[token.getTok().getIndex()] = token;
        for (Input.Tok tok : token.getToksAfter()) {
            if (tok.getIndex() < 0) {
                continue;
            }
            kToToken[tok.getIndex()] = token;
        }
    }
}

From source file:net.sf.mzmine.modules.peaklistmethods.peakpicking.adap3decompositionV2.ADAP3DecompositionV2Task.java

@Nonnull
private Feature getFeature(@Nonnull RawDataFile file, @Nonnull BetterPeak peak) {
    Chromatogram chromatogram = peak.chromatogram;

    // Retrieve scan numbers
    int representativeScan = 0;
    int[] scanNumbers = new int[chromatogram.length];
    int count = 0;
    for (int num : file.getScanNumbers()) {
        double retTime = file.getScan(num).getRetentionTime();
        if (chromatogram.contains(retTime))
            scanNumbers[count++] = num;//  w  w  w  .java 2s .c o  m
        if (retTime == peak.getRetTime())
            representativeScan = num;
    }

    // Calculate peak area
    double area = 0.0;
    for (int i = 1; i < chromatogram.length; ++i) {
        double base = chromatogram.xs[i] - chromatogram.xs[i - 1];
        double height = 0.5 * (chromatogram.ys[i] + chromatogram.ys[i - 1]);
        area += base * height;
    }

    // Create array of DataPoints
    DataPoint[] dataPoints = new DataPoint[chromatogram.length];
    count = 0;
    for (double intensity : chromatogram.ys)
        dataPoints[count++] = new SimpleDataPoint(peak.getMZ(), intensity);

    return new SimpleFeature(file, peak.getMZ(), peak.getRetTime(), peak.getIntensity(), area, scanNumbers,
            dataPoints, Feature.FeatureStatus.MANUAL, representativeScan, representativeScan,
            Range.closed(peak.getFirstRetTime(), peak.getLastRetTime()),
            Range.closed(peak.getMZ() - 0.01, peak.getMZ() + 0.01), Range.closed(0.0, peak.getIntensity()));
}

From source file:com.yahoo.gondola.container.impl.ZookeeperShardManagerServer.java

private void processAction(ZookeeperAction action) throws InterruptedException {
    ZookeeperStat stat = currentStats.get(action.memberId);
    if (action.action == ZookeeperAction.Action.NOOP) {
        return;/* w w  w.  j a v  a  2s  .  c  om*/
    }
    trace("[{}-{}] Processing action={} args={}", gondola.getHostId(), stat.memberId, action.action,
            action.args);
    ZookeeperAction.Args args = action.parseArgs();
    for (int i = 0; i < RETRY_TIME; i++) {
        try {
            switch (action.action) {
            case NOOP:
                break;
            case START_SLAVE:
                delegate.startObserving(args.fromShard, args.toShard, args.timeoutMs);
                stat.mode = SLAVE;
                break;
            case STOP_SLAVE:
                delegate.stopObserving(args.fromShard, args.toShard, args.timeoutMs);
                stat.mode = NORMAL;
                break;
            case MIGRATE_1:
                delegate.migrateBuckets(Range.closed(args.rangeStart, args.rangeStop), args.fromShard,
                        args.toShard, args.timeoutMs);
                stat.mode = MIGRATING_1;
                break;
            case MIGRATE_2:
                delegate.setBuckets(Range.closed(args.rangeStart, args.rangeStop), args.fromShard, args.toShard,
                        args.complete);
                stat.mode = MIGRATING_2;
                break;
            case MIGRATE_3:
                delegate.setBuckets(Range.closed(args.rangeStart, args.rangeStop), args.fromShard, args.toShard,
                        args.complete);
                stat.mode = NORMAL;
                break;
            case MIGRATE_ROLLBACK:
                delegate.rollbackBuckets(Range.closed(args.rangeStart, args.rangeStop));
                stat.mode = NORMAL;
                break;

            }
            stat.status = RUNNING;
            stat.reason = null;
        } catch (ShardManagerProtocol.ShardManagerException e) {
            logger.warn("[{}-{}] Cannot execute action={} args={} reason={}", gondola.getHostId(),
                    action.memberId, action, action.args, e.getMessage());
            stat.status = FAILED;
            stat.reason = e.getMessage();
        }
        writeStat(stat.memberId, stat);
        if (stat.status != FAILED) {
            break;
        }
        Thread.sleep(RETRY_WAIT_TIME);
    }
}

From source file:org.onosproject.driver.optical.power.OplinkPowerConfigUtil.java

/**
 * Returns the target port power range.//  ww w. jav  a 2  s.c  om
 *
 * @param portNum the port number
 * @return power range
 */
private Range<Long> getTargetPortPowerRange(PortNumber portNum) {
    OpenFlowSwitch ofs = getOpenFlowDevice();
    if (ofs == null) {
        return null;
    }
    PortDescType portType = getPortDescType((OpenFlowOpticalSwitch) ofs, portNum);
    Type devType = ofs.deviceType();
    // FIXME
    // Short time hard code.
    // The power range will be obtained from physical device in the future.
    switch (devType) {
    case OPTICAL_AMPLIFIER:
        if (portType == PortDescType.PA_LINE_OUT || portType == PortDescType.BA_LINE_OUT) {
            return Range.closed(EDFA_POWER_OUT_LOW_THRES, EDFA_POWER_OUT_HIGH_THRES);
        }
        break;
    case ROADM:
        if (portType == PortDescType.PA_LINE_OUT) {
            return Range.closed(ROADM_POWER_LINE_OUT_LOW_THRES, ROADM_POWER_LINE_OUT_HIGH_THRES);
        } else if (portType == PortDescType.EXP_OUT || portType == PortDescType.AUX_OUT) {
            return Range.closed(ROADM_POWER_OTHER_OUT_LOW_THRES, ROADM_POWER_OTHER_OUT_HIGH_THRES);
        }
        break;
    case FIBER_SWITCH:
        return Range.closed(SWITCH_POWER_LOW_THRES, SWITCH_POWER_HIGH_THRES);
    default:
        log.warn("Unexpected device type: {}", devType);
        break;
    }
    // Unexpected port or device type. Do not need warning here for port polling.
    return null;
}

From source file:com.b2international.snowowl.snomed.core.ecl.SnomedEclRefinementEvaluator.java

/**
 * Handles evaluation of attribute refinements with groups
 * @see https://confluence.ihtsdotools.org/display/DOCECL/6.2+Refinements
 *///  w  ww. ja v  a  2s  .  c  o m
protected Promise<Expression> eval(final BranchContext context, AttributeGroup group) {
    final Cardinality cardinality = group.getCardinality();
    final boolean isUnbounded = cardinality == null ? true : cardinality.getMax() == UNBOUNDED_CARDINALITY;
    final long min = cardinality == null ? 1 : cardinality.getMin();
    final long max = isUnbounded ? Long.MAX_VALUE : cardinality.getMax();
    final Range<Long> groupCardinality = Range.closed(min, max);

    if (min == 0) {
        if (isUnbounded) {
            return focusConcepts.resolveToExpression(context);
        } else {
            final Range<Long> exclusionRange = Range.closed(max + 1, Long.MAX_VALUE);
            return evaluateGroup(context, exclusionRange, group.getRefinement()).thenWith(input -> {
                final Set<String> excludedMatches = FluentIterable.from(input).transform(Property::getObjectId)
                        .toSet();
                return focusConcepts.resolveToExclusionExpression(context, excludedMatches);
            });
        }
    } else {
        return evaluateGroup(context, groupCardinality, group.getRefinement()).thenWith(input -> {
            final Set<String> matchingIds = FluentIterable.from(input).transform(Property::getObjectId).toSet();
            return focusConcepts.resolveToAndExpression(context, matchingIds);
        });
    }
}

From source file:io.github.msdk.io.mzml.MzMLConverter.java

@SuppressWarnings("null")
@Nonnull//from w  w w .  j  av  a 2  s.com
List<IsolationInfo> extractIsolations(Spectrum spectrum) {
    PrecursorList precursorListElement = spectrum.getPrecursorList();
    if ((precursorListElement == null) || (precursorListElement.getCount().equals(0)))
        return Collections.emptyList();

    List<IsolationInfo> isolations = new ArrayList<>();

    List<Precursor> precursorList = precursorListElement.getPrecursor();
    for (Precursor parent : precursorList) {

        Double precursorMz = null;
        Double isolationWindowTarget = null;
        Double isolationWindowLower = null;
        Double isolationWindowUpper = null;
        Integer precursorCharge = null;

        SelectedIonList selectedIonListElement = parent.getSelectedIonList();
        if ((selectedIonListElement == null) || (selectedIonListElement.getCount().equals(0)))
            return Collections.emptyList();
        List<ParamGroup> selectedIonParams = selectedIonListElement.getSelectedIon();
        if (selectedIonParams == null)
            continue;

        for (ParamGroup pg : selectedIonParams) {
            // cvMz is sometimes used is used in mzML 1.0 files
            String cvVal = extractCVValue(pg, MzMLCV.cvMz);
            if (!Strings.isNullOrEmpty(cvVal))
                precursorMz = Double.parseDouble(cvVal);

            cvVal = extractCVValue(pg, MzMLCV.cvPrecursorMz);
            if (!Strings.isNullOrEmpty(cvVal))
                precursorMz = Double.parseDouble(cvVal);

            cvVal = extractCVValue(pg, MzMLCV.cvChargeState);
            if (!Strings.isNullOrEmpty(cvVal))
                precursorCharge = Integer.parseInt(cvVal);

        }

        String cvVal = extractCVValue(parent.getIsolationWindow(), MzMLCV.cvIsolationWindowLowerOffset);
        if (!Strings.isNullOrEmpty(cvVal))
            isolationWindowLower = Double.parseDouble(cvVal);

        cvVal = extractCVValue(parent.getIsolationWindow(), MzMLCV.cvIsolationWindowUpperOffset);
        if (!Strings.isNullOrEmpty(cvVal))
            isolationWindowUpper = Double.parseDouble(cvVal);

        cvVal = extractCVValue(parent.getIsolationWindow(), MzMLCV.cvIsolationWindowTarget);
        if (!Strings.isNullOrEmpty(cvVal))
            isolationWindowTarget = Double.parseDouble(cvVal);

        if (precursorMz != null) {
            if (isolationWindowTarget == null)
                isolationWindowTarget = precursorMz;
            if (isolationWindowLower == null)
                isolationWindowLower = 0.5;
            if (isolationWindowUpper == null)
                isolationWindowUpper = 0.5;
            Range<Double> isolationRange = Range.closed(isolationWindowTarget - isolationWindowLower,
                    isolationWindowTarget + isolationWindowUpper);
            IsolationInfo isolation = MSDKObjectBuilder.getIsolationInfo(isolationRange, null, precursorMz,
                    precursorCharge, null);
            isolations.add(isolation);
        }
    }

    return Collections.unmodifiableList(isolations);
}

From source file:org.noroomattheinn.visibletesla.Prefs.java

private Range<Long> getLoadPeriod() {
    Range<Long> range = Range.closed(Long.MIN_VALUE, Long.MAX_VALUE);

    long now = System.currentTimeMillis();
    LoadPeriod period = nameToLoadPeriod.get(loadPeriod.get());
    if (period == null) {
        period = LoadPeriod.All;/*from  w w w. ja v  a  2  s .  c  o m*/
        loadPeriod.set(nameToLoadPeriod.inverse().get(period));
    }
    switch (period) {
    case None:
        range = Range.closed(now + 1000, now + 1000L); // Empty Range
        break;
    case Last7:
        range = Range.closed(now - (7 * 24 * 60 * 60 * 1000L), now);
        break;
    case Last14:
        range = Range.closed(now - (14 * 24 * 60 * 60 * 1000L), now);
        break;
    case Last30:
        range = Range.closed(now - (30 * 24 * 60 * 60 * 1000L), now);
        break;
    case ThisWeek:
        Range<Date> thisWeek = getThisWeek();
        range = Range.closed(thisWeek.lowerEndpoint().getTime(), thisWeek.upperEndpoint().getTime());
        break;
    case ThisMonth:
        Range<Date> thisMonth = getThisMonth();
        range = Range.closed(thisMonth.lowerEndpoint().getTime(), thisMonth.upperEndpoint().getTime());
        break;
    case All:
    default:
        break;

    }
    return range;
}

From source file:org.onosproject.drivers.oplink.OplinkOpticalPowerConfig.java

private Range<Long> getPowerRange(PortNumber port, String directionKey, String minKey, String maxKey) {
    // TODO/*from   w ww .j a  v  a2 s . c  o m*/
    // Optical protection switch does not support power range configuration, it'll reply error.
    // To prevent replying error log flooding from netconf session when polling all ports information,
    // use general power range of [-60, 60] instead.
    if (handler().get(DeviceService.class).getDevice(data().deviceId()).type() == Device.Type.FIBER_SWITCH) {
        return RANGE_GENERAL;
    }
    String reply = netconfGet(handler(), getPowerRangeFilter(port, directionKey));
    HierarchicalConfiguration info = configAt(reply, KEY_PORTS_PORT_PROPERTY);
    if (info == null) {
        return null;
    }
    long minPower = (long) (info.getDouble(minKey) * POWER_MULTIPLIER);
    long maxPower = (long) (info.getDouble(maxKey) * POWER_MULTIPLIER);
    return Range.closed(minPower, maxPower);
}