diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/smartdashboard/SendableBuilderImpl.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/smartdashboard/SendableBuilderImpl.java index a14ee7dc46..6c07fe355d 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/smartdashboard/SendableBuilderImpl.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/smartdashboard/SendableBuilderImpl.java @@ -9,6 +9,7 @@ import edu.wpi.first.networktables.NTSendableBuilder; import edu.wpi.first.networktables.NetworkTable; import edu.wpi.first.networktables.NetworkTableEntry; import edu.wpi.first.networktables.NetworkTableValue; +import edu.wpi.first.util.function.BooleanConsumer; import java.util.ArrayList; import java.util.List; import java.util.function.BooleanSupplier; diff --git a/wpiutil/src/main/java/edu/wpi/first/util/function/BooleanConsumer.java b/wpiutil/src/main/java/edu/wpi/first/util/function/BooleanConsumer.java new file mode 100644 index 0000000000..98fd6a28cf --- /dev/null +++ b/wpiutil/src/main/java/edu/wpi/first/util/function/BooleanConsumer.java @@ -0,0 +1,22 @@ +// Copyright (c) FIRST and other WPILib contributors. +// Open Source Software; you can modify and/or share it under the terms of +// the WPILib BSD license file in the root directory of this project. + +package edu.wpi.first.util.function; + +/** + * Represents an operation that accepts a single boolean-valued argument and returns no result. This + * is the primitive type specialization of {@link java.util.function.Consumer} for boolean. Unlike + * most other functional interfaces, BooleanConsumer is expected to operate via side-effects. + * + *
This is a functional interface whose functional method is {@link #accept(boolean)}. + */ +@FunctionalInterface +public interface BooleanConsumer { + /** + * Performs this operation on the given argument. + * + * @param value the input argument + */ + void accept(boolean value); +} diff --git a/wpiutil/src/main/java/edu/wpi/first/util/function/FloatConsumer.java b/wpiutil/src/main/java/edu/wpi/first/util/function/FloatConsumer.java new file mode 100644 index 0000000000..0fc7ff75bb --- /dev/null +++ b/wpiutil/src/main/java/edu/wpi/first/util/function/FloatConsumer.java @@ -0,0 +1,22 @@ +// Copyright (c) FIRST and other WPILib contributors. +// Open Source Software; you can modify and/or share it under the terms of +// the WPILib BSD license file in the root directory of this project. + +package edu.wpi.first.util.function; + +/** + * Represents an operation that accepts a single float-valued argument and returns no result. This + * is the primitive type specialization of {@link java.util.function.Consumer} for float. Unlike + * most other functional interfaces, BooleanConsumer is expected to operate via side-effects. + * + *
This is a functional interface whose functional method is {@link #accept(float)}. + */ +@FunctionalInterface +public interface FloatConsumer { + /** + * Performs this operation on the given argument. + * + * @param value the input argument + */ + void accept(float value); +} diff --git a/wpiutil/src/main/java/edu/wpi/first/util/function/FloatSupplier.java b/wpiutil/src/main/java/edu/wpi/first/util/function/FloatSupplier.java new file mode 100644 index 0000000000..eb94b2bb4a --- /dev/null +++ b/wpiutil/src/main/java/edu/wpi/first/util/function/FloatSupplier.java @@ -0,0 +1,24 @@ +// Copyright (c) FIRST and other WPILib contributors. +// Open Source Software; you can modify and/or share it under the terms of +// the WPILib BSD license file in the root directory of this project. + +package edu.wpi.first.util.function; + +/** + * Represents a supplier of float-valued results. + * + *
This is the float-producing primitive specialization of {@link java.util.function.Supplier}. + * + *
There is no requirement that a distinct result be returned each time the supplier is invoked. + * + *
This is a functional interface whose functional method is {@link #getAsFloat()}. + */ +@FunctionalInterface +public interface FloatSupplier { + /** + * Gets a result. + * + * @return a result + */ + float getAsFloat(); +} diff --git a/wpiutil/src/main/java/edu/wpi/first/util/sendable/SendableBuilder.java b/wpiutil/src/main/java/edu/wpi/first/util/sendable/SendableBuilder.java index 7d5bcf4835..35d98fa3f3 100644 --- a/wpiutil/src/main/java/edu/wpi/first/util/sendable/SendableBuilder.java +++ b/wpiutil/src/main/java/edu/wpi/first/util/sendable/SendableBuilder.java @@ -4,6 +4,7 @@ package edu.wpi.first.util.sendable; +import edu.wpi.first.util.function.BooleanConsumer; import java.util.function.BooleanSupplier; import java.util.function.Consumer; import java.util.function.DoubleConsumer; @@ -41,23 +42,6 @@ public interface SendableBuilder { */ void setSafeState(Runnable func); - /** - * Represents an operation that accepts a single boolean-valued argument and returns no result. - * This is the primitive type specialization of Consumer for boolean. Unlike most other functional - * interfaces, BooleanConsumer is expected to operate via side-effects. - * - *
This is a functional interface whose functional method is accept(boolean). - */ - @FunctionalInterface - interface BooleanConsumer { - /** - * Performs the operation on the given value. - * - * @param value the value - */ - void accept(boolean value); - } - /** * Add a boolean property. *