My related class:
package net.gencat.transversal.espaidoc.domain.model.reference;
import java.util.UUID;
import lombok.Getter;
@Getter
public class ReferenceId {
private final UUID id;
private ReferenceId(UUID id) {
validate(id);
this.id = id;
}
public static ReferenceId of(UUID id) {
return new ReferenceId(id);
}
private static void validate(UUID id) {
if (id == null) {
throw new IllegalArgumentException("Value cannot be null or empty");
}
}
}
As you can see, my factory method is of(UUID id).
When I'm trying to create a Mapper related with ReferenceId class,I'm getting:
ReferenceId does not have an accessible constructor.
How could I instruct to mapstruct that uses of(... factory methods instead of...?
AFAIK Mapstruct needs at least a public non arg c'tor or any other, annotated with
@Defaultor a factory class.C'tor only
privatecannot work, because the mapper class that Mapstruct creates must instantiate an object of the target class.Anyway, I do not see the difference to use
of()or, then public, c'torReferenceId(UUID id).