SET_CLIENT(JenkinsHttpConnection client) {
+ return s -> {
+ s.setClient(client);
+ return s;
+ };
+ }
+
+
+}
diff --git a/jenkins-client/src/main/java/com/offbytwo/jenkins/helper/Range.java b/jenkins-client/src/main/java/com/offbytwo/jenkins/helper/Range.java
index 8b70eb09..cdbdc60a 100644
--- a/jenkins-client/src/main/java/com/offbytwo/jenkins/helper/Range.java
+++ b/jenkins-client/src/main/java/com/offbytwo/jenkins/helper/Range.java
@@ -16,122 +16,127 @@
* The same as {0,N}.
* {N}: Just retrieve the N-th element. The same as {N,N+1}.
*
- *
+ *
* You can use the {@link Range} class like this:
- *
+ *
*
* Range fromAndTo = Range.build().from(1).to(5);
* Range fromOnly = Range.build().from(3).build();
* Range toOnly = Range.build().to(5).build();
* Range only = Range.build().only(3);
*
- *
- * @author Karl Heinz Marbaise
*
+ * @author Karl Heinz Marbaise
*/
public final class Range {
- public static final String CURLY_BRACKET_OPEN = "%7B"; // {
- public static final String CURLY_BRACKET_CLOSE = "%7D"; // }
+ /**
+ * This represents {@code {} (left curly bracket).
+ */
+ public static final String CURLY_BRACKET_OPEN = "%7B";
+ /**
+ * This represents {@code }} (right curly bracket).
+ */
+ public static final String CURLY_BRACKET_CLOSE = "%7D";
private Integer from;
private Integer to;
private Range() {
- this.from = null;
- this.to = null;
+ this.from = null;
+ this.to = null;
}
private Range setFrom(int from) {
- if (from < 0) {
- throw new IllegalArgumentException("from value must be greater or equal null.");
- }
- this.from = new Integer(from);
- return this;
+ if (from < 0) {
+ throw new IllegalArgumentException("from value must be greater or equal null.");
+ }
+ this.from = new Integer(from);
+ return this;
}
private Range setTo(int to) {
- if (to < 0) {
- throw new IllegalArgumentException("to must be greater or equal null.");
- }
- this.to = new Integer(to);
- return this;
+ if (to < 0) {
+ throw new IllegalArgumentException("to must be greater or equal null.");
+ }
+ this.to = new Integer(to);
+ return this;
}
public String getRangeString() {
- StringBuilder sb = new StringBuilder();
- sb.append(CURLY_BRACKET_OPEN);
- if (this.from != null) {
- sb.append(String.format("%d", this.from));
- }
+ StringBuilder sb = new StringBuilder();
+ sb.append(CURLY_BRACKET_OPEN);
+ if (this.from != null) {
+ sb.append(String.format("%d", this.from));
+ }
- sb.append(',');
+ sb.append(',');
- if (this.to != null) {
- sb.append(String.format("%d", this.to));
- }
+ if (this.to != null) {
+ sb.append(String.format("%d", this.to));
+ }
- sb.append(CURLY_BRACKET_CLOSE);
- return sb.toString();
+ sb.append(CURLY_BRACKET_CLOSE);
+ return sb.toString();
}
public static final class FromBuilder {
- private Range range;
-
- public FromBuilder(Range range) {
- this.range = range;
- }
-
- public Range to(int t) {
- this.range.setTo(t);
- if (range.to <= range.from) {
- throw new IllegalArgumentException("to must be greater than from");
- }
- return this.range;
- }
-
- public Range build() {
- return this.range;
- }
+ private Range range;
+
+ public FromBuilder(Range range) {
+ this.range = range;
+ }
+
+ public Range to(int t) {
+ this.range.setTo(t);
+ if (range.to <= range.from) {
+ throw new IllegalArgumentException("to must be greater than from");
+ }
+ return this.range;
+ }
+
+ public Range build() {
+ return this.range;
+ }
}
public static final class ToBuilder {
- private Range range;
+ private Range range;
- public ToBuilder(Range range) {
- this.range = range;
- }
+ public ToBuilder(Range range) {
+ this.range = range;
+ }
- public Range build() {
- return this.range;
- }
+ public Range build() {
+ return this.range;
+ }
}
public static final class Builder {
- private Range range;
-
- protected Builder() {
- this.range = new Range();
- }
-
- public FromBuilder from(int f) {
- this.range.setFrom(f);
- return new FromBuilder(this.range);
- }
-
- public ToBuilder to(int t) {
- this.range.setTo(t);
- return new ToBuilder(this.range);
- }
-
- public Range only(int only) {
- this.range.from = new Integer(only);
- this.range.to = new Integer(only + 1);
- return this.range;
- }
+ private Range range;
+
+ protected Builder() {
+ this.range = new Range();
+ }
+
+ public FromBuilder from(int f) {
+ this.range.setFrom(f);
+ return new FromBuilder(this.range);
+ }
+
+ public ToBuilder to(int t) {
+ this.range.setTo(t);
+ return new ToBuilder(this.range);
+ }
+
+ public Range only(int only) {
+ this.range.from = new Integer(only);
+ this.range.to = new Integer(only + 1);
+ return this.range;
+ }
}
public static Builder build() {
- return new Builder();
+ return new Builder();
}
}
\ No newline at end of file
diff --git a/jenkins-client/src/main/java/com/offbytwo/jenkins/model/Artifact.java b/jenkins-client/src/main/java/com/offbytwo/jenkins/model/Artifact.java
index 6d0b0e69..a6c7a2f0 100644
--- a/jenkins-client/src/main/java/com/offbytwo/jenkins/model/Artifact.java
+++ b/jenkins-client/src/main/java/com/offbytwo/jenkins/model/Artifact.java
@@ -16,24 +16,27 @@ public String getDisplayPath() {
return displayPath;
}
- public void setDisplayPath(String displayPath) {
+ public Artifact setDisplayPath(String displayPath) {
this.displayPath = displayPath;
+ return this;
}
public String getFileName() {
return fileName;
}
- public void setFileName(String fileName) {
+ public Artifact setFileName(String fileName) {
this.fileName = fileName;
+ return this;
}
public String getRelativePath() {
return relativePath;
}
- public void setRelativePath(String relativePath) {
+ public Artifact setRelativePath(String relativePath) {
this.relativePath = relativePath;
+ return this;
}
@Override
diff --git a/jenkins-client/src/main/java/com/offbytwo/jenkins/model/BaseModel.java b/jenkins-client/src/main/java/com/offbytwo/jenkins/model/BaseModel.java
index 95f70bab..5275d36b 100644
--- a/jenkins-client/src/main/java/com/offbytwo/jenkins/model/BaseModel.java
+++ b/jenkins-client/src/main/java/com/offbytwo/jenkins/model/BaseModel.java
@@ -7,6 +7,7 @@
package com.offbytwo.jenkins.model;
import com.offbytwo.jenkins.client.JenkinsHttpConnection;
+import java.util.function.Predicate;
/**
* The base model.
@@ -17,8 +18,7 @@ public class BaseModel {
* The class.
*/
private String _class;
-
-
+
/**
* Get the class.
* @return class
@@ -43,7 +43,13 @@ public JenkinsHttpConnection getClient() {
* Set the HTTP client.
* @param client {@link JenkinsHttpConnection}.
*/
- public void setClient(final JenkinsHttpConnection client) {
+ public BaseModel setClient(final JenkinsHttpConnection client) {
this.client = client;
+ return this;
}
+
+ protected static Predicate super Build> isBuildNumberEqualTo(int buildNumber) {
+ return build -> build.getNumber() == buildNumber;
+ }
+
}
diff --git a/jenkins-client/src/main/java/com/offbytwo/jenkins/model/Build.java b/jenkins-client/src/main/java/com/offbytwo/jenkins/model/Build.java
index f48e38e8..470707d9 100644
--- a/jenkins-client/src/main/java/com/offbytwo/jenkins/model/Build.java
+++ b/jenkins-client/src/main/java/com/offbytwo/jenkins/model/Build.java
@@ -8,6 +8,7 @@
import java.io.IOException;
+import org.apache.http.HttpStatus;
import org.apache.http.client.HttpResponseException;
public class Build extends BaseModel {
@@ -82,16 +83,19 @@ public String getUrl() {
return url;
}
- protected void setNumber(int number) {
+ protected Build setNumber(int number) {
this.number = number;
+ return this;
}
- protected void setQueueId(int queueId) {
+ protected Build setQueueId(int queueId) {
this.queueId = queueId;
+ return this;
}
- protected void setUrl(String url) {
+ protected Build setUrl(String url) {
this.url = url;
+ return this;
}
/**
@@ -122,6 +126,7 @@ public TestReport getTestReport() throws IOException {
* @throws IOException in case of an error.
*/
public TestResult getTestResult() throws IOException {
+
return client.get(this.getUrl() + "/testReport/?depth=1", TestResult.class);
}
@@ -141,7 +146,7 @@ public String Stop() throws HttpResponseException, IOException {
return client.get(url + "stop");
} catch (HttpResponseException ex) {
- if (ex.getStatusCode() == 405) {
+ if (ex.getStatusCode() == HttpStatus.SC_METHOD_NOT_ALLOWED) {
stopPost();
return "";
}
@@ -164,7 +169,7 @@ public String Stop(boolean crumbFlag) throws HttpResponseException, IOException
return client.get(url + "stop");
} catch (HttpResponseException ex) {
- if (ex.getStatusCode() == 405) {
+ if (ex.getStatusCode() == HttpStatus.SC_METHOD_NOT_ALLOWED) {
stopPost(crumbFlag);
return "";
}
diff --git a/jenkins-client/src/main/java/com/offbytwo/jenkins/model/BuildCause.java b/jenkins-client/src/main/java/com/offbytwo/jenkins/model/BuildCause.java
index ab15f94f..821a027f 100644
--- a/jenkins-client/src/main/java/com/offbytwo/jenkins/model/BuildCause.java
+++ b/jenkins-client/src/main/java/com/offbytwo/jenkins/model/BuildCause.java
@@ -29,48 +29,54 @@ public String getShortDescription() {
return shortDescription;
}
- public void setShortDescription(String shortDescription) {
+ public BuildCause setShortDescription(String shortDescription) {
this.shortDescription = shortDescription;
+ return this;
}
public int getUpstreamBuild() {
return upstreamBuild;
}
- public void setUpstreamBuild(Integer upstreamBuild) {
+ public BuildCause setUpstreamBuild(Integer upstreamBuild) {
this.upstreamBuild = upstreamBuild;
+ return this;
}
public String getUpstreamProject() {
return upstreamProject;
}
- public void setUpstreamProject(String upstreamProject) {
+ public BuildCause setUpstreamProject(String upstreamProject) {
this.upstreamProject = upstreamProject;
+ return this;
}
public String getUpstreamUrl() {
return upstreamUrl;
}
- public void setUpstreamUrl(String upstreamUrl) {
+ public BuildCause setUpstreamUrl(String upstreamUrl) {
this.upstreamUrl = upstreamUrl;
+ return this;
}
public String getUserId() {
return userId;
}
- public void setUserId(String userId) {
+ public BuildCause setUserId(String userId) {
this.userId = userId;
+ return this;
}
public String getUserName() {
return userName;
}
- public void setUserName(String userName) {
+ public BuildCause setUserName(String userName) {
this.userName = userName;
+ return this;
}
@Override
diff --git a/jenkins-client/src/main/java/com/offbytwo/jenkins/model/BuildChangeSet.java b/jenkins-client/src/main/java/com/offbytwo/jenkins/model/BuildChangeSet.java
index 1987cc49..2b7cf520 100644
--- a/jenkins-client/src/main/java/com/offbytwo/jenkins/model/BuildChangeSet.java
+++ b/jenkins-client/src/main/java/com/offbytwo/jenkins/model/BuildChangeSet.java
@@ -24,8 +24,9 @@ public class BuildChangeSet {
/**
* @param items {@link BuildChangeSet}
*/
- public void setItems(List items) {
+ public BuildChangeSet setItems(List items) {
this.items = items;
+ return this;
}
/**
@@ -45,8 +46,9 @@ public String getKind() {
/**
* @param kind the kind of (usually svn, git).
*/
- public void setKind(String kind) {
+ public BuildChangeSet setKind(String kind) {
this.kind = kind;
+ return this;
}
@Override
diff --git a/jenkins-client/src/main/java/com/offbytwo/jenkins/model/BuildChangeSetAuthor.java b/jenkins-client/src/main/java/com/offbytwo/jenkins/model/BuildChangeSetAuthor.java
index 9abdd1ba..af416581 100644
--- a/jenkins-client/src/main/java/com/offbytwo/jenkins/model/BuildChangeSetAuthor.java
+++ b/jenkins-client/src/main/java/com/offbytwo/jenkins/model/BuildChangeSetAuthor.java
@@ -13,16 +13,18 @@ public String getAbsoluteUrl() {
return absoluteUrl;
}
- public void setAbsoluteUrl(String absoluteUrl) {
+ public BuildChangeSetAuthor setAbsoluteUrl(String absoluteUrl) {
this.absoluteUrl = absoluteUrl;
+ return this;
}
public String getFullName() {
return fullName;
}
- public void setFullName(String fullName) {
+ public BuildChangeSetAuthor setFullName(String fullName) {
this.fullName = fullName;
+ return this;
}
@Override
diff --git a/jenkins-client/src/main/java/com/offbytwo/jenkins/model/BuildChangeSetItem.java b/jenkins-client/src/main/java/com/offbytwo/jenkins/model/BuildChangeSetItem.java
index e817d12b..922a19b1 100644
--- a/jenkins-client/src/main/java/com/offbytwo/jenkins/model/BuildChangeSetItem.java
+++ b/jenkins-client/src/main/java/com/offbytwo/jenkins/model/BuildChangeSetItem.java
@@ -27,72 +27,81 @@ public List getAffectedPaths() {
return affectedPaths;
}
- public void setAffectedPaths(List affectedPaths) {
+ public BuildChangeSetItem setAffectedPaths(List affectedPaths) {
this.affectedPaths = affectedPaths;
+ return this;
}
public String getCommitId() {
return commitId;
}
- public void setCommitId(String commitId) {
+ public BuildChangeSetItem setCommitId(String commitId) {
this.commitId = commitId;
+ return this;
}
public String getTimestamp() {
return timestamp;
}
- public void setTimestamp(String timeStamp) {
+ public BuildChangeSetItem setTimestamp(String timeStamp) {
this.timestamp = timeStamp;
+ return this;
}
public String getComment() {
return comment;
}
- public void setComment(String comment) {
+ public BuildChangeSetItem setComment(String comment) {
this.comment = comment;
+ return this;
}
public String getDate() {
return date;
}
- public void setDate(String date) {
+ public BuildChangeSetItem setDate(String date) {
this.date = date;
+ return this;
}
public String getId() {
return id;
}
- public void setId(String id) {
+ public BuildChangeSetItem setId(String id) {
this.id = id;
+ return this;
}
public String getMsg() {
return msg;
}
- public void setMsg(String msg) {
+ public BuildChangeSetItem setMsg(String msg) {
this.msg = msg;
+ return this;
}
public List getPaths() {
return paths;
}
- public void setPaths(List paths) {
+ public BuildChangeSetItem setPaths(List paths) {
this.paths = paths;
+ return this;
}
public BuildChangeSetAuthor getAuthor() {
return author;
}
- public void setAuthor(BuildChangeSetAuthor author) {
+ public BuildChangeSetItem setAuthor(BuildChangeSetAuthor author) {
this.author = author;
+ return this;
}
@Override
diff --git a/jenkins-client/src/main/java/com/offbytwo/jenkins/model/BuildChangeSetPath.java b/jenkins-client/src/main/java/com/offbytwo/jenkins/model/BuildChangeSetPath.java
index e5078f3a..5758ee78 100644
--- a/jenkins-client/src/main/java/com/offbytwo/jenkins/model/BuildChangeSetPath.java
+++ b/jenkins-client/src/main/java/com/offbytwo/jenkins/model/BuildChangeSetPath.java
@@ -27,16 +27,18 @@ public String getEditType() {
* @param editType the SCM operation, add
or edit
or delete
* @see EditType
*/
- public void setEditType(String editType) {
+ public BuildChangeSetPath setEditType(String editType) {
this.editType = editType;
+ return this;
}
public String getFile() {
return file;
}
- public void setFile(String file) {
+ public BuildChangeSetPath setFile(String file) {
this.file = file;
+ return this;
}
@Override
diff --git a/jenkins-client/src/main/java/com/offbytwo/jenkins/model/BuildWithDetails.java b/jenkins-client/src/main/java/com/offbytwo/jenkins/model/BuildWithDetails.java
index 8674e921..d3ce5842 100644
--- a/jenkins-client/src/main/java/com/offbytwo/jenkins/model/BuildWithDetails.java
+++ b/jenkins-client/src/main/java/com/offbytwo/jenkins/model/BuildWithDetails.java
@@ -7,9 +7,6 @@
package com.offbytwo.jenkins.model;
import com.fasterxml.jackson.annotation.JsonProperty;
-import com.google.common.base.Predicate;
-import com.google.common.base.Strings;
-import com.google.common.collect.ImmutableMap;
import com.offbytwo.jenkins.helper.BuildConsoleStreamListener;
import org.apache.http.Header;
import org.apache.http.HttpResponse;
@@ -24,14 +21,15 @@
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
+import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
-import static com.google.common.collect.Collections2.filter;
+import static java.util.stream.Collectors.toList;
+import static java.util.stream.Collectors.toMap;
/**
* This class represents build information with details about what has been done
@@ -111,7 +109,7 @@ public BuildResult getResult() {
};
- private List actions; // TODO: Should be improved.
+ private List>>> actions; // TODO: Should be improved.
private boolean building;
private String description;
private String displayName;
@@ -163,31 +161,12 @@ public boolean isBuilding() {
}
public List getCauses() {
- // actions is a List