Avoid re-creating required action comparator (#29122)

closes #29130 

Signed-off-by: Michal Růžička <michal.ruza@gmail.com>
This commit is contained in:
mruzicka 2024-04-29 09:18:50 +02:00 committed by GitHub
parent a6e2ab5523
commit ae1aaef96c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -28,17 +28,11 @@ import java.util.Map;
*/ */
public class RequiredActionProviderModel implements Serializable { public class RequiredActionProviderModel implements Serializable {
public static class RequiredActionComparator implements Comparator<RequiredActionProviderModel> { public interface RequiredActionComparator extends Comparator<RequiredActionProviderModel> {
public static final RequiredActionComparator SINGLETON = new RequiredActionComparator(); RequiredActionComparator SINGLETON = Comparator
@Override
public int compare(RequiredActionProviderModel o1, RequiredActionProviderModel o2) {
return Comparator
.comparingInt(RequiredActionProviderModel::getPriority) .comparingInt(RequiredActionProviderModel::getPriority)
.thenComparing(RequiredActionProviderModel::getName, Comparator.nullsFirst(String.CASE_INSENSITIVE_ORDER)) .thenComparing(RequiredActionProviderModel::getName, Comparator.nullsFirst(String.CASE_INSENSITIVE_ORDER))
.compare(o1, o2); ::compare;
}
} }
private String id; private String id;