From ae1aaef96c80563c7d78ed617556fbbd91d7ad30 Mon Sep 17 00:00:00 2001 From: mruzicka Date: Mon, 29 Apr 2024 09:18:50 +0200 Subject: [PATCH] Avoid re-creating required action comparator (#29122) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit closes #29130 Signed-off-by: Michal Růžička --- .../models/RequiredActionProviderModel.java | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/server-spi/src/main/java/org/keycloak/models/RequiredActionProviderModel.java b/server-spi/src/main/java/org/keycloak/models/RequiredActionProviderModel.java index 887aaad29d..2dd1ee4981 100755 --- a/server-spi/src/main/java/org/keycloak/models/RequiredActionProviderModel.java +++ b/server-spi/src/main/java/org/keycloak/models/RequiredActionProviderModel.java @@ -28,17 +28,11 @@ import java.util.Map; */ public class RequiredActionProviderModel implements Serializable { - public static class RequiredActionComparator implements Comparator { - public static final RequiredActionComparator SINGLETON = new RequiredActionComparator(); - - @Override - public int compare(RequiredActionProviderModel o1, RequiredActionProviderModel o2) { - - return Comparator - .comparingInt(RequiredActionProviderModel::getPriority) - .thenComparing(RequiredActionProviderModel::getName, Comparator.nullsFirst(String.CASE_INSENSITIVE_ORDER)) - .compare(o1, o2); - } + public interface RequiredActionComparator extends Comparator { + RequiredActionComparator SINGLETON = Comparator + .comparingInt(RequiredActionProviderModel::getPriority) + .thenComparing(RequiredActionProviderModel::getName, Comparator.nullsFirst(String.CASE_INSENSITIVE_ORDER)) + ::compare; } private String id;