forked from jenkinsci/java-client-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathComputer.java
More file actions
101 lines (84 loc) · 2.61 KB
/
Computer.java
File metadata and controls
101 lines (84 loc) · 2.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
/*
* Copyright (c) 2013 Cosmin Stejerean, Karl Heinz Marbaise, and contributors.
*
* Distributed under the MIT license: http://opensource.org/licenses/MIT
*/
package com.offbytwo.jenkins.model;
import java.io.IOException;
import java.util.List;
import com.google.common.net.UrlEscapers;
import com.offbytwo.jenkins.JenkinsServer;
/**
* @author Kelly Plummer
*
*/
public class Computer extends BaseModel {
private String displayName;
public List<Computer> getComputers() {
return computer;
}
public void setComputer(List<Computer> computer) {
this.computer = computer;
}
List<Computer> computer;
private JenkinsServer jenkinsServer;
public Computer() {
}
public Computer(String displayName) {
this();
this.displayName = displayName;
}
public String getDisplayName() {
return this.displayName;
}
public Computer setJenkinsServer(JenkinsServer jenkinsServer) {
this.jenkinsServer = jenkinsServer;
return this;
}
public JenkinsServer getJenkinsServer() {
return jenkinsServer;
}
public ComputerWithDetails details() throws IOException {
String name;
if ("master".equals(displayName)) {
name = "(master)";
} else {
name = UrlEscapers.urlPathSegmentEscaper().escape(displayName);
}
// TODO: Check if depth=2 is a good idea or if it could be solved
// better.
ComputerWithDetails computerWithDetails = client.get("/computer/" + name + "/?depth=2",
ComputerWithDetails.class);
computerWithDetails.setClient(client);
return computerWithDetails;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Computer other = (Computer) obj;
if (computer == null) {
if (other.computer != null)
return false;
} else if (!computer.equals(other.computer))
return false;
if (displayName == null) {
if (other.displayName != null)
return false;
} else if (!displayName.equals(other.displayName))
return false;
return true;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((computer == null) ? 0 : computer.hashCode());
result = prime * result + ((displayName == null) ? 0 : displayName.hashCode());
return result;
}
}