有 Android 兼容的 Property Utils 替代品吗?
Android 上是否有相当于 org.apache.commons.beanutils.PropertyUtils 的方便实用工具?
由于对 PropertyDescriptor
和 IndexedPropertyDescriptor
的一些依赖,我似乎无法在我的 Android 应用程序中使用 bean utils
。所以我想知道是否有其他选择?
基本上我想做的就是使用方法名称作为字符串“someMethod”并将其输入到 setMethod(anObject, "someMethod", value)
中,就像 PropertyUtils
所做的那样;但不必求助于令人讨厌的反射...
或者我的双手被束缚并且我需要使用反射?
Is there a handy-dandy equivalent to org.apache.commons.beanutils.PropertyUtils
on Android?
I can't seem to use bean utils
in my android app due to some dependencies on PropertyDescriptor
,and IndexedPropertyDescriptor
. So I'm wondering if there are any alternatives?
Basically all I want to do is use a method name as a string "someMethod" and feed that into setMethod(anObject, "someMethod", value)
, much like PropertyUtils
does; but without having to resort to the nasties of reflection...
Or are my hands tied and I need to use Reflection?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
有一个适用于 Android 的桥接库: android-java-air-bridge.jar< /a>.只需包含到项目路径中并在 Android 项目中使用所有 apache beanutils 功能,就像在普通 java 应用程序中使用一样。此外,还有许多其他类已移至此 Android 支持库。看看清单。
There is bridge library which works on Android: android-java-air-bridge.jar. Just include into project path and use all apache beanutils features in your Android project as you could use in ordinary java application. Moreover, there are lot of other classes which moved to this Android supporting library. Look at the list.
可以根据
PropertyUtils
使用库或编写自己的代码。但它肯定不是花花公子。您可以大致了解在此线程中需要做什么。显然有一些项目已经成功解决了这个问题,所以你可以研究他们的解决方案。查看 Drawingpad-base 和 libgdx。您可以在第一个项目的
com.madrobot.beans
包中找到PropertyUtils
,在第二个项目的com.badlogic.gdx.beans
中找到PropertyUtils
。There is a possibilty to use libraries or write own code depending on the
PropertyUtils
. But it sure isn't dandy. You can get the general idea about what has to be done in this thread.There are apparently some projects who have successfully solved the issue, so you can study thier solution. Take a look at Drawingpad-base and libgdx. You can find
PropertyUtils
in the packagecom.madrobot.beans
in the first project andcom.badlogic.gdx.beans
in the second.