Fix CS warnings in cds-access-client and enable enforcement
[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 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
16 /**
17  * A specialized always-empty implementation of {@link java.util.Queue}. This implementation will always refuse new
18  * elements in its {@link #offer(Object)} method.
19
20  * @author Robert Varga
21  *
22  * @param <E> the type of elements held in this collection
23  */
24 // TODO: move this class into yangtools.util
25 @Beta
26 public final class EmptyQueue<E> extends AbstractQueue<E> {
27     private static final EmptyQueue<?> INSTANCE = new EmptyQueue<>();
28
29     private EmptyQueue() {
30         // No instances
31     }
32
33     @SuppressWarnings("unchecked")
34     public static <T> Queue<T> getInstance() {
35         return (Queue<T>) INSTANCE;
36     }
37
38     @Override
39     public boolean offer(final E entry) {
40         return false;
41     }
42
43     @Override
44     public E poll() {
45         return null;
46     }
47
48     @Override
49     public E peek() {
50         return null;
51     }
52
53     @Override
54     public Iterator<E> iterator() {
55         return Collections.emptyIterator();
56     }
57
58     @Override
59     public int size() {
60         return 0;
61     }
62 }