This project has retired. For details please refer to its
Attic page.
Iterables 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 */1920package org.apache.chemistry.opencmis.jcr.util;
2122import org.apache.commons.collections.iterators.EmptyIterator;
23import org.apache.commons.collections.iterators.IteratorChain;
24import org.apache.commons.collections.iterators.SingletonIterator;
2526import java.util.Iterator;
2728publicclassIterables {
29privateIterables() {}
3031publicstatic <T> Iterable<T> concat(final Iterable<T> it1, final Iterable<T> it2) {
32returnnew Iterable<T>() {
33 @SuppressWarnings("unchecked")
34public Iterator<T> iterator() {
35returnnew IteratorChain(it1.iterator(), it2.iterator());
36 }
37 };
38 }
3940publicstatic <T> Iterable<T> singleton(final T element) {
41returnnew Iterable<T>() {
42 @SuppressWarnings("unchecked")
43public Iterator<T> iterator() {
44returnnew SingletonIterator(element);
45 }
46 };
47 }
4849publicstatic <T> Iterable<T> empty() {
50returnnew Iterable<T>() {
51 @SuppressWarnings("unchecked")
52public Iterator<T> iterator() {
53return EmptyIterator.INSTANCE;
54 }
55 };
56 }
57 }