mirror of
https://github.com/google/nomulus
synced 2026-09-05 15:46:55 +00:00
Support creation of EPP fee objects using custom descriptions
This is a reasonable thing that custom code might want to do (Donuts already has a use case). ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=144216929
This commit is contained in:
@@ -16,17 +16,27 @@ package google.registry.model.domain.fee;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static google.registry.util.PreconditionsUtils.checkArgumentNotNull;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/** A credit, in currency units specified elsewhere in the xml, and with an optional description. */
|
||||
public class Credit extends BaseFee {
|
||||
|
||||
/** Creates a Credit for the given amount and type with the default description. */
|
||||
public static Credit create(BigDecimal cost, FeeType type, Object... descriptionArgs) {
|
||||
checkArgumentNotNull(type, "Must specify the type of the credit");
|
||||
return createWithCustomDescription(cost, type, type.renderDescription(descriptionArgs));
|
||||
}
|
||||
|
||||
/** Creates a Credit for the given amount and type with a custom description. */
|
||||
public static Credit createWithCustomDescription(
|
||||
BigDecimal cost, FeeType type, String description) {
|
||||
Credit instance = new Credit();
|
||||
instance.cost = checkNotNull(cost);
|
||||
checkArgument(instance.cost.signum() < 0);
|
||||
instance.type = checkNotNull(type);
|
||||
instance.generateDescription(descriptionArgs);
|
||||
instance.description = description;
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user