@Test public void testGetAddressesRecursive() { ReferenceBook book = ReferenceBook.builder("book") .setAddressGroups( ImmutableList.of( new AddressGroup( "a", ImmutableSortedSet.of("1.1.1.1"), ImmutableSortedSet.of("b", "c")), new AddressGroup("b", ImmutableSortedSet.of("2.2.2.2"), null), new AddressGroup("c", null, null))) .build(); assertThat( book.getAddressesRecursive("a"), equalTo(ImmutableSet.of(IpWildcard.parse("1.1.1.1"), IpWildcard.parse("2.2.2.2")))); }
public Set<IpWildcard> getAddressesRecursive(String addressGroupName) { Set<String> allGroupNames = new HashSet<>(); addGroupAndDescendantNames(addressGroupName, allGroupNames); return allGroupNames.stream() .flatMap(groupName -> getAddressGroup(groupName).get().getAddresses().stream()) .map(IpWildcard::parse) .collect(ImmutableSet.toImmutableSet()); }
ReferenceBook implements Comparable<ReferenceBook>, Serializable { public Set<IpWildcard> getAddressesRecursive(String addressGroupName) { Set<String> allGroupNames = new HashSet<>(); addGroupAndDescendantNames(addressGroupName, allGroupNames); return allGroupNames.stream() .flatMap(groupName -> getAddressGroup(groupName).get().getAddresses().stream()) .map(IpWildcard::parse) .collect(ImmutableSet.toImmutableSet()); } }
ReferenceBook implements Comparable<ReferenceBook>, Serializable { public Set<IpWildcard> getAddressesRecursive(String addressGroupName) { Set<String> allGroupNames = new HashSet<>(); addGroupAndDescendantNames(addressGroupName, allGroupNames); return allGroupNames.stream() .flatMap(groupName -> getAddressGroup(groupName).get().getAddresses().stream()) .map(IpWildcard::parse) .collect(ImmutableSet.toImmutableSet()); } private  ReferenceBook(
      String name,
      List<AddressGroup> addressGroups,
      List<FilterGroup> filterGroups,
      List<InterfaceGroup> interfaceGroups,
      List<ServiceEndpoint> serviceEndpoints,
      List<ServiceObjectGroup> serviceObjectGroups,
      List<ServiceObject> serviceObjects); }
ReferenceBook implements Comparable<ReferenceBook>, Serializable { public Set<IpWildcard> getAddressesRecursive(String addressGroupName) { Set<String> allGroupNames = new HashSet<>(); addGroupAndDescendantNames(addressGroupName, allGroupNames); return allGroupNames.stream() .flatMap(groupName -> getAddressGroup(groupName).get().getAddresses().stream()) .map(IpWildcard::parse) .collect(ImmutableSet.toImmutableSet()); } private  ReferenceBook(
      String name,
      List<AddressGroup> addressGroups,
      List<FilterGroup> filterGroups,
      List<InterfaceGroup> interfaceGroups,
      List<ServiceEndpoint> serviceEndpoints,
      List<ServiceObjectGroup> serviceObjectGroups,
      List<ServiceObject> serviceObjects); static Builder builder(String name); @Override int compareTo(ReferenceBook o); @Override boolean equals(Object o); Optional<AddressGroup> getAddressGroup(String groupName); @Nonnull @JsonProperty(PROP_ADDRESS_GROUPS) SortedSet<AddressGroup> getAddressGroups(); Optional<FilterGroup> getFilterGroup(String groupName); @Nonnull @JsonProperty(PROP_FILTER_GROUPS) SortedSet<FilterGroup> getFilterGroups(); Optional<InterfaceGroup> getInterfaceGroup(String groupName); @Nonnull @JsonProperty(PROP_INTERFACE_GROUPS) SortedSet<InterfaceGroup> getInterfaceGroups(); @Nonnull @JsonProperty(PROP_NAME) String getName(); @Nonnull @JsonProperty(PROP_SERVICE_ENDPOINTS) SortedSet<ServiceEndpoint> getServiceEndpoints(); @Nonnull @JsonProperty(PROP_SERVICE_OBJECT_GROUPS) SortedSet<ServiceObjectGroup> getServiceObjectGroups(); @Nonnull @JsonProperty(PROP_SERVICE_OBJECTS) SortedSet<ServiceObject> getServiceObjects(); @Override int hashCode(); Set<IpWildcard> getAddressesRecursive(String addressGroupName); }
ReferenceBook implements Comparable<ReferenceBook>, Serializable { public Set<IpWildcard> getAddressesRecursive(String addressGroupName) { Set<String> allGroupNames = new HashSet<>(); addGroupAndDescendantNames(addressGroupName, allGroupNames); return allGroupNames.stream() .flatMap(groupName -> getAddressGroup(groupName).get().getAddresses().stream()) .map(IpWildcard::parse) .collect(ImmutableSet.toImmutableSet()); } private  ReferenceBook(
      String name,
      List<AddressGroup> addressGroups,
      List<FilterGroup> filterGroups,
      List<InterfaceGroup> interfaceGroups,
      List<ServiceEndpoint> serviceEndpoints,
      List<ServiceObjectGroup> serviceObjectGroups,
      List<ServiceObject> serviceObjects); static Builder builder(String name); @Override int compareTo(ReferenceBook o); @Override boolean equals(Object o); Optional<AddressGroup> getAddressGroup(String groupName); @Nonnull @JsonProperty(PROP_ADDRESS_GROUPS) SortedSet<AddressGroup> getAddressGroups(); Optional<FilterGroup> getFilterGroup(String groupName); @Nonnull @JsonProperty(PROP_FILTER_GROUPS) SortedSet<FilterGroup> getFilterGroups(); Optional<InterfaceGroup> getInterfaceGroup(String groupName); @Nonnull @JsonProperty(PROP_INTERFACE_GROUPS) SortedSet<InterfaceGroup> getInterfaceGroups(); @Nonnull @JsonProperty(PROP_NAME) String getName(); @Nonnull @JsonProperty(PROP_SERVICE_ENDPOINTS) SortedSet<ServiceEndpoint> getServiceEndpoints(); @Nonnull @JsonProperty(PROP_SERVICE_OBJECT_GROUPS) SortedSet<ServiceObjectGroup> getServiceObjectGroups(); @Nonnull @JsonProperty(PROP_SERVICE_OBJECTS) SortedSet<ServiceObject> getServiceObjects(); @Override int hashCode(); Set<IpWildcard> getAddressesRecursive(String addressGroupName);  }