package com.cadrlife.devsearch.domain;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.elasticsearch.common.base.Objects;
import org.elasticsearch.common.base.Strings;
public class Project {
private String id = "";
private String repo = "";
private String name = "";
private String slug = "";
private String cloneCommand = "";
private String cloneUrl = "";
private String projectType = "";
private String lastIndexed;
private String lastChanged;
private Path checkoutPath;
private String defaultBranch = "master";
private List<String> fileUpdates = new ArrayList<>();
private boolean updateComplete;
public String getId() {
return id;
}
public Project setId(String id) {
this.id = id;
return this;
}
public String getRepo() {
return repo;
}
public Project setRepo(String repo) {
this.repo = repo;
return this;
}
public String getName() {
return name;
}
public Project setName(String name) {
this.name = name;
return this;
}
public String getLastIndexed() {
return lastIndexed;
}
public Project setLastIndexedDate(Date date) {
return setLastIndexed(DevSearchDateFormat.format(date));
}
public Project setLastIndexed(String lastIndexed) {
this.lastIndexed = lastIndexed;
return this;
}
public String getLastChanged() {
return lastChanged;
}
public Project setLastChangedDate(Date date) {
return setLastChanged(DevSearchDateFormat.format(date));
}
public Project setLastChanged(String lastIndexed) {
this.lastChanged = lastIndexed;
return this;
}
public String getProjectType() {
return projectType;
}
public Project setProjectType(String projectType) {
this.projectType = projectType;
return this;
}
public Project setSlug(String slug) {
this.slug = slug;
return this;
}
@Override
public int hashCode(){
return Objects.hashCode(name, repo);
}
@Override
public boolean equals(final Object obj){
if(obj instanceof Project){
final Project other = (Project) obj;
return Objects.equal(name, other.name) && Objects.equal(repo, other.repo);
}
return false;
}
public String getSlug() {
return slug;
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this);
}
public String getCloneCommand() {
return cloneCommand;
}
public Project setCloneCommand(String cloneCommand) {
this.cloneCommand = cloneCommand;
return this;
}
public Path getCheckoutPath() {
return checkoutPath;
}
public Project setCheckoutPath(Path checkoutPath) {
this.checkoutPath = checkoutPath;
return this;
}
public String getCloneUrl() {
return cloneUrl;
}
public Project setCloneUrl(String cloneUrl) {
this.cloneUrl = cloneUrl;
return this;
}
public String getDefaultBranch() {
return defaultBranch;
}
public Project setDefaultBranch(String defaultBranch) {
this.defaultBranch = defaultBranch;
return this;
}
public Project addFileUpdate(String relativePath) {
fileUpdates.add(relativePath);
return this;
}
public List<String> getFileUpdates() {
return fileUpdates;
}
public Project setFileUpdates(List<String> fileUpdates) {
this.fileUpdates = fileUpdates;
return this;
}
public Project setUpdateComplete(boolean updateComplete) {
this.updateComplete = updateComplete;
return this;
}
public boolean isUpdateComplete() {
return updateComplete;
}
public boolean hasRepo() {
return !Strings.isNullOrEmpty(repo);
}
}