|
10 | 10 |
|
11 | 11 | import java.beans.PropertyChangeListener; |
12 | 12 | import java.beans.VetoableChangeListener; |
| 13 | +import java.lang.reflect.InvocationTargetException; |
| 14 | +import java.lang.reflect.Method; |
13 | 15 | import java.math.BigDecimal; |
14 | 16 | import java.util.ArrayList; |
15 | 17 | import java.util.Arrays; |
|
24 | 26 | import javax.xml.bind.annotation.XmlElementRefs; |
25 | 27 | import javax.xml.bind.annotation.XmlElements; |
26 | 28 | import javax.xml.bind.annotation.XmlType; |
| 29 | +import javax.xml.namespace.QName; |
| 30 | + |
27 | 31 | import com.kscs.util.jaxb.BoundList; |
28 | 32 | import com.kscs.util.jaxb.BoundListProxy; |
29 | 33 | import com.kscs.util.jaxb.Buildable; |
@@ -362,12 +366,52 @@ protected<_P extends BodyarchType >_P init(final _P _product) { |
362 | 366 | if (this.inertialOrJointOrFreejoint!= null) { |
363 | 367 | final List<JAXBElement<?>> inertialOrJointOrFreejoint = new ArrayList<JAXBElement<?>>(this.inertialOrJointOrFreejoint.size()); |
364 | 368 | for (Buildable _item: this.inertialOrJointOrFreejoint) { |
365 | | - inertialOrJointOrFreejoint.add(((JAXBElement<?> ) _item.build())); |
| 369 | + try { |
| 370 | + inertialOrJointOrFreejoint.add(buildRecoursive(_item)); |
| 371 | + } catch (NoSuchMethodException | SecurityException | IllegalAccessException |
| 372 | + | IllegalArgumentException | InvocationTargetException e) { |
| 373 | + // TODO Auto-generated catch block |
| 374 | + e.printStackTrace(); |
| 375 | + } |
366 | 376 | } |
367 | 377 | _product.inertialOrJointOrFreejoint = inertialOrJointOrFreejoint; |
368 | 378 | } |
369 | 379 | return super.init(_product); |
370 | 380 | } |
| 381 | + private JAXBElement<?> buildRecoursive(Object o) throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException{ |
| 382 | + Class<? extends Object> class1 = o.getClass(); |
| 383 | + System.out.println("Class "+class1); |
| 384 | + Method setNameMethod = class1.getMethod("build"); |
| 385 | + Object product = setNameMethod.invoke(o); |
| 386 | + if(JAXBElement.class.isInstance(product)) |
| 387 | + return (JAXBElement<?>)product; |
| 388 | + if (product==null) |
| 389 | + throw new NullPointerException(); |
| 390 | + if(BodyarchType.class.isInstance(product)) { |
| 391 | + BodyarchType bat = (BodyarchType)product; |
| 392 | + JAXBElement<BodyarchType> element =new JAXBElement<BodyarchType>(new QName("body"),BodyarchType.class,bat); |
| 393 | + return element; |
| 394 | + } |
| 395 | + return buildRecoursive(product); |
| 396 | + } |
| 397 | + |
| 398 | + /** |
| 399 | + * Returns a new builder to build an additional value of the "body" property. |
| 400 | + * Use {@link org.mujoco.xml.BodyarchType.Builder#end()} to return to the current builder. |
| 401 | + * |
| 402 | + * @return |
| 403 | + * a new builder to build an additional value of the "body" property. |
| 404 | + * Use {@link org.mujoco.xml.BodyarchType.Builder#end()} to return to the current builder. |
| 405 | + */ |
| 406 | + public BodyarchType.Builder<? extends BodyType.Builder<_B>> addBody() { |
| 407 | + if (this.inertialOrJointOrFreejoint == null) { |
| 408 | + this.inertialOrJointOrFreejoint = new ArrayList<Buildable>(); |
| 409 | + } |
| 410 | + final BodyarchType.Builder<BodyType.Builder<_B>> body_Builder = new BodyarchType.Builder<BodyType.Builder<_B>>(this, null, false); |
| 411 | + //System.out.println("Builder type is "+body_Builder.getClass()); |
| 412 | + this.inertialOrJointOrFreejoint.add(body_Builder); |
| 413 | + return body_Builder; |
| 414 | + } |
371 | 415 |
|
372 | 416 | /** |
373 | 417 | * Adds the given items to the value of "inertialOrJointOrFreejoint" |
|
0 commit comments