According to JEP 395 a record with additional constructors can be used:
public record Aliases(List<String> value) {
public Aliases(Integer raw) {
this(List.of(raw.toString()));
}
}
Or with multiple values as array:
public record Aliases(List<String> value) {
public Aliases(Integer... raws) {
this(Arrays.stream(raws).map(Object::toString).toList());
}
}
Where as using a typed List is not working:
public record Aliases(List<String> value) {
public Aliases(List<Integer> rawList) {
this(rawList.stream().map(Object::toString).toList());
}
}
It says
error: invalid canonical constructor in record Aliases
I would like to understand what is happening in behind and why it is not working?