class PrefixUtils {

  public static SortedSet<IpWildcard> asPositiveIpWildcards(IpSpace ipSpace) {
    // TODO use an IpSpace visitor
    if (ipSpace == null) {
      return null;
    } else if (ipSpace instanceof IpWildcardIpSpace) {
      return ImmutableSortedSet.of(((IpWildcardIpSpace) ipSpace).getIpWildcard());
    } else if (ipSpace instanceof IpWildcardSetIpSpace) {
      return ((IpWildcardSetIpSpace) ipSpace).getWhitelist();
    } else if (ipSpace instanceof UniverseIpSpace) {
      return ImmutableSortedSet.of();
    } else {
      throw new BatfishException(
          String.format("Cannot represent as SortedSet<IpWildcard>: %s", ipSpace));
    }
  }

}