001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.wicket.markup.repeater.data;
018
019import java.util.Collections;
020import java.util.Iterator;
021import java.util.List;
022
023import org.apache.wicket.model.IModel;
024
025
026/**
027 * A convenience class to represent an empty data provider.
028 * 
029 * @author Phil Kulak
030 * @param <T>
031 */
032public class EmptyDataProvider<T> implements IDataProvider<T>
033{
034        private static final long serialVersionUID = 1L;
035
036        private static EmptyDataProvider<?> INSTANCE = new EmptyDataProvider<Void>();
037
038        /**
039         * @param <T>
040         * @return the singleton instance of this class
041         */
042        @SuppressWarnings("unchecked")
043        public static <T> EmptyDataProvider<T> getInstance()
044        {
045                return (EmptyDataProvider<T>)INSTANCE;
046        }
047
048        @Override
049        public Iterator<T> iterator(long first, long count)
050        {
051                List<T> list = Collections.emptyList();
052                return list.iterator();
053        }
054
055        @Override
056        public long size()
057        {
058                return 0;
059        }
060
061        @Override
062        public IModel<T> model(Object object)
063        {
064                return null;
065        }
066}