I receive a List of MediaDTO and this Object has two attributes:
String sizeType and String URL.

In 'sizeType' comes the image´s size: small, medium, large, and thumbnail.

So I have to filter the sizeType of these objects and create 4 new lists based on them.

This is how I get the List<MediaDTO> mediaDTO:

`medias=[MediaDTO(sizeType=THUMBNAIL, liveloUrl=https://s3.sao01.cloud-object-storage.appdomain.cloud/catalog-media-storage/id-source/productId/skuseller2/thumbnail/celular-iphone-11-azul.png), MediaDTO(sizeType=SMALL, liveloUrl=https://s3.sao01.cloud-object-storage.appdomain.cloud/catalog-media-storage/id-source/productId/skuseller2/small/celular-iphone-11-azul.png), MediaDTO(sizeType=SMALL, liveloUrl=https://s3.sao01.cloud-object-storage.appdomain.cloud/catalog-media-storage/id-source/productId/skuseller2/medium/celular-iphone-11-azul.png), MediaDTO(sizeType=LARGE, liveloUrl=https://s3.sao01.cloud-object-storage.appdomain.cloud/catalog-media-storage/id-source/productId/skuseller2/large/celular-iphone-11-azul.png), MediaDTO(sizeType=THUMBNAIL, liveloUrl=https://s3.sao01.cloud-object-storage.appdomain.cloud/catalog-media-storage/id-source/productId/skuseller2/thumbnail/celular-iphone-11-vermelho.png), MediaDTO(sizeType=SMALL, liveloUrl=https://s3.sao01.cloud-object-storage.appdomain.cloud/catalog-media-storage/id-source/productId/skuseller2/small/celular-iphone-11-vermelho.png), MediaDTO(sizeType=MEDIUM, liveloUrl=https://s3.sao01.cloud-object-storage.appdomain.cloud/catalog-media-storage/id-source/productId/skuseller2/medium/celular-iphone-11-vermelho.png), MediaDTO(sizeType=LARGE, liveloUrl=https://s3.sao01.cloud-object-storage.appdomain.cloud/catalog-media-storage/id-source/productId/skuseller2/large/celular-iphone-11-vermelho.png)]`

I achieved filtering for one of the sizes. This works!
However, I could not figure out how can I filter over the 4 sizes and create 4 new lists of it.

If I fix some error another appears ... so I´m really stuck.
And by the way I´ve been searching for a solution on the internet and in the forum for a couple of days but did´nt find something that fits.

If someone might help, I´d really be grateful.

I was thinking about using a 'forEach' to filter but even like that, I could filter just one size.
Thanks in advance.

\*\*This is what I got till now: \*\*

```java
public class ProcessProductDTO {
    String processId;
    OperationProcess operation;
    String categoryId;
    ProductDTO productDTO;
}

public class ProductDTO {
    String id;
    Boolean active;
    String displayName;
    String longDescription;
    List<MediaDTO> medias;
    List<AttributeDTO> attributes;
}

public class MediaDTO {
    String sizeType;
    String liveloUrl;
}

```

```java
    public Properties toOccProductPropertiesDTO(ProcessProductDTO processProductDTO) throws JsonProcessingException { 

    String pSpecs = convertAttributes(processProductDTO.getProductDTO().getAttributes()); 
    //List<String> medias = convertMedias(processProductDTO.getProductDTO().getMedias()); 
    return Properties.builder() 
    .id(processProductDTO.getProductDTO().getId()) .active(processProductDTO.getProductDTO().getActive()) 
    .listPrices(new HashMap()) 
    .p_specs(pSpecs) 
    //.medias(medias) 
    .displayName(processProductDTO.getProductDTO()
    .getDisplayName()) 
    .longDescription(processProductDTO.getProductDTO().getLongDescription()) 
    .build(); }

    private String convertAttributes(List<AttributeDTO> attributes) throws JsonProcessingException {
        Map<String, String> attribs = attributes.stream()
                .collect(Collectors.toMap(AttributeDTO::getName, AttributeDTO::getValue));
        return objectMapper.writeValueAsString(attribs);
    }

    private List<MediaDTO> convertMedias(ProcessProductDTO processProduct, List<MediaDTO> mediaDTO){
        List<MediaDTO> filteredList = processProduct.getProductDTO().getMedias();
        Set<String> filterSet = mediaDTO.stream().map(MediaDTO::getSizeType).collect(Collectors.toSet());

        return filteredList.stream().filter(url -> filterSet.contains("SMALL")).collect(Collectors.toList());
    }

```

**UPDATE**

I got the following result:

```
    private Properties toOccProductPropertiesDTO(ProcessProductDTO processProductDTO) throws JsonProcessingException {
    String pSpecs = convertAttributes(processProductDTO.getProductDTO().getAttributes());
    MediaOccDTO medias = convertMedias(processProductDTO.getProductDTO().getMedias());
    return Properties.builder()
            .id(processProductDTO.getProductDTO().getId())
            .active(processProductDTO.getProductDTO().getActive())
            .listPrices(new HashMap())
            .p_specs(pSpecs)
            .medias(medias)
            .displayName(processProductDTO.getProductDTO().getDisplayName())
            .longDescription(processProductDTO.getProductDTO().getLongDescription())
            .build();
}

private MediaOccDTO convertMedias(List<MediaDTO> mediaDTOs){
    String smallImageUrls = generateOccUrl(mediaDTOs, ImageSizeType.SMALL);
    String mediumImageUrls = generateOccUrl(mediaDTOs, ImageSizeType.MEDIUM);
    String largeImageUrls = generateOccUrl(mediaDTOs, ImageSizeType.LARGE);
    String thumbImageUrls = generateOccUrl(mediaDTOs, ImageSizeType.THUMB);
    return MediaOccDTO.builder()
            .p_smallImageUrls(smallImageUrls)
            .p_mediumImageUrls(mediumImageUrls)
            .p_largeImageUrls(largeImageUrls)
            .p_thumbImageUrls(thumbImageUrls)
            .build();
}

private String generateOccUrl(List<MediaDTO> mediaDTOs, ImageSizeType imageSizeType){
    return mediaDTOs.stream()
            .filter(m -> m.getSizeType().equals(imageSizeType))
            .map(MediaDTO::getLiveloUrl)
            .reduce(",", String::concat);
}

```

The problem is:

the comparison: m.getSizeType().equals(imageSizeType)
is always false, so the list gets created empty...