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

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

Introduction

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

Prototype

public static <C extends Comparable<?>> Range<C> atLeast(C endpoint) 

Source Link

Document

Returns a range that contains all values greater than or equal to endpoint .

Usage

From source file:org.openmhealth.dsu.domain.DataPointSearchCriteriaBuilder.java

public DataPointSearchCriteriaBuilder setCreationTimestampLowerEndpoint(OffsetDateTime lowerEndpoint) {
    this.creationTimestampLowerEndpoint = lowerEndpoint != null ? Range.atLeast(lowerEndpoint) : Range.all();
    return this;
}

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

/**
 * @see net.sf.mzmine.modules.masslistmethods.shoulderpeaksfilter.peakpicking.twostep.peakmodel.PeakModel#getBasePeakWidth()
 *//*from   w  ww.jav  a2  s  .  c o m*/
public Range<Double> getWidth(double partialIntensity) {

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

    if (partialIntensity < shoulderIntensity)
        return shoulderPeak.getWidth(partialIntensity);
    else
        return mainPeak.getWidth(partialIntensity);

}

From source file:io.druid.timeline.partition.SingleDimensionShardSpec.java

@Override
public Map<String, Range<String>> getDomain() {
    Range<String> range;/* w  w w  .  j av a  2 s. com*/
    if (start == null && end == null) {
        range = Range.all();
    } else if (start == null) {
        range = Range.atMost(end);
    } else if (end == null) {
        range = Range.atLeast(start);
    } else {
        range = Range.closed(start, end);
    }
    return ImmutableMap.of(dimension, range);
}

From source file:com.github.fge.grappa.matchers.join.JoinMatcherBuilder.java

/**
 * Return a rule with a minimum number of cycles to run
 *
 * @param nrCycles the number of cycles/*from w  w w .  j  a va 2 s.  c o m*/
 * @return a rule
 * @throws IllegalArgumentException {@code nrCycles} is less than 0
 *
 * @see Range#atLeast(Comparable)
 */
public Rule min(int nrCycles) {
    Preconditions.checkArgument(nrCycles >= 0,
            "illegal repetition number specified (" + nrCycles + "), must be 0 or greater");
    return range(Range.atLeast(nrCycles));
}

From source file:org.ow2.proactive.scheduler.common.job.factories.spi.model.factory.RangeParserValidator.java

protected Range<T> extractRange(String value, Converter<T> converter) throws ModelSyntaxException {
    String rangeRegexp = "^([^),]+)$|^([^),]+),([^),]+)$";
    try {// w ww .j av a 2 s.  co  m
        List<String> modelArguments = parseAndGetRegexGroups(value, rangeRegexp);
        if (modelArguments.size() == 1) {
            T minValue = converter.convert(modelArguments.get(0));
            return Range.atLeast(minValue);
        } else if (modelArguments.size() == 2) {
            T minValue = converter.convert(modelArguments.get(0));
            T maxValue = converter.convert(modelArguments.get(1));
            return Range.closed(minValue, maxValue);
        } else {
            throw new ModelSyntaxException("Internal error, regular expression for " + getType() + " '"
                    + rangeRegexp + "' is invalid.");
        }
    } catch (ConversionException | IllegalArgumentException e) {
        throw new ModelSyntaxException(
                "Illegal " + getType() + " range expression '" + value + "', " + e.getMessage(), e);
    }
}

From source file:org.apache.druid.timeline.partition.SingleDimensionShardSpec.java

private Range<String> getRange() {
    Range<String> range;//from ww  w.j  av  a  2s.c o  m
    if (start == null && end == null) {
        range = Range.all();
    } else if (start == null) {
        range = Range.atMost(end);
    } else if (end == null) {
        range = Range.atLeast(start);
    } else {
        range = Range.closed(start, end);
    }
    return range;
}

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

public DollarRange(boolean lowerBounds, boolean upperBounds, boolean closedLeft, boolean closedRight,
        @Nullable Value lower, @Nullable Value upper) {
    super();//  ww w .ja v a  2  s.co  m
    Value lowerBound;
    Value upperBound;
    if ((lower != null) && (upper != null) && (lower.compareTo(upper) > 0)) {
        lowerBound = upper;
        upperBound = lower;
        reversed = true;
    } else {
        lowerBound = lower;
        upperBound = upper;
    }
    if (!lowerBounds && !upperBounds) {
        range = Range.all();
    } else if (!lowerBounds) {
        if (closedRight) {
            range = Range.atMost(upperBound);
        } else {
            range = Range.lessThan(upperBound);
        }
    } else if (!upperBounds) {
        if (closedLeft) {
            range = Range.atLeast(lowerBound);
        } else {
            range = Range.greaterThan(lowerBound);
        }
    } else if (closedLeft) {
        if (closedRight) {
            range = Range.closed(lowerBound, upperBound);
        } else {
            //openRight
            range = Range.closedOpen(lowerBound, upperBound);
        }
    } else if (!closedLeft) {
        //openLeft
        if (closedRight) {
            range = Range.openClosed(lowerBound, upperBound);
        } else {
            //openRight
            if (lowerBound.equals(upperBound)) {
                throw new IllegalArgumentException(
                        "Cannot have an open range with lower bounds being the same as upper " + "bounds");
            } else {
                range = Range.open(lowerBound, upperBound);
            }
        }
    } else {
        throw new IllegalStateException();
    }
}

From source file:org.robotframework.ide.eclipse.main.plugin.project.library.ArgumentsDescriptor.java

public Range<Integer> getPossibleNumberOfArguments() {
    int min = 0;/*ww w .j a va 2 s .  c o  m*/
    boolean isUnbounded = false;
    for (final Argument argument : arguments) {
        if (argument.isRequired()) {
            min++;
        }
        isUnbounded |= argument.isVarArg() || argument.isKwArg();
    }
    return isUnbounded ? Range.atLeast(min) : Range.closed(min, arguments.size());
}

From source file:org.jpmml.evaluator.DiscretizationUtil.java

static public Range<Double> toRange(Interval interval) {
    Double leftMargin = interval.getLeftMargin();
    Double rightMargin = interval.getRightMargin();

    // "The attributes leftMargin and rightMargin are optional but at least one value must be defined"
    if (leftMargin == null && rightMargin == null) {
        throw new InvalidFeatureException(interval);
    } // End if/*w w  w .  j  av  a 2s. c  o m*/

    if (leftMargin != null && rightMargin != null && (leftMargin).compareTo(rightMargin) > 0) {
        throw new InvalidFeatureException(interval);
    }

    Interval.Closure closure = interval.getClosure();
    switch (closure) {
    case OPEN_OPEN: {
        if (leftMargin == null) {
            return Range.lessThan(rightMargin);
        } else

        if (rightMargin == null) {
            return Range.greaterThan(leftMargin);
        }

        return Range.open(leftMargin, rightMargin);
    }
    case OPEN_CLOSED: {
        if (leftMargin == null) {
            return Range.atMost(rightMargin);
        } else

        if (rightMargin == null) {
            return Range.greaterThan(leftMargin);
        }

        return Range.openClosed(leftMargin, rightMargin);
    }
    case CLOSED_OPEN: {
        if (leftMargin == null) {
            return Range.lessThan(rightMargin);
        } else

        if (rightMargin == null) {
            return Range.atLeast(leftMargin);
        }

        return Range.closedOpen(leftMargin, rightMargin);
    }
    case CLOSED_CLOSED: {
        if (leftMargin == null) {
            return Range.atMost(rightMargin);
        } else

        if (rightMargin == null) {
            return Range.atLeast(leftMargin);
        }

        return Range.closed(leftMargin, rightMargin);
    }
    default:
        throw new UnsupportedFeatureException(interval, closure);
    }
}

From source file:com.wealdtech.jackson.modules.DateTimeRangeDeserializer.java

public static Range<DateTime> deserialize(final String txt) throws IOException {
      final int txtLen = txt.length();

      final int firstDateChar;
      boolean lowerClosed;
      if (txt.charAt(0) == '[') {
          firstDateChar = 1;// ww  w .j  av a  2  s .co m
          lowerClosed = true;
      } else if (txt.charAt(0) == '(') {
          firstDateChar = 1;
          lowerClosed = false;
      } else if (txt.charAt(0) >= '0' && txt.charAt(0) <= '9') {
          // Lazy version
          firstDateChar = 0;
          lowerClosed = true;
      } else {
          throw new DataError.Bad("Unexpected first character in range \"" + txt + "\"");
      }

      boolean upperClosed;
      if (txt.charAt(txtLen - 1) == ']') {
          upperClosed = true;
      } else if (txt.charAt(txtLen - 1) == ')') {
          upperClosed = false;
      } else if (firstDateChar == 0) {
          upperClosed = false;
      } else {
          throw new DataError.Bad("Unexpected last character in range \"" + txt + "\"");
      }

      final Iterator<String> dateTimes;
      if (txt.indexOf(WEALD_SPLITTER_CHAR) != -1) {
          dateTimes = WEALD_SPLITTER.split(txt.substring(firstDateChar, txtLen - firstDateChar)).iterator();
      } else if (txt.indexOf(GUAVA_SPLITTER_CHAR) != -1) {
          dateTimes = GUAVA_SPLITTER.split(txt.substring(firstDateChar, txtLen - firstDateChar)).iterator();
      } else {
          throw new DataError.Bad("Cannot find a range separator in range \"" + txt + "\"");
      }
      String start = dateTimes.next();
      String end = dateTimes.next();

      boolean lowerBound;
      final DateTime lowerPoint;
      if (start.equals(NEGATIVE_INFINITY)) {
          lowerBound = false;
          lowerPoint = null;
      } else {
          lowerBound = true;
          lowerPoint = DateTimeDeserializer.deserialize(start);
      }

      boolean upperBound;
      final DateTime upperPoint;
      if (end.equals(POSITIVE_INFINITY)) {
          upperBound = false;
          upperPoint = null;
      } else {
          upperBound = true;
          upperPoint = DateTimeDeserializer.deserialize(end);
      }

      if (lowerBound == false && upperBound == false) {
          return Range.all();
      } else if (lowerBound == false) {
          // Upper present
          if (upperClosed == true) {
              return Range.lessThan(upperPoint);
          } else {
              return Range.atMost(upperPoint);
          }
      } else if (upperBound == false) {
          // Lower present
          if (lowerClosed == true) {
              return Range.atLeast(lowerPoint);
          } else {
              return Range.greaterThan(lowerPoint);
          }
      } else {
          // Both present
          if (lowerClosed == true) {
              if (upperClosed == true) {
                  return Range.closed(lowerPoint, upperPoint);
              } else {
                  return Range.closedOpen(lowerPoint, upperPoint);
              }
          } else {
              if (upperClosed == true) {
                  return Range.openClosed(lowerPoint, upperPoint);
              } else {
                  return Range.open(lowerPoint, upperPoint);
              }
          }
      }
  }