-
Notifications
You must be signed in to change notification settings - Fork 0
/
AutonomousLoader.java
40 lines (31 loc) · 1.02 KB
/
AutonomousLoader.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package frc.robot.ShamLib;
import edu.wpi.first.wpilibj.smartdashboard.SendableChooser;
import edu.wpi.first.wpilibj2.command.Command;
import java.util.HashMap;
import java.util.Map;
@Deprecated
public class AutonomousLoader<C extends Command, E extends Enum<E>> {
Map<E, C> autoRoutes = new HashMap<>();
private final SendableChooser chooser;
public AutonomousLoader(Map<E, C> autoRoutes) {
// Routes
this.autoRoutes = autoRoutes;
this.chooser = composeSendableChooser();
}
private SendableChooser composeSendableChooser() {
int iterations = 0;
SendableChooser chooser = new SendableChooser();
for (Map.Entry<E, C> e : autoRoutes.entrySet()) {
if (iterations == 0) chooser.setDefaultOption(e.getKey().name(), e.getKey());
else chooser.addOption(e.getKey().name(), e.getKey());
iterations++;
}
return chooser;
}
public SendableChooser getSendableChooser() {
return chooser;
}
public C getCurrentSelection() {
return autoRoutes.get(chooser.getSelected());
}
}