blob: f5f8b83be4630271b6f9a4543c6fbc991453a3e2 (
plain) (
blame)
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
|
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.applicationmodel;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonValue;
import java.util.Objects;
/**
* @author bjorncs
*/
// TODO: Remove this and use ApplicationId instead (if you need it for the JSON stuff move it to that layer and don't let it leak)
public class ApplicationInstanceReference implements Comparable<ApplicationInstanceReference> {
private final TenantId tenantId;
private final ApplicationInstanceId applicationInstanceId;
public ApplicationInstanceReference(TenantId tenantId, ApplicationInstanceId applicationInstanceId) {
this.tenantId = tenantId;
this.applicationInstanceId = applicationInstanceId;
}
@JsonProperty("tenantId")
public TenantId tenantId() {
return tenantId;
}
@JsonProperty("applicationInstanceId")
public ApplicationInstanceId applicationInstanceId() {
return applicationInstanceId;
}
// Jackson's StdKeySerializer uses toString() (and ignores annotations) for objects used as Map keys.
// Therefore, we use toString() as the JSON-producing method, which is really sad.
@JsonValue
@Override
public String toString() {
return asString();
}
public String asString() {
return tenantId.value() + ":" + applicationInstanceId.value();
}
@Override
public int compareTo(ApplicationInstanceReference o) {
return this.asString().compareTo(o.asString());
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
ApplicationInstanceReference that = (ApplicationInstanceReference) o;
return Objects.equals(tenantId, that.tenantId) &&
Objects.equals(applicationInstanceId, that.applicationInstanceId);
}
@Override
public int hashCode() {
return Objects.hash(tenantId, applicationInstanceId);
}
}
|