mirror of
https://github.com/google/nomulus.git
synced 2025-05-27 22:50:08 +02: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:
parent
3ee98988c5
commit
a5d5c9e2fd
3 changed files with 32 additions and 16 deletions
|
@ -16,6 +16,7 @@ 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 com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Range;
|
||||
|
@ -28,15 +29,14 @@ import org.joda.time.DateTime;
|
|||
* description.
|
||||
*/
|
||||
public class Fee extends BaseFee {
|
||||
|
||||
/** Creates a Fee for the given cost and type with the default description. */
|
||||
public static Fee create(BigDecimal cost, FeeType type, Object... descriptionArgs) {
|
||||
Fee instance = new Fee();
|
||||
instance.cost = checkNotNull(cost);
|
||||
checkArgument(instance.cost.signum() >= 0);
|
||||
instance.type = checkNotNull(type);
|
||||
instance.generateDescription(descriptionArgs);
|
||||
return instance;
|
||||
checkArgumentNotNull(type, "Must specify the type of the fee");
|
||||
return createWithCustomDescription(cost, type, type.renderDescription(descriptionArgs));
|
||||
}
|
||||
|
||||
/** Creates a Fee for the given cost, type, and valid date range with the default description. */
|
||||
public static Fee create(
|
||||
BigDecimal cost, FeeType type, Range<DateTime> validDateRange, Object... descriptionArgs) {
|
||||
Fee instance = create(cost, type, descriptionArgs);
|
||||
|
@ -44,8 +44,19 @@ public class Fee extends BaseFee {
|
|||
return instance;
|
||||
}
|
||||
|
||||
public static final ImmutableSet<String> FEE_EXTENSION_URIS = ImmutableSet.of(
|
||||
ServiceExtension.FEE_0_12.getUri(),
|
||||
ServiceExtension.FEE_0_11.getUri(),
|
||||
ServiceExtension.FEE_0_6.getUri());
|
||||
/** Creates a Fee for the given cost and type with a custom description. */
|
||||
public static Fee createWithCustomDescription(BigDecimal cost, FeeType type, String description) {
|
||||
Fee instance = new Fee();
|
||||
instance.cost = checkNotNull(cost);
|
||||
checkArgument(instance.cost.signum() >= 0);
|
||||
instance.type = checkNotNull(type);
|
||||
instance.description = description;
|
||||
return instance;
|
||||
}
|
||||
|
||||
public static final ImmutableSet<String> FEE_EXTENSION_URIS =
|
||||
ImmutableSet.of(
|
||||
ServiceExtension.FEE_0_12.getUri(),
|
||||
ServiceExtension.FEE_0_11.getUri(),
|
||||
ServiceExtension.FEE_0_6.getUri());
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue