Search in sources :

Example 1 with Description

use of org.atlasapi.content.v2.model.udt.Description in project atlas-deer by atlasapi.

the class DescriptionSerialization method serialize.

public Description serialize(org.atlasapi.content.Description description) {
    if (description == null) {
        return null;
    }
    Description internal = new Description();
    internal.setTitle(description.getTitle());
    internal.setImage(description.getImage());
    internal.setSynopsis(description.getSynopsis());
    internal.setThumbnail(description.getThumbnail());
    return internal;
}
Also used : Description(org.atlasapi.content.v2.model.udt.Description)

Example 2 with Description

use of org.atlasapi.content.v2.model.udt.Description in project atlas-deer by atlasapi.

the class ItemSummarySerialization method serialize.

public ItemSummary serialize(org.atlasapi.content.ItemSummary itemSummary) {
    ItemSummary internal = new ItemSummary();
    internal.setType("item");
    internal.setTitle(itemSummary.getTitle());
    Optional<String> description = itemSummary.getDescription();
    if (description.isPresent()) {
        internal.setDescription(description.get());
    }
    Optional<String> image = itemSummary.getImage();
    if (image.isPresent()) {
        internal.setImage(image.get());
    }
    Optional<Integer> releaseYear = itemSummary.getReleaseYear();
    if (releaseYear.isPresent()) {
        internal.setReleaseYear(releaseYear.get());
    }
    Optional<ImmutableSet<Certificate>> certificates = itemSummary.getCertificates();
    if (certificates.isPresent()) {
        internal.setCertificate(certificates.get().stream().map(certificate::serialize).filter(Objects::nonNull).collect(Collectors.toSet()));
    }
    if (itemSummary instanceof EpisodeSummary) {
        internal.setType("episode");
        internal.setEpisodeNumber(((EpisodeSummary) itemSummary).getEpisodeNumber().orElse(null));
    }
    return internal;
}
Also used : ImmutableSet(com.google.common.collect.ImmutableSet) EpisodeSummary(org.atlasapi.content.EpisodeSummary) Objects(java.util.Objects) ItemSummary(org.atlasapi.content.v2.model.udt.ItemSummary)

Aggregations

ImmutableSet (com.google.common.collect.ImmutableSet)1 Objects (java.util.Objects)1 EpisodeSummary (org.atlasapi.content.EpisodeSummary)1 Description (org.atlasapi.content.v2.model.udt.Description)1 ItemSummary (org.atlasapi.content.v2.model.udt.ItemSummary)1