@Override public void handlePatch(Operation patchOp) { ResourceUtils.handlePatch( patchOp, getState(patchOp), getStateDescription(), ImageState.class, null); }
@Override public void handlePatch(Operation patchOp) { final ImageState currentState = getState(patchOp); final ImageState patchBody = patchOp.getBody(ImageState.class); // If more sophisticated logic is needed use ServiceStateCollectionUpdateRequest final Function<Operation, Boolean> diskConfigsHandler = (op) -> { if (patchBody.diskConfigs == null) { // unmodified return false; } // For the sake of optimization first check size and only then actually compare if (currentState.diskConfigs != null && currentState.diskConfigs.size() == patchBody.diskConfigs.size() && currentState.diskConfigs.equals(patchBody.diskConfigs)) { // unmodified: same size and same disks return false; } // and override with patched value currentState.diskConfigs = patchBody.diskConfigs; // modified return true; }; // Delegate to built-in PATCH logic ResourceUtils.handlePatch(this, patchOp, currentState, getStateDescription(), ImageState.class, diskConfigsHandler); }
ImageState imageState = op.getBody(ImageState.class); Utils.validateState(getStateDescription(), imageState);
ImageState imageState = op.getBody(ImageState.class); Utils.validateState(getStateDescription(), imageState);