[wpilibj] Trigger: implement BooleanSupplier interface (#3811)

This commit is contained in:
Starlight220
2021-12-21 21:33:16 +02:00
committed by GitHub
parent 9f8f330e96
commit b5fd29774f

View File

@@ -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 {
*
* <p>This method will be called repeatedly a command is linked to the Trigger.
*
* <p>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.
*
* <p>This method will be called repeatedly a command is linked to the Trigger.
*
* <p>Functionally identical to {@link Trigger#get()}.
*
* @return whether or not the trigger condition is active.
*/
@Override
public boolean getAsBoolean() {
return m_isActive.getAsBoolean();
}