List of usage examples for com.google.common.collect DiscreteDomain integers
public static DiscreteDomain<Integer> integers()
From source file:org.nickelproject.util.sources.Sequences.java
public static Source<Integer> integer(final int min, final int max) { return Sources.from(ContiguousSet.create(Range.closedOpen(min, max), DiscreteDomain.integers())); }
From source file:sf.net.experimaestro.utils.RangeUtils.java
/** * Transforms a range into an array of {@linkplain Integer} *//*from w w w . j a v a2s . co m*/ public static Integer[] toIntegerArray(Range<Integer> closed) { ContiguousSet<Integer> integers = ContiguousSet.create(closed, DiscreteDomain.integers()); return integers.toArray(new Integer[integers.size()]); }
From source file:org.onlab.util.ClosedOpenRange.java
/** * Creates a range from a Guava's range. * * @param range Guava's range/*from w w w . j av a 2 s . c o m*/ * @return this range */ public static ClosedOpenRange of(Range<Integer> range) { return new ClosedOpenRange(range.canonical(DiscreteDomain.integers()).lowerEndpoint(), range.canonical(DiscreteDomain.integers()).upperEndpoint()); }
From source file:com.stackframe.base.Numbers.java
private static Set<Number> positiveIntegers() { // Consider adding BigInteger and other subclasses of Number that are integers. Set<? extends Number> longKeys = ContiguousSet.create(Range.greaterThan(0L), DiscreteDomain.longs()); Set<? extends Number> intKeys = ContiguousSet.create(Range.greaterThan(0), DiscreteDomain.integers()); return Sets.union(longKeys, intKeys); }
From source file:org.onosproject.store.resource.impl.EncodedDiscreteResources.java
static EncodedDiscreteResources of(Set<DiscreteResource> resources, DiscreteResourceCodec codec) { RangeSet<Integer> rangeSet = TreeRangeSet.create(); resources.stream().map(x -> x.valueAs(Object.class)).flatMap(Tools::stream).map(x -> codec.encode(x)) .map(Range::singleton).map(x -> x.canonical(DiscreteDomain.integers())).forEach(rangeSet::add); return new EncodedDiscreteResources(rangeSet, codec); }
From source file:org.apache.aurora.scheduler.cron.quartz.Quartz.java
/** * Convert an Aurora CrontabEntry to a Quartz CronExpression. */// ww w . ja v a 2s .co m static CronExpression cronExpression(CrontabEntry entry, TimeZone timeZone) { String dayOfMonth; if (entry.hasWildcardDayOfMonth()) { dayOfMonth = "?"; // special quartz token meaning "don't care" } else { dayOfMonth = entry.getDayOfMonthAsString(); } String dayOfWeek; if (entry.hasWildcardDayOfWeek() && !entry.hasWildcardDayOfMonth()) { dayOfWeek = "?"; } else { List<Integer> daysOfWeek = Lists.newArrayList(); for (Range<Integer> range : entry.getDayOfWeek().asRanges()) { for (int i : ContiguousSet.create(range, DiscreteDomain.integers())) { daysOfWeek.add(i + 1); // Quartz has an off-by-one with what the "standard" defines. } } dayOfWeek = Joiner.on(",").join(daysOfWeek); } String rawCronExpresion = String.join(" ", "0", entry.getMinuteAsString(), entry.getHourAsString(), dayOfMonth, entry.getMonthAsString(), dayOfWeek); CronExpression cronExpression; try { cronExpression = new CronExpression(rawCronExpresion); } catch (ParseException e) { throw new RuntimeException(e); } cronExpression.setTimeZone(timeZone); return cronExpression; }
From source file:org.sonar.java.filters.AnyRuleIssueFilter.java
private static Set<Integer> filteredLines(Tree tree) { SyntaxToken firstSyntaxToken = tree.firstToken(); SyntaxToken lastSyntaxToken = tree.lastToken(); if (firstSyntaxToken != null && lastSyntaxToken != null) { return ContiguousSet.create(Range.closed(firstSyntaxToken.line(), lastSyntaxToken.line()), DiscreteDomain.integers()); }//from www .j a v a2 s . c o m return new HashSet<>(); }
From source file:com.google.googlejavaformat.java.SnippetFormatter.java
private static Range<Integer> offsetRange(Range<Integer> range, int offset) { range = range.canonical(DiscreteDomain.integers()); return Range.closedOpen(range.lowerEndpoint() + offset, range.upperEndpoint() + offset); }
From source file:com.comphenix.protocol.compat.guava.Guava17.java
@Override public Set<Integer> toSet(Range<Integer> range) { return ContiguousSet.create(range, DiscreteDomain.integers()); }
From source file:org.apache.aurora.scheduler.configuration.SanitizedConfiguration.java
/** * Constructs a SanitizedConfiguration object and populates the set of instance IDs for * the provided {@link org.apache.aurora.scheduler.storage.entities.ITaskConfig}. * * @param sanitized A sanitized configuration. *//* w w w . j a va 2 s . c o m*/ @VisibleForTesting public SanitizedConfiguration(IJobConfiguration sanitized) { this.sanitized = sanitized; this.instanceIds = ContiguousSet.create(Range.closedOpen(0, sanitized.getInstanceCount()), DiscreteDomain.integers()); }