必要な型の配列を構築する方法があります。プリミティブ型で機能します。しかし、カスタム オブジェクトの配列がある場合は機能しません。だから私はそれを微調整しました。しかし、それでも失敗します。コードは次のようになります。
private Object buildArray( String type, Object object) {
final Class<?> requiredType = loadClass(type);
final String typeName = type.substring(2).replace(";", "").trim();
Object[] array = ((Object[]) object);
ArrayList<Object> arrayList = new ArrayList<Object>(array.length);
for (Object customObj : array) {
arrayList.add(castToRequiredType(typeName, customObj));
}
return arrayList.toArray();
}
In this : をクラスのwhere にcastToRequiredType
キャストします。また、構築する配列の型はです。の配列を動的に構築することに行き詰まっています。CustomObject
CustomType
CustomType
CustomType
CustomType
この方向の助けは大歓迎です。前もって感謝します。