[command] Add withName inline decorator to Java (#2420)

This is an inline decorator for setting the name of a command
(equivalent to calling setName()).

It's not possible to implement this for C++, as it would slice the derived
class to return it by value.
This commit is contained in:
Starlight220
2020-04-06 02:11:23 +03:00
committed by GitHub
parent 2ecb8dab7d
commit f4c5c0f5b5

View File

@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018-2019 FIRST. All Rights Reserved. */
/* Copyright (c) 2018-2020 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
@@ -56,6 +56,18 @@ public abstract class CommandBase implements Sendable, Command {
SendableRegistry.setName(this, name);
}
/**
* Decorates this Command with a name.
* Is an inline function for #setName(String);
*
* @param name name
* @return the decorated Command
*/
public Command withName(String name) {
this.setName(name);
return this;
}
/**
* Gets the subsystem name of this Command.
*