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:edu.si.sidora.tabularmetadata.spring.SpringITFramework.java

protected static Range<Integer> getIntRange() {
    return Range.closed(56, 23423);
}

From source file:com.wandrell.tabletop.interval.DefaultInterval.java

/**
 * Constructs a {@code DefaultInterval} with the specified limits.
 * <p>/*w  w  w.j  ava  2  s.c  om*/
 * The lower limit should be lower or equal to the upper, otherwise an
 * {@code IllegalIntervalLimitException} is thrown.
 * 
 * @param lowerLimit
 *            the lower limit
 * @param upperLimit
 *            the upper limit
 */
public DefaultInterval(final Integer lowerLimit, final Integer upperLimit) {
    super();

    checkNotNull(lowerLimit, "Received a null pointer as lower limit");
    checkNotNull(upperLimit, "Received a null pointer as upper limit");

    range = Range.closed(lowerLimit, upperLimit);
}

From source file:jetbrains.jetpad.cell.util.Cells.java

public static Cell findClosestFocusableToSide(Cell current, Vector loc) {
    if (!current.visible().get())
        return null;

    Rectangle bounds = current.getBounds();
    Range<Integer> range = Range.closed(bounds.origin.y, bounds.origin.y + bounds.dimension.y);
    if (!range.contains(loc.y)) {
        return null;
    }/*  w  w  w . j  av a2  s.  c  o  m*/
    Cell result = null;
    int distance = Integer.MAX_VALUE;
    for (Cell child : current.children()) {
        if (!child.visible().get())
            continue;

        Cell closest = findClosestFocusableToSide(child, loc);
        if (closest == null)
            continue;
        int newDistance = (int) closest.getBounds().distance(loc);

        if (newDistance < distance) {
            result = closest;
            distance = newDistance;
        }
    }

    if (result == null && current.focusable().get()) {
        return current;
    }

    return result;
}

From source file:org.feature4j.config.BucketRangeFeatureOverrideFactory.java

public Optional<Range<Integer>> getRange(String rangeString) {
    Optional<Range<Integer>> optRange = Optional.absent();
    if (rangeString != null && !rangeString.isEmpty()) {
        java.util.regex.Matcher regexMatcher = RANGE_PATTERN.matcher(rangeString);
        if (regexMatcher.matches()) {
            String lower = regexMatcher.group(1);
            String upper = (regexMatcher.group(3) != null) ? regexMatcher.group(3) : lower;
            Range<Integer> range = Range.closed(Integer.valueOf(lower), Integer.valueOf(upper));
            optRange = Optional.of(range);
        }//  w  w  w . j  ava 2  s  . c o  m
    }
    return optRange;
}

From source file:dollar.api.types.DollarRange.java

public DollarRange(@NotNull Value start, @NotNull Value finish) {
    super();/*from w w  w .j av a2  s  .c  om*/
    Value startUnwrap;
    Value finishUnwrap;

    if (start.compareTo(finish) < 0) {
        startUnwrap = start.$unwrap();
        finishUnwrap = finish.$unwrap();
    } else {
        startUnwrap = finish.$unwrap();
        finishUnwrap = start.$unwrap();
        reversed = true;

    }

    assert startUnwrap != null;
    assert finishUnwrap != null;
    range = Range.closed(startUnwrap, finishUnwrap);
}

From source file:net.sf.mzmine.modules.masslistmethods.shoulderpeaksfilter.peakmodels.LorentzianPeak.java

/**
 * @see net.sf.mzmine.modules.masslistmethods.shoulderpeaksfilter.peakpicking.twostep.peakmodel.PeakModel#getBasePeakWidth()
 *///w ww  . j a v  a  2 s  .  c  om
public Range<Double> getWidth(double partialIntensity) {

    // The height value must be bigger than zero.
    if (partialIntensity <= 0)
        return Range.atLeast(0.0);

    // Using the Lorentzian function we calculate the peak width
    double squareX = ((intensityMain / partialIntensity) - 1) * squareHWHM;

    double sideRange = (double) Math.sqrt(squareX);

    // This range represents the width of our peak in m/z terms
    Range<Double> rangePeak = Range.closed(mzMain - sideRange, mzMain + sideRange);

    return rangePeak;
}

From source file:edu.si.sidora.tabularmetadata.spring.SpringITFramework.java

protected static Range<Float> getFloatRange() {
    return Range.closed(56F, 23423F);
}

From source file:org.robotframework.ide.eclipse.main.plugin.project.build.validation.MockReporter.java

@Override
public void handleProblem(final RobotProblem problem, final IFile file, final RobotToken token,
        final Map<String, Object> additionalAttributes) {
    final ProblemPosition position = new ProblemPosition(token.getLineNumber(),
            Range.closed(token.getStartOffset(), token.getStartOffset() + token.getText().length()));
    handleProblem(problem, file, position, additionalAttributes);
}

From source file:cz.cuni.mff.ms.brodecva.botnicek.ide.compile.library.Randomize.java

private static List<List<TemplateElement>> createChoices(final int starsCount) {
    final ImmutableList.Builder<List<TemplateElement>> builder = ImmutableList.builder();

    final String space = AIML.WORD_DELIMITER.getValue();
    final String randomStart = RANDOM_START;
    final String randomEnd = RANDOM_END;

    final ImmutableSortedSet<Integer> set = ContiguousSet.create(Range.closed(1, starsCount),
            DiscreteDomain.integers());/*  w ww  .  ja v  a2  s .  c  o m*/

    for (int picked = 1; picked <= starsCount; picked++) {
        final Star pickedStar = Star.create(new AIMLIndex(picked));
        final SetView<Integer> rest = Sets.difference(set, ImmutableSet.of(picked));

        // @formatter:off
        // <li><star index="3"/> <srai>RANDOMSTART <srai>REMOVESTART <star index="3"/> <star index="1"/> <star index="2"/> <star index="4"/> REMOVEEND</srai> RANDOMEND</srai><li>
        builder.add(ImmutableList.<TemplateElement>of(pickedStar, Text.create(space),
                Srai.create(Text.create(randomStart + space), Srai.create(removeCopies(pickedStar, rest)),
                        Text.create(space + randomEnd))));
        // @formatter:on
    }

    return builder.build();
}

From source file:de.unijena.bioinf.ChemistryBase.ms.Deviation.java

public Range<Double> getRange(double mz) {
    final double abs = absoluteFor(mz);
    return Range.closed(mz - abs, mz + abs);
}