![JAR search and dependency download from the Maven repository](/logo.png)
com.vaadin.collaborationengine.ListOperationResult Maven / Gradle / Ivy
/*
* Copyright 2020-2022 Vaadin Ltd.
*
* This program is available under Commercial Vaadin Runtime License 1.0
* (CVRLv1).
*
* For the full License, see http://vaadin.com/license/cvrl-1
*/
package com.vaadin.collaborationengine;
import java.util.concurrent.CompletableFuture;
/**
* The result of a list operation in a {@link CollaborationList}.
*
* It provides access to the key of the affected item and to the
* {@link CompletableFuture} of the operation.
*
* @author Vaadin Ltd
*/
public class ListOperationResult implements ListInsertResult {
private final ListKey key;
private final CompletableFuture completableFuture;
ListOperationResult(ListKey key, CompletableFuture completableFuture) {
this.key = key;
this.completableFuture = completableFuture;
}
/**
* Gets the key of the item.
*
* @return the item key, not null
*/
@Override
public ListKey getKey() {
return key;
}
/**
* The result of the asynchronous operation.
*
* @return the result of the operation, not null
*/
@Override
public CompletableFuture getCompletableFuture() {
return completableFuture;
}
/* Map to a void parameterized type for existing list operations */
ListOperationResult mapToVoid() {
return new ListOperationResult<>(key,
completableFuture.thenApply(t -> null));
}
}