forked from TNG/ArchUnit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for casts TNG#710 Signed-off-by: Kaammill <>
- Loading branch information
Showing
9 changed files
with
188 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
archunit/src/main/java/com/tngtech/archunit/core/domain/TypeCast.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/* | ||
* Copyright 2014-2022 TNG Technology Consulting GmbH | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.tngtech.archunit.core.domain; | ||
|
||
import com.tngtech.archunit.PublicAPI; | ||
import com.tngtech.archunit.core.domain.properties.HasOwner; | ||
import com.tngtech.archunit.core.domain.properties.HasSourceCodeLocation; | ||
import com.tngtech.archunit.core.domain.properties.HasType; | ||
|
||
import static com.google.common.base.MoreObjects.toStringHelper; | ||
import static com.google.common.base.Preconditions.checkNotNull; | ||
import static com.tngtech.archunit.PublicAPI.Usage.ACCESS; | ||
|
||
@PublicAPI(usage = ACCESS) | ||
public final class TypeCast implements HasType, HasOwner<JavaCodeUnit>, HasSourceCodeLocation { | ||
|
||
private final JavaCodeUnit owner; | ||
private final JavaClass value; | ||
private final int lineNumber; | ||
private final SourceCodeLocation sourceCodeLocation; | ||
|
||
private TypeCast(JavaCodeUnit owner, JavaClass value, int lineNumber) { | ||
this.owner = checkNotNull(owner); | ||
this.value = checkNotNull(value); | ||
this.lineNumber = lineNumber; | ||
sourceCodeLocation = SourceCodeLocation.of(owner.getOwner(), lineNumber); | ||
} | ||
|
||
@Override | ||
@PublicAPI(usage = ACCESS) | ||
public JavaClass getRawType() { | ||
return value; | ||
} | ||
|
||
@Override | ||
@PublicAPI(usage = ACCESS) | ||
public JavaType getType() { | ||
return value; | ||
} | ||
|
||
@Override | ||
@PublicAPI(usage = ACCESS) | ||
public JavaCodeUnit getOwner() { | ||
return owner; | ||
} | ||
|
||
@PublicAPI(usage = ACCESS) | ||
public int getLineNumber() { | ||
return lineNumber; | ||
} | ||
|
||
@Override | ||
public SourceCodeLocation getSourceCodeLocation() { | ||
return sourceCodeLocation; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return toStringHelper(this) | ||
.add("owner", owner) | ||
.add("target", value) | ||
.add("lineNumber", lineNumber) | ||
.toString(); | ||
} | ||
|
||
static TypeCast from(JavaCodeUnit owner, JavaClass target, int lineNumber) { | ||
return new TypeCast(owner, target, lineNumber); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
archunit/src/main/java/com/tngtech/archunit/core/importer/RawTypeCast.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* Copyright 2014-2022 TNG Technology Consulting GmbH | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.tngtech.archunit.core.importer; | ||
|
||
import com.tngtech.archunit.core.domain.JavaClassDescriptor; | ||
|
||
import static com.google.common.base.MoreObjects.toStringHelper; | ||
|
||
class RawTypeCast { | ||
|
||
private final JavaClassDescriptor target; | ||
private final int lineNumber; | ||
|
||
private RawTypeCast(JavaClassDescriptor target, int lineNumber) { | ||
this.target = target; | ||
this.lineNumber = lineNumber; | ||
} | ||
|
||
static RawTypeCast from(JavaClassDescriptor target, int lineNumber) { | ||
return new RawTypeCast(target, lineNumber); | ||
} | ||
|
||
JavaClassDescriptor getTarget() { | ||
return target; | ||
} | ||
|
||
int getLineNumber() { | ||
return lineNumber; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return toStringHelper(this) | ||
.add("target", target) | ||
.add("lineNumber", lineNumber) | ||
.toString(); | ||
} | ||
} |