package org.batfish.referencelibrary;

import static com.google.common.base.MoreObjects.firstNonNull;
import static com.google.common.base.Preconditions.checkArgument;

import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.SortedSet;
import java.util.TreeSet;
import javax.annotation.Nonnull;
import org.batfish.datamodel.IpWildcard;

public class AddressGroup implements Comparable<AddressGroup> {

  private static final String PROP_ADDRESSES = "addresses";
  private static final String PROP_NAME = "name";

  @Nonnull private SortedSet<String> _addresses;
  @Nonnull private String _name;

  public AddressGroup(
      @JsonProperty(PROP_ADDRESSES) SortedSet<String> addresses,
      @JsonProperty(PROP_NAME) String name) {
    checkArgument(name != null, "Address group name cannot not be null");
    ReferenceLibrary.checkValidName(name, "address group");

    _name = name;
    _addresses = firstNonNull(addresses, new TreeSet<String>());

    // check if all the input address strings can be mapped to an IpSpace
    _addresses.stream().map(s -> new IpWildcard(s).toIpSpace());
  }

  @Override
  public int compareTo(AddressGroup o) {
    return _name.compareTo(o._name);
  }

  @JsonProperty(PROP_ADDRESSES)
  public SortedSet<String> getAddresses() {
    return _addresses;
  }

  @JsonProperty(PROP_NAME)
  public String getName() {
    return _name;
  }
}

@@ -299,24 +299,58 @@
 on.Nonnull;%0A
+import javax.annotation.Nullable;%0A
 import org.b
@@ -663,24 +663,34 @@
 roup(%0A      
+@Nullable 
 @JsonPropert
@@ -742,16 +742,26 @@
 ,%0A      
+@Nullable 
 @JsonPro
@@ -998,22 +998,16 @@
 TreeSet%3C
-String
 %3E());%0A%0A 
@@ -1073,21 +1073,24 @@
 to an Ip
-Space
+WildCard
 %0A    _ad
@@ -1101,55 +1101,31 @@
 ses.
-stream().map(s -%3E new IpWildcard(s).toIpSpace()
+forEach(IpWildcard::new
 );%0A 
@@ -1255,16 +1255,27 @@
 RESSES)%0A
+  @Nonnull%0A
   public
@@ -1365,16 +1365,27 @@
 P_NAME)%0A
+  @Nonnull%0A
   public

swap to forEach to fix build, and assorted minor cleanups