Repository: square/okhttp
File: okhttp/src/main/kotlin/okhttp3/CacheControl.kt (Kotlin)

Code before:

    /** Don't accept an unvalidated cached response. */
    fun noCache() = commonNoCache()

    /** Don't store the server's response in any cache. */
    fun noStore() = commonNoStore()

    /**
     * Only accept the response if it is in the cache. If the response isn't cached, a `504
     * Unsatisfiable Request` response will be returned.
     */
    fun onlyIfCached() = commonOnlyIfCached()

    /** Don't accept a transformed response. */
    fun noTransform() = commonNoTransform()

    fun immutable() = commonImmutable()

    /**
     * Sets the maximum age of a cached response. If the cache response's age exceeds [maxAge], it
     * will not be used and a network request will be made.
     *
     * @param maxAge a non-negative duration. This is stored and transmitted with [TimeUnit.SECONDS]
     *     precision; finer precision will be lost.
     */
    @JvmSynthetic // Don't expose @JvmInline types in the Java API.
    fun maxAge(maxAge: Duration) = apply {
      require(maxAge.inWholeSeconds >= 0) { "maxAge < 0: ${maxAge.inWholeSeconds}" }
      maxAgeSeconds = maxAge.inWholeSeconds.commonClampToInt()
    }

    @JvmSynthetic // Don't expose @JvmInline types in the Java API.
    fun maxStale(maxStale: Duration) = apply {
      require(maxStale.inWholeSeconds >= 0) { "maxStale < 0: ${maxStale.inWholeSeconds}" }
      maxStaleSeconds = maxStale.inWholeSeconds.commonClampToInt()
    }

    @JvmSynthetic // Don't expose @JvmInline types in the Java API.
    fun minFresh(minFresh: Duration) = apply {
      require(minFresh.inWholeSeconds >= 0) { "minFresh < 0: ${minFresh.inWholeSeconds}" }
      minFreshSeconds = minFresh.inWholeSeconds.commonClampToInt()
    }

    /**
     * Sets the maximum age of a cached response. If the cache response's age exceeds [maxAge], it
     * will not be used and a network request will be made.
     *
     * @param maxAge a non-negative integer. This is stored and transmitted with [TimeUnit.SECONDS]
     *     precision; finer precision will be lost.
     */
    fun maxAge(

Review comment (suggestion):
You shouldn't need any of these annotations as functions accepting value types should already have their names mangled to include a hypen which is an invalid character in Java method names. The API dump should confirm.

Code after:

    /** Don't accept an unvalidated cached response. */
    fun noCache() = commonNoCache()

    /** Don't store the server's response in any cache. */
    fun noStore() = commonNoStore()

    /**
     * Only accept the response if it is in the cache. If the response isn't cached, a `504
     * Unsatisfiable Request` response will be returned.
     */
    fun onlyIfCached() = commonOnlyIfCached()

    /** Don't accept a transformed response. */
    fun noTransform() = commonNoTransform()

    fun immutable() = commonImmutable()

    /**
     * Sets the maximum age of a cached response. If the cache response's age exceeds [maxAge], it
     * will not be used and a network request will be made.
     *
     * @param maxAge a non-negative duration. This is stored and transmitted with [TimeUnit.SECONDS]
     *     precision; finer precision will be lost.
     */
    fun maxAge(maxAge: Duration) =
      apply {
        val maxAgeSeconds = maxAge.inWholeSeconds
        require(maxAgeSeconds >= 0) { "maxAge < 0: $maxAgeSeconds" }
        this.maxAgeSeconds = maxAgeSeconds.commonClampToInt()
      }

    fun maxStale(maxStale: Duration) =
      apply {
        val maxStaleSeconds = maxStale.inWholeSeconds
        require(maxStaleSeconds >= 0) { "maxStale < 0: $maxStaleSeconds" }
        this.maxStaleSeconds = maxStaleSeconds.commonClampToInt()
      }

    fun minFresh(minFresh: Duration) =
      apply {
        val minFreshSeconds = minFresh.inWholeSeconds
        require(minFreshSeconds >= 0) { "minFresh < 0: $minFreshSeconds" }
        this.minFreshSeconds = minFreshSeconds.commonClampToInt()
      }

    /**
     * Sets the maximum age of a cached response. If the cache response's age exceeds [maxAge], it
     * will not be used and a network request will be made.
     *
     * @param maxAge a non-negative integer. This is stored and transmitted with [TimeUnit.SECONDS]