有 Android 兼容的 Property Utils 替代品吗?

发布于 2024-11-18 19:07:37 字数 414 浏览 4 评论 0原文

Android 上是否有相当于 org.apache.commons.beanutils.PropertyUtils 的方便实用工具?

由于对 PropertyDescriptorIndexedPropertyDescriptor 的一些依赖,我似乎无法在我的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

寻找我们的幸福 2024-11-25 19:07:37

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.

很快妥协 2024-11-25 19:07:37

可以根据 PropertyUtils 使用库或编写自己的代码。但它肯定不是花花公子。您可以大致了解在此线程中需要做什么

显然有一些项目已经成功解决了这个问题,所以你可以研究他们的解决方案。查看 Drawingpad-baselibgdx。您可以在第一个项目的 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 package com.madrobot.beans in the first project and com.badlogic.gdx.beans in the second.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文