diff options
author | zaaarf <zaaarf@proton.me> | 2023-03-18 19:30:31 +0100 |
---|---|---|
committer | zaaarf <zaaarf@proton.me> | 2023-03-18 19:30:31 +0100 |
commit | 0e1e1bd3a470e44a79fb3c917477d6f865ff5257 (patch) | |
tree | 91f96532a27a7db9a019a5caa13eb3d37264c27e /src/main/java/ftbsc/lll/processor/tools/ArrayContainer.java | |
parent | c446cca43eaef4200e45c77c88c6ab4e46599a01 (diff) |
feat: anonymous and inner class handling, implemented united @Find
Diffstat (limited to 'src/main/java/ftbsc/lll/processor/tools/ArrayContainer.java')
-rw-r--r-- | src/main/java/ftbsc/lll/processor/tools/ArrayContainer.java | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/main/java/ftbsc/lll/processor/tools/ArrayContainer.java b/src/main/java/ftbsc/lll/processor/tools/ArrayContainer.java new file mode 100644 index 0000000..c32a621 --- /dev/null +++ b/src/main/java/ftbsc/lll/processor/tools/ArrayContainer.java @@ -0,0 +1,38 @@ +package ftbsc.lll.processor.tools; + +import javax.lang.model.type.ArrayType; +import javax.lang.model.type.TypeKind; +import javax.lang.model.type.TypeMirror; + +/** + * Utility class that extrapolates information from a {@link TypeMirror}, + * making it considerably easier to get informations about an + * array. + * @since 0.4.0 + */ +public class ArrayContainer { + /** + * The nesting level of the array - a type who is not an array will have 0. + */ + public final int arrayLevel; + + /** + * The innermost component of the array, corresponding to the type of the base + * component. + */ + public final TypeMirror innermostComponent; + + /** + * Creates a new {@link ArrayContainer} from a {@link TypeMirror}. + * @param t the {@link TypeMirror} representing the type. + */ + public ArrayContainer(TypeMirror t) { + int arrayLevel = 0; + while(t.getKind() == TypeKind.ARRAY) { + t = ((ArrayType) t).getComponentType(); + arrayLevel++; + } + this.arrayLevel = arrayLevel; + this.innermostComponent = t; + } +} |