Skip to content

Commit

Permalink
shortcuts for Address + Contact
Browse files Browse the repository at this point in the history
  • Loading branch information
homebeaver committed Mar 6, 2021
1 parent 3f41f62 commit bd0188d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/main/java/com/klst/edoc/api/BusinessParty.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,20 @@

public interface BusinessParty extends BusinessPartyFactory {

/*
* a shortcut for getAddress()
*/
default PostalAddress getAddress() {
return ((BusinessPartyAddress)this).getAddress();
}

/*
* a shortcut for getIContact()
*/
default IContact getContact() {
return ((BusinessPartyContact)this).getIContact();
}

// use factory: createParty(String name, String tradingName, PostalAddress address, IContact contact);
// instead setter:
// public void setRegistrationName(String name);
Expand Down
9 changes: 9 additions & 0 deletions src/test/java/com/klst/readme/OrderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.junit.Test;

import com.klst.edoc.api.BusinessParty;
import com.klst.edoc.api.BusinessPartyAddress;
import com.klst.edoc.api.IAmount;
import com.klst.edoc.api.IContact;
import com.klst.edoc.api.PostalAddress;
Expand Down Expand Up @@ -108,6 +109,14 @@ public void cioTest() {
order.setContractReference("CONTRACT_2020-25987");
order.setPreviousOrderResponseReference("PREV_ORDER_R_ID");

BusinessParty buyer = order.getBuyer();
// test shortcuts for Address + Contact
if(buyer instanceof TradeParty) {
BusinessPartyAddress buyerAddress = (BusinessPartyAddress)buyer;
LOG.info("buyerAddress (no shortcut):"+buyerAddress.getAddress());
}
LOG.info("buyer Address:"+buyer.getAddress() + " Contact:"+buyer.getContact());

// ---------------
IAmount amount = new Amount(new BigDecimal(60.00));
// 60 <> 60.00, aber mit compare to ==
Expand Down

0 comments on commit bd0188d

Please sign in to comment.