com.remondis.remap.ReassignAssertBuilder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of remap Show documentation
Show all versions of remap Show documentation
A declarative mapping library for converting objects field by field.
The newest version!
package com.remondis.remap;
import static com.remondis.remap.Lang.denyNull;
import static com.remondis.remap.MappingConfiguration.getPropertyFromFieldSelector;
import java.beans.PropertyDescriptor;
/**
* This class is used to build an assertion about a reassign operation.
*
* @param
* The source object
* @param
* The destination object
* @param
* The type of the selected field.
*
* @author schuettec
*/
public class ReassignAssertBuilder {
private PropertyDescriptor sourceProperty;
private AssertConfiguration asserts;
private Class destination;
ReassignAssertBuilder(PropertyDescriptor sourceProperty, Class destination, AssertConfiguration asserts) {
super();
this.sourceProperty = sourceProperty;
this.asserts = asserts;
this.destination = destination;
}
/**
* Reassigns a source field to the specified destination field.
*
* @param destinationSelector
* {@link TypedSelector} to select the destination field.
*
* @return Returns the {@link MappingConfiguration} for further mapping configuration.
*/
public AssertConfiguration to(FieldSelector destinationSelector) {
denyNull("destinationSelector", destinationSelector);
PropertyDescriptor destinationProperty = getPropertyFromFieldSelector(Target.DESTINATION, ReassignBuilder.ASSIGN,
this.destination, destinationSelector, asserts.getMapping()
.isFluentSettersAllowed());
ReassignTransformation transformation = new ReassignTransformation(asserts.getMapping(), sourceProperty,
destinationProperty);
asserts.addAssertion(transformation);
return asserts;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy