From 00dbaf6e20a517939582a1e3e9fd510ac16140dc Mon Sep 17 00:00:00 2001 From: iseki Date: Fri, 22 Mar 2024 19:27:23 +0800 Subject: [PATCH] feat: add componentN for Kotlin destruct-assign --- api/cmdpipe.api | 3 +++ src/main/java/space/iseki/cmdpipe/Cmd.java | 27 ++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/api/cmdpipe.api b/api/cmdpipe.api index 1662614..be0c14a 100644 --- a/api/cmdpipe.api +++ b/api/cmdpipe.api @@ -45,6 +45,9 @@ public abstract interface class space/iseki/cmdpipe/Cmd$StreamProcessor { public abstract interface class space/iseki/cmdpipe/Cmd$StreamProcessor$Ctx { public abstract fun cmd ()Lspace/iseki/cmdpipe/Cmd; + public fun component1 ()Lspace/iseki/cmdpipe/Cmd; + public fun component2 ()Lspace/iseki/cmdpipe/Cmd$Stdio; + public fun component3 ()Ljava/lang/Object; public fun getCmd ()Lspace/iseki/cmdpipe/Cmd; public fun getStdio ()Lspace/iseki/cmdpipe/Cmd$Stdio; public fun getStream ()Ljava/lang/Object; diff --git a/src/main/java/space/iseki/cmdpipe/Cmd.java b/src/main/java/space/iseki/cmdpipe/Cmd.java index c5d2443..3d83d80 100644 --- a/src/main/java/space/iseki/cmdpipe/Cmd.java +++ b/src/main/java/space/iseki/cmdpipe/Cmd.java @@ -169,6 +169,33 @@ interface Ctx { default @NotNull T getStream() { return stream(); } + + /** + * Get the command. + * + * @return the command + */ + default @NotNull Cmd component1() { + return cmd(); + } + + /** + * Get the standard IO stream. + * + * @return the standard IO stream + */ + default @NotNull Stdio component2() { + return stdio(); + } + + /** + * Get the stream. + * + * @return the stream + */ + default @NotNull T component3() { + return stream(); + } } @FunctionalInterface