@Test public void toAddressBook() { ReferenceBookBean bean = new ReferenceBookBean( ReferenceBook.builder("book2") .setAddressGroups( ImmutableList.of(new AddressGroup(ImmutableSortedSet.of(), "ag1"))) .setFilterGroups(ImmutableList.of(new FilterGroup(ImmutableList.of(), "fg1"))) .setInterfaceGroups( ImmutableList.of(new InterfaceGroup(ImmutableSortedSet.of(), "ig1"))) .setServiceEndpoints(ImmutableList.of(new ServiceEndpoint("ag1", "se1", "so1"))) .setServiceObjectGroups( ImmutableList.of(new ServiceObjectGroup("sog1", ImmutableSortedSet.of()))) .setServiceObjects( ImmutableList.of(new ServiceObject(IpProtocol.TCP, "so1", new SubRange(2, 3)))) .build()); beanBookMatch(bean, bean.toAddressBook()); }
public ReferenceBook toAddressBook() { return ReferenceBook.builder(name) .setAddressGroups( firstNonNull(addressGroups, Collections.<AddressGroupBean>emptySet()).stream() .map(agb -> agb.toAddressGroup()) .collect(Collectors.toList())) .setFilterGroups( firstNonNull(filterGroups, Collections.<FilterGroupBean>emptySet()).stream() .map(fgb -> fgb.toFilterGroup()) .collect(Collectors.toList())) .setInterfaceGroups( firstNonNull(interfaceGroups, Collections.<InterfaceGroupBean>emptySet()).stream() .map(igb -> igb.toInterfaceGroup()) .collect(Collectors.toList())) .setServiceEndpoints( firstNonNull(serviceEndpoints, Collections.<ServiceEndpointBean>emptySet()).stream() .map(seb -> seb.toServiceEndpoint()) .collect(Collectors.toList())) .setServiceObjectGroups( firstNonNull(serviceObjectGroups, Collections.<ServiceObjectGroupBean>emptySet()) .stream() .map(sogb -> sogb.toServiceObjectGroup()) .collect(Collectors.toList())) .setServiceObjects( firstNonNull(serviceObjects, Collections.<ServiceObjectBean>emptySet()).stream() .map(seb -> seb.toServiceObject()) .collect(Collectors.toList())) .build(); }
ReferenceBookBean { public ReferenceBook toAddressBook() { return ReferenceBook.builder(name) .setAddressGroups( firstNonNull(addressGroups, Collections.<AddressGroupBean>emptySet()).stream() .map(agb -> agb.toAddressGroup()) .collect(Collectors.toList())) .setFilterGroups( firstNonNull(filterGroups, Collections.<FilterGroupBean>emptySet()).stream() .map(fgb -> fgb.toFilterGroup()) .collect(Collectors.toList())) .setInterfaceGroups( firstNonNull(interfaceGroups, Collections.<InterfaceGroupBean>emptySet()).stream() .map(igb -> igb.toInterfaceGroup()) .collect(Collectors.toList())) .setServiceEndpoints( firstNonNull(serviceEndpoints, Collections.<ServiceEndpointBean>emptySet()).stream() .map(seb -> seb.toServiceEndpoint()) .collect(Collectors.toList())) .setServiceObjectGroups( firstNonNull(serviceObjectGroups, Collections.<ServiceObjectGroupBean>emptySet()) .stream() .map(sogb -> sogb.toServiceObjectGroup()) .collect(Collectors.toList())) .setServiceObjects( firstNonNull(serviceObjects, Collections.<ServiceObjectBean>emptySet()).stream() .map(seb -> seb.toServiceObject()) .collect(Collectors.toList())) .build(); } }
ReferenceBookBean { public ReferenceBook toAddressBook() { return ReferenceBook.builder(name) .setAddressGroups( firstNonNull(addressGroups, Collections.<AddressGroupBean>emptySet()).stream() .map(agb -> agb.toAddressGroup()) .collect(Collectors.toList())) .setFilterGroups( firstNonNull(filterGroups, Collections.<FilterGroupBean>emptySet()).stream() .map(fgb -> fgb.toFilterGroup()) .collect(Collectors.toList())) .setInterfaceGroups( firstNonNull(interfaceGroups, Collections.<InterfaceGroupBean>emptySet()).stream() .map(igb -> igb.toInterfaceGroup()) .collect(Collectors.toList())) .setServiceEndpoints( firstNonNull(serviceEndpoints, Collections.<ServiceEndpointBean>emptySet()).stream() .map(seb -> seb.toServiceEndpoint()) .collect(Collectors.toList())) .setServiceObjectGroups( firstNonNull(serviceObjectGroups, Collections.<ServiceObjectGroupBean>emptySet()) .stream() .map(sogb -> sogb.toServiceObjectGroup()) .collect(Collectors.toList())) .setServiceObjects( firstNonNull(serviceObjects, Collections.<ServiceObjectBean>emptySet()).stream() .map(seb -> seb.toServiceObject()) .collect(Collectors.toList())) .build(); } @JsonCreator private  ReferenceBookBean();  ReferenceBookBean(ReferenceBook book); }
ReferenceBookBean { public ReferenceBook toAddressBook() { return ReferenceBook.builder(name) .setAddressGroups( firstNonNull(addressGroups, Collections.<AddressGroupBean>emptySet()).stream() .map(agb -> agb.toAddressGroup()) .collect(Collectors.toList())) .setFilterGroups( firstNonNull(filterGroups, Collections.<FilterGroupBean>emptySet()).stream() .map(fgb -> fgb.toFilterGroup()) .collect(Collectors.toList())) .setInterfaceGroups( firstNonNull(interfaceGroups, Collections.<InterfaceGroupBean>emptySet()).stream() .map(igb -> igb.toInterfaceGroup()) .collect(Collectors.toList())) .setServiceEndpoints( firstNonNull(serviceEndpoints, Collections.<ServiceEndpointBean>emptySet()).stream() .map(seb -> seb.toServiceEndpoint()) .collect(Collectors.toList())) .setServiceObjectGroups( firstNonNull(serviceObjectGroups, Collections.<ServiceObjectGroupBean>emptySet()) .stream() .map(sogb -> sogb.toServiceObjectGroup()) .collect(Collectors.toList())) .setServiceObjects( firstNonNull(serviceObjects, Collections.<ServiceObjectBean>emptySet()).stream() .map(seb -> seb.toServiceObject()) .collect(Collectors.toList())) .build(); } @JsonCreator private  ReferenceBookBean();  ReferenceBookBean(ReferenceBook book); @Override boolean equals(Object o); @Override int hashCode(); ReferenceBook toAddressBook(); }
ReferenceBookBean { public ReferenceBook toAddressBook() { return ReferenceBook.builder(name) .setAddressGroups( firstNonNull(addressGroups, Collections.<AddressGroupBean>emptySet()).stream() .map(agb -> agb.toAddressGroup()) .collect(Collectors.toList())) .setFilterGroups( firstNonNull(filterGroups, Collections.<FilterGroupBean>emptySet()).stream() .map(fgb -> fgb.toFilterGroup()) .collect(Collectors.toList())) .setInterfaceGroups( firstNonNull(interfaceGroups, Collections.<InterfaceGroupBean>emptySet()).stream() .map(igb -> igb.toInterfaceGroup()) .collect(Collectors.toList())) .setServiceEndpoints( firstNonNull(serviceEndpoints, Collections.<ServiceEndpointBean>emptySet()).stream() .map(seb -> seb.toServiceEndpoint()) .collect(Collectors.toList())) .setServiceObjectGroups( firstNonNull(serviceObjectGroups, Collections.<ServiceObjectGroupBean>emptySet()) .stream() .map(sogb -> sogb.toServiceObjectGroup()) .collect(Collectors.toList())) .setServiceObjects( firstNonNull(serviceObjects, Collections.<ServiceObjectBean>emptySet()).stream() .map(seb -> seb.toServiceObject()) .collect(Collectors.toList())) .build(); } @JsonCreator private  ReferenceBookBean();  ReferenceBookBean(ReferenceBook book); @Override boolean equals(Object o); @Override int hashCode(); ReferenceBook toAddressBook(); public String name; public Set<AddressGroupBean> addressGroups; public Set<FilterGroupBean> filterGroups; public Set<InterfaceGroupBean> interfaceGroups; public Set<ServiceEndpointBean> serviceEndpoints; public Set<ServiceObjectGroupBean> serviceObjectGroups; public Set<ServiceObjectBean> serviceObjects; }