是否有可能使用公共静态方法来查找对象实例,该方法需要一个字段对象作为参数?通过给定的字段对象查找类实例
那是什么我搜索:
public class Foo {
private Bar myObject;
public static Foo get(Bar bar) {
// return an instance of Foo which has stored a
// reference to bar inside myObject or null if not found
}
}
我希望你明白我的关心。 Google没有帮助,我只是猜测可能有一个使用Java Reflection的解决方案。非常感谢您的帮助。