private <PermissionType extends Permission> void updatePermissionSet(
            APIPatch.Operation operation,
            PermissionSetPatch<PermissionType> permissionSetPatch,
            PermissionType permission) throws GuacamoleException {

        // Add or remove permission based on operation
        switch (operation) {

            // Add permission
            case add:
                permissionSetPatch.addPermission(permission);
                break;

            // Remove permission
            case remove:
                permissionSetPatch.removePermission(permission);
                break;

            // Unsupported patch operation
            default:
                throw new GuacamoleClientException("Unsupported patch operation: \"" + operation + "\"");

        }

    }
Updates the given permission set patch by queuing an add or remove
operation for the given permission based on the given patch operation.

@param <PermissionType>
    The type of permission stored within the permission set.

@param operation
    The patch operation to perform.

@param permissionSetPatch
    The permission set patch being modified.

@param permission
    The permission being added or removed from the set.

@throws GuacamoleException
    If the requested patch operation is not supported.
guacamole/src/main/java/org/apache/guacamole/rest/permission/PermissionSetResource.java