Remove unnecessary checks for weight value in the compare function.
@@ -188,20 +188,9 @@ public class RestrictedGuacamoleTunnelService
@Override
public int compare(ModeledConnection a, ModeledConnection b) {
- int weightA, weightB;
- // Check if weight of a is non-null and retrieve it.
- if (a.getConnectionWeight().intValue() > 0)
- weightA = a.getConnectionWeight().intValue();
- // In all other cases assign 1 for sorting.
- else
- weightA = 1;
-
- // Check if weight of b is null, assign 1 if it is.
- if (b.getConnectionWeight().intValue() > 0)
- weightB = b.getConnectionWeight().intValue();
- // In all other cases assign 1 for sorting.
- else
- weightB = 1;
+ // Get connection weight for the two systems being compared.
+ int weightA = a.getConnectionWeight().intValue();
+ int weightB = b.getConnectionWeight().intValue();
// Get current active connections, add 1 to both to avoid calculations with 0.
int connsA = getActiveConnections(a).size() + 1;
