This project has retired. For details please refer to its
Attic page.
EmptyItemIterable xref
1/*2 * Licensed to the Apache Software Foundation (ASF) under one3 * or more contributor license agreements. See the NOTICE file4 * distributed with this work for additional information5 * regarding copyright ownership. The ASF licenses this file6 * to you under the Apache License, Version 2.0 (the7 * "License"); you may not use this file except in compliance8 * with the License. You may obtain a copy of the License at9 *10 * http://www.apache.org/licenses/LICENSE-2.011 *12 * Unless required by applicable law or agreed to in writing,13 * software distributed under the License is distributed on an14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY15 * KIND, either express or implied. See the License for the16 * specific language governing permissions and limitations17 * under the License.18 */19package org.apache.chemistry.opencmis.client.runtime.util;
2021import java.util.Iterator;
22import java.util.NoSuchElementException;
2324import org.apache.chemistry.opencmis.client.api.ItemIterable;
2526/**27 * An empty item iterable.28 */29publicclass EmptyItemIterable<T> implements ItemIterable<T> {
3031publicstaticfinal EmptyItemIterable<?> INSTANCE = new EmptyItemIterable<Object>();
3233 @SuppressWarnings("unchecked")
34publicstatic <U> EmptyItemIterable<U> instance() {
35return (EmptyItemIterable<U>) INSTANCE;
36 }
3738public ItemIterable<T> skipTo(long position) {
39if (position != 0) {
40thrownew IllegalArgumentException(String.valueOf(position));
41 }
42returnthis;
43 }
4445public ItemIterable<T> getPage() {
46returnthis;
47 }
4849public ItemIterable<T> getPage(int maxNumItems) {
50returnthis;
51 }
5253 @SuppressWarnings("unchecked")
54public Iterator<T> iterator() {
55return (Iterator<T>) EmptyIterator.INSTANCE;
56 }
5758publiclong getPageNumItems() {
59return 0;
60 }
6162publicboolean getHasMoreItems() {
63return false;
64 }
6566publiclong getTotalNumItems() {
67return 0;
68 }
6970/**71 * An empty iterator.72 */73publicstaticclass EmptyIterator<V> implements Iterator<V> {
74publicstaticfinal Iterator<?> INSTANCE = new EmptyIterator<Object>();
7576publicboolean hasNext() {
77return false;
78 }
7980public V next() {
81thrownew NoSuchElementException();
82 }
8384publicvoid remove() {
85thrownew UnsupportedOperationException();
86 }
87 }
8889 }