/** * Copy constructor * @param addressPair */ private AddressPair(AddressPair addressPair) { this(addressPair.getMacAddress(), addressPair.getIpAddress()); }
/** * @return a AddressPair constructed with this Builder. */ public AddressPair build() { // Use the copy constructor to copy the builder's state (config) object and pass back to the user. // Immutability is preserved, and fields are defined only once. return new AddressPair(addressPair); }
.adminStateUp(Boolean.TRUE) .deviceId("d6b4d3a5-c700-476f-b609-1493dd9dadc0") .allowedAddressPairs(ImmutableSet.of(AddressPair.builder("12", "111.222.333.444").build())) .build(); assertEquals(port.getAllowedAddressPairs().iterator().next().getIpAddress(), "192.168.1.1"); assertEquals(port.getAllowedAddressPairs().iterator().next().getMacAddress(), "12:12"); assertEquals(port.getName(), "port1"); assertEquals(port.getStatus(), NetworkStatus.ACTIVE);
@Override public String toString() { return string().toString(); }
@Override public String toString() { return string().toString(); }
/** * Copy constructor * @param addressPair */ private AddressPair(AddressPair addressPair) { this(addressPair.getMacAddress(), addressPair.getIpAddress()); }
/** * No-parameters constructor used when updating. * */ private Builder() { addressPair = new AddressPair(); }
/** * @return a Builder from another AddressPair. */ public Builder fromAddressPair(AddressPair in) { return this.macAddress(in.getMacAddress()).ipAddress(in.getIpAddress()); } }
/** * No-parameters constructor used when updating. * */ private Builder() { addressPair = new AddressPair(); }
/** * @return a Builder from another AddressPair. */ public Builder fromAddressPair(AddressPair in) { return this.macAddress(in.getMacAddress()).ipAddress(in.getIpAddress()); } }
/** * Required parameters constructor used when creating. * @param macAddress * @param ipAddress */ private Builder(String macAddress, String ipAddress) { addressPair = new AddressPair(); addressPair.macAddress = macAddress; addressPair.ipAddress = ipAddress; }
/** * @return a AddressPair constructed with this Builder. */ public AddressPair build() { // Use the copy constructor to copy the builder's state (config) object and pass back to the user. // Immutability is preserved, and fields are defined only once. return new AddressPair(addressPair); }
/** * Required parameters constructor used when creating. * @param macAddress * @param ipAddress */ private Builder(String macAddress, String ipAddress) { addressPair = new AddressPair(); addressPair.macAddress = macAddress; addressPair.ipAddress = ipAddress; }