Java Code Examples for com.google.common.collect.Range#hasLowerBound()

The following examples show how to use com.google.common.collect.Range#hasLowerBound() . 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: XICManualPickerDialog.java    From mzmine3 with GNU General Public License v2.0 6 votes vote down vote up
private boolean checkRtComponentValue() {
  Range<Double> value = rtRangeComp.getValue();
  if (value == null) {
    return false;
  }
  if (!value.hasLowerBound() || !value.hasUpperBound())
    return false;

  if (value != null) {
    if (value.lowerEndpoint() > value.upperEndpoint()) {
      return false;
    }
    if (value.lowerEndpoint() >= value.upperEndpoint()) {
      return false;
    }
  }
  return true;
}
 
Example 2
Source File: PostgreSQLGuavaRangeType.java    From hibernate-types with Apache License 2.0 6 votes vote down vote up
private static String determineRangeType(Range<?> range) {
    Object anyEndpoint = range.hasLowerBound() ? range.lowerEndpoint() :
                         range.hasUpperBound() ? range.upperEndpoint() : null;

    if (anyEndpoint == null) {
        throw new IllegalArgumentException("The range " + range + " doesn't have any upper or lower bound!");
    }

    Class<?> clazz = anyEndpoint.getClass();

    if (clazz.equals(Integer.class)) {
        return "int4range";
    } else if (clazz.equals(Long.class)) {
        return "int8range";
    } else if (clazz.equals(BigDecimal.class)) {
        return "numrange";
    }

    throw new IllegalStateException("The class [" + clazz.getName() + "] is not supported!");
}
 
Example 3
Source File: PostgreSQLGuavaRangeType.java    From hibernate-types with Apache License 2.0 6 votes vote down vote up
private static String determineRangeType(Range<?> range) {
    Object anyEndpoint = range.hasLowerBound() ? range.lowerEndpoint() :
                         range.hasUpperBound() ? range.upperEndpoint() : null;

    if (anyEndpoint == null) {
        throw new IllegalArgumentException("The range " + range + " doesn't have any upper or lower bound!");
    }

    Class<?> clazz = anyEndpoint.getClass();

    if (clazz.equals(Integer.class)) {
        return "int4range";
    } else if (clazz.equals(Long.class)) {
        return "int8range";
    } else if (clazz.equals(BigDecimal.class)) {
        return "numrange";
    }

    throw new IllegalStateException("The class [" + clazz.getName() + "] is not supported!");
}
 
Example 4
Source File: DateRangeRules.java    From calcite with Apache License 2.0 6 votes vote down vote up
private boolean canRewriteExtract(RexNode operand) {
  // We rely on timeUnits being sorted (so YEAR comes before MONTH
  // before HOUR) and unique. If we have seen a predicate on YEAR,
  // operandRanges will not be empty. This checks whether we can rewrite
  // the "extract" condition. For example, in the condition
  //
  //   extract(MONTH from time) = someValue
  //   OR extract(YEAR from time) = someValue
  //
  // we cannot rewrite extract on MONTH.
  if (timeUnit == TimeUnitRange.YEAR) {
    return true;
  }
  final RangeSet<Calendar> calendarRangeSet = operandRanges.get(operand);
  if (calendarRangeSet == null || calendarRangeSet.isEmpty()) {
    return false;
  }
  for (Range<Calendar> range : calendarRangeSet.asRanges()) {
    // Cannot reWrite if range does not have an upper or lower bound
    if (!range.hasUpperBound() || !range.hasLowerBound()) {
      return false;
    }
  }
  return true;
}
 
Example 5
Source File: ConcurrentOpenLongPairRangeSet.java    From pulsar with Apache License 2.0 6 votes vote down vote up
/**
 * Adds the specified range to this {@code RangeSet} (optional operation). That is, for equal range sets a and b,
 * the result of {@code a.add(range)} is that {@code a} will be the minimal range set for which both
 * {@code a.enclosesAll(b)} and {@code a.encloses(range)}.
 *
 * <p>Note that {@code range} will merge given {@code range} with any ranges in the range set that are
 * {@linkplain Range#isConnected(Range) connected} with it. Moreover, if {@code range} is empty/invalid, this is a
 * no-op.
 */
public void add(Range<LongPair> range) {
    LongPair lowerEndpoint = range.hasLowerBound() ? range.lowerEndpoint() : LongPair.earliest;
    LongPair upperEndpoint = range.hasUpperBound() ? range.upperEndpoint() : LongPair.latest;

    long lowerValueOpen = (range.hasLowerBound() && range.lowerBoundType().equals(BoundType.CLOSED))
            ? getSafeEntry(lowerEndpoint) - 1
            : getSafeEntry(lowerEndpoint);
    long upperValueClosed = (range.hasUpperBound() && range.upperBoundType().equals(BoundType.CLOSED))
            ? getSafeEntry(upperEndpoint)
            : getSafeEntry(upperEndpoint) + 1;

    // #addOpenClosed doesn't create bitSet for lower-key because it avoids setting up values for non-exist items
    // into the key-ledger. so, create bitSet and initialize so, it can't be ignored at #addOpenClosed
    rangeBitSetMap.computeIfAbsent(lowerEndpoint.getKey(), (key) -> createNewBitSet())
            .set((int) lowerValueOpen + 1);
    this.addOpenClosed(lowerEndpoint.getKey(), lowerValueOpen, upperEndpoint.getKey(), upperValueClosed);
}
 
Example 6
Source File: FilterParser.java    From PGM with GNU Affero General Public License v3.0 6 votes vote down vote up
@MethodParser("random")
public RandomFilter parseRandom(Element el) throws InvalidXMLException {
  Node node = new Node(el);
  Range<Double> chance;
  try {
    chance = Range.closedOpen(0d, XMLUtils.parseNumber(node, Double.class));
  } catch (InvalidXMLException e) {
    chance = XMLUtils.parseNumericRange(node, Double.class);
  }

  Range<Double> valid = Range.closed(0d, 1d);
  if (valid.encloses(chance)) {
    return new RandomFilter(chance);
  } else {
    double lower = chance.hasLowerBound() ? chance.lowerEndpoint() : Double.NEGATIVE_INFINITY;
    double upper = chance.hasUpperBound() ? chance.upperEndpoint() : Double.POSITIVE_INFINITY;
    double invalid;
    if (!valid.contains(lower)) {
      invalid = lower;
    } else {
      invalid = upper;
    }

    throw new InvalidXMLException("chance value (" + invalid + ") is not between 0 and 1", el);
  }
}
 
Example 7
Source File: DateRangeRules.java    From Quicksql with MIT License 6 votes vote down vote up
private boolean canRewriteExtract(RexNode operand) {
  // We rely on timeUnits being sorted (so YEAR comes before MONTH
  // before HOUR) and unique. If we have seen a predicate on YEAR,
  // operandRanges will not be empty. This checks whether we can rewrite
  // the "extract" condition. For example, in the condition
  //
  //   extract(MONTH from time) = someValue
  //   OR extract(YEAR from time) = someValue
  //
  // we cannot rewrite extract on MONTH.
  if (timeUnit == TimeUnitRange.YEAR) {
    return true;
  }
  final RangeSet<Calendar> calendarRangeSet = operandRanges.get(operand);
  if (calendarRangeSet == null || calendarRangeSet.isEmpty()) {
    return false;
  }
  for (Range<Calendar> range : calendarRangeSet.asRanges()) {
    // Cannot reWrite if range does not have an upper or lower bound
    if (!range.hasUpperBound() || !range.hasLowerBound()) {
      return false;
    }
  }
  return true;
}
 
Example 8
Source File: DateRangeRules.java    From Bats with Apache License 2.0 6 votes vote down vote up
private boolean canRewriteExtract(RexNode operand) {
    // We rely on timeUnits being sorted (so YEAR comes before MONTH
    // before HOUR) and unique. If we have seen a predicate on YEAR,
    // operandRanges will not be empty. This checks whether we can rewrite
    // the "extract" condition. For example, in the condition
    //
    // extract(MONTH from time) = someValue
    // OR extract(YEAR from time) = someValue
    //
    // we cannot rewrite extract on MONTH.
    if (timeUnit == TimeUnitRange.YEAR) {
        return true;
    }
    final RangeSet<Calendar> calendarRangeSet = operandRanges.get(operand);
    if (calendarRangeSet == null || calendarRangeSet.isEmpty()) {
        return false;
    }
    for (Range<Calendar> range : calendarRangeSet.asRanges()) {
        // Cannot reWrite if range does not have an upper or lower bound
        if (!range.hasUpperBound() || !range.hasLowerBound()) {
            return false;
        }
    }
    return true;
}
 
Example 9
Source File: Parameter.java    From activitystreams with Apache License 2.0 5 votes vote down vote up
public Builder bound(Range<?> range) {
  if (range != null) {
    if (range.hasLowerBound()) {
      switch(range.lowerBoundType()) {
      case CLOSED:
        minInclusive(range.lowerEndpoint());
        break;
      case OPEN:
        minExclusive(range.lowerEndpoint());
        break;
      default:
        break;
      }
    } else {
      minInclusive(null);
      minExclusive(null);
    }
    if (range.hasUpperBound()) {
      switch(range.upperBoundType()) {
      case CLOSED:
        maxInclusive(range.upperEndpoint());
        break;
      case OPEN:
        maxExclusive(range.upperEndpoint());
        break;
      default:
        break;
      }
    } else {
      maxInclusive(null);
      maxExclusive(null);
    }
  }
  return this;
}
 
Example 10
Source File: RestartingS3InputStream.java    From emodb with Apache License 2.0 5 votes vote down vote up
public RestartingS3InputStream(AmazonS3 s3, String bucket, String key, @Nullable Range<Long> range) {
    _s3 = s3;
    _bucket = bucket;
    _key = key;

    S3Object s3Object;

    // Get the object synchronously so any immediate S3 errors, such as file not found, are thrown inline.
    if (range == null) {
        s3Object = _s3.getObject(new GetObjectRequest(_bucket, _key));
        _pos = 0;
        _length = s3Object.getObjectMetadata().getContentLength();
    } else {
        long start, end;

        if (range.hasLowerBound()) {
            start = range.lowerEndpoint() + (range.lowerBoundType() == BoundType.CLOSED ? 0 : 1);
        } else {
            start = 0;
        }

        if (range.hasUpperBound()) {
            end = range.upperEndpoint() - (range.upperBoundType() == BoundType.CLOSED ? 0 : 1);
        } else {
            end = Long.MAX_VALUE;
        }

        s3Object = _s3.getObject(new GetObjectRequest(_bucket, _key).withRange(start, end));

        _pos = start;
        // The S3 metadata's content length is the length of the data actually being returned by S3.
        // Since we effectively skipped the first "start" bytes we need to add them back to the total length
        // of data being read to make future calculations using _pos and _length consistent.
        _length = start + s3Object.getObjectMetadata().getContentLength();
    }

    _in = s3Object.getObjectContent();
}
 
Example 11
Source File: FilterDefinitionParser.java    From ProjectAres with GNU Affero General Public License v3.0 5 votes vote down vote up
@MethodParser("random")
public Filter parseRandom(Element el) throws InvalidXMLException {
    Node node = new Node(el);
    Range<Double> chance;
    try {
        chance = Range.closedOpen(0d, XMLUtils.parseNumber(node, Double.class));
    } catch(InvalidXMLException e) {
        chance = XMLUtils.parseNumericRange(node, Double.class);
    }

    Range<Double> valid = Range.closed(0d, 1d);
    if (valid.encloses(chance)) {
        return proto.isNoOlderThan(ProtoVersions.EVENT_QUERIES) ? new RandomFilter(chance)
                                                                : new LegacyRandomFilter(chance);
    } else {
        double lower = chance.hasLowerBound() ? chance.lowerEndpoint() : Double.NEGATIVE_INFINITY;
        double upper = chance.hasUpperBound() ? chance.upperEndpoint() : Double.POSITIVE_INFINITY;
        double invalid;
        if(!valid.contains(lower)) {
            invalid = lower;
        } else {
            invalid = upper;
        }

        throw new InvalidXMLException("chance value (" + invalid + ") is not between 0 and 1", el);
    }
}
 
Example 12
Source File: Ranges.java    From ProjectAres with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Return an english phrase describing the given {@link Range} e.g.
 *
 *     Range.all()                      -> "unbounded"
 *     Range.singleton(3)               -> "3"
 *     Range.atLeast(3)                 -> "at least 3"
 *     Range.closedOpen(3, 7)           -> "at least 3 and less than 7"
 *     Range.closed(3, 7)               -> "between 3 and 7"
 */
public static String describe(Range<?> range) {
    if(range.hasLowerBound() && range.hasUpperBound() && range.lowerBoundType() == BoundType.CLOSED && range.upperBoundType() == BoundType.CLOSED) {
        if(range.lowerEndpoint().equals(range.upperEndpoint())) {
            // singleton
            return range.lowerEndpoint().toString();
        } else {
            // closed-closed
            return "between " + range.lowerEndpoint() + " and " + range.upperEndpoint();
        }
    }

    final List<String> parts = new ArrayList<>(2);

    if(range.hasLowerBound()) {
        parts.add((range.lowerBoundType() == BoundType.CLOSED ? "at least " : "more than ") + range.lowerEndpoint());
    }

    if(range.hasUpperBound()) {
        parts.add((range.upperBoundType() == BoundType.CLOSED ? "at most " : "less than ") + range.upperEndpoint());
    }

    switch(parts.size()) {
        case 0: return "unbounded";
        case 1: return parts.get(0);
        default: return parts.get(0) + " and " + parts.get(1);
    }
}
 
Example 13
Source File: InternalSubCreator.java    From SubServers-2 with Apache License 2.0 5 votes vote down vote up
/**
 * Creates an Internal SubCreator
 *
 * @param host Host
 * @param ports The range of ports to auto-select from
 * @param log Whether SubCreator should log to console
 * @param gitBash The Git Bash directory
 */
public InternalSubCreator(InternalHost host, Range<Integer> ports, boolean log, String gitBash) {
    if (!ports.hasLowerBound() || !ports.hasUpperBound()) throw new IllegalArgumentException("Port range is not bound");
    if (Util.isNull(host, ports, log, gitBash)) throw new NullPointerException();
    this.host = host;
    this.ports = ports;
    this.log = new Container<Boolean>(log);
    this.gitBash = (System.getenv("ProgramFiles(x86)") == null)?Pattern.compile("%(ProgramFiles)\\(x86\\)%", Pattern.CASE_INSENSITIVE).matcher(gitBash).replaceAll("%$1%"):gitBash;
    if (this.gitBash.endsWith(File.pathSeparator)) this.gitBash = this.gitBash.substring(0, this.gitBash.length() - 1);
    this.thread = new TreeMap<String, CreatorTask>();
    reload();
}
 
Example 14
Source File: RangeUtil.java    From kylin-on-parquet-v2 with Apache License 2.0 4 votes vote down vote up
/**
 * remove from self the elements that exist in other
 * @return
 */
public static <C extends Comparable<?>> List<Range<C>> remove(Range<C> self, Range<C> other) {

    // mimic the following logic in guava 18:
    //        RangeSet<C> rangeSet = TreeRangeSet.create();
    //        rangeSet.add(self);
    //        rangeSet.remove(other);
    //        return Lists.newArrayList(rangeSet.asRanges());

    if (other == null || !self.isConnected(other)) {
        return Collections.singletonList(self);
    }

    Range<C> share = self.intersection(other);
    if (share.isEmpty()) {
        return Collections.singletonList(self);
    }

    List<Range<C>> ret = Lists.newArrayList();

    //see left part
    if (!self.hasLowerBound()) {
        if (share.hasLowerBound()) {
            if (share.lowerBoundType() == BoundType.CLOSED) {
                ret.add(Range.lessThan(share.lowerEndpoint()));
            } else {
                ret.add(Range.atMost(share.lowerEndpoint()));
            }
        }
    } else {
        if (self.lowerEndpoint() != share.lowerEndpoint()) {
            if (self.lowerBoundType() == BoundType.CLOSED) {
                if (share.lowerBoundType() == BoundType.CLOSED) {
                    ret.add(Range.closedOpen(self.lowerEndpoint(), share.lowerEndpoint()));
                } else {
                    ret.add(Range.closed(self.lowerEndpoint(), share.lowerEndpoint()));
                }
            } else {
                if (share.lowerBoundType() == BoundType.CLOSED) {
                    ret.add(Range.open(self.lowerEndpoint(), share.lowerEndpoint()));
                } else {
                    ret.add(Range.openClosed(self.lowerEndpoint(), share.lowerEndpoint()));
                }
            }
        } else {
            if (self.lowerBoundType() == BoundType.CLOSED && share.lowerBoundType() == BoundType.OPEN) {
                ret.add(Range.closed(self.lowerEndpoint(), share.lowerEndpoint()));
            }
        }
    }

    //see right part 
    if (!self.hasUpperBound()) {
        if (share.hasUpperBound()) {
            if (share.upperBoundType() == BoundType.CLOSED) {
                ret.add(Range.greaterThan(share.upperEndpoint()));
            } else {
                ret.add(Range.atLeast(share.upperEndpoint()));
            }
        }
    } else {
        if (self.upperEndpoint() != share.upperEndpoint()) {
            if (self.upperBoundType() == BoundType.CLOSED) {
                if (share.upperBoundType() == BoundType.CLOSED) {
                    ret.add(Range.openClosed(share.upperEndpoint(), self.upperEndpoint()));
                } else {
                    ret.add(Range.closed(share.upperEndpoint(), self.upperEndpoint()));
                }
            } else {
                if (share.upperBoundType() == BoundType.CLOSED) {
                    ret.add(Range.open(share.upperEndpoint(), self.upperEndpoint()));
                } else {
                    ret.add(Range.closedOpen(share.upperEndpoint(), self.upperEndpoint()));
                }
            }
        } else {
            if (self.upperBoundType() == BoundType.CLOSED && share.upperBoundType() == BoundType.OPEN) {
                ret.add(Range.closed(self.upperEndpoint(), share.upperEndpoint()));
            }
        }
    }

    return ret;

}
 
Example 15
Source File: ScreenDensitySelector.java    From bundletool with Apache License 2.0 4 votes vote down vote up
/**
 * For a given range of devices dpi served by a split, returns the range of resources that are
 * reachable from this split.
 *
 * <p>The reachable resources can cover a be different dpi range than that of the devices since a
 * resource with dpi smaller than the lowest dpi device can be still preferred by that device.
 *
 * @param deviceDpiRange range of device dpis to serve by a given split
 * @param values {@link ConfigValue} objects of a resource under consideration
 * @return range of resource config values that can be matched by any device served by the split
 */
@CheckReturnValue
private ImmutableList<ConfigValue> getReachableConfigValues(
    Range<Integer> deviceDpiRange, ImmutableList<ConfigValue> values, Version bundleVersion) {
  // We are calculating the lowest and highest dpi of the resource that could be matched by the
  // devices from the given deviceDpiRange.
  // We take the lowest eligible dpi device and find the best matching resource for it, similarly
  // at the other end of the servedDpiRange. Because the best matching is monotonic, all resource
  // configs between those extremes and no others could be matched by any device that falls into
  // that dpi range.

  Optional<Integer> lowestResourceDpi = Optional.empty();
  Optional<Integer> highestResourceDpi = Optional.empty();
  if (deviceDpiRange.hasLowerBound()) {
    lowestResourceDpi =
        Optional.of(
            selectBestConfigValue(values, deviceDpiRange.lowerEndpoint(), bundleVersion)
                .getConfig()
                .getDensity());
  }
  if (deviceDpiRange.hasUpperBound()) {
    highestResourceDpi =
        Optional.of(
            selectBestConfigValue(values, deviceDpiRange.upperEndpoint(), bundleVersion)
                .getConfig()
                .getDensity());
  }

  Range<Integer> effectiveDpiRange;

  if (deviceDpiRange.equals(Range.all())) {
    effectiveDpiRange = Range.all();
  } else if (!lowestResourceDpi.isPresent()) {
    effectiveDpiRange = Range.atMost(highestResourceDpi.get());
  } else if (!highestResourceDpi.isPresent()) {
    effectiveDpiRange = Range.atLeast(lowestResourceDpi.get());
  } else {
    effectiveDpiRange = Range.closed(lowestResourceDpi.get(), highestResourceDpi.get());
  }

  return values.stream()
      .filter(configValue -> effectiveDpiRange.contains(configValue.getConfig().getDensity()))
      .collect(toImmutableList());
}
 
Example 16
Source File: InternalSubCreator.java    From SubServers-2 with Apache License 2.0 4 votes vote down vote up
@Override
public void setPortRange(Range<Integer> value) {
    if (!value.hasLowerBound() || !value.hasUpperBound()) throw new IllegalArgumentException("Port range is not bound");
    ports = value;
}
 
Example 17
Source File: Ranges.java    From ProjectAres with GNU Affero General Public License v3.0 4 votes vote down vote up
public static void assertUpperBound(Range<?> range) {
    if(!range.hasLowerBound()) {
        throw new IllegalArgumentException("Range has no upper bound");
    }
}
 
Example 18
Source File: Ranges.java    From ProjectAres with GNU Affero General Public License v3.0 4 votes vote down vote up
public static Optional<Integer> minimum(Range<Integer> range) {
    return range.hasLowerBound() ? Optional.of(range.lowerBoundType() == BoundType.CLOSED ? range.lowerEndpoint()
                                                                                          : Integer.valueOf(range.lowerEndpoint() + 1))
                                 : Optional.empty();
}
 
Example 19
Source File: ConcurrentOpenLongPairRangeSet.java    From pulsar with Apache License 2.0 4 votes vote down vote up
public void remove(Range<LongPair> range) {
    LongPair lowerEndpoint = range.hasLowerBound() ? range.lowerEndpoint() : LongPair.earliest;
    LongPair upperEndpoint = range.hasUpperBound() ? range.upperEndpoint() : LongPair.latest;

    long lower = (range.hasLowerBound() && range.lowerBoundType().equals(BoundType.CLOSED))
            ? getSafeEntry(lowerEndpoint)
            : getSafeEntry(lowerEndpoint) + 1;
    long upper = (range.hasUpperBound() && range.upperBoundType().equals(BoundType.CLOSED))
            ? getSafeEntry(upperEndpoint)
            : getSafeEntry(upperEndpoint) - 1;

    // if lower-bound is not set then remove all the keys less than given upper-bound range
    if (lowerEndpoint.equals(LongPair.earliest)) {
        // remove all keys with
        rangeBitSetMap.forEach((key, set) -> {
            if (key < upperEndpoint.getKey()) {
                rangeBitSetMap.remove(key);
            }
        });
    }

    // if upper-bound is not set then remove all the keys greater than given lower-bound range
    if (upperEndpoint.equals(LongPair.latest)) {
        // remove all keys with
        rangeBitSetMap.forEach((key, set) -> {
            if (key > lowerEndpoint.getKey()) {
                rangeBitSetMap.remove(key);
            }
        });
    }

    // remove all the keys between two endpoint keys
    rangeBitSetMap.forEach((key, set) -> {
        if (lowerEndpoint.getKey() == upperEndpoint.getKey()) {
            set.clear((int) lower, (int) upper + 1);
        } else {
            // eg: remove-range: [(3,5) - (5,5)] -> Delete all items from 3,6->3,N,4.*,5,0->5,5
            if (key == lowerEndpoint.getKey()) {
                // remove all entries from given position to last position
                set.clear((int) lower, set.previousSetBit(set.size()));
            } else if (key == upperEndpoint.getKey()) {
                // remove all entries from 0 to given position
                set.clear(0, (int) upper + 1);
            } else if (key > lowerEndpoint.getKey() && key < upperEndpoint.getKey()) {
                rangeBitSetMap.remove(key);
            }
        }
        // remove bit-set if set is empty
        if (set.isEmpty()) {
            rangeBitSetMap.remove(key);
        }
    });

    updatedAfterCachedForSize = true;
    updatedAfterCachedForToString = true;
}
 
Example 20
Source File: Host.java    From SubServers-2 with Apache License 2.0 3 votes vote down vote up
/**
 * This constructor is required to launch your host from the drivers list. Do not add or remove any arguments.
 *
 * @param plugin SubServers Internals
 * @param name The Name of your Host
 * @param ports The range of ports to auto-select from
 * @param log Whether apps like SubCreator should log to console (does not apply to servers)
 * @param enabled If your host is Enabled
 * @param address The address of your Host
 * @param directory The runtime directory of your Host
 * @param gitBash The Git Bash directory
 */
@SuppressWarnings("deprecation")
public Host(SubProxy plugin, String name, boolean enabled, Range<Integer> ports, boolean log, InetAddress address, String directory, String gitBash) {
    if (name.contains(" ")) throw new InvalidHostException("Host names cannot have spaces: " + name);
    if (!ports.hasLowerBound() || !ports.hasUpperBound()) throw new InvalidHostException("Port range is not bound");
    if (Util.isNull(plugin, name, enabled, ports, log, address, directory, gitBash)) throw new NullPointerException();
    signature = plugin.api.signAnonymousObject();
    SubAPI.getInstance().getInternals().subprotocol.whitelist(address.getHostAddress());
}