package fr.alecharp.picshare.domain;

import com.google.common.collect.Sets;

import java.time.LocalDate;
import java.util.*;

/**
 * @author Adrien Lecharpentier
 */
public class Event {
    private String id;

    private String title;
    private LocalDate date;
    private Set<Picture> pictures = new TreeSet<>(
            (p1, p2) -> p1.title().compareTo(p2.title())
    );

    private Event() {
        this(null, null);
    }

    public Event(String title, LocalDate date) {
        this.id = UUID.randomUUID().toString();
        this.title = title;
        this.date = date;
    }

    public String id() {
        return id;
    }

    public String title() {
        return title;
    }

    public LocalDate date() {
        return date;
    }

    public Set<Picture> pictures() {
        return Collections.unmodifiableSet(pictures);
    }

    public Event pictures(Set<Picture> pictures) {
        this.pictures.addAll(Sets.newHashSet(pictures));
        return this;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Event event = (Event) o;
        return Objects.equals(title, event.title) &&
                Objects.equals(date, event.date);
    }

    @Override
    public int hashCode() {
        return Objects.hash(date);
    }
}

@@ -35,47 +35,8 @@
 n;%0A%0A
-import com.google.common.collect.Sets;%0A
 %0Aimp
@@ -897,24 +897,8 @@
 All(
-Sets.newHashSet(
 pict
@@ -902,17 +902,16 @@
 ictures)
-)
 ;%0A      

Remove useless usage of