@@ -65,12 +65,12 @@ public ServiceId(String service, String group, boolean interfaceMode) {
6565 this (null , service , group , null , interfaceMode );
6666 }
6767
68- public ServiceId (String namespace , String service , String group ) {
69- this (namespace , service , group , null , false );
68+ public ServiceId (String service , String group , String catalog , boolean interfaceMode ) {
69+ this (null , service , group , catalog , interfaceMode );
7070 }
7171
72- public ServiceId (String namespace , String service , String group , boolean interfaceMode ) {
73- this (namespace , service , group , null , interfaceMode );
72+ public ServiceId (String namespace , String service , String group ) {
73+ this (namespace , service , group , null , false );
7474 }
7575
7676 public ServiceId (String namespace , String service , String group , String catalog , boolean interfaceMode ) {
@@ -139,23 +139,26 @@ public boolean match(ServiceId target, String defaultGroup) {
139139 /**
140140 * Determines if two service IDs match according to the specified matching rules.
141141 *
142- * @param source the source service ID to match against (may be null)
143- * @param target the target service ID to check (may be null)
144- * @param defaultGroup the default group name to use when source group is empty (may be null)
142+ * @param source the source service ID to match against (maybe null)
143+ * @param target the target service ID to check (maybe null)
144+ * @param defaultGroup the default group name to use when source group is empty (maybe null)
145145 * @return true if the service IDs match according to the rules, false otherwise
146146 */
147147 public static boolean match (ServiceId source , ServiceId target , String defaultGroup ) {
148- String sourceService = source == null ? null : source .getService ();
149- String targetService = target == null ? null : target .getService ();
148+ if (source == null || target == null ) {
149+ return false ;
150+ }
151+ String sourceService = source .getService ();
152+ String targetService = target .getService ();
150153 if (sourceService == null || !sourceService .equalsIgnoreCase (targetService )) {
151154 return false ;
152155 }
153- String sourceGroup = source == null ? null : source .getGroup ();
154- String targetGroup = target == null ? null : target .getGroup ();
155- if (! DEFAULT_GROUP_BIPREDICATE .test (sourceGroup , defaultGroup )) {
156- return DEFAULT_GROUP_BIPREDICATE . test ( targetGroup , defaultGroup ) ;
156+ String sourceGroup = source .getGroup ();
157+ String targetGroup = target .getGroup ();
158+ if (DEFAULT_GROUP_BIPREDICATE .test (sourceGroup , defaultGroup ) || DEFAULT_GROUP_BIPREDICATE . test ( targetGroup , defaultGroup )) {
159+ return true ;
157160 }
158- return sourceGroup .equalsIgnoreCase (targetGroup );
161+ return sourceGroup == null ? targetGroup == null : sourceGroup .equalsIgnoreCase (targetGroup );
159162 }
160163
161164 /**
@@ -186,4 +189,4 @@ public static String getServiceName(String serviceNameWithGroup, String splitter
186189 return index < 0 || index >= parts .size () ? StringUtils .EMPTY_STRING : parts .get (index );
187190 }
188191
189- }
192+ }
0 commit comments