'MapStruct. Mapping fields of list element by expression

Good afternoon! There is an object that contains field as type List, is it possible to set each (some) field of type T, by values generated in the annotation by the expression parameter?

For example:

Target object:

public class CustomList<T extends CustomEntity> extends CustomEntity {
    
    private List<T> field;
    
    public CustomList() {
        field = new ArrayList();
    }
}

Mapper interface:

@Mapper
public interface Mapper {
    @Mapping(target = "java(field.foreach(f -> f.getId))", expression = "java(UUID.randomUUID().toString())")
    CustomList<SomeObject> map (Object object);
}

How can such an idea be implemented? In the documentation, I found only examples with 1:1 mapping.

Edited:

Also, i try to use this:

public class IterableNonIntegrableUtil {

  @SetElements
  public CustomList<SomeObject> map(Object object) {
    CustomList<SomeObject> customList= new CustomList<>();
    customList.getField()
        .forEach(item -> item.setUid(UUID.randomUUID().toString()));
    return customList;
  }}




@Qualifier
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.CLASS)
public @interface SetElements{}



Mapper interface:
@Mapper(uses = IterableNonIntegrableUtil.class)
    public interface Mapper {
        @Mapping(target = "field", souce = "object", 
qualifiedBy=SetElements.class)
        CustomList<SomeObject> map (Object object);}

But in this case i have some error with Qualifier.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source