Skip to content

Method in Record is treated as a fluent setter #3886

@filiphr

Description

@filiphr

I have a very similiar reproducer with Mapstruct Version 1.6.3:

import java.time.LocalDate;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.ReportingPolicy;

@Mapper(unmappedTargetPolicy = ReportingPolicy.ERROR)
public interface RangeMapper {

  @Mapping(target = "validFrom", source = "rangeContainer.a")
  @Mapping(target = "validTo", source = "rangeContainer.b")
  RangeRecord toRange(RangeContainer rangeContainer);

  record RangeRecord(LocalDate validFrom, LocalDate validTo) {

    public RangeRecord restrictTo(RangeRecord other) {
      return null;
    }
  }

  class RangeContainer {
    private LocalDate a;
    private LocalDate b;

    public LocalDate getA() {
      return a;
    }

    public void setA(LocalDate a) {
      this.a = a;
    }

    public LocalDate getB() {
      return b;
    }

    public void setB(LocalDate b) {
      this.b = b;
    }
  }

}

On compile I get the error Unmapped target property: "restrictTo"..

Originally posted by @sbluemel in #3146

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions