Package org.powertac.common
Class TariffSpecification
java.lang.Object
org.powertac.common.state.XStreamStateLoggable
org.powertac.common.TariffMessage
org.powertac.common.TariffSpecification
- All Implemented Interfaces:
ValidatableMessage
@Domain(fields={"broker","powerType","expiration","minDuration","signupPayment","earlyWithdrawPayment","periodicPayment","supersedes"}) public class TariffSpecification extends TariffMessage
Represents a Tariff offered by a Broker to customers. A TariffSpecification
may specify upfront and periodic payments, and
aggregates a set of Rate instances that specify
prices for energy in various circumstances. This class is a value type -- a
serializable, immutable data structure. You need to initialize a
Tariff from it to make serious use of it. New tariffs and their Rates
are communicated to Customers and to Brokers when tariffs are published.
TariffSpecifications and their associated Rates and HourlyCharges are specified from the Customer's viewpoint in terms of quantities and charges. In other words, a positive charge means the broker pays the customer, while a positive energy quantity means the broker sends energy to the customer.
Note: Must be serialized "deep" to gather up the Rates and associated HourlyCharge instances.
State log entry format for new instance:
long brokerId, PowerType powerType
State log fields for readResolve():
long brokerId, PowerType powerType, long minDuration,
double signupPayment, double earlyWithdrawPayment,
double periodicPayment, List
- Author:
- John Collins
-
Field Summary
-
Constructor Summary
Constructors Modifier Constructor Description protectedTariffSpecification()TariffSpecification(Broker broker, PowerType powerType)Creates a new TariffSpecification for a broker and a specific powerType. -
Method Summary
Modifier and Type Method Description TariffSpecificationaddRate(RateCore rate)Adds a new RateCore (Rate, RegulationRate, etc.) to this tariff.TariffSpecificationaddSupersedes(long specId)Indicates that this tariff supersedes the tariff specified by the specId, the id of the superseded tariff.BrokergetBroker()doublegetEarlyWithdrawPayment()org.joda.time.InstantgetExpiration()longgetId()longgetMinDuration()doublegetPeriodicPayment()PowerTypegetPowerType()List<Rate>getRates()Returns the Rate instances from among the rates in this tariff spec.List<RegulationRate>getRegulationRates()Returns the RegulationRate instances from among the rates in this tariff spec.doublegetSignupPayment()List<Long>getSupersedes()booleanhasRegulationRate()Returns true just in case this tariff has one or more RegulationRates.booleanisValid()A TariffSpecification is valid if it has a least one Rate, and all its Rates are valid; minDuration is non-negative;StringtoString()Returns a String giving the id, broker username, and powertypeTariffSpecificationwithEarlyWithdrawPayment(double earlyWithdrawPayment)Sets the payment for a customer who withdraws from a subscription to this tariff before the minimumDuration has expired.TariffSpecificationwithExpiration(long expiration)Sets expiration date as msec since epoch.TariffSpecificationwithExpiration(org.joda.time.Instant expiration)Sets the expiration date for this tariff.TariffSpecificationwithMinDuration(long minDuration)Sets the minimum duration of a subscription for this tariff.TariffSpecificationwithPeriodicPayment(double periodicPayment)Sets the daily payment per customer for subscriptions to this tariff.TariffSpecificationwithSignupPayment(double signupPayment)Sets the signup payment for new subscriptions.
-
Constructor Details
-
TariffSpecification
Creates a new TariffSpecification for a broker and a specific powerType. Attributes are provided by the fluentwithX()methods. -
TariffSpecification
protected TariffSpecification()
-
-
Method Details
-
getPowerType
-
getExpiration
public org.joda.time.Instant getExpiration() -
withExpiration
Sets expiration date as msec since epoch. See Issue #1016. -
withExpiration
Sets the expiration date for this tariff. After this date, customers will no longer be allowed to subscribe. -
getMinDuration
public long getMinDuration() -
withMinDuration
Sets the minimum duration of a subscription for this tariff. If a customer wishes to withdraw earlier than the minimum duration, it may be required to pay a fee as specified by the withdrawPayment. -
getSignupPayment
public double getSignupPayment() -
withSignupPayment
Sets the signup payment for new subscriptions. This is a positive number if the broker pays the customer. -
getEarlyWithdrawPayment
public double getEarlyWithdrawPayment() -
withEarlyWithdrawPayment
Sets the payment for a customer who withdraws from a subscription to this tariff before the minimumDuration has expired. A negative number indicates that the customer pays the broker. -
getPeriodicPayment
public double getPeriodicPayment() -
withPeriodicPayment
Sets the daily payment per customer for subscriptions to this tariff. A negative number indicates that the customer pays the broker. -
getId
public long getId()- Overrides:
getIdin classTariffMessage
-
getBroker
- Overrides:
getBrokerin classTariffMessage
-
getRates
Returns the Rate instances from among the rates in this tariff spec. -
getRegulationRates
Returns the RegulationRate instances from among the rates in this tariff spec. -
hasRegulationRate
public boolean hasRegulationRate()Returns true just in case this tariff has one or more RegulationRates. -
addRate
Adds a new RateCore (Rate, RegulationRate, etc.) to this tariff. -
getSupersedes
-
addSupersedes
Indicates that this tariff supersedes the tariff specified by the specId, the id of the superseded tariff. Setting this value has no effect unless the superseded tariff is revoked by sending a TariffRevoke message for that tariff. -
isValid
public boolean isValid()A TariffSpecification is valid if- it has a least one Rate, and all its Rates are valid;
- minDuration is non-negative;
- Specified by:
isValidin interfaceValidatableMessage- Overrides:
isValidin classTariffMessage
-
toString
Returns a String giving the id, broker username, and powertype
-