
com.undefinedlabs.scope.utils.sourcecode.SourceCode Maven / Gradle / Ivy
package com.undefinedlabs.scope.utils.sourcecode;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
public class SourceCode {
public static final SourceCode EMPTY = new SourceCode(new Builder());
private final String className;
private final String sourceFileName;
private final String sourceFilePath;
private final boolean hasConflicts;
public SourceCode(final Builder builder) {
className = builder.className;
sourceFileName = builder.sourceFileName;
sourceFilePath = builder.sourceFilePath;
hasConflicts = builder.hasConflicts;
}
public String getClassName() {
return className;
}
public String getSourceFileName() {
return sourceFileName;
}
public String getSourceFilePath() {
return sourceFilePath;
}
public boolean hasSourceCodeFilePath() {
return StringUtils.isNotEmpty(sourceFilePath);
}
public boolean hasConflicts() {
return hasConflicts;
}
public static Builder newBuilder() {
return new Builder();
}
public static Builder newBuilder(final SourceCode sourceCode) {
return new Builder(sourceCode);
}
@Override
public boolean equals(final Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
final SourceCode that = (SourceCode) o;
return new EqualsBuilder()
.append(className, that.className)
.append(sourceFileName, that.sourceFileName)
.append(sourceFilePath, that.sourceFilePath)
.isEquals();
}
@Override
public int hashCode() {
return new HashCodeBuilder(17, 37)
.append(className)
.append(sourceFileName)
.append(sourceFilePath)
.toHashCode();
}
@Override
public String toString() {
return new ToStringBuilder(this)
.append("className", className)
.append("sourceFileName", sourceFileName)
.append("sourceFilePath", sourceFilePath)
.toString();
}
public static class Builder {
private String className;
private String sourceFileName;
private String sourceFilePath;
private boolean hasConflicts;
Builder() {}
Builder(final SourceCode sourceCode) {
if (sourceCode != null) {
className = sourceCode.className;
sourceFileName = sourceCode.sourceFileName;
sourceFilePath = sourceCode.sourceFilePath;
}
}
public Builder withClassName(final String className) {
this.className = className;
return this;
}
public Builder withSourceFileName(final String sourceFileName) {
this.sourceFileName = sourceFileName;
return this;
}
public Builder withSourceFilePath(final String sourceCodePath) {
sourceFilePath = sourceCodePath;
return this;
}
public Builder withHasConflicts(final boolean hasConflicts) {
this.hasConflicts = hasConflicts;
return this;
}
public SourceCode build() {
return new SourceCode(this);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy