diff options
Diffstat (limited to 'src/main')
| -rw-r--r-- | src/main/java/at/gv/egiz/moazs/scheme/Mzs2MsgConverter.java | 38 | 
1 files changed, 23 insertions, 15 deletions
| diff --git a/src/main/java/at/gv/egiz/moazs/scheme/Mzs2MsgConverter.java b/src/main/java/at/gv/egiz/moazs/scheme/Mzs2MsgConverter.java index 7dddbf1..f2e6861 100644 --- a/src/main/java/at/gv/egiz/moazs/scheme/Mzs2MsgConverter.java +++ b/src/main/java/at/gv/egiz/moazs/scheme/Mzs2MsgConverter.java @@ -150,17 +150,23 @@ public class Mzs2MsgConverter {          return addresses.stream()                  .map(JAXBElement::getValue)                  .map(this::convert) -                .map(personFactory::createAddress)                  .collect(toList());      } -    private AbstractAddressType convert(at.gv.zustellung.app2mzs.xsd.persondata.AbstractAddressType address) { -        if        (address instanceof at.gv.zustellung.app2mzs.xsd.persondata.InternetAddressType ) { return convert((at.gv.zustellung.app2mzs.xsd.persondata.InternetAddressType)  address); -        } else if (address instanceof at.gv.zustellung.app2mzs.xsd.persondata.PostalAddressType   ) { return convert((at.gv.zustellung.app2mzs.xsd.persondata.PostalAddressType)    address); -        } else if (address instanceof at.gv.zustellung.app2mzs.xsd.persondata.TelephoneAddressType) { return convert((at.gv.zustellung.app2mzs.xsd.persondata.TelephoneAddressType) address); -        } else { -            throw new IllegalArgumentException(format("No conversion strategy of address of type=%s.", address.getClass().toGenericString())); -        } +    private JAXBElement<? extends  AbstractAddressType> convert(at.gv.zustellung.app2mzs.xsd.persondata.AbstractAddressType address) { +        if (address instanceof at.gv.zustellung.app2mzs.xsd.persondata.InternetAddressType) +            return personFactory.createInternetAddress( +                    convert((at.gv.zustellung.app2mzs.xsd.persondata.InternetAddressType) address)); + +        if (address instanceof at.gv.zustellung.app2mzs.xsd.persondata.PostalAddressType) +            return personFactory.createPostalAddress( +                    convert((at.gv.zustellung.app2mzs.xsd.persondata.PostalAddressType) address)); + +        if (address instanceof at.gv.zustellung.app2mzs.xsd.persondata.TelephoneAddressType) +            return personFactory.createTelephoneAddress( +                    convert((at.gv.zustellung.app2mzs.xsd.persondata.TelephoneAddressType) address)); + +        throw new IllegalArgumentException(format("No conversion strategy for address of type=%s.", address.getClass().toGenericString()));      }      private InternetAddressType convert(at.gv.zustellung.app2mzs.xsd.persondata.InternetAddressType address) { @@ -244,20 +250,22 @@ public class Mzs2MsgConverter {      //------------ PERSONS -------------------- -    public JAXBElement<AbstractPersonType> convert( +    public JAXBElement<? extends AbstractPersonType> convert(              JAXBElement<? extends at.gv.zustellung.app2mzs.xsd.persondata.AbstractPersonType> jaxbPerson) {          var mzsPerson = jaxbPerson.getValue(); +        //todo: move this to mzs          Assert.isTrue(personIsPhysical(mzsPerson) || personIsCorporateBody(mzsPerson),                  "Person is neither a PhysicalPerson nor a CorporateBody."); -        var msgPerson = (personIsPhysical(mzsPerson)) -                ? convert((at.gv.zustellung.app2mzs.xsd.persondata.PhysicalPersonType) mzsPerson) -                : convert((at.gv.zustellung.app2mzs.xsd.persondata.CorporateBodyType) mzsPerson); - -        return personFactory.createPerson(msgPerson); - +        if (personIsPhysical(mzsPerson)) { +            var msgPerson = convert((at.gv.zustellung.app2mzs.xsd.persondata.PhysicalPersonType) mzsPerson); +            return personFactory.createPhysicalPerson(msgPerson); +        } else { +            var msgPerson = convert((at.gv.zustellung.app2mzs.xsd.persondata.CorporateBodyType) mzsPerson); +            return personFactory.createCorporateBody(msgPerson); +        }      }      private boolean personIsPhysical(at.gv.zustellung.app2mzs.xsd.persondata.AbstractPersonType person) { | 
