package org.texttechnologylab.project.gruppe_05_1.domain.nlp.html;

import java.util.Objects;

/**
 * Diese Klasse ordnet das entspreche Sentiment zu einem Satz zu.
 * Sie ist ein Datencontainer für die Darstellung über FreeMarker
 */
public class SentimentOfSentence {
    int         begin;
    int         end;
    String      text;
    // RGBA Werte für die Darstellung
    float  sentiment;      // overall sentiment --> wird für den alpha (Opaque) Wert verwendet --> 0..1
    int  negative;          // red --> 0..255
    int  neutral;           // 0..255, wird momentan nicht benutzt
    int  positive;          // green --> 0..255

    public SentimentOfSentence() {}

    public SentimentOfSentence(int begin, int end, String text, float sentiment, int negative, int neutral, int positive) {
        this.begin = begin;
        this.end = end;
        this.text = text;
        this.sentiment = sentiment;
        this.negative = negative;
        this.neutral = neutral;
        this.positive = positive;
    }

    public int getBegin() {
        return begin;
    }

    public void setBegin(int begin) {
        this.begin = begin;
    }

    public int getEnd() {
        return end;
    }

    public void setEnd(int end) {
        this.end = end;
    }

    public String getText() {
        return text;
    }

    public void setText(String text) {
        this.text = text;
    }

    public float getSentiment() {
        return sentiment;
    }

    public void setSentiment(float sentiment) {
        this.sentiment = sentiment;
    }

    public int getNegative() {
        return negative;
    }

    public void setNegative(int negative) {
        this.negative = negative;
    }

    public int getNeutral() {
        return neutral;
    }

    public void setNeutral(int neutral) {
        this.neutral = neutral;
    }

    public int getPositive() {
        return positive;
    }

    public void setPositive(int positive) {
        this.positive = positive;
    }

    @Override
    public boolean equals(Object o) {
        if (!(o instanceof SentimentOfSentence that)) return false;
        return begin == that.begin && end == that.end && Double.compare(sentiment, that.sentiment) == 0 && Double.compare(negative, that.negative) == 0 && Double.compare(neutral, that.neutral) == 0 && Double.compare(positive, that.positive) == 0 && Objects.equals(text, that.text);
    }

    @Override
    public int hashCode() {
        return Objects.hash(begin, end, text, sentiment, negative, neutral, positive);
    }

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder("SentimentOfSentence{");
        sb.append("begin=").append(begin);
        sb.append(", end=").append(end);
        sb.append(", text='").append(text).append('\'');
        sb.append(", sentiment=").append(sentiment);
        sb.append(", negative=").append(negative);
        sb.append(", neutral=").append(neutral);
        sb.append(", positive=").append(positive);
        sb.append('}');
        return sb.toString();
    }
}

