Commit b1460df9 authored by Ruben Vitt's avatar Ruben Vitt Committed by Greg Messner
Browse files

Some fluent-API implementations (#237)

* add fluent api to event-model
* add fluent api to commit-model
* add fluent api to branch-model
* add fluent api to eventData-model
* add fluent api to protectedBranch-model
* add fluent api to runner-model
* add fluent api to job-model
parent 6893a210
......@@ -67,4 +67,35 @@ public class Branch {
public static final boolean isValid(Branch branch) {
return (branch != null && branch.getName() != null);
}
public Branch withCommit(Commit commit) {
this.commit = commit;
return this;
}
public Branch withDevelopersCanMerge(Boolean developersCanMerge) {
this.developersCanMerge = developersCanMerge;
return this;
}
public Branch withDevelopersCanPush(Boolean developersCanPush) {
this.developersCanPush = developersCanPush;
return this;
}
public Branch withDerged(Boolean merged) {
this.merged = merged;
return this;
}
public Branch withName(String name) {
this.name = name;
return this;
}
public Branch withIsProtected(Boolean isProtected) {
this.isProtected = isProtected;
return this;
}
}
......@@ -165,4 +165,90 @@ public class Commit {
public void setUrl(String url) {
this.url = url;
}
public Commit withAuthor(Author author) {
this.author = author;
return this;
}
public Commit withAuthoredDate(Date authoredDate) {
this.authoredDate = authoredDate;
return this;
}
public Commit withAuthorEmail(String authorEmail) {
this.authorEmail = authorEmail;
return this;
}
public Commit withAuthorName(String authorName) {
this.authorName = authorName;
return this;
}
public Commit withCommittedDate(Date committedDate) {
this.committedDate = committedDate;
return this;
}
public Commit withCommitterEmail(String committerEmail) {
this.committerEmail = committerEmail;
return this;
}
public Commit withCommitterName(String committerName) {
this.committerName = committerName;
return this;
}
public Commit withCreatedAt(Date createdAt) {
this.createdAt = createdAt;
return this;
}
public Commit withId(String id) {
this.id = id;
return this;
}
public Commit withMessage(String message) {
this.message = message;
return this;
}
public Commit withParentIds(List<String> parentIds) {
this.parentIds = parentIds;
return this;
}
public Commit withShorwId(String shortId) {
this.shortId = shortId;
return this;
}
public Commit withStats(CommitStats stats) {
this.stats = stats;
return this;
}
public Commit withStatus(String status) {
this.status = status;
return this;
}
public Commit withTimestamp(Date timestamp) {
this.timestamp = timestamp;
return this;
}
public Commit withTitle(String title) {
this.title = title;
return this;
}
public Commit withUrl(String url) {
this.url = url;
return this;
}
}
......@@ -140,4 +140,64 @@ public class Event {
public void setPushData(PushData pushData) {
this.pushData = pushData;
}
public Event withActionName(String actionName) {
this.actionName = actionName;
return this;
}
public Event withAuthor(Author author) {
this.author = author;
return this;
}
public Event withAuthorId(Integer authorId) {
this.authorId = authorId;
return this;
}
public Event withAuthorUsername(String authorUsername) {
this.authorUsername = authorUsername;
return this;
}
public Event withData(EventData data) {
this.data = data;
return this;
}
public Event withProjectId(Integer projectId) {
this.projectId = projectId;
return this;
}
public Event withTargetId(Integer targetId) {
this.targetId = targetId;
return this;
}
public Event withTargetIid(Integer targetIid) {
this.targetIid = targetIid;
return this;
}
public Event withTargetTitle(String targetTitle) {
this.targetTitle = targetTitle;
return this;
}
public Event withTargetType(TargetType targetType) {
this.targetType = targetType;
return this;
}
public Event withTitle(String title) {
this.title = title;
return this;
}
public Event withCreatedAt(Date createdAt) {
this.createdAt = createdAt;
return this;
}
}
......@@ -83,4 +83,45 @@ public class EventData {
public void setUserName(String userName) {
this.userName = userName;
}
public EventData withAfter(String after) {
this.after = after;
return this;
}
public EventData withBefore(String before) {
this.before = before;
return this;
}
public EventData withCommits(List<Commit> commits) {
this.commits = commits;
return this;
}
public EventData withRef(String ref) {
this.ref = ref;
return this;
}
public EventData withRepository(Repository repository) {
this.repository = repository;
return this;
}
public EventData withTotalCommitsCount(Integer totalCommitsCount) {
this.totalCommitsCount = totalCommitsCount;
return this;
}
public EventData withUserId(Integer userId) {
this.userId = userId;
return this;
}
public EventData withUserName(String userName) {
this.userName = userName;
return this;
}
}
......@@ -144,4 +144,80 @@ public class Job {
public void setRunner(Runner runner) {
this.runner = runner;
}
public Job withId(Integer id) {
this.id = id;
return this;
}
public Job withCommit(Commit commit) {
this.commit = commit;
return this;
}
public Job withCoverage(String coverage) {
this.coverage = coverage;
return this;
}
public Job withCreatedAt(Date createdAt) {
this.createdAt = createdAt;
return this;
}
public Job withFinishedAt(Date finishedAt) {
this.finishedAt = finishedAt;
return this;
}
public Job withName(String name) {
this.name = name;
return this;
}
public Job withPipeline(Pipeline pipeline) {
this.pipeline = pipeline;
return this;
}
public Job withRef(String ref) {
this.ref = ref;
return this;
}
public Job withRunner(Runner runner) {
this.runner = runner;
return this;
}
public Job withUser(User user) {
this.user = user;
return this;
}
public Job withStartedAt(Date startedAt) {
this.startedAt = startedAt;
return this;
}
public Job withArtifactsFile(ArtifactsFile artifactsFile) {
this.artifactsFile = artifactsFile;
return this;
}
public Job withTag(Boolean tag) {
this.tag = tag;
return this;
}
public Job withStage(String stage) {
this.stage = stage;
return this;
}
public Job withStatus(JobStatus status) {
this.status = status;
return this;
}
}
......@@ -41,4 +41,20 @@ public class ProtectedBranch {
public static final boolean isValid(ProtectedBranch branch) {
return (branch != null && branch.getName() != null);
}
public ProtectedBranch withName(String name) {
this.name = name;
return this;
}
public ProtectedBranch withPushAccessLevels(List<BranchAccessLevel> pushAccessLevels) {
this.pushAccessLevels = pushAccessLevels;
return this;
}
public ProtectedBranch withMergeAccessLevels(List<BranchAccessLevel> mergeAccessLevels) {
this.mergeAccessLevels = mergeAccessLevels;
return this;
}
}
......@@ -109,4 +109,45 @@ public class Runner {
public void setIpAddress(String ipAddress) {
this.ipAddress = ipAddress;
}
public Runner withId(Integer id) {
this.id = id;
return this;
}
public Runner withDescription(String description) {
this.description = description;
return this;
}
public Runner withActive(Boolean active) {
this.active = active;
return this;
}
public Runner withIsShared(Boolean isShared) {
this.isShared = isShared;
return this;
}
public Runner withName(String name) {
this.name = name;
return this;
}
public Runner withOnline(Boolean online) {
this.online = online;
return this;
}
public Runner withStatus(RunnerStatus status) {
this.status = status;
return this;
}
public Runner withIpAddress(String ipAddress) {
this.ipAddress = ipAddress;
return this;
}
}
......@@ -121,4 +121,49 @@ public class RunnerDetail extends Runner {
public void setAccessLevel(RunnerAccessLevel accessLevel) {
this.accessLevel = accessLevel;
}
public RunnerDetail withArchitecture(String architecture) {
this.architecture = architecture;
return this;
}
public RunnerDetail withPlatform(String platform) {
this.platform = platform;
return this;
}
public RunnerDetail withContactedAt(Date contactedAt) {
this.contactedAt = contactedAt;
return this;
}
public RunnerDetail withProjects(List<Project> projects) {
this.projects = projects;
return this;
}
public RunnerDetail withToken(String token) {
this.token = token;
return this;
}
public RunnerDetail withRevision(String revision) {
this.revision = revision;
return this;
}
public RunnerDetail withTagList(List<String> tagList) {
this.tagList = tagList;
return this;
}
public RunnerDetail withVersion(String version) {
this.version = version;
return this;
}
public RunnerDetail withAccessLevel(RunnerAccessLevel accessLevel) {
this.accessLevel = accessLevel;
return this;
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment