com.remondis.remap.SetAssertBuilder 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.
package com.remondis.remap;
/**
* Builder to assert a set operation on a {@link Mapper} object using {@link AssertConfiguration}.
*
* @param The source type
* @param The destination type
* @param The type of the destination field
* @author schuettec
*/
public class SetAssertBuilder {
private TypedPropertyDescriptor destProperty;
private AssertConfiguration asserts;
SetAssertBuilder(TypedPropertyDescriptor destProperty, AssertConfiguration asserts) {
super();
this.destProperty = destProperty;
this.asserts = asserts;
}
/**
* Expects a set-mapping with a function providing a value.
*
* @return Returns the {@link AssertConfiguration} for further configuration.
*/
public AssertConfiguration withFunction() {
SetTransformation replace = new SetTransformation<>(asserts.getMapping(), destProperty.property, null);
asserts.addAssertion(replace);
return asserts;
}
/**
* Expects a set-mapping with a value supplier.
*
* @return Returns the {@link AssertConfiguration} for further configuration.
*/
public AssertConfiguration withSupplier() {
SetSupplierTransformation replace = new SetSupplierTransformation<>(asserts.getMapping(),
destProperty.property, null);
asserts.addAssertion(replace);
return asserts;
}
/**
* Expects a set-mapping with a value.
*
* @return Returns the {@link AssertConfiguration} for further configuration.
*/
public AssertConfiguration withValue() {
SetValueTransformation replace = new SetValueTransformation<>(asserts.getMapping(), destProperty.property,
null);
asserts.addAssertion(replace);
return asserts;
}
}