From b5fd29774f0870c81192293c1e3232676a795908 Mon Sep 17 00:00:00 2001 From: Starlight220 <53231611+Starlight220@users.noreply.github.com> Date: Tue, 21 Dec 2021 21:33:16 +0200 Subject: [PATCH] [wpilibj] Trigger: implement BooleanSupplier interface (#3811) --- .../first/wpilibj2/command/button/Trigger.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/button/Trigger.java b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/button/Trigger.java index 029d2fd93f..edf20f4d56 100644 --- a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/button/Trigger.java +++ b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/button/Trigger.java @@ -24,7 +24,7 @@ import java.util.function.BooleanSupplier; * certain sensor input). For this, they only have to write the {@link Trigger#get()} method to get * the full functionality of the Trigger class. */ -public class Trigger { +public class Trigger implements BooleanSupplier { private final BooleanSupplier m_isActive; /** @@ -49,9 +49,25 @@ public class Trigger { * *

This method will be called repeatedly a command is linked to the Trigger. * + *

Functionally identical to {@link Trigger#getAsBoolean()}. + * * @return whether or not the trigger condition is active. */ public boolean get() { + return this.getAsBoolean(); + } + + /** + * Returns whether or not the trigger is active. + * + *

This method will be called repeatedly a command is linked to the Trigger. + * + *

Functionally identical to {@link Trigger#get()}. + * + * @return whether or not the trigger condition is active. + */ + @Override + public boolean getAsBoolean() { return m_isActive.getAsBoolean(); }