简体   繁体   中英

Can I mapping with mapstruct a class that extends from ArrayList<Object>?

Have a problem trying to mapping a Object that extends from Arraylist into a Class that have a List, my code is:

  1. First Class, this extends from ArrayList:
public class ClassOne extends ArrayList<ClassTwo> {}
  1. I need mapping into:
public class ClassTarget {
    private String companyId;
    private List<ObjectTarget> fieldListTarget;
}

When I declare the mapper the error is:

java: Can't generate mapping method from iterable type to non-iterable type.

I think that the error is in extends ArrayList<SomeObject> I don´t know how can I mapping fields with this type of object.

Iterable is an Interface, that a class can implement. An ArrayList implements that, and with that indirectly also your class ClassOne . Have you tried to change your class to

public class ClassTarget implements Iterable {
    ...
}

and implement the necessary methods?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM