1 4 package com.nightlabs.ipanema.accounting.tariffpriceconfig; 5 6 import java.util.Collection ; 7 import java.util.HashMap ; 8 import java.util.Map ; 9 10 import com.nightlabs.ipanema.accounting.CustomerGroup; 11 import com.nightlabs.ipanema.accounting.Price; 12 import com.nightlabs.ipanema.accounting.PriceConfig; 13 import com.nightlabs.ipanema.accounting.Tariff; 14 import com.nightlabs.ipanema.trade.OfferItem; 15 16 31 public abstract class TariffPriceConfig extends PriceConfig 32 { 33 45 private Map customerGroups = new HashMap (); 46 47 59 private Map tariffs = new HashMap (); 60 61 protected TariffPriceConfig() 62 { 63 } 64 68 public TariffPriceConfig(String organisationID, long priceConfigID) 69 { 70 super(organisationID, priceConfigID); 71 } 72 73 76 public Price getPrice(OfferItem offerItem) 77 { 78 return null; 79 } 80 81 84 public boolean isDependentOnOffer() 85 { 86 return false; 87 } 88 89 90 93 public Collection getCustomerGroups() 94 { 95 return customerGroups.values(); 96 } 97 public void addCustomerGroup(CustomerGroup customerGroup) 98 { 99 customerGroups.put(customerGroup.getPrimaryKey(), customerGroup); 100 } 101 public CustomerGroup getCustomerGroup(String organisationID, String customerGroupID, boolean throwExceptionIfNotExistent) 102 { 103 CustomerGroup customerGroup = (CustomerGroup) customerGroups.get(CustomerGroup.getPrimaryKey(organisationID, customerGroupID)); 104 if (customerGroup == null && throwExceptionIfNotExistent) 105 throw new IllegalArgumentException ("No CustomerGroup registered with organisationID=\""+organisationID+"\" customerGroupID=\""+customerGroupID+"\"!"); 106 return customerGroup; 107 } 108 public boolean containsCustomerGroup(CustomerGroup customerGroup) 109 { 110 return customerGroups.containsKey(customerGroup.getPrimaryKey()); 111 } 112 public CustomerGroup removeCustomerGroup(String organisationID, String customerGroupID) 113 { 114 return (CustomerGroup) customerGroups.remove( 115 CustomerGroup.getPrimaryKey(organisationID, customerGroupID)); 116 } 117 118 121 public Collection getTariffs() 122 { 123 return tariffs.values(); 124 } 125 public void addTariff(Tariff tariff) 126 { 127 tariffs.put(tariff.getPrimaryKey(), tariff); 128 } 129 public Tariff getTariff(String organisationID, long tariffID, boolean throwExceptionIfNotExistent) 130 { 131 Tariff tariff = (Tariff) tariffs.get(Tariff.getPrimaryKey(organisationID, tariffID)); 132 if (tariff == null && throwExceptionIfNotExistent) 133 throw new IllegalArgumentException ("There is no Tariff registered with organisationID=\""+organisationID+"\" tariffID=\""+tariffID+"\"!"); 134 135 return tariff; 136 } 137 public boolean containsTariff(Tariff tariff) 138 { 139 return tariffs.containsKey(tariff.getPrimaryKey()); 140 } 141 public Tariff removeTariff(String organisationID, long tariffID) 142 { 143 return (Tariff) tariffs.remove(Tariff.getPrimaryKey(organisationID, tariffID)); 144 } 145 } 146 | Popular Tags |