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

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

The newest version!
package com.remondis.remap;

/**
 * An implementation to generalize a {@link Mapper} using {@link InternalMapper}.
 *
 * @param  the source type
 * @param  the destination type.
 */
class MapperAdapter implements InternalMapper {

  private Mapper mapper;

  public MapperAdapter(Mapper mapper) {
    super();
    this.mapper = mapper;
  }

  @Override
  public D map(S source, D destination) {
    return mapper.map(source, destination);
  }

  @Override
  public D map(S source) {
    return mapper.map(source);
  }

  @Override
  public Projection getProjection() {
    Class source = mapper.getMapping()
        .getSource();
    Class destination = mapper.getMapping()
        .getDestination();
    return new Projection<>(source, destination);
  }

  Mapper getMapper() {
    return mapper;
  }

}