mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-22 01:11:42 +00:00
[commands] Deprecate proxy supplier constructor (#6553)
This commit is contained in:
@@ -186,8 +186,13 @@ public final class Commands {
|
||||
*
|
||||
* @param supplier the command supplier
|
||||
* @return the command
|
||||
* @deprecated The ProxyCommand supplier constructor has been deprecated in favor of directly
|
||||
* proxying a {@link DeferredCommand}, see ProxyCommand documentaion for more details. As a
|
||||
* replacement, consider using `defer(supplier).asProxy()`.
|
||||
* @see ProxyCommand
|
||||
*/
|
||||
@Deprecated(since = "2025", forRemoval = true)
|
||||
@SuppressWarnings("removal")
|
||||
public static Command deferredProxy(Supplier<Command> supplier) {
|
||||
return new ProxyCommand(supplier);
|
||||
}
|
||||
|
||||
@@ -31,8 +31,14 @@ public class ProxyCommand extends Command {
|
||||
* only initialization time command construction is needed, use {@link DeferredCommand} instead.
|
||||
*
|
||||
* @param supplier the command supplier
|
||||
* @deprecated This constructor's similarity to {@link DeferredCommand} is confusing and opens
|
||||
* potential footguns for users who do not fully understand the semantics and implications of
|
||||
* proxying, but who simply want runtime construction. Users who do know what they are doing
|
||||
* and need a supplier-constructed proxied command should instead proxy a DeferredCommand
|
||||
* using the <code>asProxy</code> decorator.
|
||||
* @see DeferredCommand
|
||||
*/
|
||||
@Deprecated(since = "2025", forRemoval = true)
|
||||
public ProxyCommand(Supplier<Command> supplier) {
|
||||
m_supplier = requireNonNullParam(supplier, "supplier", "ProxyCommand");
|
||||
}
|
||||
@@ -45,8 +51,9 @@ public class ProxyCommand extends Command {
|
||||
*/
|
||||
@SuppressWarnings("this-escape")
|
||||
public ProxyCommand(Command command) {
|
||||
this(() -> command);
|
||||
setName("Proxy(" + command.getName() + ")");
|
||||
Command nullCheckedCommand = requireNonNullParam(command, "command", "ProxyCommand");
|
||||
m_supplier = () -> nullCheckedCommand;
|
||||
setName("Proxy(" + nullCheckedCommand.getName() + ")");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user