Skip to content

Commit

Permalink
java format
Browse files Browse the repository at this point in the history
  • Loading branch information
rzblue committed Oct 23, 2024
1 parent 7b9f907 commit 93e24af
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions wpilibj/src/main/java/edu/wpi/first/wpilibj/Alert.java
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,10 @@ public Alert(String group, String text, AlertType type) {
* @param active Whether to display the alert.
*/
public void set(boolean active) {
if (active == m_active) return;
if (active == m_active) {
return;
}

if (active) {
m_activeStartTime = RobotController.getFPGATime();
m_group.getSetForType(m_type).add(new PublishedAlert(m_activeStartTime, m_text));
Expand Down Expand Up @@ -140,8 +143,7 @@ public void setText(String text) {
}
}

private static final record PublishedAlert(long timestamp, String text)
implements Comparable<PublishedAlert> {
private record PublishedAlert(long timestamp, String text) implements Comparable<PublishedAlert> {
private static final Comparator<PublishedAlert> comparator =
Comparator.comparingLong((PublishedAlert alert) -> alert.timestamp())
.thenComparing(Comparator.comparing((PublishedAlert alert) -> alert.text()));
Expand All @@ -165,7 +167,7 @@ private String[] getStrings(AlertType type) {
// TODO: some optimizations available here- could iterate explicitly and cache the array for
// potential reuse (if size is same, refill array, if nothing has changed, return original
// array)
return getSetForType(type).stream().map((a) -> a.text()).toArray(String[]::new);
return getSetForType(type).stream().map(a -> a.text()).toArray(String[]::new);
}

@Override
Expand Down

0 comments on commit 93e24af

Please sign in to comment.