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 java.util.AbstractQueue;
11 import java.util.Collections;
12 import java.util.Iterator;
13 import java.util.Queue;
16 * A specialized always-empty implementation of {@link java.util.Queue}. This implementation will always refuse new
17 * elements in its {@link #offer(Object)} method.
19 * @author Robert Varga
21 * @param <E> the type of elements held in this collection
23 // TODO: move this class into yangtools.util
24 final class EmptyQueue<T> extends AbstractQueue<T> {
25 private static final EmptyQueue<?> INSTANCE = new EmptyQueue<>();
27 private EmptyQueue() {
31 @SuppressWarnings("unchecked")
32 static <T> Queue<T> getInstance() {
33 return (Queue<T>) INSTANCE;
37 public boolean offer(final T e) {
52 public Iterator<T> iterator() {
53 return Collections.emptyIterator();