使用反射查找类型为String,Boolean,Integer的字段 [英] find fields of type String, Boolean, Integer using reflection
本文介绍了使用反射查找类型为String,Boolean,Integer的字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以在类型为
java.lang.Character.TYPE
java.lang.Byte.TYPE
java.lang.Short.TYPE
java.lang.Integer.TYPE
java.lang.Long.TYPE
java.lang.Float.TYPE
java.lang.Double.TYPE
有一个用于字符,字节,短等的isPrimitive方法.
there is a isPrimitive method for char, byte, short etc.
推荐答案
我正在寻找一种对包装类型返回true的方法.Springs ClassUtils提供了一种这样的方法
I was looking for one method that would return true for wrapper types. Springs ClassUtils provides one such method
ClassUtils.isPrimitiveOrWrapper(field.getType())
对于我要求的所有上述条件均返回true,但String除外
returns true for all of the above that I requested, except String
这篇关于使用反射查找类型为String,Boolean,Integer的字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文