code cleanup

This commit is contained in:
anhefti 2024-02-08 08:42:48 +01:00
parent 8d1d9d8dda
commit 4bf398cb25

View file

@ -9,7 +9,6 @@
package ch.ethz.seb.sebserver.gui.service.session; package ch.ethz.seb.sebserver.gui.service.session;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
@ -443,7 +442,7 @@ public final class ClientConnectionTable implements FullPageMonitoringGUIUpdate
} }
private void sortTable() { private void sortTable() {
Set<String> connectionTokens = getSelectedConnectionTokens(); final Set<String> connectionTokens = getSelectedConnectionTokens();
this.sortList.clear(); this.sortList.clear();
this.sortList.addAll(this.tableMapping.values()); this.sortList.addAll(this.tableMapping.values());
@ -839,7 +838,7 @@ public final class ClientConnectionTable implements FullPageMonitoringGUIUpdate
final Set<String> result = new HashSet<>(); final Set<String> result = new HashSet<>();
for (int i = 0; i < selectionIndices.length; i++) { for (int i = 0; i < selectionIndices.length; i++) {
UpdatableTableItem item = this.tableMapping.values() final UpdatableTableItem item = this.tableMapping.values()
.stream() .stream()
.collect(Collectors.toList()) .collect(Collectors.toList())
.get(selectionIndices[i]); .get(selectionIndices[i]);
@ -850,18 +849,18 @@ public final class ClientConnectionTable implements FullPageMonitoringGUIUpdate
return result; return result;
} }
private int[] getSelectedTableIndices(Set<String> connectionTokens){ private int[] getSelectedTableIndices(final Set<String> connectionTokens){
if(connectionTokens.isEmpty()){ if(connectionTokens.isEmpty()){
return new int[]{}; return new int[]{};
} }
int[] selectedTableIndices = new int[connectionTokens.size()]; final int[] selectedTableIndices = new int[connectionTokens.size()];
int index = 0; int index = 0;
int tableIndices = 0; int tableIndices = 0;
for (UpdatableTableItem item : this.tableMapping.values()) { for (final UpdatableTableItem item : this.tableMapping.values()) {
if (connectionTokens.contains(item.staticData.connectionToken)) { if (index < selectedTableIndices.length && connectionTokens.contains(item.staticData.connectionToken)) {
selectedTableIndices[index] = tableIndices; selectedTableIndices[index] = tableIndices;
index++; index++;
} }