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.v1.regions.available.response.AvailableRegion;
import com.sinch.sdk.domains.numbers.models.v1.regions.available.response.AvailableRegionListResponse;
import java.util.Collection;
import java.util.Collections;
import java.util.stream.Collectors;
public class AvailableRegionsDtoConverter {
public static Collection convert(AvailableRegionListResponse dto) {
Collection list = dto.getContent();
if (null == list) {
return Collections.emptyList();
}
return list.stream().map(AvailableRegionsDtoConverter::convert).collect(Collectors.toList());
}
public static Region convert(AvailableRegion dto) {
return Region.builder()
.setRegionCode(dto.getRegionCode())
.setRegionName(dto.getRegionName())
.setTypes(
null != dto.getTypes()
? dto.getTypes().stream()
.map(f -> NumberType.from(f.value()))
.collect(Collectors.toList())
: null)
.build();
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy