Skip to content

Commit 3de7e41

Browse files
committed
Attempting to add a recoursive builder for Body objects. The marshal and
unmarshal support it. the builder does not...
1 parent efdffff commit 3de7e41

3 files changed

Lines changed: 93 additions & 46 deletions

File tree

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
<arg>-selectorClassName=Selector</arg>
7474
<arg>-builderClassName=Builder</arg>
7575
<arg>-builderInterfaceName=BuildSupport</arg>
76-
<arg>-copyAlways=n</arg>
76+
<arg>-copyAlways=y</arg>
7777
<arg>-buildMethodName=build</arg>
7878
<arg>-endMethodName=end</arg>
7979
<arg>-Xmeta</arg>

src/main/java/org/mujoco/xml/BodyarchType.java

Lines changed: 64 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -320,15 +320,19 @@ public BodyarchType visit(final PropertyVisitor _visitor_) {
320320
return this;
321321
}
322322

323-
public static class Builder<_B >
324-
extends BodyType.Builder<_B>
323+
public static class Builder<__B >
324+
extends BodyType.Builder<__B>
325325
implements Buildable
326326
{
327327

328328
private List<Buildable> inertialOrJointOrFreejoint;
329+
329330

330-
public Builder(final _B _parentBuilder, final BodyarchType _other, final boolean _copy) {
331-
super(_parentBuilder, _other, _copy);
331+
public Builder() {
332+
super(null, null, false);
333+
}
334+
public Builder(final __B _parentBuilder, final BodyarchType _other, final boolean _copy) {
335+
super((__B)_parentBuilder, _other, _copy);
332336
if (_other!= null) {
333337
if (_other.inertialOrJointOrFreejoint == null) {
334338
this.inertialOrJointOrFreejoint = null;
@@ -341,7 +345,24 @@ public Builder(final _B _parentBuilder, final BodyarchType _other, final boolean
341345
}
342346
}
343347

344-
public Builder(final _B _parentBuilder, final BodyarchType _other, final boolean _copy, final PropertyTree _propertyTree, final PropertyTreeUse _propertyTreeUse) {
348+
/**
349+
* Returns a new builder to build an additional value of the "body" property.
350+
* Use {@link org.mujoco.xml.BodyarchType.Builder#end()} to return to the current builder.
351+
*
352+
* @return
353+
* a new builder to build an additional value of the "body" property.
354+
* Use {@link org.mujoco.xml.BodyarchType.Builder#end()} to return to the current builder.
355+
*/
356+
public BodyarchType.Builder<? extends Mujoco.Worldbody.Builder<__B>> addBody() {
357+
if (this.inertialOrJointOrFreejoint == null) {
358+
this.inertialOrJointOrFreejoint = new ArrayList<Buildable>();
359+
}
360+
final BodyarchType.Builder<Mujoco.Worldbody.Builder<__B>> body_Builder = new BodyarchType.Builder<Mujoco.Worldbody.Builder<__B>>(this, null, false);
361+
this.inertialOrJointOrFreejoint.add(body_Builder);
362+
return body_Builder;
363+
}
364+
365+
public Builder(final __B _parentBuilder, final BodyarchType _other, final boolean _copy, final PropertyTree _propertyTree, final PropertyTreeUse _propertyTreeUse) {
345366
super(_parentBuilder, _other, _copy, _propertyTree, _propertyTreeUse);
346367
if (_other!= null) {
347368
final PropertyTree inertialOrJointOrFreejointPropertyTree = ((_propertyTree == null)?null:_propertyTree.get("inertialOrJointOrFreejoint"));
@@ -358,7 +379,8 @@ public Builder(final _B _parentBuilder, final BodyarchType _other, final boolean
358379
}
359380
}
360381

361-
protected<_P extends BodyarchType >_P init(final _P _product) {
382+
383+
protected<_P extends BodyarchType >_P init(final _P _product) {
362384
if (this.inertialOrJointOrFreejoint!= null) {
363385
final List<JAXBElement<?>> inertialOrJointOrFreejoint = new ArrayList<JAXBElement<?>>(this.inertialOrJointOrFreejoint.size());
364386
for (Buildable _item: this.inertialOrJointOrFreejoint) {
@@ -375,7 +397,7 @@ protected<_P extends BodyarchType >_P init(final _P _product) {
375397
* @param inertialOrJointOrFreejoint
376398
* Items to add to the value of the "inertialOrJointOrFreejoint" property
377399
*/
378-
public BodyarchType.Builder<_B> addInertialOrJointOrFreejoint(final Iterable<? extends JAXBElement<?>> inertialOrJointOrFreejoint) {
400+
public BodyarchType.Builder<__B> addInertialOrJointOrFreejoint(final Iterable<? extends JAXBElement<?>> inertialOrJointOrFreejoint) {
379401
if (inertialOrJointOrFreejoint!= null) {
380402
if (this.inertialOrJointOrFreejoint == null) {
381403
this.inertialOrJointOrFreejoint = new ArrayList<Buildable>();
@@ -393,7 +415,7 @@ public BodyarchType.Builder<_B> addInertialOrJointOrFreejoint(final Iterable<? e
393415
* @param inertialOrJointOrFreejoint
394416
* New value of the "inertialOrJointOrFreejoint" property.
395417
*/
396-
public BodyarchType.Builder<_B> withInertialOrJointOrFreejoint(final Iterable<? extends JAXBElement<?>> inertialOrJointOrFreejoint) {
418+
public BodyarchType.Builder<__B> withInertialOrJointOrFreejoint(final Iterable<? extends JAXBElement<?>> inertialOrJointOrFreejoint) {
397419
if (this.inertialOrJointOrFreejoint!= null) {
398420
this.inertialOrJointOrFreejoint.clear();
399421
}
@@ -406,7 +428,7 @@ public BodyarchType.Builder<_B> withInertialOrJointOrFreejoint(final Iterable<?
406428
* @param inertialOrJointOrFreejoint
407429
* Items to add to the value of the "inertialOrJointOrFreejoint" property
408430
*/
409-
public BodyarchType.Builder<_B> addInertialOrJointOrFreejoint(JAXBElement<?> ... inertialOrJointOrFreejoint) {
431+
public BodyarchType.Builder<__B> addInertialOrJointOrFreejoint(JAXBElement<?> ... inertialOrJointOrFreejoint) {
410432
addInertialOrJointOrFreejoint(Arrays.asList(inertialOrJointOrFreejoint));
411433
return this;
412434
}
@@ -417,7 +439,7 @@ public BodyarchType.Builder<_B> addInertialOrJointOrFreejoint(JAXBElement<?> ...
417439
* @param inertialOrJointOrFreejoint
418440
* New value of the "inertialOrJointOrFreejoint" property.
419441
*/
420-
public BodyarchType.Builder<_B> withInertialOrJointOrFreejoint(JAXBElement<?> ... inertialOrJointOrFreejoint) {
442+
public BodyarchType.Builder<__B> withInertialOrJointOrFreejoint(JAXBElement<?> ... inertialOrJointOrFreejoint) {
421443
withInertialOrJointOrFreejoint(Arrays.asList(inertialOrJointOrFreejoint));
422444
return this;
423445
}
@@ -428,7 +450,7 @@ public BodyarchType.Builder<_B> withInertialOrJointOrFreejoint(JAXBElement<?> ..
428450
* @param inertial_
429451
* Items to add to the value of the "inertial_" property
430452
*/
431-
public BodyarchType.Builder<_B> addInertial(final Iterable<? extends JAXBElement<InertialType>> inertial_) {
453+
public BodyarchType.Builder<__B> addInertial(final Iterable<? extends JAXBElement<InertialType>> inertial_) {
432454
return addInertialOrJointOrFreejoint(inertial_);
433455
}
434456

@@ -438,7 +460,7 @@ public BodyarchType.Builder<_B> addInertial(final Iterable<? extends JAXBElement
438460
* @param inertial_
439461
* Items to add to the value of the "inertial_" property
440462
*/
441-
public BodyarchType.Builder<_B> addInertial(JAXBElement<InertialType> ... inertial_) {
463+
public BodyarchType.Builder<__B> addInertial(JAXBElement<InertialType> ... inertial_) {
442464
return addInertial(Arrays.asList(inertial_));
443465
}
444466

@@ -448,7 +470,7 @@ public BodyarchType.Builder<_B> addInertial(JAXBElement<InertialType> ... inerti
448470
* @param joint_
449471
* Items to add to the value of the "joint_" property
450472
*/
451-
public BodyarchType.Builder<_B> addJoint(final Iterable<? extends JAXBElement<JointType>> joint_) {
473+
public BodyarchType.Builder<__B> addJoint(final Iterable<? extends JAXBElement<JointType>> joint_) {
452474
return addInertialOrJointOrFreejoint(joint_);
453475
}
454476

@@ -458,7 +480,7 @@ public BodyarchType.Builder<_B> addJoint(final Iterable<? extends JAXBElement<Jo
458480
* @param joint_
459481
* Items to add to the value of the "joint_" property
460482
*/
461-
public BodyarchType.Builder<_B> addJoint(JAXBElement<JointType> ... joint_) {
483+
public BodyarchType.Builder<__B> addJoint(JAXBElement<JointType> ... joint_) {
462484
return addJoint(Arrays.asList(joint_));
463485
}
464486

@@ -468,7 +490,7 @@ public BodyarchType.Builder<_B> addJoint(JAXBElement<JointType> ... joint_) {
468490
* @param freejoint_
469491
* Items to add to the value of the "freejoint_" property
470492
*/
471-
public BodyarchType.Builder<_B> addFreejoint(final Iterable<? extends JAXBElement<JointType>> freejoint_) {
493+
public BodyarchType.Builder<__B> addFreejoint(final Iterable<? extends JAXBElement<JointType>> freejoint_) {
472494
return addInertialOrJointOrFreejoint(freejoint_);
473495
}
474496

@@ -478,7 +500,7 @@ public BodyarchType.Builder<_B> addFreejoint(final Iterable<? extends JAXBElemen
478500
* @param freejoint_
479501
* Items to add to the value of the "freejoint_" property
480502
*/
481-
public BodyarchType.Builder<_B> addFreejoint(JAXBElement<JointType> ... freejoint_) {
503+
public BodyarchType.Builder<__B> addFreejoint(JAXBElement<JointType> ... freejoint_) {
482504
return addFreejoint(Arrays.asList(freejoint_));
483505
}
484506

@@ -488,7 +510,7 @@ public BodyarchType.Builder<_B> addFreejoint(JAXBElement<JointType> ... freejoin
488510
* @param geom_
489511
* Items to add to the value of the "geom_" property
490512
*/
491-
public BodyarchType.Builder<_B> addGeom(final Iterable<? extends JAXBElement<GeomType>> geom_) {
513+
public BodyarchType.Builder<__B> addGeom(final Iterable<? extends JAXBElement<GeomType>> geom_) {
492514
return addInertialOrJointOrFreejoint(geom_);
493515
}
494516

@@ -498,7 +520,7 @@ public BodyarchType.Builder<_B> addGeom(final Iterable<? extends JAXBElement<Geo
498520
* @param geom_
499521
* Items to add to the value of the "geom_" property
500522
*/
501-
public BodyarchType.Builder<_B> addGeom(JAXBElement<GeomType> ... geom_) {
523+
public BodyarchType.Builder<__B> addGeom(JAXBElement<GeomType> ... geom_) {
502524
return addGeom(Arrays.asList(geom_));
503525
}
504526

@@ -508,7 +530,7 @@ public BodyarchType.Builder<_B> addGeom(JAXBElement<GeomType> ... geom_) {
508530
* @param site_
509531
* Items to add to the value of the "site_" property
510532
*/
511-
public BodyarchType.Builder<_B> addSite(final Iterable<? extends JAXBElement<SiteType>> site_) {
533+
public BodyarchType.Builder<__B> addSite(final Iterable<? extends JAXBElement<SiteType>> site_) {
512534
return addInertialOrJointOrFreejoint(site_);
513535
}
514536

@@ -518,7 +540,7 @@ public BodyarchType.Builder<_B> addSite(final Iterable<? extends JAXBElement<Sit
518540
* @param site_
519541
* Items to add to the value of the "site_" property
520542
*/
521-
public BodyarchType.Builder<_B> addSite(JAXBElement<SiteType> ... site_) {
543+
public BodyarchType.Builder<__B> addSite(JAXBElement<SiteType> ... site_) {
522544
return addSite(Arrays.asList(site_));
523545
}
524546

@@ -528,7 +550,7 @@ public BodyarchType.Builder<_B> addSite(JAXBElement<SiteType> ... site_) {
528550
* @param camera_
529551
* Items to add to the value of the "camera_" property
530552
*/
531-
public BodyarchType.Builder<_B> addCamera(final Iterable<? extends JAXBElement<CameraType>> camera_) {
553+
public BodyarchType.Builder<__B> addCamera(final Iterable<? extends JAXBElement<CameraType>> camera_) {
532554
return addInertialOrJointOrFreejoint(camera_);
533555
}
534556

@@ -538,7 +560,7 @@ public BodyarchType.Builder<_B> addCamera(final Iterable<? extends JAXBElement<C
538560
* @param camera_
539561
* Items to add to the value of the "camera_" property
540562
*/
541-
public BodyarchType.Builder<_B> addCamera(JAXBElement<CameraType> ... camera_) {
563+
public BodyarchType.Builder<__B> addCamera(JAXBElement<CameraType> ... camera_) {
542564
return addCamera(Arrays.asList(camera_));
543565
}
544566

@@ -548,7 +570,7 @@ public BodyarchType.Builder<_B> addCamera(JAXBElement<CameraType> ... camera_) {
548570
* @param light_
549571
* Items to add to the value of the "light_" property
550572
*/
551-
public BodyarchType.Builder<_B> addLight(final Iterable<? extends JAXBElement<LightType>> light_) {
573+
public BodyarchType.Builder<__B> addLight(final Iterable<? extends JAXBElement<LightType>> light_) {
552574
return addInertialOrJointOrFreejoint(light_);
553575
}
554576

@@ -558,7 +580,7 @@ public BodyarchType.Builder<_B> addLight(final Iterable<? extends JAXBElement<Li
558580
* @param light_
559581
* Items to add to the value of the "light_" property
560582
*/
561-
public BodyarchType.Builder<_B> addLight(JAXBElement<LightType> ... light_) {
583+
public BodyarchType.Builder<__B> addLight(JAXBElement<LightType> ... light_) {
562584
return addLight(Arrays.asList(light_));
563585
}
564586

@@ -568,7 +590,7 @@ public BodyarchType.Builder<_B> addLight(JAXBElement<LightType> ... light_) {
568590
* @param composite_
569591
* Items to add to the value of the "composite_" property
570592
*/
571-
public BodyarchType.Builder<_B> addComposite(final Iterable<? extends JAXBElement<BodyarchType.Composite>> composite_) {
593+
public BodyarchType.Builder<__B> addComposite(final Iterable<? extends JAXBElement<BodyarchType.Composite>> composite_) {
572594
return addInertialOrJointOrFreejoint(composite_);
573595
}
574596

@@ -578,7 +600,7 @@ public BodyarchType.Builder<_B> addComposite(final Iterable<? extends JAXBElemen
578600
* @param composite_
579601
* Items to add to the value of the "composite_" property
580602
*/
581-
public BodyarchType.Builder<_B> addComposite(JAXBElement<BodyarchType.Composite> ... composite_) {
603+
public BodyarchType.Builder<__B> addComposite(JAXBElement<BodyarchType.Composite> ... composite_) {
582604
return addComposite(Arrays.asList(composite_));
583605
}
584606

@@ -588,7 +610,7 @@ public BodyarchType.Builder<_B> addComposite(JAXBElement<BodyarchType.Composite>
588610
* @param body_
589611
* Items to add to the value of the "body_" property
590612
*/
591-
public BodyarchType.Builder<_B> addBody(final Iterable<? extends JAXBElement<BodyarchType>> body_) {
613+
public BodyarchType.Builder<__B> addBody(final Iterable<? extends JAXBElement<BodyarchType>> body_) {
592614
return addInertialOrJointOrFreejoint(body_);
593615
}
594616

@@ -598,7 +620,7 @@ public BodyarchType.Builder<_B> addBody(final Iterable<? extends JAXBElement<Bod
598620
* @param body_
599621
* Items to add to the value of the "body_" property
600622
*/
601-
public BodyarchType.Builder<_B> addBody(JAXBElement<BodyarchType> ... body_) {
623+
public BodyarchType.Builder<__B> addBody(JAXBElement<BodyarchType> ... body_) {
602624
return addBody(Arrays.asList(body_));
603625
}
604626

@@ -608,7 +630,7 @@ public BodyarchType.Builder<_B> addBody(JAXBElement<BodyarchType> ... body_) {
608630
* @param include_
609631
* Items to add to the value of the "include_" property
610632
*/
611-
public BodyarchType.Builder<_B> addInclude(final Iterable<? extends JAXBElement<IncludeType>> include_) {
633+
public BodyarchType.Builder<__B> addInclude(final Iterable<? extends JAXBElement<IncludeType>> include_) {
612634
return addInertialOrJointOrFreejoint(include_);
613635
}
614636

@@ -618,7 +640,7 @@ public BodyarchType.Builder<_B> addInclude(final Iterable<? extends JAXBElement<
618640
* @param include_
619641
* Items to add to the value of the "include_" property
620642
*/
621-
public BodyarchType.Builder<_B> addInclude(JAXBElement<IncludeType> ... include_) {
643+
public BodyarchType.Builder<__B> addInclude(JAXBElement<IncludeType> ... include_) {
622644
return addInclude(Arrays.asList(include_));
623645
}
624646

@@ -629,7 +651,7 @@ public BodyarchType.Builder<_B> addInclude(JAXBElement<IncludeType> ... include_
629651
* New value of the "name" property.
630652
*/
631653
@Override
632-
public BodyarchType.Builder<_B> withName(final String name) {
654+
public BodyarchType.Builder<__B> withName(final String name) {
633655
super.withName(name);
634656
return this;
635657
}
@@ -641,7 +663,7 @@ public BodyarchType.Builder<_B> withName(final String name) {
641663
* New value of the "childclass" property.
642664
*/
643665
@Override
644-
public BodyarchType.Builder<_B> withChildclass(final String childclass) {
666+
public BodyarchType.Builder<__B> withChildclass(final String childclass) {
645667
super.withChildclass(childclass);
646668
return this;
647669
}
@@ -653,7 +675,7 @@ public BodyarchType.Builder<_B> withChildclass(final String childclass) {
653675
* New value of the "mocap" property.
654676
*/
655677
@Override
656-
public BodyarchType.Builder<_B> withMocap(final Boolean mocap) {
678+
public BodyarchType.Builder<__B> withMocap(final Boolean mocap) {
657679
super.withMocap(mocap);
658680
return this;
659681
}
@@ -665,7 +687,7 @@ public BodyarchType.Builder<_B> withMocap(final Boolean mocap) {
665687
* New value of the "pos" property.
666688
*/
667689
@Override
668-
public BodyarchType.Builder<_B> withPos(final String pos) {
690+
public BodyarchType.Builder<__B> withPos(final String pos) {
669691
super.withPos(pos);
670692
return this;
671693
}
@@ -677,7 +699,7 @@ public BodyarchType.Builder<_B> withPos(final String pos) {
677699
* New value of the "quat" property.
678700
*/
679701
@Override
680-
public BodyarchType.Builder<_B> withQuat(final String quat) {
702+
public BodyarchType.Builder<__B> withQuat(final String quat) {
681703
super.withQuat(quat);
682704
return this;
683705
}
@@ -689,7 +711,7 @@ public BodyarchType.Builder<_B> withQuat(final String quat) {
689711
* New value of the "axisangle" property.
690712
*/
691713
@Override
692-
public BodyarchType.Builder<_B> withAxisangle(final String axisangle) {
714+
public BodyarchType.Builder<__B> withAxisangle(final String axisangle) {
693715
super.withAxisangle(axisangle);
694716
return this;
695717
}
@@ -701,7 +723,7 @@ public BodyarchType.Builder<_B> withAxisangle(final String axisangle) {
701723
* New value of the "euler" property.
702724
*/
703725
@Override
704-
public BodyarchType.Builder<_B> withEuler(final String euler) {
726+
public BodyarchType.Builder<__B> withEuler(final String euler) {
705727
super.withEuler(euler);
706728
return this;
707729
}
@@ -713,7 +735,7 @@ public BodyarchType.Builder<_B> withEuler(final String euler) {
713735
* New value of the "xyaxes" property.
714736
*/
715737
@Override
716-
public BodyarchType.Builder<_B> withXyaxes(final String xyaxes) {
738+
public BodyarchType.Builder<__B> withXyaxes(final String xyaxes) {
717739
super.withXyaxes(xyaxes);
718740
return this;
719741
}
@@ -725,7 +747,7 @@ public BodyarchType.Builder<_B> withXyaxes(final String xyaxes) {
725747
* New value of the "zaxis" property.
726748
*/
727749
@Override
728-
public BodyarchType.Builder<_B> withZaxis(final String zaxis) {
750+
public BodyarchType.Builder<__B> withZaxis(final String zaxis) {
729751
super.withZaxis(zaxis);
730752
return this;
731753
}
@@ -737,7 +759,7 @@ public BodyarchType.Builder<_B> withZaxis(final String zaxis) {
737759
* New value of the "user" property.
738760
*/
739761
@Override
740-
public BodyarchType.Builder<_B> withUser(final String user) {
762+
public BodyarchType.Builder<__B> withUser(final String user) {
741763
super.withUser(user);
742764
return this;
743765
}
@@ -751,12 +773,12 @@ public BodyarchType build() {
751773
}
752774
}
753775

754-
public BodyarchType.Builder<_B> copyOf(final BodyarchType _other) {
776+
public BodyarchType.Builder<__B> copyOf(final BodyarchType _other) {
755777
_other.copyTo(this);
756778
return this;
757779
}
758780

759-
public BodyarchType.Builder<_B> copyOf(final BodyarchType.Builder _other) {
781+
public BodyarchType.Builder<__B> copyOf(final BodyarchType.Builder _other) {
760782
return copyOf(_other.build());
761783
}
762784

0 commit comments

Comments
 (0)