private void validateState(NetworkInterfaceState state) { Utils.validateState(getStateDescription(), state); if (state.address != null) { if (!InetAddressValidator.getInstance().isValidInet4Address( state.address)) { throw new IllegalArgumentException("IP address is invalid"); } } if (state.networkLink == null && state.subnetLink == null) { throw new IllegalArgumentException( "Either subnetLink or networkLink must be set"); } } }
private void validateState(NetworkInterfaceState state) { Utils.validateState(getStateDescription(), state); if (state.address != null) { if (state.subnetLink == null) { throw new IllegalArgumentException( "SubnetLink must not be null when address is set"); } if (!InetAddressValidator.getInstance().isValidInet4Address( state.address)) { throw new IllegalArgumentException("IP address is invalid"); } } if (state.networkLink == null && state.subnetLink == null) { throw new IllegalArgumentException( "Either subnetLink or networkLink must be set"); } } }
@Override public void handlePatch(Operation patch) { NetworkInterfaceState currentState = getState(patch); ResourceUtils.handlePatch(patch, currentState, getStateDescription(), NetworkInterfaceState.class, t -> { NetworkInterfaceState patchBody = patch.getBody(NetworkInterfaceState.class); boolean hasStateChanged = false; if (patchBody.endpointLink != null && currentState.endpointLink == null) { currentState.endpointLink = patchBody.endpointLink; hasStateChanged = true; } if (patchBody.securityGroupLinks != null) { if (currentState.securityGroupLinks == null) { currentState.securityGroupLinks = patchBody.securityGroupLinks; hasStateChanged = true; } else { for (String link : patchBody.securityGroupLinks) { if (!currentState.securityGroupLinks.contains(link)) { currentState.securityGroupLinks.add(link); hasStateChanged = true; } } } } return hasStateChanged; }); }
@Override public void handlePatch(Operation patch) { NetworkInterfaceState currentState = getState(patch); ResourceUtils.handlePatch(this, patch, currentState, getStateDescription(), NetworkInterfaceState.class, t -> { NetworkInterfaceState patchBody = patch.getBody(NetworkInterfaceState.class); boolean hasStateChanged = false; if (patchBody.endpointLink != null && currentState.endpointLink == null) { currentState.endpointLink = patchBody.endpointLink; hasStateChanged = true; } if (patchBody.securityGroupLinks != null) { if (currentState.securityGroupLinks == null) { currentState.securityGroupLinks = patchBody.securityGroupLinks; hasStateChanged = true; } else { for (String link : patchBody.securityGroupLinks) { if (!currentState.securityGroupLinks.contains(link)) { currentState.securityGroupLinks.add(link); hasStateChanged = true; } } } } return hasStateChanged; }); }