package com.flipkart.foxtrot.common.query.datetime;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.flipkart.foxtrot.common.query.Filter;
import com.flipkart.foxtrot.common.query.FilterOperator;
import com.flipkart.foxtrot.common.query.FilterVisitor;
import com.google.common.base.Strings;
import io.dropwizard.util.Duration;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;

import javax.validation.constraints.NotNull;

@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class LastFilter extends Filter {

    private long currentTime;

    private RoundingMode roundingMode;

    @NotNull
    private Duration duration;

    public LastFilter() {
        super(FilterOperator.last);
        currentTime = System.currentTimeMillis();
        super.setField("_timestamp");
    }

    @Builder
    public LastFilter(String field, long currentTime, Duration duration, RoundingMode roundingMode) {
        super(FilterOperator.last);
        super.setField(Strings.isNullOrEmpty(field) ? "_timestamp" : field);
        this.currentTime = currentTime == 0 ? System.currentTimeMillis() : currentTime;
        this.duration = duration;
        this.roundingMode = roundingMode == null ? RoundingMode.NONE : roundingMode;
    }

    public void setDuration(Duration duration) {
        this.duration = duration;
        this.roundingMode = roundingMode == null ? RoundingMode.NONE : roundingMode;
    }

    @Override
    public <T> T accept(FilterVisitor<T> visitor) {
        return visitor.visit(this);
    }

    @JsonIgnore
    public TimeWindow getWindow() {
        return WindowUtil.calculate(currentTime, duration, roundingMode);
    }

    @Override
    @JsonIgnore
    public boolean isFilterTemporal() {
        return true;
    }

}

@@ -1590,24 +1590,122 @@
 is);%0A    %7D%0A%0A
+    @Override%0A    @JsonIgnore%0A    public boolean isFilterTemporal() %7B%0A        return true;%0A    %7D%0A%0A
     @JsonIgn
@@ -1700,32 +1700,32 @@
     @JsonIgnore%0A
-
     public TimeW
@@ -1847,79 +1847,1160 @@
     
-@JsonIgnore%0A    public boolean isFilterTemporal() %7B%0A        return true
+public int hashCode() %7B%0A        int result = getOperator().hashCode();%0A        result = 31 * result + getField().hashCode();%0A        if (!getField().equals(%22_timestamp%22)) %7B%0A            result = result * 21 + (getCurrentTime() == 0%0A                                    ? 43%0A                                    : Long.valueOf(getCurrentTime()).hashCode());%0A        %7D%0A        else %7B%0A            result = result * 21 + Long.valueOf(getCurrentTime() / (long) 30000).hashCode();%0A        %7D%0A        result = result * 13 + getRoundingMode().name().hashCode();%0A        result = result * 7 + getDuration().toString().hashCode();%0A        return result;%0A    %7D%0A%0A    @Override%0A    public boolean equals(Object o) %7B%0A        if (this == o) %7B%0A            return true;%0A        %7D%0A        else if (!(o instanceof LastFilter)) %7B%0A            return false;%0A        %7D%0A%0A        LastFilter that = (LastFilter) o;%0A%0A        return getField().equals(that.getField()) && getOperator().equals(that.getOperator()) &&%0A                getDuration().equals(that.getDuration()) && getRoundingMode().equals(that.getRoundingMode()) &&%0A                getCurrentTime() == that.getCurrentTime()
 ;%0A  

Fix cache issue