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

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

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