net.intelie.pipes.time.PointSpan Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pipes-api Show documentation
Show all versions of pipes-api Show documentation
Intelie Pipes' API classes and interfaces
package net.intelie.pipes.time;
import java.time.ZoneId;
import java.util.Objects;
import static net.intelie.pipes.util.Preconditions.checkNotNull;
public class PointSpan extends TimeSpanBase {
public static final PointSpan NOW = new PointSpan(null);
private static final long serialVersionUID = 1L;
private final Period periods;
public PointSpan(Period periods) {
super(periods == null ? "now" : checkNotNull(periods, "periods") + " ago");
this.periods = periods;
}
@Override
public PointSpan forceZone(ZoneId zone) {
return new PointSpan(forceZone(periods, zone));
}
@Override
public long start(long reference) {
if (periods != null)
reference = periods.sub(reference);
return reference;
}
@Override
public boolean isFixed() {
return false;
}
@Override
public long end(long reference) {
return start(reference);
}
@Override
public boolean isPoint() {
return true;
}
@Override
public boolean includesPresent() {
return periods == null;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof PointSpan)) return false;
PointSpan that = (PointSpan) o;
return Objects.equals(this.periods, that.periods);
}
@Override
public int hashCode() {
return Objects.hash(this.periods);
}
}