package com.apobates.forum.core.entity.proxy;

import com.apobates.forum.core.entity.TopicCarousel;
import com.apobates.forum.core.entity.TopicCarouselSlide;
import com.apobates.forum.utils.lang.ForumReplicable;
import java.util.Set;
import java.util.TreeSet;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 *
 * @author xiaofanku
 * @since 20200614
 */
public final class TopicCarouselReplica extends TopicCarousel implements ForumReplicable<TopicCarousel,TopicCarouselReplica>{
    //幻灯片集合
    private Set<TopicCarouselSlide> slides = new TreeSet<>();
    public static Function<TopicCarousel,TopicCarouselReplica> copyCarousel = (TopicCarousel topicCarousel) -> {
        return ForumReplicable.replica(topicCarousel, TopicCarouselReplica.class).orElseGet(TopicCarouselReplica::new);
    };
    
    public Set<TopicCarouselSlide> getSlides() {
        return slides;
    }
    
    public void setSlides(Set<TopicCarouselSlide> slides) {
        this.slides = slides;
    }
    
    public void setSlides(Stream<TopicCarouselSlide> slides){
        this.slides = slides.collect(Collectors.toSet());
    }
}