A - B - public interface Filter<A,B> extends MappedTypePair<A,B>
| Modifier and Type | Method and Description |
|---|---|
boolean |
appliesTo(Property source,
Property destination)
This method will be called at build time to determine if this filter
should be applied to the mapping of the specified properties
|
<D extends B> |
filterDestination(D destinationValue,
Type<?> sourceType,
String sourceName,
Type<D> destType,
String destName,
MappingContext mappingContext)
This method is called to provide the Filter an opportunity to modify the
destination field's value in some way before it is mapped onto the
destination type.
|
boolean |
filtersDestination()
Called at code generation time to determine whether this filter modifies
the destination.
|
<S extends A> |
filterSource(S sourceValue,
Type<S> sourceType,
String sourceName,
Type<?> destType,
String destName,
MappingContext mappingContext)
This method is called to provide the Filter an opportunity to replace the
source field value before it is passed into the mapping code which
transforms it to the destination type.
|
boolean |
filtersSource()
Called at code generation time to determine whether this filter modifies
the source.
|
<S extends A,D extends B> |
shouldMap(Type<S> sourceType,
String sourceName,
S source,
Type<D> destType,
String destName,
D dest,
MappingContext mappingContext)
This method is called at runtime to determine whether the mapping implied
by the field names and types should be performed; if
false
is returned, the mapping is skipped. |
getAType, getBTypeboolean appliesTo(Property source, Property destination)
source - the source propertydestination - the destination propertyboolean filtersSource()
Implementations should not implement dynamic behavior here, as this method will most likely be called only once (at generation time) for a given Filter instance.
boolean filtersDestination()
Implementations should not implement dynamic behavior here, as this method will most likely be called only once (at generation time) for a given Filter instance.
<S extends A,D extends B> boolean shouldMap(Type<S> sourceType, String sourceName, S source, Type<D> destType, String destName, D dest, MappingContext mappingContext)
false
is returned, the mapping is skipped.sourceType - the type of the source fieldsourceName - the name of the source fieldsource - the value of the source fielddestType - the type of the destination fielddestName - the name of the destination fielddest - the value of the destination fieldmappingContext - the current mapping context<D extends B> D filterDestination(D destinationValue, Type<?> sourceType, String sourceName, Type<D> destType, String destName, MappingContext mappingContext)
Note that the return value should still be an instance of the provided destination type, else ClassCastException will likely occur.
destinationValue - the destination valuesourceType - the type of the source fieldsourceName - the name of the source fielddestType - the type of the destination fielddestName - the name of the destination fieldmappingContext - the current mapping context<S extends A> S filterSource(S sourceValue, Type<S> sourceType, String sourceName, Type<?> destType, String destName, MappingContext mappingContext)
It's recommended that the filter should return a new instance if it's necessary to modify the source, as a mapping request is not generally expected to have side effects on the source.
sourceValue - the source valuesourceType - the type of the source fieldsourceName - the name of the source fielddestType - the type of the destination fielddestName - the name of the destination fieldmappingContext - the current mapping contextCopyright © 2019 Glasnost. All rights reserved.