/
TenantUsage.java
65 lines (57 loc) · 1.6 KB
/
TenantUsage.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.eclipse.hawkbit.repository.report.model;
import lombok.Data;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
/**
* System usage stats element for a tenant.
*/
@Data
public class TenantUsage {
private final String tenantName;
private long targets;
private long artifacts;
private long actions;
private long overallArtifactVolumeInBytes;
private Map<String, String> usageData;
/**
* Constructor.
*
* @param tenantName
* name of the tenant
*/
public TenantUsage(final String tenantName) {
this.tenantName = tenantName;
}
public Map<String, String> getUsageData() {
return Collections.unmodifiableMap(getLazyUsageData());
}
private Map<String, String> getLazyUsageData() {
if (usageData == null) {
usageData = new HashMap<>();
}
return usageData;
}
/**
* Add a key and value as usage data to the system usage stats.
*
* @param key
* the key to set
* @param value
* the value to set
* @return tenant stats element with new usage added
*/
public TenantUsage addUsageData(final String key, final String value) {
getLazyUsageData().put(key, value);
return this;
}
}