-
Notifications
You must be signed in to change notification settings - Fork 111
Expand file tree
/
Copy pathGitLabAvatar.java
More file actions
54 lines (43 loc) · 1.65 KB
/
GitLabAvatar.java
File metadata and controls
54 lines (43 loc) · 1.65 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
package io.jenkins.plugins.gitlabbranchsource.helpers;
import edu.umd.cs.findbugs.annotations.NonNull;
import io.jenkins.cli.shaded.org.apache.commons.lang.StringUtils;
import java.util.Objects;
import jenkins.scm.api.metadata.AvatarMetadataAction;
public class GitLabAvatar extends AvatarMetadataAction {
private final GitLabAvatarLocation location;
/**
* Back compat, to keep existing configs working upon plugin upgrade
*/
private final String avatar;
public GitLabAvatar(String avatarUrl, String serverName, String projectPath, boolean isProject) {
this.avatar = null;
this.location = new GitLabAvatarLocation(avatarUrl, serverName, projectPath, isProject);
}
public GitLabAvatar(String avatarUrl) {
this.avatar = null;
this.location = new GitLabAvatarLocation(avatarUrl);
}
@Override
public String getAvatarImageOf(@NonNull String size) {
if (StringUtils.isNotBlank(avatar)) {
// Back compat, to keep existing configs working upon plugin upgrade
return GitLabAvatarCache.buildUrl(new GitLabAvatarLocation(avatar), size);
}
return location != null && location.available() ? GitLabAvatarCache.buildUrl(location, size) : null;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
GitLabAvatar that = (GitLabAvatar) o;
return Objects.equals(location, that.location);
}
@Override
public int hashCode() {
return location != null ? location.hashCode() : 0;
}
}