forked from gooddata/gooddata-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAccount.java
More file actions
96 lines (78 loc) · 2.63 KB
/
Copy pathAccount.java
File metadata and controls
96 lines (78 loc) · 2.63 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
/*
* Copyright (C) 2007-2014, GoodData(R) Corporation. All rights reserved.
*/
package com.gooddata.account;
import org.codehaus.jackson.annotate.JsonCreator;
import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.annotate.JsonProperty;
import org.codehaus.jackson.annotate.JsonTypeInfo;
import org.codehaus.jackson.annotate.JsonTypeName;
import org.codehaus.jackson.map.annotate.JsonSerialize;
import org.springframework.web.util.UriTemplate;
/**
* Account setting
*/
@JsonTypeName("accountSetting")
@JsonTypeInfo(include = JsonTypeInfo.As.WRAPPER_OBJECT, use = JsonTypeInfo.Id.NAME)
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
public class Account {
public static final String URI = "/gdc/account/profile/{id}";
public static final UriTemplate TEMPLATE = new UriTemplate(URI);
public static final String LOGIN_URI = "/gdc/account/login/{id}";
public static final UriTemplate LOGIN_TEMPLATE = new UriTemplate(LOGIN_URI);
public static final String CURRENT_ID = "current";
private final String firstName;
private final String lastName;
@JsonIgnore
private final Links links;
@JsonCreator
public Account(@JsonProperty("firstName") String firstName,
@JsonProperty("lastName") String lastName,
@JsonProperty("links") Links links) {
this.firstName = firstName;
this.lastName = lastName;
this.links = links;
}
/* Just for serialization test */
Account(String firstName, String lastName) {
this.firstName = firstName;
this.lastName = lastName;
links = null;
}
public String getFirstName() {
return firstName;
}
public String getLastName() {
return lastName;
}
@JsonIgnore
public String getSelfLink() {
return links.getSelf();
}
@JsonIgnore
public String getProjectsLink() {
return links.getProjects();
}
@JsonIgnore
public String getId() {
return TEMPLATE.match(getSelfLink()).get("id");
}
@JsonIgnoreProperties(ignoreUnknown = true)
private static class Links {
private final String self;
private final String projects;
@JsonCreator
public Links(@JsonProperty("self") String self, @JsonProperty("projects") String projects) {
this.self = self;
this.projects = projects;
}
public String getSelf() {
return self;
}
public String getProjects() {
return projects;
}
}
}