use of com.metabroadcast.common.intl.Countries in project atlas-deer by atlasapi.
the class PolicySerialization method deserialize.
public org.atlasapi.content.Policy deserialize(Policy internal) {
if (internal == null) {
return null;
}
org.atlasapi.content.Policy policy = new org.atlasapi.content.Policy();
identifiedSetter.deserialize(policy, internal);
policy.setAvailabilityStart(toDateTime(internal.getAvailabilityStart()));
policy.setAvailabilityEnd(toDateTime(internal.getAvailabilityEnd()));
policy.setDrmPlayableFrom(toDateTime(internal.getDrmPlayableFrom()));
Set<String> availableCountries = internal.getAvailableCountries();
if (availableCountries != null) {
policy.setAvailableCountries(availableCountries.stream().map(Countries::fromCode).collect(Collectors.toSet()));
}
policy.setAvailabilityLength(internal.getAvailabilityLength());
String revenueContract = internal.getRevenueContract();
if (revenueContract != null) {
policy.setRevenueContract(org.atlasapi.content.Policy.RevenueContract.fromKey(revenueContract));
}
policy.setSubscriptionPackages(internal.getSubscriptionPackages());
Price internalPrice = internal.getPrice();
if (internalPrice != null) {
policy.setPrice(price.deserialize(internalPrice));
}
List<Pricing> pricing = internal.getPricing();
if (pricing != null) {
policy.setPricing(pricing.stream().map(this.pricing::deserialize).collect(Collectors.toList()));
}
Long serviceId = internal.getServiceId();
if (serviceId != null) {
policy.setServiceId(Id.valueOf(serviceId));
}
Long playerId = internal.getPlayerId();
if (playerId != null) {
policy.setPlayerId(Id.valueOf(playerId));
}
if (internal.getPlatform() != null) {
policy.setPlatform(org.atlasapi.content.Policy.Platform.fromKey(internal.getPlatform()));
}
if (internal.getNetwork() != null) {
policy.setNetwork(org.atlasapi.content.Policy.Network.fromKey(internal.getNetwork()));
}
policy.setActualAvailabilityStart(toDateTime(internal.getActualAvailabilityStart()));
return policy;
}