fun toReadableDiff()

in src/main/java/com/spotify/heroic/client/api/query/DateRange.kt [51:79]


    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)
    }