forked from gooddata/gooddata-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLcmEntity.java
More file actions
144 lines (121 loc) · 4.61 KB
/
Copy pathLcmEntity.java
File metadata and controls
144 lines (121 loc) · 4.61 KB
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
/*
* Copyright (C) 2007-2018, GoodData(R) Corporation. All rights reserved.
* This source code is licensed under the BSD-style license found in the
* LICENSE.txt file in the root directory of this source tree.
*/
package com.gooddata.lcm;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.gooddata.util.GoodDataToStringBuilder;
import java.util.Map;
import java.util.Objects;
import static com.gooddata.lcm.LcmEntity.LinkCategory.CLIENT;
import static com.gooddata.lcm.LcmEntity.LinkCategory.DATA_PRODUCT;
import static com.gooddata.lcm.LcmEntity.LinkCategory.PROJECT;
import static com.gooddata.lcm.LcmEntity.LinkCategory.SEGMENT;
import static com.gooddata.util.Validate.notEmpty;
import static com.gooddata.util.Validate.notNull;
import static com.gooddata.util.Validate.notNullState;
/**
* Single Life Cycle Management entity representing the relation between {@link com.gooddata.project.Project},
* Client, Segment and DataProduct.
*/
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class LcmEntity {
private final String projectId;
private final String projectTitle;
private final String clientId;
private final String segmentId;
private final String dataProductId;
private final Map<String, String> links;
/**
* Creates new instance of given project id and title
* @param projectId id of the project
* @param projectTitle title of the project
* @param links links
*/
public LcmEntity(final String projectId, final String projectTitle, final Map<String, String> links) {
this(projectId, projectTitle, null, null, null, links);
}
@JsonCreator
public LcmEntity(@JsonProperty("projectId") final String projectId,
@JsonProperty("projectTitle") final String projectTitle,
@JsonProperty("clientId") final String clientId,
@JsonProperty("segmentId") final String segmentId,
@JsonProperty("dataProductId") final String dataProductId,
@JsonProperty("links") final Map<String, String> links) {
this.projectId = notEmpty(projectId, "projectId");
this.projectTitle = notNull(projectTitle, "projectTitle");
this.clientId = clientId;
this.segmentId = segmentId;
this.dataProductId = dataProductId;
this.links = notNull(links, "links");
}
public String getProjectId() {
return projectId;
}
public String getProjectTitle() {
return projectTitle;
}
public String getClientId() {
return clientId;
}
public String getSegmentId() {
return segmentId;
}
public String getDataProductId() {
return dataProductId;
}
public Map<String, String> getLinks() {
return links;
}
@JsonIgnore
public String getProjectUri() {
return getLink(PROJECT);
}
@JsonIgnore
public String getClientUri() {
return getLink(CLIENT);
}
@JsonIgnore
public String getSegmentUri() {
return getLink(SEGMENT);
}
@JsonIgnore
public String getDataProductUri() {
return getLink(DATA_PRODUCT);
}
private String getLink(final String link) {
return notNullState(links, "links").get(link);
}
@Override
public boolean equals(final Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
final LcmEntity lcmEntity = (LcmEntity) o;
return Objects.equals(projectId, lcmEntity.projectId) &&
Objects.equals(projectTitle, lcmEntity.projectTitle) &&
Objects.equals(clientId, lcmEntity.clientId) &&
Objects.equals(segmentId, lcmEntity.segmentId) &&
Objects.equals(dataProductId, lcmEntity.dataProductId) &&
Objects.equals(links, lcmEntity.links);
}
@Override
public int hashCode() {
return Objects.hash(projectId, projectTitle, clientId, segmentId, dataProductId, links);
}
@Override
public String toString() {
return GoodDataToStringBuilder.defaultToString(this);
}
public static class LinkCategory {
public static final String PROJECT = "project";
public static final String CLIENT = "client";
public static final String SEGMENT = "segment";
public static final String DATA_PRODUCT = "dataProduct";
}
}