net.sf.chainedoptions
Class AbstractBeanConverter
java.lang.Object
net.sf.chainedoptions.AbstractBeanConverter
- All Implemented Interfaces:
- BeanConverter
- Direct Known Subclasses:
- StringBeanConverter
public abstract class AbstractBeanConverter
- extends java.lang.Object
- implements BeanConverter
Abstract class that implements the BeanConverter interface and provides an
implementation of convert(List)
that loops through a list of beans
and calls a template method for each bean.
Subclasses must implement the template method convertBean(Object)
.
Below is an example of such an implementation:
package com.acme.valuehandler;
import com.acme.valuehandler.model.RegionBean;
public class RegionBeanConverter extends AbstractBeanConverter {
protected LabelValueBean convertBean(Object bean) {
RegionBean regionBean = ((RegionBean) bean);
return new LabelValueBean(regionBean.getName(), regionBean.getCode());
}
}
- Author:
- Mattias Arthursson, Ulrik Sandberg
Method Summary |
java.util.List |
convert(java.util.List beans)
Default implementation that loops through the supplied list of beans and
calls convertBean(Object) on each one of them. |
protected abstract LabelValueBean |
convertBean(java.lang.Object object)
Template method that must provide the conversion of a single object into
a LabelValueBean . |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
AbstractBeanConverter
public AbstractBeanConverter()
convert
public java.util.List convert(java.util.List beans)
- Default implementation that loops through the supplied list of beans and
calls
convertBean(Object)
on each one of them.
- Specified by:
convert
in interface BeanConverter
- Parameters:
beans
- list of beans of any kind.
- Returns:
- a new List containing the corresponding
LabelValueBean
objects.
convertBean
protected abstract LabelValueBean convertBean(java.lang.Object object)
- Template method that must provide the conversion of a single object into
a
LabelValueBean
.
- Parameters:
object
- An object to convert.
- Returns:
- A LabelValueBean object.
Copyright ? 2005. All Rights Reserved.