All Downloads are FREE. Search and download functionalities are using the official Maven repository.

mb.pie.api.Output.kt Maven / Gradle / Ivy

The newest version!
package mb.pie.api

import java.io.Serializable

/**
 * Type for task outputs. It must adhere to the following properties:
 *
 * * Implements [Serializable].
 * * Implements [equals][Object.equals] and [hashCode][Object.hashCode].
 *
 * Failure to adhere to these properties will cause unsound incrementality.
 */
typealias Out = Serializable?


/**
 * Wrapper for transient outputs; outputs that cannot be serialized. A transient output will be recreated when an attempt is made to
 * deserialize it, and then cached.
 */
interface OutTransient : Out {
  val v: T
  val consistent: Boolean
}

data class OutTransientImpl(
  @Transient override val v: T,
  @Transient override val consistent: Boolean = false
) : OutTransient {
  constructor(v: T) : this(v, true)
}


/**
 * Specialization of [OutTransient], where a serializable value [e] is used for change detection through equality.
 */
interface OutTransientEquatable : OutTransient {
  val e: E
}

data class OutTransientEquatableImpl(
  @Transient override val v: T,
  @Transient override val consistent: Boolean = false,
  override val e: E
) : OutTransientEquatable {
  constructor(v: T, e: E) : this(v, true, e)
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy