Skip to content

Commit

Permalink
Merge pull request #14 from neonailol/5
Browse files Browse the repository at this point in the history
#5 - Port Func interface across platforms
  • Loading branch information
neonailol committed Jan 21, 2018
2 parents 03e0c77 + 92c5631 commit 5b9b931
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 6 deletions.
6 changes: 6 additions & 0 deletions kactoos-common/src/main/kotlin/nnl/rocks/kactoos/Aliases.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,9 @@ internal typealias KText = () -> String
* @since 0.2
*/
internal typealias KBiFunc<X, Y, Z> = (X, Y) -> Z

/**
* Alias for [Func]
* @since 0.2
*/
internal typealias KFunc<X, Y> = (X) -> Y
18 changes: 18 additions & 0 deletions kactoos-common/src/main/kotlin/nnl/rocks/kactoos/Func.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package nnl.rocks.kactoos

/**
* Function.
*
* @since 0.2
*/
expect interface Func<in X : Any, out Y : Any> {

/**
* Apply it.
*
* @param input The argument
* @return The result of type [Y]
* @since 0.2
*/
fun apply(input: X): Y
}
18 changes: 18 additions & 0 deletions kactoos-js/src/main/kotlin/nnl/rocks/kactoos/Func.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package nnl.rocks.kactoos

/**
* Function.
*
* @since 0.2
*/
actual interface Func<in X : Any, out Y : Any> {

/**
* Apply it.
*
* @param input The argument
* @return The result of type [Y]
* @since 0.2
*/
actual fun apply(input: X): Y
}
10 changes: 4 additions & 6 deletions kactoos-jvm/src/main/kotlin/nnl/rocks/kactoos/Func.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,17 @@ package nnl.rocks.kactoos
* @see nnl.rocks.kactoos.func.UncheckedFunc
* @see nnl.rocks.kactoos.func.IoCheckedFunc
*
* @since 0.1
* @since 0.2
*/
@FunctionalInterface
interface Func<in X : Any, out Y : Any> {
actual interface Func<in X : Any, out Y : Any> {

/**
* Apply it.
* @param input The argument
* @return The result
* @return The result of type [Y]
* @throws Exception If fails
*/
@Throws(Exception::class)
fun apply(input: X): Y
actual fun apply(input: X): Y
}

internal typealias KFunc<X, Y> = (X) -> Y
18 changes: 18 additions & 0 deletions kactoos-native/src/main/kotlin/nnl/rocks/kactoos/Func.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package nnl.rocks.kactoos

/**
* Function.
*
* @since 0.2
*/
actual interface Func<in X : Any, out Y : Any> {

/**
* Apply it.
*
* @param input The argument
* @return The result of type [Y]
* @since 0.2
*/
actual fun apply(input: X): Y
}

0 comments on commit 5b9b931

Please sign in to comment.