mardi 26 octobre 2021

Convert List to Iterable by mapping values?

I have the following method taking a generic interface:

protected Iterable<Category> getEntity() {

    List<CategoryDTO> categoryList = categoryService.findAll();

    // now I need to set an Iterable<Category> list and return it
    // ... ???
    Iterable<Category> iterable;
    return iterable;
}

But as it is impossible to create interface instance, I have really no idea how to fill Iterable<Category> list and return it.

Here is my Category interface that I am trying to set and return:

public interface Category {
    String getName();

    String getItemType();
}

How can I fix that problem?

Aucun commentaire:

Enregistrer un commentaire