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.sal.connect.netconf.listener;
10 import static com.google.common.base.Preconditions.checkState;
12 import com.google.common.util.concurrent.AbstractFuture;
13 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
15 final class UncancellableFuture<V> extends AbstractFuture<V> {
16 private volatile boolean uncancellable = false;
18 UncancellableFuture(final boolean uncancellable) {
19 this.uncancellable = uncancellable;
22 public boolean setUncancellable() {
31 public boolean isUncancellable() {
36 public boolean cancel(final boolean mayInterruptIfRunning) {
37 return !uncancellable && super.cancel(mayInterruptIfRunning);
40 @SuppressFBWarnings(value = "NP_PARAMETER_MUST_BE_NONNULL_BUT_MARKED_AS_NULLABLE",
41 justification = "Unrecognised NullableDecl")
43 public boolean set(final V value) {
44 checkState(uncancellable);
45 return super.set(value);
49 protected boolean setException(final Throwable throwable) {
50 checkState(uncancellable);
51 return super.setException(throwable);