javaarchunit

archunit - navigate from JavaType to corresponding JavaClasss


How am I supposed to navigate from a JavaType instance in archunit to the corresponding JavaClass? I need to check if a method return type is primitive but JavaMethod.getJavaType() returns a JavaType that offers no means to check if the return type is primitive.


Solution

  • If you're not interested in generic type information, you can use javaType.toErasure() to navigate to the corresponding JavaClass.