package com.ssj.service.kmt.dto;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.TreeSet;

import static java.util.stream.Collectors.collectingAndThen;
import static java.util.stream.Collectors.toCollection;

public class KnowHowDetailsDTO implements Serializable {

    private static final long serialVersionUID = 8294356977626600268L;

    private String id;
    private String name;
    private List<TestPointDTO> points;
    private boolean selected = false;
    private String wrongCount;
    private String correctCount;
    private String grade;
    private String versionName;
    private int semester;
    private String howName;

    public KnowHowDetailsDTO (){

    }

    public KnowHowDetailsDTO (String id, String name) {
        this.id = id;
        this.name = name;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public List<TestPointDTO> getPoints() {
        return points;
    }

    public void setPoints(List<TestPointDTO> points) {
        this.points = points.stream().collect(collectingAndThen(
                toCollection(() -> new TreeSet<>(Comparator.comparing(TestPointDTO::getId))), ArrayList::new));
    }

    public void addPoint (TestPointDTO pointDTO){
        if (points == null) {
            points = new ArrayList<>();
        }
        points.add(pointDTO);
    }

    public boolean isSelected() {
        return selected;
    }

    public void setSelected(boolean selected) {
        this.selected = selected;
    }

    public String getWrongCount() {
        return wrongCount;
    }

    public void setWrongCount(String wrongCount) {
        this.wrongCount = wrongCount;
    }

    public String getCorrectCount() {
        return correctCount;
    }

    public void setCorrectCount(String correctCount) {
        this.correctCount = correctCount;
    }

    public String getGrade() {
        return grade;
    }

    public void setGrade(String grade) {
        this.grade = grade;
    }

    public String getVersionName() {
        return versionName;
    }

    public void setVersionName(String versionName) {
        this.versionName = versionName;
    }

    public int getSemester() {
        return semester;
    }

    public void setSemester(int semester) {
        this.semester = semester;
    }

    public String getHowName() {
        return howName;
    }

    public void setHowName(String howName) {
        this.howName = howName;
    }
}
