0
중첩 된 Java 객체 구조에서 주어진 경로 문자열에 의해 값을 설정하려고합니다. 속성을 존재 나던 collction 속성이 자동으로 인스턴스화해야하는 경우 : 주어진 경로에 대해 객체를 자동으로 인스턴스화하고 값을 설정합니다.
public class A {
List<B> bs;
// getter/setter
}
public class B {
String b1;
String b2;
// getter/setter
}
public Object setValueForPath(String path, Object value){
// magic starts
// Set Value for Path
// automatically instantiate Objects if nessesary
}
A result = setValueForPath("bs[0].b1", "test") // return full Object structure
assertEqual(result.getBbs().get(0).getB1(), "test");
가 어떻게이 문제를 해결할 수
?
Apache commons OGNL : http://commons.apache.org/proper/commons-ognl/language-guide.html을 참조하십시오. –