Skip to content

Package: ParentEndPoint

ParentEndPoint

nameinstructionbranchcomplexitylinemethod
ParentEndPoint()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getEndPoint(Exchange, Object, String, Map)
M: 28 C: 0
0%
M: 4 C: 0
0%
M: 3 C: 0
0%
M: 5 C: 0
0%
M: 1 C: 0
0%
getEndPoints()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getRegex()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
matches(Exchange, Object, String, Map)
M: 8 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
setEndPoints(List)
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
setRegex(String)
M: 13 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
toLog(StringBuffer, String)
M: 51 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 11 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2017, 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.List;
16: import java.util.Map;
17: import java.util.regex.Pattern;
18:
19: import javax.xml.bind.annotation.XmlAccessType;
20: import javax.xml.bind.annotation.XmlAccessorType;
21: import javax.xml.bind.annotation.XmlAnyElement;
22: import javax.xml.bind.annotation.XmlRootElement;
23: import javax.xml.bind.annotation.XmlTransient;
24: import javax.xml.bind.annotation.XmlType;
25:
26: import org.apache.camel.Exchange;
27:
28: @XmlRootElement(name = "endPoint")
29: @XmlAccessorType(XmlAccessType.PROPERTY)
30: @XmlType(propOrder = {
31: "regex",
32: "endPoints"
33: })
34: public class ParentEndPoint implements EndPoint {
35:
36: @XmlTransient
37: private Pattern pattern;
38: @XmlTransient
39: private String regexPlaceholderReplaced;
40:
41: private String regex;
42: private List<EndPoint> endPoints;
43:
44: @Override
45: @XmlTransient
46: public boolean matches(Exchange exchange, Object value, String previous, Map<String, Object> properties) {
47: return EndpointsUtil.matches(exchange, value, previous, properties, pattern);
48: }
49:
50: @Override
51: @XmlTransient
52: public String getEndPoint(Exchange exchange, Object value, String previous, Map<String, Object> properties) {
53:• for (EndPoint endPoint : endPoints) {
54:• if (endPoint.matches(exchange, value, previous, properties)) {
55: return endPoint.getEndPoint(exchange, value, previous, properties);
56: }
57: }
58: return null;
59: }
60:
61: public String getRegex() {
62: return regex;
63: }
64:
65: public void setRegex(String regex) {
66: this.regex = regex;
67: regexPlaceholderReplaced = EndPoint.replacePlaceholder(regex);
68: pattern = EndPoint.parseRegex(regexPlaceholderReplaced);
69: }
70:
71: @XmlAnyElement
72: public List<EndPoint> getEndPoints() {
73: return endPoints;
74: }
75:
76: public void setEndPoints(List<EndPoint> endPoints) {
77: this.endPoints = endPoints;
78: }
79:
80: @Override
81: public void toLog(StringBuffer buffer, String prefix) {
82: buffer.append(prefix);
83: buffer.append("Regex: ");
84: buffer.append(regexPlaceholderReplaced);
85: buffer.append("\n");
86: prefix += "\t";
87:• for (EndPoint endPoint : endPoints) {
88: buffer.append(prefix);
89: endPoint.toLog(buffer, prefix);
90: buffer.append("\n");
91: }
92: }
93:
94: }