2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.netconf.client.mdsal;
10 import static com.google.common.base.Preconditions.checkState;
12 import com.google.common.util.concurrent.AbstractFuture;
14 final class UncancellableFuture<V> extends AbstractFuture<V> {
15 private volatile boolean uncancellable = false;
17 UncancellableFuture(final boolean uncancellable) {
18 this.uncancellable = uncancellable;
21 public boolean setUncancellable() {
30 public boolean isUncancellable() {
35 public boolean cancel(final boolean mayInterruptIfRunning) {
36 return !uncancellable && super.cancel(mayInterruptIfRunning);
40 public boolean set(final V value) {
41 checkState(uncancellable);
42 return super.set(value);
46 protected boolean setException(final Throwable throwable) {
47 checkState(uncancellable);
48 return super.setException(throwable);