Source:
<code>private List<AssignableReplica> getOrderedAssignableReplica(ClusterModel clusterModel) { Map<String, Set<AssignableReplica>> replicasByResource = clusterModel.getAssignableReplicaMap(); List<AssignableReplica> orderedAssignableReplicas = replicasByResource.values().stream().flatMap(replicas -> replicas.stream()) .collect(Collectors.toList()); Map<String, ResourceAssignment> bestPossibleAssignment = clusterModel.getContext().getBestPossibleAssignment(); Map<String, ResourceAssignment> baselineAssignment = clusterModel.getContext().getBaselineAssignment(); orderedAssignableReplicas.sort((replica1, replica2) -> { String resourceName1 = replica1.getResourceName(); String resourceName2 = replica2.getResourceName(); if (bestPossibleAssignment.containsKey(resourceName1) == bestPossibleAssignment .containsKey(resourceName2)) { if (baselineAssignment.containsKey(resourceName1) == baselineAssignment .containsKey(resourceName2)) { int statePriority1 = replica1.getStatePriority(); int statePriority2 = replica2.getStatePriority(); if (statePriority1 == statePriority2) { long replicaHash1 = Objects .hash(replica1.toString().hashCode(), clusterModel.getAssignableNodes().keySet()); long replicaHash2 = Objects <START> .hash(replica2.toString().hashCode(), clusterModel.getAssignableNodes().keySet()); <END> return (int) (replicaHash1 - replicaHash2); } else { return statePriority1 - statePriority2; } } else { return baselineAssignment.containsKey(resourceName1) ? -1 : 1; } } else { return bestPossibleAssignment.containsKey(resourceName1) ? -1 : 1; } }); return orderedAssignableReplicas; }</code><technical_language>Is this hashing algorithm deterministic</technical_language>

Target:
private List<AssignableReplica> getOrderedAssignableReplica(ClusterModel clusterModel) { Map<String, Set<AssignableReplica>> replicasByResource = clusterModel.getAssignableReplicaMap(); List<AssignableReplica> orderedAssignableReplicas = replicasByResource.values().stream().flatMap(replicas -> replicas.stream()) .collect(Collectors.toList()); Map<String, ResourceAssignment> bestPossibleAssignment = clusterModel.getContext().getBestPossibleAssignment(); Map<String, ResourceAssignment> baselineAssignment = clusterModel.getContext().getBaselineAssignment(); orderedAssignableReplicas.sort((replica1, replica2) -> { String resourceName1 = replica1.getResourceName(); String resourceName2 = replica2.getResourceName(); if (bestPossibleAssignment.containsKey(resourceName1) == bestPossibleAssignment .containsKey(resourceName2)) { if (baselineAssignment.containsKey(resourceName1) == baselineAssignment .containsKey(resourceName2)) { int statePriority1 = replica1.getStatePriority(); int statePriority2 = replica2.getStatePriority(); if (statePriority1 == statePriority2) { Long replicaHash1 = (long) Objects .hash(replica1.toString(), clusterModel.getAssignableNodes().keySet()); Long replicaHash2 = (long) Objects .hash(replica2.toString(), clusterModel.getAssignableNodes().keySet()); if (!replicaHash1.equals(replicaHash2)) { return replicaHash1.compareTo(replicaHash2); } else { return replica1.toString().compareTo(replica2.toString()); } } else { return statePriority1 - statePriority2; } } else { return baselineAssignment.containsKey(resourceName1) ? -1 : 1; } } else { return bestPossibleAssignment.containsKey(resourceName1) ? -1 : 1; } }); return orderedAssignableReplicas; }