2 * Copyright (c) 2016 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.controller.cluster.access.client;
10 import com.google.common.annotations.Beta;
11 import java.util.AbstractQueue;
12 import java.util.Collections;
13 import java.util.Iterator;
14 import java.util.Queue;
15 import org.opendaylight.yangtools.concepts.Immutable;
18 * A specialized always-empty implementation of {@link java.util.Queue}. This implementation will always refuse new
19 * elements in its {@link #offer(Object)} method.
20 * @author Robert Varga
22 * @param <E> the type of elements held in this collection
24 // TODO: move this class into yangtools.util
26 public final class EmptyQueue<E> extends AbstractQueue<E> implements Immutable {
27 private static final EmptyQueue<?> INSTANCE = new EmptyQueue<>();
29 private EmptyQueue() {
33 @SuppressWarnings("unchecked")
34 public static <T> Queue<T> getInstance() {
35 return (Queue<T>) INSTANCE;
39 public boolean offer(final E entry) {
54 public Iterator<E> iterator() {
55 return Collections.emptyIterator();