X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fcds-access-client%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Faccess%2Fclient%2FEmptyQueue.java;fp=opendaylight%2Fmd-sal%2Fcds-access-client%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Faccess%2Fclient%2FEmptyQueue.java;h=31d863a36cf8721de52969ed0bfb5e94dfad4922;hp=0000000000000000000000000000000000000000;hb=9b4f21460c6dcb10c381df631d064d05de16546c;hpb=e514a5fc59ade7ac2ce5faf0ba5c75c3cb259c7f diff --git a/opendaylight/md-sal/cds-access-client/src/main/java/org/opendaylight/controller/cluster/access/client/EmptyQueue.java b/opendaylight/md-sal/cds-access-client/src/main/java/org/opendaylight/controller/cluster/access/client/EmptyQueue.java new file mode 100644 index 0000000000..31d863a36c --- /dev/null +++ b/opendaylight/md-sal/cds-access-client/src/main/java/org/opendaylight/controller/cluster/access/client/EmptyQueue.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.controller.cluster.access.client; + +import java.util.AbstractQueue; +import java.util.Collections; +import java.util.Iterator; +import java.util.Queue; + +/** + * A specialized always-empty implementation of {@link java.util.Queue}. This implementation will always refuse new + * elements in its {@link #offer(Object)} method. + + * @author Robert Varga + * + * @param the type of elements held in this collection + */ +// TODO: move this class into yangtools.util +final class EmptyQueue extends AbstractQueue { + private static final EmptyQueue INSTANCE = new EmptyQueue<>(); + + private EmptyQueue() { + // No instances + } + + @SuppressWarnings("unchecked") + static Queue getInstance() { + return (Queue) INSTANCE; + } + + @Override + public boolean offer(final T e) { + return false; + } + + @Override + public T poll() { + return null; + } + + @Override + public T peek() { + return null; + } + + @Override + public Iterator iterator() { + return Collections.emptyIterator(); + } + + @Override + public int size() { + return 0; + } +} \ No newline at end of file