JAXBを使用してBeanに設定したい文字列値があります。したがって、RuntimeTypeInfoSetのインスタンスがあり、RuntimePropertyInfoを取得し、その呼び出しからgetAccessorを呼び出して、プロパティのアクセサーを取得できます。問題は、アクセサが値がすでに正しいタイプである必要があることです。どうすれば変換できますか?
質問する
108 次
1 に答える
1
答えは、トランスデューサーインスタンスを使用することです。
switch (property.kind()) {
case VALUE:
case ATTRIBUTE:
transducer = ((RuntimeNonElementRef) property).getTransducer();
break;
case ELEMENT:
transducer = ((RuntimeElementPropertyInfo) property).getTypes().get(0).getTransducer();
break;
case REFERENCE:
case MAP:
default:
throw new UnsupportedOperationException("Don't know how to handle property kind " + property.kind() + " for " + property);
}
于 2012-04-11T12:19:12.927 に答える