All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jvnet.hyperjaxb3.item.AbstractItemList Maven / Gradle / Ivy

There is a newer version: 4.0.8
Show newest version
package org.jvnet.hyperjaxb3.item;

import java.io.Serializable;
import java.util.AbstractList;
import java.util.List;

public abstract class AbstractItemList>
		extends AbstractList implements ItemList, Serializable {

	private static final long serialVersionUID = -6512320214488719797L;

	protected final List core;

	public AbstractItemList(final List core) {
		super();
		if (core == null) {
			throw new IllegalArgumentException("Core list must be null.");
		}
		this.core = core;
	}

	@Override
	public ListType get(int index) {
		final ItemType item = core.get(index);
		return item.getItem();
	}

	@Override
	public ListType set(int index, ListType element) {

		final ItemType oldItem = core.get(index);
		final ListType oldValue = oldItem.getItem();
		oldItem.setItem(element);
		return oldValue;
	}

	@Override
	public void add(int index, ListType element) {
		final ItemType item = create(element);
		core.add(index, item);
	}

	@Override
	public ListType remove(int index) {
		final ItemType item = core.remove(index);
		return item.getItem();
	}

	@Override
	public int size() {
		return core.size();
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy