BUG-5280: separate request sequence and transmit sequence
[controller.git] / opendaylight / md-sal / cds-access-client / src / main / java / org / opendaylight / controller / cluster / access / client / EmptyQueue.java
1 /*
2  * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.controller.cluster.access.client;
9
10 import java.util.AbstractQueue;
11 import java.util.Collections;
12 import java.util.Iterator;
13 import java.util.Queue;
14
15 /**
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.
18
19  * @author Robert Varga
20  *
21  * @param <E> the type of elements held in this collection
22  */
23 // TODO: move this class into yangtools.util
24 final class EmptyQueue<T> extends AbstractQueue<T> {
25     private static final EmptyQueue<?> INSTANCE = new EmptyQueue<>();
26
27     private EmptyQueue() {
28         // No instances
29     }
30
31     @SuppressWarnings("unchecked")
32     static <T> Queue<T> getInstance() {
33         return (Queue<T>) INSTANCE;
34     }
35
36     @Override
37     public boolean offer(final T e) {
38         return false;
39     }
40
41     @Override
42     public T poll() {
43         return null;
44     }
45
46     @Override
47     public T peek() {
48         return null;
49     }
50
51     @Override
52     public Iterator<T> iterator() {
53         return Collections.emptyIterator();
54     }
55
56     @Override
57     public int size() {
58         return 0;
59     }
60 }