diff --git a/archunit/src/main/java/com/tngtech/archunit/core/domain/Dependency.java b/archunit/src/main/java/com/tngtech/archunit/core/domain/Dependency.java index 2993a8abf..95a32909c 100644 --- a/archunit/src/main/java/com/tngtech/archunit/core/domain/Dependency.java +++ b/archunit/src/main/java/com/tngtech/archunit/core/domain/Dependency.java @@ -58,7 +58,6 @@ public final class Dependency implements HasDescription, Comparable, HasSourceCodeLocation { private final JavaClass originClass; private final JavaClass targetClass; - private final int lineNumber; private final String description; private final SourceCodeLocation sourceCodeLocation; private final int hashCode; @@ -70,7 +69,6 @@ private Dependency(JavaClass originClass, JavaClass targetClass, int lineNumber, this.originClass = originClass; this.targetClass = targetClass; - this.lineNumber = lineNumber; this.description = description; this.sourceCodeLocation = SourceCodeLocation.of(originClass, lineNumber); hashCode = Objects.hash(originClass, targetClass, lineNumber, description); @@ -276,7 +274,7 @@ public SourceCodeLocation getSourceCodeLocation() { @PublicAPI(usage = ACCESS) public int compareTo(Dependency o) { return ComparisonChain.start() - .compare(lineNumber, o.lineNumber) + .compare(sourceCodeLocation.getLineNumber(), o.sourceCodeLocation.getLineNumber()) .compare(getDescription(), o.getDescription()) .result(); } @@ -297,7 +295,7 @@ public boolean equals(Object obj) { Dependency other = (Dependency) obj; return Objects.equals(this.originClass, other.originClass) && Objects.equals(this.targetClass, other.targetClass) - && Objects.equals(this.lineNumber, other.lineNumber) + && Objects.equals(this.sourceCodeLocation.getLineNumber(), other.sourceCodeLocation.getLineNumber()) && Objects.equals(this.description, other.description); } @@ -306,7 +304,7 @@ public String toString() { return MoreObjects.toStringHelper(this) .add("originClass", originClass) .add("targetClass", targetClass) - .add("lineNumber", lineNumber) + .add("sourceCodeLocation", sourceCodeLocation) .add("description", description) .toString(); } diff --git a/archunit/src/main/java/com/tngtech/archunit/core/domain/InstanceofCheck.java b/archunit/src/main/java/com/tngtech/archunit/core/domain/InstanceofCheck.java index d0212a682..adafd5a02 100644 --- a/archunit/src/main/java/com/tngtech/archunit/core/domain/InstanceofCheck.java +++ b/archunit/src/main/java/com/tngtech/archunit/core/domain/InstanceofCheck.java @@ -29,14 +29,12 @@ public final class InstanceofCheck implements HasType, HasOwner, H private final JavaCodeUnit owner; private final JavaClass type; - private final int lineNumber; private final boolean declaredInLambda; private final SourceCodeLocation sourceCodeLocation; private InstanceofCheck(JavaCodeUnit owner, JavaClass type, int lineNumber, boolean declaredInLambda) { this.owner = checkNotNull(owner); this.type = checkNotNull(type); - this.lineNumber = lineNumber; this.declaredInLambda = declaredInLambda; sourceCodeLocation = SourceCodeLocation.of(owner.getOwner(), lineNumber); } @@ -61,7 +59,7 @@ public JavaCodeUnit getOwner() { @PublicAPI(usage = ACCESS) public int getLineNumber() { - return lineNumber; + return sourceCodeLocation.getLineNumber(); } @PublicAPI(usage = ACCESS) @@ -79,7 +77,7 @@ public String toString() { return toStringHelper(this) .add("owner", owner) .add("type", type) - .add("lineNumber", lineNumber) + .add("sourceCodeLocation", sourceCodeLocation) .add("declaredInLambda", declaredInLambda) .toString(); } diff --git a/archunit/src/main/java/com/tngtech/archunit/core/domain/JavaAccess.java b/archunit/src/main/java/com/tngtech/archunit/core/domain/JavaAccess.java index db44e6f15..93d0bad63 100644 --- a/archunit/src/main/java/com/tngtech/archunit/core/domain/JavaAccess.java +++ b/archunit/src/main/java/com/tngtech/archunit/core/domain/JavaAccess.java @@ -37,15 +37,13 @@ public abstract class JavaAccess private final JavaCodeUnit origin; private final TARGET target; - private final int lineNumber; private final SourceCodeLocation sourceCodeLocation; private final boolean declaredInLambda; JavaAccess(JavaAccessBuilder builder) { this.origin = checkNotNull(builder.getOrigin()); this.target = checkNotNull(builder.getTarget()); - this.lineNumber = builder.getLineNumber(); - this.sourceCodeLocation = SourceCodeLocation.of(getOriginOwner(), lineNumber); + this.sourceCodeLocation = SourceCodeLocation.of(getOriginOwner(), builder.getLineNumber()); this.declaredInLambda = builder.isDeclaredInLambda(); } @@ -77,7 +75,7 @@ public TARGET getTarget() { @PublicAPI(usage = ACCESS) public int getLineNumber() { - return lineNumber; + return sourceCodeLocation.getLineNumber(); } @Override @@ -100,7 +98,7 @@ public boolean isDeclaredInLambda() { @Override public String toString() { return getClass().getSimpleName() + - "{origin=" + origin + ", target=" + target + ", lineNumber=" + lineNumber + additionalToStringFields() + '}'; + "{origin=" + origin + ", target=" + target + ", lineNumber=" + getLineNumber() + additionalToStringFields() + '}'; } String additionalToStringFields() { diff --git a/archunit/src/main/java/com/tngtech/archunit/core/domain/ReferencedClassObject.java b/archunit/src/main/java/com/tngtech/archunit/core/domain/ReferencedClassObject.java index 886157feb..06b029c8c 100644 --- a/archunit/src/main/java/com/tngtech/archunit/core/domain/ReferencedClassObject.java +++ b/archunit/src/main/java/com/tngtech/archunit/core/domain/ReferencedClassObject.java @@ -29,14 +29,12 @@ public final class ReferencedClassObject implements HasType, HasOwner, HasSourceCodeLocation { private final JavaCodeUnit owner; private final JavaClass value; - private final int lineNumber; private final SourceCodeLocation sourceCodeLocation; private final boolean declaredInLambda; private ReferencedClassObject(JavaCodeUnit owner, JavaClass value, int lineNumber, boolean declaredInLambda) { this.owner = checkNotNull(owner); this.value = checkNotNull(value); - this.lineNumber = lineNumber; sourceCodeLocation = SourceCodeLocation.of(owner.getOwner(), lineNumber); this.declaredInLambda = declaredInLambda; } @@ -66,7 +64,7 @@ public JavaClass getValue() { @PublicAPI(usage = ACCESS) public int getLineNumber() { - return lineNumber; + return sourceCodeLocation.getLineNumber(); } @Override