Skip to content

Package: KuraNamespace$Builder

KuraNamespace$Builder

nameinstructionbranchcomplexitylinemethod
KuraNamespace.Builder()
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%
accountName()
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%
accountName(String)
M: 11 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
build()
M: 19 C: 0
0%
M: 4 C: 0
0%
M: 3 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2017, 2022 Red Hat Inc 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: * Red Hat Inc - initial API and implementation
12: *******************************************************************************/
13: package org.eclipse.kapua.client.gateway.kura;
14:
15: import java.util.Objects;
16: import java.util.stream.Collectors;
17: import java.util.stream.Stream;
18:
19: import org.eclipse.kapua.client.gateway.Topic;
20: import org.eclipse.kapua.client.gateway.mqtt.MqttNamespace;
21:
22: public class KuraNamespace implements MqttNamespace {
23:
24: public static final class Builder {
25:
26: private String accountName;
27:
28: public Builder accountName(final String accountName) {
29: Objects.requireNonNull(accountName);
30: Topic.ensureNotSpecial(accountName);
31:
32: this.accountName = accountName;
33: return this;
34: }
35:
36: public String accountName() {
37: return accountName;
38: }
39:
40: public KuraNamespace build() {
41:• if (accountName == null || accountName.isEmpty()) {
42: throw new IllegalArgumentException("'accountName' must be set");
43: }
44:
45: return new KuraNamespace(accountName);
46: }
47: }
48:
49: private final String accountName;
50:
51: private KuraNamespace(final String accountName) {
52: this.accountName = accountName;
53: }
54:
55: @Override
56: public String dataTopic(final String clientId, final String applicationId, final Topic topic) {
57: Topic.ensureNotSpecial(clientId);
58: Topic.ensureNotSpecial(applicationId);
59:
60: return Stream.concat(
61: Stream.of(
62: accountName,
63: clientId,
64: applicationId),
65: topic.stream())
66: .collect(Collectors.joining("/"));
67: }
68:
69: }