generified PagedListHolded (SPR-6825)

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@2960 50f2f4bb-b051-0410-bef5-90022cba6387
This commit is contained in:
Juergen Hoeller 2010-02-11 23:24:45 +00:00
parent 2f48d5f2ba
commit bbdbb86f08
1 changed files with 10 additions and 10 deletions

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2008 the original author or authors. * Copyright 2002-2010 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -47,14 +47,14 @@ import org.springframework.util.Assert;
* @see #getPageList() * @see #getPageList()
* @see org.springframework.beans.support.MutableSortDefinition * @see org.springframework.beans.support.MutableSortDefinition
*/ */
public class PagedListHolder implements Serializable { public class PagedListHolder<E> implements Serializable {
public static final int DEFAULT_PAGE_SIZE = 10; public static final int DEFAULT_PAGE_SIZE = 10;
public static final int DEFAULT_MAX_LINKED_PAGES = 10; public static final int DEFAULT_MAX_LINKED_PAGES = 10;
private List source; private List<E> source;
private Date refreshDate; private Date refreshDate;
@ -77,7 +77,7 @@ public class PagedListHolder implements Serializable {
* @see #setSource * @see #setSource
*/ */
public PagedListHolder() { public PagedListHolder() {
this(new ArrayList(0)); this(new ArrayList<E>(0));
} }
/** /**
@ -86,7 +86,7 @@ public class PagedListHolder implements Serializable {
* @param source the source List * @param source the source List
* @see MutableSortDefinition#setToggleAscendingOnProperty * @see MutableSortDefinition#setToggleAscendingOnProperty
*/ */
public PagedListHolder(List source) { public PagedListHolder(List<E> source) {
this(source, new MutableSortDefinition(true)); this(source, new MutableSortDefinition(true));
} }
@ -95,7 +95,7 @@ public class PagedListHolder implements Serializable {
* @param source the source List * @param source the source List
* @param sort the SortDefinition to start with * @param sort the SortDefinition to start with
*/ */
public PagedListHolder(List source, SortDefinition sort) { public PagedListHolder(List<E> source, SortDefinition sort) {
setSource(source); setSource(source);
setSort(sort); setSort(sort);
} }
@ -104,7 +104,7 @@ public class PagedListHolder implements Serializable {
/** /**
* Set the source list for this holder. * Set the source list for this holder.
*/ */
public void setSource(List source) { public void setSource(List<E> source) {
Assert.notNull(source, "Source List must not be null"); Assert.notNull(source, "Source List must not be null");
this.source = source; this.source = source;
this.refreshDate = new Date(); this.refreshDate = new Date();
@ -114,7 +114,7 @@ public class PagedListHolder implements Serializable {
/** /**
* Return the source list for this holder. * Return the source list for this holder.
*/ */
public List getSource() { public List<E> getSource() {
return this.source; return this.source;
} }
@ -268,7 +268,7 @@ public class PagedListHolder implements Serializable {
/** /**
* Return a sub-list representing the current page. * Return a sub-list representing the current page.
*/ */
public List getPageList() { public List<E> getPageList() {
return getSource().subList(getFirstElementOnPage(), getLastElementOnPage() + 1); return getSource().subList(getFirstElementOnPage(), getLastElementOnPage() + 1);
} }
@ -325,7 +325,7 @@ public class PagedListHolder implements Serializable {
* Can be overridden in subclasses. * Can be overridden in subclasses.
* @see PropertyComparator#sort(java.util.List, SortDefinition) * @see PropertyComparator#sort(java.util.List, SortDefinition)
*/ */
protected void doSort(List source, SortDefinition sort) { protected void doSort(List<E> source, SortDefinition sort) {
PropertyComparator.sort(source, sort); PropertyComparator.sort(source, sort);
} }