Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Offer a way to retrieve the component type of a JavaClass that is an array #187

Closed
codecholeric opened this issue Jun 25, 2019 · 0 comments

Comments

@codecholeric
Copy link
Collaborator

As a follow up of #114 we should offer a way to get the component type of an array (compare the Java Reflection API -> arrayClass.getComponentType())
For example a JavaClass representing an array com.some.Foo[] should return com.some.Foo as the component type. Likewise com.some.Foo[][] should return com.some.Foo[] as its component type.
On the contrary to the Reflection API and to be consistent with ArchUnit's API, we should call this method

Optional<JavaClass> tryGetComponentType()

and return Optional.absent() if the respective JavaClass is no array type. Additionally we could offer JavaClass getComponentType() throwing an exception if the JavaClass is no array type for cases where the nature of the JavaClass is already known.

Note: The JavaType within JavaClass already offers a method

Optional<JavaType> tryGetComponentType()

So to implement the feature during class creation the respective JavaType.getName() must be resolved against the matching JavaClass.

alexfedorenchik added a commit to alexfedorenchik/ArchUnit that referenced this issue Oct 5, 2019
…n array.

Issue: TNG#187

Signed-off-by: Alexander Fedorenchik <alexander.fedorenchik@gmail.com>
codecholeric added a commit to alexfedorenchik/ArchUnit that referenced this issue Nov 3, 2019
…Guava AssertJ

Issue: TNG#187
Signed-off-by: Peter Gafert <peter.gafert@tngtech.com>
codecholeric added a commit to alexfedorenchik/ArchUnit that referenced this issue Nov 3, 2019
…esent. Background is, that if those component types are not referenced in another place (e.g. the two-dim component type is not also a field type somewhere, etc.), we will otherwise create a "simple" class stub here on the fly, and that simple stub will not get processed anymore and thus will not get any component type. In other words, the component type chain would then be broken.

Issue: TNG#187
Signed-off-by: Peter Gafert <peter.gafert@tngtech.com>
codecholeric added a commit to alexfedorenchik/ArchUnit that referenced this issue Nov 3, 2019
…n array (or we've already checked javaClass.isArray())

Issue: TNG#187
Signed-off-by: Peter Gafert <peter.gafert@tngtech.com>
codecholeric pushed a commit to alexfedorenchik/ArchUnit that referenced this issue Nov 3, 2019
…n array.

Issue: TNG#187

Signed-off-by: Alexander Fedorenchik <alexander.fedorenchik@gmail.com>
codecholeric added a commit to alexfedorenchik/ArchUnit that referenced this issue Nov 3, 2019
…Guava AssertJ

Issue: TNG#187
Signed-off-by: Peter Gafert <peter.gafert@tngtech.com>
codecholeric added a commit to alexfedorenchik/ArchUnit that referenced this issue Nov 3, 2019
…esent. Background is, that if those component types are not referenced in another place (e.g. the two-dim component type is not also a field type somewhere, etc.), we will otherwise create a "simple" class stub here on the fly, and that simple stub will not get processed anymore and thus will not get any component type. In other words, the component type chain would then be broken.

Issue: TNG#187
Signed-off-by: Peter Gafert <peter.gafert@tngtech.com>
codecholeric added a commit to alexfedorenchik/ArchUnit that referenced this issue Nov 3, 2019
…n array (or we've already checked javaClass.isArray())

Issue: TNG#187
Signed-off-by: Peter Gafert <peter.gafert@tngtech.com>
codecholeric pushed a commit that referenced this issue Feb 21, 2021
…n array.

Issue: #187

Signed-off-by: Alexander Fedorenchik <alexander.fedorenchik@gmail.com>
codecholeric added a commit that referenced this issue Feb 21, 2021
…Guava AssertJ

Issue: #187
Signed-off-by: Peter Gafert <peter.gafert@tngtech.com>
codecholeric added a commit that referenced this issue Feb 21, 2021
…esent. Background is, that if those component types are not referenced in another place (e.g. the two-dim component type is not also a field type somewhere, etc.), we will otherwise create a "simple" class stub here on the fly, and that simple stub will not get processed anymore and thus will not get any component type. In other words, the component type chain would then be broken.

Issue: #187
Signed-off-by: Peter Gafert <peter.gafert@tngtech.com>
codecholeric added a commit that referenced this issue Feb 21, 2021
…n array (or we've already checked javaClass.isArray())

Issue: #187
Signed-off-by: Peter Gafert <peter.gafert@tngtech.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant