/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements. See the NOTICE file distributed with this
 * work for additional information regarding copyright ownership. The ASF
 * licenses this file to You under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package wicket.markup.repeater.util;

import java.util.Iterator;

import wicket.markup.repeater.RefreshingView;
import wicket.model.IModel;

/**
 * Iterator adapter that wraps adaptee's elements with a model. Convinient when
 * implementing {@link RefreshingView}.
 * 
 * @param <T>
 * 
 * @author Igor Vaynberg (ivaynberg)
 * 
 * 
 */
public abstract class ModelIteratorAdapter<T> implements Iterator<IModel<T>>
{
	private Iterator<T> delegate;

	/**
	 * Constructor
	 * 
	 * @param delegate
	 *            iterator that will be wrapped
	 */
	public ModelIteratorAdapter(Iterator<T> delegate)
	{
		this.delegate = delegate;
	}

	/**
	 * @see java.util.Iterator#hasNext()
	 */
	public boolean hasNext()
	{
		return delegate.hasNext();
	}

	/**
	 * @see java.util.Iterator#next()
	 */
	public IModel<T> next()
	{
		return model(delegate.next());
	}

	/**
	 * @see java.util.Iterator#remove()
	 */
	public void remove()
	{
		delegate.remove();
	}

	/**
	 * This method is used to wrap the provided object with an implementation of
	 * IModel. The provided object is guaranteed to be returned from the
	 * delegate iterator.
	 * 
	 * @param object
	 *            object to be wrapped
	 * @return IModel wrapper for the object
	 */
	abstract protected IModel<T> model(T object);
}

@@ -102,16 +102,17 @@
 eements.
+ 
  See the
@@ -144,17 +144,17 @@
 with
+%0D%0A *
  this
-%0D%0A *
  wor
@@ -216,16 +216,20 @@
 hip.
+%0D%0A *
  The ASF
 %0D%0A *
@@ -224,20 +224,16 @@
  The ASF
-%0D%0A *
  license
@@ -292,17 +292,17 @@
  2.0
+%0D%0A *
  (the
-%0D%0A *
  %22Li
@@ -361,16 +361,20 @@
 nce with
+%0D%0A *
  the Lic
@@ -378,20 +378,17 @@
 License.
-%0D%0A *
+ 
  You may
@@ -423,21 +423,25 @@
 e at%0D%0A *
- 
 %0D%0A *
+     
  http://
@@ -475,25 +475,24 @@
 ENSE-2.0%0D%0A *
- 
 %0D%0A * Unless 
@@ -625,16 +625,20 @@
 SIS,
+%0D%0A *
  WITHOUT
 %0D%0A *
@@ -633,20 +633,16 @@
  WITHOUT
-%0D%0A *
  WARRANT
@@ -698,24 +698,28 @@
 implied.
+%0D%0A *
  See the
 %0D%0A * Lic
@@ -710,20 +710,16 @@
  See the
-%0D%0A *
  License
@@ -770,16 +770,20 @@
 ions and
+%0D%0A *
  limitat
@@ -792,20 +792,16 @@
 ns under
-%0D%0A *
  the Lic

Fix license header for unit test.