com.sinch.sdk.domains.numbers.adapters.converters.AvailableRegionsDtoConverter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sinch-sdk-java Show documentation
Show all versions of sinch-sdk-java Show documentation
SDK providing a Java API for the Sinch REST APIs.
package com.sinch.sdk.domains.numbers.adapters.converters;
import com.sinch.sdk.domains.numbers.models.NumberType;
import com.sinch.sdk.domains.numbers.models.Region;
import com.sinch.sdk.domains.numbers.models.dto.v1.AvailableRegionDto;
import com.sinch.sdk.domains.numbers.models.dto.v1.ListAvailableRegionsResponseDto;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
public class AvailableRegionsDtoConverter {
public static Collection convert(ListAvailableRegionsResponseDto dto) {
List list = dto.getAvailableRegions();
if (null == list) {
return Collections.emptyList();
}
return list.stream().map(AvailableRegionsDtoConverter::convert).collect(Collectors.toList());
}
public static Region convert(AvailableRegionDto dto) {
return Region.builder()
.setRegionCode(dto.getRegionCode())
.setRegionName(dto.getRegionName())
.setTypes(
null != dto.getTypes()
? dto.getTypes().stream().map(NumberType::from).collect(Collectors.toList())
: null)
.build();
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy