
com.undefinedlabs.scope.utils.sourcecode.SourceCodeFrame Maven / Gradle / Ivy
package com.undefinedlabs.scope.utils.sourcecode;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
public class SourceCodeFrame {
public static final SourceCodeFrame EMPTY =
new SourceCodeFrame(SourceCode.EMPTY, "", -1, SourceCodeBoundary.EMPTY);
private final SourceCode sourceCode;
private final String methodName;
private final int methodLine;
private final String linkPathWithMethodLine;
private final SourceCodeBoundary boundary;
private final String linkPathWithMethodBoundaries;
public SourceCodeFrame(
final SourceCode sourceCode,
final String methodName,
final int methodLine,
final SourceCodeBoundary boundary) {
this.sourceCode = sourceCode;
this.methodName = methodName;
this.methodLine = methodLine;
linkPathWithMethodLine =
SourceCodeFrameUtils.INSTANCE.buildLinkPathWithMethodLine(sourceCode, methodLine);
this.boundary = boundary;
linkPathWithMethodBoundaries =
SourceCodeFrameUtils.INSTANCE.buildLinkPathWithMethodBoundaries(boundary);
}
public SourceCode getSourceCode() {
return sourceCode;
}
public String getMethodName() {
return methodName;
}
public int getMethodLine() {
return methodLine;
}
public String getLinkPathWithMethodLine() {
return linkPathWithMethodLine;
}
public SourceCodeBoundary getBoundary() {
return boundary;
}
public String getLinkPathWithMethodBoundaries() {
return linkPathWithMethodBoundaries;
}
@Override
public boolean equals(final Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
final SourceCodeFrame that = (SourceCodeFrame) o;
return new EqualsBuilder()
.append(methodLine, that.methodLine)
.append(sourceCode, that.sourceCode)
.append(methodName, that.methodName)
.append(linkPathWithMethodLine, that.linkPathWithMethodLine)
.append(boundary, that.boundary)
.append(linkPathWithMethodBoundaries, that.linkPathWithMethodBoundaries)
.isEquals();
}
@Override
public int hashCode() {
return new HashCodeBuilder(17, 37)
.append(sourceCode)
.append(methodName)
.append(methodLine)
.append(linkPathWithMethodLine)
.append(boundary)
.append(linkPathWithMethodBoundaries)
.toHashCode();
}
@Override
public String toString() {
return new ToStringBuilder(this)
.append("sourceCode", sourceCode)
.append("methodName", methodName)
.append("methodLine", methodLine)
.append("linkPathWithMethodLine", linkPathWithMethodLine)
.append("boundary", boundary)
.append("linkPathWithMethodBoundaries", linkPathWithMethodBoundaries)
.toString();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy