I want to make sure that all fields of a Class should be primitive type or collection of primitive type:
class MyClass {
String a;
int b;
float c;
int[] d;
List<String>;
}
How can I achieve that?
I've tried the following code to make part of it works
javaField.rawType.isPrimitive // check whether the field is primitive type
javaField.rawType.simpleName == "String" // check whether it's String
But how can I check whether the field is an Array of primitive type, such as int[] byte[], or a List of primitive type, such as List<String>, etc?
In other words:
- How can I know the generic type inside a
List<T>?
- How to describe an Array of a primitive type?