Java Code Examples for com.google.common.collect.ImmutableRangeSet#copyOf()

The following examples show how to use com.google.common.collect.ImmutableRangeSet#copyOf() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: F5BigipConfiguration.java    From batfish with Apache License 2.0 6 votes vote down vote up
private @Nonnull Optional<TransformationStep> computeOutgoingSnatPoolTransformation(
    SnatPool snatPool) {
  RangeSet<Ip> pool =
      ImmutableRangeSet.copyOf(
          snatPool.getMembers().stream()
              .map(_snatTranslations::get)
              .filter(Objects::nonNull)
              .map(SnatTranslation::getAddress)
              .filter(Objects::nonNull)
              .map(Range::singleton)
              .collect(ImmutableList.toImmutableList()));
  return pool.isEmpty()
      ? Optional.empty()
      : Optional.of(
          new ApplyAll(
              ASSIGN_EPHEMERAL_SOURCE_PORT,
              new AssignIpAddressFromPool(TransformationType.SOURCE_NAT, IpField.SOURCE, pool)));
}
 
Example 2
Source File: CrontabEntry.java    From attic-aurora with Apache License 2.0 6 votes vote down vote up
private CrontabEntry(
    RangeSet<Integer> minute,
    RangeSet<Integer> hour,
    RangeSet<Integer> dayOfMonth,
    RangeSet<Integer> month,
    RangeSet<Integer> dayOfWeek) {

  checkEnclosed("minute", MINUTE, minute);
  checkEnclosed("hour", HOUR, hour);
  checkEnclosed("dayOfMonth", DAY_OF_MONTH, dayOfMonth);
  checkEnclosed("month", MONTH, month);
  checkEnclosed("dayOfWeek", DAY_OF_WEEK, dayOfWeek);

  this.minute = ImmutableRangeSet.copyOf(minute);
  this.hour = ImmutableRangeSet.copyOf(hour);
  this.dayOfMonth = ImmutableRangeSet.copyOf(dayOfMonth);
  this.month = ImmutableRangeSet.copyOf(month);
  this.dayOfWeek = ImmutableRangeSet.copyOf(dayOfWeek);

  checkArgument(hasWildcardDayOfMonth() || hasWildcardDayOfWeek(),
      "Specifying both dayOfWeek and dayOfMonth is not supported.");
}
 
Example 3
Source File: AssignIpAddressFromPool.java    From batfish with Apache License 2.0 5 votes vote down vote up
@JsonCreator
private static AssignIpAddressFromPool jsonCreator(
    @JsonProperty(PROP_TRANSFORMATION_TYPE) TransformationType type,
    @JsonProperty(PROP_IP_FIELD) IpField ipField,
    @JsonProperty(PROP_IP_RANGES) RangeSet<Ip> ipRanges) {
  checkNotNull(type, PROP_TRANSFORMATION_TYPE + " cannot be null");
  checkNotNull(ipField, PROP_IP_FIELD + " cannot be null");
  checkNotNull(ipRanges, PROP_IP_RANGES + " cannot be null");
  return new AssignIpAddressFromPool(type, ipField, ImmutableRangeSet.copyOf(ipRanges));
}
 
Example 4
Source File: PaloAltoConfiguration.java    From batfish with Apache License 2.0 5 votes vote down vote up
@Nonnull
private RangeSet<Ip> ipRangeSetFromRuleEndpoints(
    Collection<RuleEndpoint> endpoints, Vsys vsys, Warnings w) {
  RangeSet<Ip> rangeSet = TreeRangeSet.create();
  endpoints.stream()
      .map(endpoint -> ruleEndpointToIpRangeSet(endpoint, vsys, w))
      .forEach(rangeSet::addAll);
  return ImmutableRangeSet.copyOf(rangeSet);
}
 
Example 5
Source File: AddressGroup.java    From batfish with Apache License 2.0 5 votes vote down vote up
/**
 * Returns a {@link com.google.common.collect.RangeSet} containing the union of all addresses
 * owned by members. Returns empty RangeSet if there are no members.
 */
public RangeSet<Ip> getIpRangeSet(
    Map<String, AddressObject> addressObjects, Map<String, AddressGroup> addressGroups) {
  RangeSet<Ip> rangeSet = TreeRangeSet.create();
  getDescendantObjects(addressObjects, addressGroups, new HashSet<>()).stream()
      .map(addrObjName -> addressObjects.get(addrObjName).getAddressAsRangeSet())
      .forEach(rangeSet::addAll);
  return ImmutableRangeSet.copyOf(rangeSet);
}
 
Example 6
Source File: CrontabEntry.java    From attic-aurora with Apache License 2.0 5 votes vote down vote up
private RangeSet<Integer> parseMinute() {
  RangeSet<Integer> minutes = TreeRangeSet.create();
  for (String component : getComponents(rawMinute)) {
    minutes.addAll(parseComponent(MINUTE, component));
  }
  return ImmutableRangeSet.copyOf(minutes);
}
 
Example 7
Source File: CrontabEntry.java    From attic-aurora with Apache License 2.0 5 votes vote down vote up
private RangeSet<Integer> parseHour() {
  RangeSet<Integer> hours = TreeRangeSet.create();
  for (String component : getComponents(rawHour)) {
    hours.addAll(parseComponent(HOUR, component));
  }
  return ImmutableRangeSet.copyOf(hours);
}
 
Example 8
Source File: CrontabEntry.java    From attic-aurora with Apache License 2.0 5 votes vote down vote up
private RangeSet<Integer> parseDayOfWeek() {
  RangeSet<Integer> daysOfWeek = TreeRangeSet.create();
  for (String component : getComponents(rawDayOfWeek)) {
    daysOfWeek.addAll(parseComponent(DAY_OF_WEEK, replaceNameAliases(component, DAY_NAMES)));
  }
  return ImmutableRangeSet.copyOf(daysOfWeek);
}
 
Example 9
Source File: CrontabEntry.java    From attic-aurora with Apache License 2.0 5 votes vote down vote up
private RangeSet<Integer> parseMonth() {
  RangeSet<Integer> months = TreeRangeSet.create();
  for (String component : getComponents(rawMonth)) {
    months.addAll(parseComponent(MONTH, replaceNameAliases(component, MONTH_NAMES)));
  }
  return ImmutableRangeSet.copyOf(months);
}
 
Example 10
Source File: CrontabEntry.java    From attic-aurora with Apache License 2.0 5 votes vote down vote up
private RangeSet<Integer> parseDayOfMonth() {
  RangeSet<Integer> daysOfMonth = TreeRangeSet.create();
  for (String component : getComponents(rawDayOfMonth)) {
    daysOfMonth.addAll(parseComponent(DAY_OF_MONTH, component));
  }
  return ImmutableRangeSet.copyOf(daysOfMonth);
}
 
Example 11
Source File: NumberSpace.java    From batfish with Apache License 2.0 4 votes vote down vote up
protected NumberSpace(RangeSet<T> rangeset) {
  _rangeset = ImmutableRangeSet.copyOf(rangeset);
}
 
Example 12
Source File: AssignIpAddressFromPool.java    From batfish with Apache License 2.0 4 votes vote down vote up
public AssignIpAddressFromPool(TransformationType type, IpField ipField, RangeSet<Ip> ranges) {
  checkArgument(!ranges.isEmpty(), "Pool ranges cannot be empty");
  _type = type;
  _ipField = ipField;
  _ipRanges = ImmutableRangeSet.copyOf(ranges);
}
 
Example 13
Source File: ResolvedRangeConstraint.java    From yangtools with Eclipse Public License 1.0 4 votes vote down vote up
ResolvedRangeConstraint(final ConstraintMetaDefinition meta, final RangeSet<T> ranges) {
    this.meta = requireNonNull(meta);
    this.ranges = ImmutableRangeSet.copyOf(ranges);
}
 
Example 14
Source File: ResolvedLengthConstraint.java    From yangtools with Eclipse Public License 1.0 4 votes vote down vote up
ResolvedLengthConstraint(final ConstraintMetaDefinition meta, final RangeSet<Integer> ranges) {
    this.meta = requireNonNull(meta);
    this.ranges = ImmutableRangeSet.copyOf(ranges);
}
 
Example 15
Source File: FieldUtil.java    From jpmml-evaluator with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public RangeSet<Double> load(Field<?> field){
	return ImmutableRangeSet.<Double>copyOf(parseValidRanges((Field & HasContinuousDomain)field));
}