All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.remondis.remap.SetAssertBuilder Maven / Gradle / Ivy

There is a newer version: 4.3.7
Show newest version
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;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy