1
|
package eu.dnetlib.pace.model.gt;
|
2
|
|
3
|
import java.util.List;
|
4
|
import java.util.Set;
|
5
|
|
6
|
import org.apache.commons.lang.StringUtils;
|
7
|
|
8
|
import com.google.common.collect.ComparisonChain;
|
9
|
import com.google.common.collect.Lists;
|
10
|
import com.google.common.collect.Ordering;
|
11
|
import com.google.common.collect.Sets;
|
12
|
import com.google.gson.Gson;
|
13
|
|
14
|
public class Author implements Comparable<Author> {
|
15
|
|
16
|
private String id;
|
17
|
private String fullname;
|
18
|
private String firstname;
|
19
|
private String secondnames;
|
20
|
|
21
|
private List<Match> matches = Lists.newArrayList();
|
22
|
private Set<Author> coauthors = Sets.newHashSet();
|
23
|
|
24
|
public Author() {
|
25
|
super();
|
26
|
}
|
27
|
|
28
|
public Author(final Author a) {
|
29
|
this.id = a.getId();
|
30
|
this.fullname = a.getFullname();
|
31
|
this.firstname = a.getFirstname();
|
32
|
this.secondnames = a.getSecondnames();
|
33
|
|
34
|
this.matches = a.getMatches();
|
35
|
this.coauthors = a.getCoauthors();
|
36
|
}
|
37
|
|
38
|
public boolean hasMatches() {
|
39
|
return (getMatches() != null) && !getMatches().isEmpty();
|
40
|
}
|
41
|
|
42
|
public boolean hasCoauthors() {
|
43
|
return (getCoauthors() != null) && !getCoauthors().isEmpty();
|
44
|
}
|
45
|
|
46
|
public boolean isWellFormed() {
|
47
|
return StringUtils.isNotBlank(getSecondnames()) && StringUtils.isNotBlank(getFirstname());
|
48
|
}
|
49
|
|
50
|
public String getId() {
|
51
|
return id;
|
52
|
}
|
53
|
|
54
|
public void setId(final String id) {
|
55
|
this.id = id;
|
56
|
}
|
57
|
|
58
|
public String getFullname() {
|
59
|
return fullname;
|
60
|
}
|
61
|
|
62
|
public void setFullname(final String fullname) {
|
63
|
this.fullname = fullname;
|
64
|
}
|
65
|
|
66
|
public String getFirstname() {
|
67
|
return firstname;
|
68
|
}
|
69
|
|
70
|
public void setFirstname(final String firstname) {
|
71
|
this.firstname = firstname;
|
72
|
}
|
73
|
|
74
|
public String getSecondnames() {
|
75
|
return secondnames;
|
76
|
}
|
77
|
|
78
|
public void setSecondnames(final String secondnames) {
|
79
|
this.secondnames = secondnames;
|
80
|
}
|
81
|
|
82
|
public List<Match> getMatches() {
|
83
|
return matches;
|
84
|
}
|
85
|
|
86
|
public void setMatches(final List<Match> matches) {
|
87
|
this.matches = matches;
|
88
|
}
|
89
|
|
90
|
public Set<Author> getCoauthors() {
|
91
|
return coauthors;
|
92
|
}
|
93
|
|
94
|
public void setCoauthors(final Set<Author> coauthors) {
|
95
|
this.coauthors = coauthors;
|
96
|
}
|
97
|
|
98
|
@Override
|
99
|
public String toString() {
|
100
|
return new Gson().toJson(this);
|
101
|
}
|
102
|
|
103
|
@Override
|
104
|
public int hashCode() {
|
105
|
return getId().hashCode();
|
106
|
}
|
107
|
|
108
|
@Override
|
109
|
public int compareTo(final Author o) {
|
110
|
return ComparisonChain.start()
|
111
|
.compare(this.getId(), o.getId(), Ordering.natural().nullsLast())
|
112
|
.result();
|
113
|
}
|
114
|
|
115
|
@Override
|
116
|
public boolean equals(final Object o) {
|
117
|
return (o instanceof Author) && getId().equals(((Author) o).getId());
|
118
|
}
|
119
|
|
120
|
}
|