Example #1
0
  private static void checkNetworkConnection(NetworkConnection val) {
    assertNotNull(val, String.format(NOT_NULL_OBJECT_FMT, "NetworkConnection", ""));

    // Check required fields
    assertNotNull(
        val.getNetwork(), String.format(NOT_NULL_OBJECT_FMT, "Network", "NetworkConnection"));
    assertNotNull(
        val.getIpAddressAllocationMode(),
        String.format(NOT_NULL_OBJECT_FMT, "IpAddressAllocationMode", "NetworkConnection"));
    IpAddressAllocationMode mode =
        NetworkConnection.IpAddressAllocationMode.valueOf(val.getIpAddressAllocationMode());
    assertTrue(
        NetworkConnection.IpAddressAllocationMode.ALL.contains(mode),
        String.format(
            REQUIRED_VALUE_OBJECT_FMT,
            "IpAddressAllocationMode",
            "NetworkConnection",
            val.getIpAddressAllocationMode(),
            Iterables.toString(NetworkConnection.IpAddressAllocationMode.ALL)));

    // Check optional fields
    if (val.getIpAddress() != null) {
      checkIpAddress(val.getIpAddress());
    }
    if (val.getExternalIpAddress() != null) {
      checkIpAddress(val.getExternalIpAddress());
    }

    if (val.getMACAddress() != null) {
      checkMacAddress(val.getMACAddress());
    }

    // FIXME Missing?
    // val.getVCloudExtension();
  }
Example #2
0
 public Builder fromNetworkConnection(NetworkConnection in) {
   return networkConnectionIndex(in.getNetworkConnectionIndex())
       .ipAddress(in.getIpAddress())
       .externalIpAddress(in.getExternalIpAddress())
       .isConnected(in.isConnected())
       .macAddress(in.getMACAddress())
       .ipAddressAllocationMode(in.getIpAddressAllocationMode())
       .network(in.getNetwork())
       .needsCustomization(in.needsCustomization());
 }