in src/main/java/com/spotify/heroic/client/api/query/DateRange.kt [43:79]
fun multiply(factor: Long): DateRange
/**
* Build a readable diff.
*
* <p>Like "10 seconds", or "2 hours".
*/
fun toReadableDiff(): String
@JsonTypeName("relative")
data class Relative(val unit: TimeUnit, val value: Long) : DateRange {
companion object {
@JvmStatic
fun withTime(unit: TimeUnit, value: Long) : Relative {
return Relative(unit, value)
}
}
override fun diff(unit: TimeUnit): Long {
return unit.convert(value, this.unit)
}
override fun multiply(factor: Long): DateRange {
return Relative(unit, this.value * factor)
}
override fun toReadableDiff(): String {
return String.format("%d %s", value, unit.toString().toLowerCase(Locale.ENGLISH))
}
@JsonCreator
constructor(
@JsonProperty("unit") unit: String,
@JsonProperty("value") value: Long
): this(TimeUnit.valueOf(unit.toUpperCase(Locale.ENGLISH)), value)
}