org.oddjob.beanbus.destinations
Class BeanCopy<F,T>
java.lang.Object
org.oddjob.beanbus.AbstractDestination<F>
org.oddjob.beanbus.destinations.BeanCopy<F,T>
- Type Parameters:
F
- FromT
- To
- All Implemented Interfaces:
- Iterable<F>, Collection<F>, ArooaSessionAware, BusFilter<F,T>, Outbound<T>
public class BeanCopy<F,T>
- extends AbstractDestination<F>
- implements BusFilter<F,T>, ArooaSessionAware
Description
Copy the properties of a bean to another bean.Example
Copy beans into bean properties given by the class.
<oddjob>
<job>
<bean class="org.oddjob.beanbus.drivers.IterableBusDriver" id="bus">
<beans>
<value value="${iterable}"/>
</beans>
<to>
<bean class="org.oddjob.beanbus.destinations.BeanCopy">
<arooaClass>
<class name="org.oddjob.beanbus.destinations.BeanCopyTest$BeanTo"/>
</arooaClass>
<to>
<list/>
</to>
<mappings>
<value key="fruit" value="snack"/>
<value key="quantity" value="number"/>
<value key="price" value="COST"/>
</mappings>
</bean>
</to>
</bean>
</job>
</oddjob>
Example
Copy beans into a dynamically created bean.
<oddjob>
<job>
<bean class="org.oddjob.beanbus.drivers.IterableBusDriver" id="bus">
<beans>
<value value="${iterable}"/>
</beans>
<to>
<bean class="org.oddjob.beanbus.destinations.BeanCopy">
<arooaClass>
<magic-class name="BeanCopyTestMagiClass">
<properties>
<value key="snack" value="java.lang.String"/>
<value key="number" value="java.lang.Integer"/>
<value key="COST" value="java.lang.Double"/>
</properties>
</magic-class>
</arooaClass>
<to>
<list/>
</to>
<mappings>
<value key="fruit" value="snack"/>
<value key="quantity" value="number"/>
<value key="price" value="COST"/>
</mappings>
</bean>
</to>
</bean>
</job>
</oddjob>
Example
Copy beans into a dynamically created bean the properties of which match
the source bean.
<oddjob>
<job>
<bean class="org.oddjob.beanbus.drivers.IterableBusDriver" id="bus">
<beans>
<value value="${iterable}"/>
</beans>
<to>
<bean class="org.oddjob.beanbus.destinations.BeanCopy">
<to>
<list/>
</to>
<mappings>
<value key="fruit" value="snack"/>
<value key="quantity" value="number"/>
<value key="price" value="COST"/>
</mappings>
</bean>
</to>
</bean>
</job>
</oddjob>
- Author:
- rob
Methods inherited from class org.oddjob.beanbus.AbstractDestination |
addAll, clear, contains, containsAll, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray |
Methods inherited from interface java.util.Collection |
addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray |
BeanCopy
public BeanCopy()
setArooaSession
public void setArooaSession(ArooaSession session)
- Specified by:
setArooaSession
in interface ArooaSessionAware
add
public boolean add(F bean)
- Specified by:
add
in interface Collection<F>
createClassFromBean
protected ArooaClass createClassFromBean(F bean)
setArooaClass
public void setArooaClass(ArooaClass arooaClass)
setTo
public void setTo(Collection<? super T> to)
- Description copied from interface:
Outbound
- Set the out bound destination.
- Specified by:
setTo
in interface Outbound<T>
getTo
public Collection<? super T> getTo()
setMappings
public void setMappings(String from,
String to)
getName
public String getName()
setName
public void setName(String name)
toString
public String toString()
- Overrides:
toString
in class Object