|
| 1 | + protected<_P extends BodyarchType >_P init(final _P _product) { |
| 2 | + if (this.inertialOrJointOrFreejoint!= null) { |
| 3 | + final List<JAXBElement<?>> inertialOrJointOrFreejoint = new ArrayList<JAXBElement<?>>(this.inertialOrJointOrFreejoint.size()); |
| 4 | + for (Buildable _item: this.inertialOrJointOrFreejoint) { |
| 5 | + try { |
| 6 | + inertialOrJointOrFreejoint.add(buildRecoursive(_item)); |
| 7 | + } catch (NoSuchMethodException | SecurityException | IllegalAccessException |
| 8 | + | IllegalArgumentException | InvocationTargetException e) { |
| 9 | + // TODO Auto-generated catch block |
| 10 | + e.printStackTrace(); |
| 11 | + } |
| 12 | + } |
| 13 | + _product.inertialOrJointOrFreejoint = inertialOrJointOrFreejoint; |
| 14 | + } |
| 15 | + return super.init(_product); |
| 16 | + } |
| 17 | + private JAXBElement<?> buildRecoursive(Object o) throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException{ |
| 18 | + Class<? extends Object> class1 = o.getClass(); |
| 19 | + //System.out.println("Class "+class1); |
| 20 | + Method setNameMethod = class1.getMethod("build"); |
| 21 | + Object product = setNameMethod.invoke(o); |
| 22 | + if(JAXBElement.class.isInstance(product)) |
| 23 | + return (JAXBElement<?>)product; |
| 24 | + if (product==null) |
| 25 | + throw new NullPointerException(); |
| 26 | + if(BodyarchType.class.isInstance(product)) { |
| 27 | + BodyarchType bat = (BodyarchType)product; |
| 28 | + return new JAXBElement<BodyarchType>(new QName("body"),BodyarchType.class,bat); |
| 29 | + } |
| 30 | + //GeomType |
| 31 | + if(GeomType.class.isInstance(product)) { |
| 32 | + GeomType bat = (GeomType)product; |
| 33 | + return new JAXBElement<GeomType>(new QName("geom"),GeomType.class,bat); |
| 34 | + } |
| 35 | + //LightType |
| 36 | + if(LightType.class.isInstance(product)) { |
| 37 | + LightType bat = (LightType)product; |
| 38 | + return new JAXBElement<LightType>(new QName("light"),LightType.class,bat); |
| 39 | + } |
| 40 | + //JointType |
| 41 | + if(JointType.class.isInstance(product)) { |
| 42 | + JointType bat = (JointType)product; |
| 43 | + if(bat.getType()==JointtypeType.FREE) { |
| 44 | + bat.setType(null); |
| 45 | + return new JAXBElement<JointType>(new QName("freejoint"),JointType.class,bat); |
| 46 | + } |
| 47 | + return new JAXBElement<JointType>(new QName("joint"),JointType.class,bat); |
| 48 | + } |
| 49 | +// //FreejointType |
| 50 | +// if(FreejointType.class.isInstance(product)) { |
| 51 | +// FreejointType bat = (FreejointType)product; |
| 52 | +// return new JAXBElement<FreejointType>(new QName("freejoint"),FreejointType.class,bat); |
| 53 | +// } |
| 54 | + |
| 55 | + //CameraType |
| 56 | + if(CameraType.class.isInstance(product)) { |
| 57 | + CameraType bat = (CameraType)product; |
| 58 | + return new JAXBElement<CameraType>(new QName("camera"),CameraType.class,bat); |
| 59 | + } |
| 60 | + //InertialType |
| 61 | + if(InertialType.class.isInstance(product)) { |
| 62 | + InertialType bat = (InertialType)product; |
| 63 | + return new JAXBElement<InertialType>(new QName("inertial"),InertialType.class,bat); |
| 64 | + } |
| 65 | + return buildRecoursive(product); |
| 66 | + } |
| 67 | + /** |
| 68 | + * Returns a new builder to build an additional value of the "camera" property. |
| 69 | + * Use {@link org.mujoco.xml.body.CameraType.Builder#end()} to return to the current builder. |
| 70 | + * |
| 71 | + * @return |
| 72 | + * a new builder to build an additional value of the "camera" property. |
| 73 | + * Use {@link org.mujoco.xml.body.CameraType.Builder#end()} to return to the current builder. |
| 74 | + */ |
| 75 | + public org.mujoco.xml.body.InertialType.Builder<? extends BodyType.Builder<_B>> addInertial() { |
| 76 | + if (this.inertialOrJointOrFreejoint == null) { |
| 77 | + this.inertialOrJointOrFreejoint = new ArrayList<Buildable>(); |
| 78 | + } |
| 79 | + final org.mujoco.xml.body.InertialType.Builder<BodyType.Builder<_B>> camera_Builder = new org.mujoco.xml.body.InertialType.Builder<BodyType.Builder<_B>>(this, null, false); |
| 80 | + this.inertialOrJointOrFreejoint.add(camera_Builder); |
| 81 | + return camera_Builder; |
| 82 | + } |
| 83 | + /** |
| 84 | + * Returns a new builder to build an additional value of the "camera" property. |
| 85 | + * Use {@link org.mujoco.xml.body.CameraType.Builder#end()} to return to the current builder. |
| 86 | + * |
| 87 | + * @return |
| 88 | + * a new builder to build an additional value of the "camera" property. |
| 89 | + * Use {@link org.mujoco.xml.body.CameraType.Builder#end()} to return to the current builder. |
| 90 | + */ |
| 91 | + public org.mujoco.xml.body.CameraType.Builder<? extends BodyType.Builder<_B>> addCamera() { |
| 92 | + if (this.inertialOrJointOrFreejoint == null) { |
| 93 | + this.inertialOrJointOrFreejoint = new ArrayList<Buildable>(); |
| 94 | + } |
| 95 | + final org.mujoco.xml.body.CameraType.Builder<BodyType.Builder<_B>> camera_Builder = new org.mujoco.xml.body.CameraType.Builder<BodyType.Builder<_B>>(this, null, false); |
| 96 | + this.inertialOrJointOrFreejoint.add(camera_Builder); |
| 97 | + return camera_Builder; |
| 98 | + } |
| 99 | + /** |
| 100 | + * Returns a new builder to build an additional value of the "body" property. |
| 101 | + * Use {@link org.mujoco.xml.BodyarchType.Builder#end()} to return to the current builder. |
| 102 | + * |
| 103 | + * @return |
| 104 | + * a new builder to build an additional value of the "body" property. |
| 105 | + * Use {@link org.mujoco.xml.BodyarchType.Builder#end()} to return to the current builder. |
| 106 | + */ |
| 107 | + public BodyarchType.Builder<? extends BodyType.Builder<_B>> addBody() { |
| 108 | + if (this.inertialOrJointOrFreejoint == null) { |
| 109 | + this.inertialOrJointOrFreejoint = new ArrayList<Buildable>(); |
| 110 | + } |
| 111 | + final BodyarchType.Builder<BodyType.Builder<_B>> body_Builder = new BodyarchType.Builder<BodyType.Builder<_B>>(this, null, false); |
| 112 | + //System.out.println("Builder type is "+body_Builder.getClass()); |
| 113 | + this.inertialOrJointOrFreejoint.add(body_Builder); |
| 114 | + return body_Builder; |
| 115 | + } |
| 116 | + /** |
| 117 | + * Returns a new builder to build an additional value of the "geom" property. |
| 118 | + * Use {@link org.mujoco.xml.body.GeomType.Builder#end()} to return to the current builder. |
| 119 | + * |
| 120 | + * @return |
| 121 | + * a new builder to build an additional value of the "geom" property. |
| 122 | + * Use {@link org.mujoco.xml.body.GeomType.Builder#end()} to return to the current builder. |
| 123 | + */ |
| 124 | + public org.mujoco.xml.body.GeomType.Builder<? extends BodyType.Builder<_B>> addGeom() { |
| 125 | + if (this.inertialOrJointOrFreejoint == null) { |
| 126 | + this.inertialOrJointOrFreejoint = new ArrayList<Buildable>(); |
| 127 | + } |
| 128 | + final org.mujoco.xml.body.GeomType.Builder<BodyType.Builder<_B>> geom_Builder = new org.mujoco.xml.body.GeomType.Builder<BodyType.Builder<_B>>(this, null, false); |
| 129 | + this.inertialOrJointOrFreejoint.add(geom_Builder); |
| 130 | + return geom_Builder; |
| 131 | + } |
| 132 | + |
| 133 | + /** |
| 134 | + * Returns a new builder to build an additional value of the "light" property. |
| 135 | + * Use {@link org.mujoco.xml.body.LightType.Builder#end()} to return to the current builder. |
| 136 | + * |
| 137 | + * @return |
| 138 | + * a new builder to build an additional value of the "light" property. |
| 139 | + * Use {@link org.mujoco.xml.body.LightType.Builder#end()} to return to the current builder. |
| 140 | + */ |
| 141 | + public org.mujoco.xml.body.LightType.Builder<? extends BodyType.Builder<_B>> addLight() { |
| 142 | + if (this.inertialOrJointOrFreejoint == null) { |
| 143 | + this.inertialOrJointOrFreejoint = new ArrayList<Buildable>(); |
| 144 | + } |
| 145 | + final org.mujoco.xml.body.LightType.Builder<BodyType.Builder<_B>> light_Builder = new org.mujoco.xml.body.LightType.Builder<BodyType.Builder<_B>>(this, null, false); |
| 146 | + this.inertialOrJointOrFreejoint.add(light_Builder); |
| 147 | + return light_Builder; |
| 148 | + } |
| 149 | + //JointType |
| 150 | + /** |
| 151 | + * Returns a new builder to build an additional value of the "joint" property. |
| 152 | + * Use {@link org.mujoco.xml.body.FreejointType.Builder#end()} to return to the current builder. |
| 153 | + * |
| 154 | + * @return |
| 155 | + * a new builder to build an additional value of the "joint" property. |
| 156 | + * Use {@link org.mujoco.xml.body.FreejointType.Builder#end()} to return to the current builder. |
| 157 | + */ |
| 158 | + public org.mujoco.xml.body.JointType.Builder<? extends BodyType.Builder<_B>> addFreejoint() { |
| 159 | + return addJoint(JointtypeType.FREE); |
| 160 | + } |
| 161 | + |
| 162 | + //JointType |
| 163 | + /** |
| 164 | + * Returns a new builder to build an additional value of the "joint" property. |
| 165 | + * Use {@link org.mujoco.xml.body.JointType.Builder#end()} to return to the current builder. |
| 166 | + * |
| 167 | + * @return |
| 168 | + * a new builder to build an additional value of the "joint" property. |
| 169 | + * Use {@link org.mujoco.xml.body.JointType.Builder#end()} to return to the current builder. |
| 170 | + */ |
| 171 | + public org.mujoco.xml.body.JointType.Builder<? extends BodyType.Builder<_B>> addJoint(JointtypeType type) { |
| 172 | + if (this.inertialOrJointOrFreejoint == null) { |
| 173 | + this.inertialOrJointOrFreejoint = new ArrayList<Buildable>(); |
| 174 | + } |
| 175 | + final org.mujoco.xml.body.JointType.Builder<BodyType.Builder<_B>> joint_builder = new org.mujoco.xml.body.JointType.Builder<BodyType.Builder<_B>>(this, null, false); |
| 176 | + this.inertialOrJointOrFreejoint.add(joint_builder); |
| 177 | + joint_builder.withType(type); |
| 178 | + return joint_builder; |
| 179 | + } |
0 commit comments