Improve BaseFee class and its children

Checks are added to ensure that fees are always non-negative, while credits are always negative, as required by the EPP fee extension specification. Also, BaseFee is made specifically abstract.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=131620110
This commit is contained in:
mountford 2016-08-29 12:08:24 -07:00 committed by Ben McIlwain
parent 8059ab5c90
commit 59ac00478e
3 changed files with 12 additions and 1 deletions

View file

@ -28,7 +28,7 @@ import org.joda.time.Period;
/** Base class for the fee and credit types. */
@XmlTransient
public class BaseFee extends ImmutableObject {
public abstract class BaseFee extends ImmutableObject {
/** Enum for when a fee is applied. */
public enum AppliedType {
@ -71,6 +71,13 @@ public class BaseFee extends ImmutableObject {
return firstNonNull(refundable, true);
}
/**
* According to the fee extension specification, a fee must always be non-negative, while a credit
* must always be negative. Essentially, they are the same thing, just with different sign.
* However, we need them to be separate classes for proper JAXB handling.
*
* @see "https://tools.ietf.org/html/draft-brown-epp-fees-03#section-2.4"
*/
public BigDecimal getCost() {
return cost;
}