Skip to content

Package: EndpointsUtil

EndpointsUtil

nameinstructionbranchcomplexitylinemethod
matches(Exchange, Object, String, Map, Pattern)
M: 16 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2020, 2022 Eurotech and/or its affiliates and others
3: *
4: * This program and the accompanying materials are made
5: * available under the terms of the Eclipse Public License 2.0
6: * which is available at https://www.eclipse.org/legal/epl-2.0/
7: *
8: * SPDX-License-Identifier: EPL-2.0
9: *
10: * Contributors:
11: * Eurotech - initial API and implementation
12: *******************************************************************************/
13: package org.eclipse.kapua.broker.core.router;
14:
15: import java.util.Map;
16: import java.util.regex.Pattern;
17:
18: import org.eclipse.kapua.broker.core.message.MessageConstants;
19:
20: import org.apache.camel.Exchange;
21:
22: public class EndpointsUtil {
23:
24: private EndpointsUtil() { }
25:
26: public static boolean matches(Exchange exchange, Object value, String previous, Map<String, Object> properties, Pattern pattern) {
27:
28:• if (previous == null) {
29: String originaTopic = exchange.getIn().getHeader(MessageConstants.PROPERTY_ORIGINAL_TOPIC, String.class);
30: // TODO if pattern is null it is an error so it should be correct to throw an exception or leave the NullPointerException raised by the method?!
31: return pattern.matcher(originaTopic).matches();
32: } else {
33: return false;
34: }
35: }
36:
37: }