|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.omnaest.utils.beans.copier.PreparedBeanCopier<FROM,TO>
public class PreparedBeanCopier<FROM,TO>
A PreparedBeanCopier will prepare reflection based property copy actions for two given Class types in advance.
This allows to execute the copy process about 5 - 10 times faster than the Apache Commons
BeanUtils.copyProperties(Object, Object)
E.g. for bean copy actions including instantiations of Maps or Lists this implementations is only about 5 - 10
times slower than regular getter and setter transfer constructs.
The overall speed is about 5-10 seconds for about 10000000 copy operations invoked by the same
PreparedBeanCopier instance.
The PreparedBeanCopier can be based on interfaces when being constructed, which allows to copy a reduced set of
properties by giving an interface with a subset of the instance properties at construction time and the implementing instance
during copy method invocation.
The PreparedBeanCopier.Configuration allows to set various options, like:
PreparedBeanCopier.Configuration.setHandlingPrimitivesAndWrappers(boolean)PreparedBeanCopier.Configuration.setHandlingLists(boolean)PreparedBeanCopier.Configuration.setHandlingSets(boolean)PreparedBeanCopier.Configuration.setHandlingMaps(boolean)PreparedBeanCopier.Configuration.setHandlingArbitraryObjects(boolean)deepCloneProperties(Object) and deepCopyProperties(Object, Object) instances are thread safe per default,
as long as any at setExceptionHandler(ExceptionHandler) or at Configuration#add(CopierFactory) or
Configuration#add(InstanceFactoryCreator) provided instances are thread safe.
| Nested Class Summary | |
|---|---|
static class |
PreparedBeanCopier.Configuration
|
static interface |
PreparedBeanCopier.CopierFactory
Factory for PreparedBeanCopier.CopierFactory.Copier instances |
static interface |
PreparedBeanCopier.InstanceFactoryCreator
|
static interface |
PreparedBeanCopier.MetaDataHandler
|
static class |
PreparedBeanCopier.NonMatchingPropertyException
|
static interface |
PreparedBeanCopier.Transformer
A PreparedBeanCopier.Transformer will return new transformed instances for another given instance |
| Constructor Summary | |
|---|---|
PreparedBeanCopier(Class<? extends FROM> typeFrom,
Class<? extends TO> typeTo)
|
|
PreparedBeanCopier(Class<? extends FROM> typeFrom,
Class<? extends TO> typeTo,
PreparedBeanCopier.Configuration configuration)
|
|
| Method Summary | |
|---|---|
TO |
deepCloneProperties(FROM instanceFrom)
|
PreparedBeanCopier<FROM,TO> |
deepCopyProperties(FROM instanceFrom,
TO instanceTo)
|
List<String> |
getNonMatchingPropertyNameList()
Returns a List of all non matching property names |
boolean |
hasNonMatchingProperties()
Returns true if there are properties which could not be matched |
PreparedBeanCopier<FROM,TO> |
setExceptionHandler(ExceptionHandler exceptionHandler)
|
PreparedBeanCopier<FROM,TO> |
setPropertyAccessTypeFrom(BeanPropertyAccessor.PropertyAccessType propertyAccessTypeFrom)
|
PreparedBeanCopier<FROM,TO> |
setPropertyAccessTypeTo(BeanPropertyAccessor.PropertyAccessType propertyAccessTypeTo)
|
PreparedBeanCopier<FROM,TO> |
throwExceptionWhenAnyPropertiesAreNotMatching()
Throws an PreparedBeanCopier.NonMatchingPropertyException if hasNonMatchingProperties() is true |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public PreparedBeanCopier(Class<? extends FROM> typeFrom,
Class<? extends TO> typeTo)
typeFrom - typeTo - PreparedBeanCopier
public PreparedBeanCopier(Class<? extends FROM> typeFrom,
Class<? extends TO> typeTo,
PreparedBeanCopier.Configuration configuration)
typeFrom - ClasstypeTo - Classconfiguration - PreparedBeanCopier.ConfigurationPreparedBeanCopier| Method Detail |
|---|
public TO deepCloneProperties(FROM instanceFrom)
instanceFrom -
public PreparedBeanCopier<FROM,TO> deepCopyProperties(FROM instanceFrom,
TO instanceTo)
instanceFrom - instanceTo -
public PreparedBeanCopier<FROM,TO> setExceptionHandler(ExceptionHandler exceptionHandler)
exceptionHandler - ExceptionHandler
public PreparedBeanCopier<FROM,TO> setPropertyAccessTypeFrom(BeanPropertyAccessor.PropertyAccessType propertyAccessTypeFrom)
propertyAccessTypeFrom - BeanPropertyAccessor.PropertyAccessType
public PreparedBeanCopier<FROM,TO> setPropertyAccessTypeTo(BeanPropertyAccessor.PropertyAccessType propertyAccessTypeTo)
propertyAccessTypeTo - BeanPropertyAccessor.PropertyAccessType
public List<String> getNonMatchingPropertyNameList()
List of all non matching property names
hasNonMatchingProperties()public boolean hasNonMatchingProperties()
getNonMatchingPropertyNameList()
public PreparedBeanCopier<FROM,TO> throwExceptionWhenAnyPropertiesAreNotMatching()
throws PreparedBeanCopier.NonMatchingPropertyException
PreparedBeanCopier.NonMatchingPropertyException if hasNonMatchingProperties() is true
PreparedBeanCopier.NonMatchingPropertyExceptionhasNonMatchingProperties()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||