package SuMoC.backend.trend.dto; import SuMoC.backend.notification.interfaces.Notifieable; import SuMoC.backend.trend.enums.*; import lombok.Data; import lombok.NoArgsConstructor; @Data @NoArgsConstructor public class TrendDetectionDTO implements Notifieable { private Long userId; private TrendTimespan timespan; private TrendType type; private StatAttribute attribute; private DeltaType deltaType; private double changeValue; private TrendConnotation trendConnotation; public TrendDetectionDTO(Long userId, TrendTimespan timespan, TrendType type, StatAttribute attribute, DeltaType deltaType, double changeValue) { this.userId = userId; this.timespan = timespan; this.type = type; this.attribute = attribute; this.deltaType = deltaType; this.changeValue = changeValue; this.trendConnotation = getTrendConnotation(); } public static TrendDetectionDTO mockTrendDetectionDTO() { return new TrendDetectionDTO(null, TrendTimespan.WEEKLY, TrendType.INCREASING, StatAttribute.CAR_DISTANCE, DeltaType.ABSOLUTE, 15.0); } public TrendConnotation getTrendConnotation() { if (this.type == TrendType.INCREASING) { return switch (attribute) { case CAR_DISTANCE -> TrendConnotation.NEGATIVE; default -> TrendConnotation.NEUTRAL; }; } else if (type == TrendType.DECREASING) { return switch (attribute) { case CAR_DISTANCE -> TrendConnotation.POSITIVE; default -> TrendConnotation.NEUTRAL; }; } else { return TrendConnotation.NEUTRAL; } } }