1 5 package com.nightlabs.ipanema.trade; 6 7 import java.io.Serializable ; 8 import java.util.HashMap ; 9 import java.util.Map ; 10 11 import com.nightlabs.ipanema.accounting.Currency; 12 13 14 26 public class Order 27 implements Serializable 28 { 29 33 private String organisationID; 34 35 38 private long orderID; 39 40 43 private Currency currency; 44 45 48 private OrganisationLegalEntity vendor; 49 50 53 private LegalEntity customer; 54 55 58 protected boolean customerChangeable = true; 59 60 73 private Map items = new HashMap (); 74 75 89 private Map offers = new HashMap (); 90 91 public Order() {} 92 93 public Order(OrganisationLegalEntity vendor, LegalEntity customer, long orderID, Currency currency) 94 { 95 if (vendor == null) 96 throw new NullPointerException ("vendor"); 97 98 if (customer == null) 99 throw new NullPointerException ("customer"); 100 101 if (currency == null) 102 throw new NullPointerException ("currency"); 103 104 this.vendor = vendor; 105 this.customer = customer; 106 this.organisationID = vendor.getOrganisationID(); 107 this.orderID = orderID; 108 this.currency = currency; 109 } 110 111 114 public String getOrganisationID() 115 { 116 return organisationID; 117 } 118 121 public long getOrderID() 122 { 123 return orderID; 124 } 125 126 public static String getPrimaryKey(String organisationID, long orderID) 127 { 128 return organisationID + '/' + Long.toHexString(orderID); 129 } 130 public String getPrimaryKey() 131 { 132 return organisationID + '/' + Long.toHexString(orderID); 133 } 134 135 138 public Currency getCurrency() 139 { 140 return currency; 141 } 142 145 public OrganisationLegalEntity getVendor() 146 { 147 return vendor; 148 } 149 152 public LegalEntity getCustomer() 153 { 154 return customer; 155 } 156 159 public void setCustomer(LegalEntity customer) 160 { 161 if (!customerChangeable) 162 throw new IllegalStateException ("Customer cannot be changed anymore!"); 163 164 this.customer = customer; 165 } 166 169 public boolean isCustomerChangeable() 170 { 171 return customerChangeable; 172 } 173 } 174 | Popular Tags |