mirror of
https://github.com/google/nomulus.git
synced 2025-05-14 08:27:14 +02:00
Simplify the use of the fee extension a little
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=133149148
This commit is contained in:
parent
1ee02108ae
commit
01e2e0141d
11 changed files with 57 additions and 92 deletions
|
@ -24,7 +24,7 @@ import org.joda.money.CurrencyUnit;
|
|||
* of items requesting the fees for particular commands and domains. For some versions of the fee
|
||||
* extension, the currency is also specified here; for other versions it is contained in the
|
||||
* individual items.
|
||||
*
|
||||
*
|
||||
* @type C the type of extension item used by this command (e.g. v6 items for a v6 extension)
|
||||
* @type R the type of response returned for for this command (e.g. v6 responses for a v6 extension)
|
||||
*/
|
||||
|
@ -33,13 +33,14 @@ public interface FeeCheckCommandExtension<
|
|||
R extends FeeCheckResponseExtension<?>>
|
||||
extends CommandExtension {
|
||||
|
||||
/** True if this version of the fee extension specifies the currency at the top level. */
|
||||
public boolean isCurrencySupported();
|
||||
/**
|
||||
* Three-character ISO4217 currency code.
|
||||
*
|
||||
* <p>Returns null if this version of the fee extension doesn't specify currency at the top level.
|
||||
*/
|
||||
public CurrencyUnit getCurrency();
|
||||
|
||||
/** Three-character currency code; throws an exception if currency is not supported. */
|
||||
public CurrencyUnit getCurrency() throws UnsupportedOperationException;
|
||||
|
||||
public ImmutableSet<C> getItems();
|
||||
|
||||
|
||||
public R createResponse(ImmutableList<? extends FeeCheckResponseExtensionItem> items);
|
||||
}
|
||||
|
|
|
@ -35,18 +35,19 @@ public interface FeeQueryCommandExtensionItem {
|
|||
UPDATE
|
||||
}
|
||||
|
||||
/** True if this version of fee extension includes a currency in this type of query item. */
|
||||
public boolean isCurrencySupported();
|
||||
|
||||
/** A three-character ISO4217 currency code; throws an exception if currency is not supported. */
|
||||
public CurrencyUnit getCurrency() throws UnsupportedOperationException;
|
||||
/**
|
||||
* Three-character ISO4217 currency code.
|
||||
*
|
||||
* <p>Returns null if this version of the fee extension doesn't specify currency at the top level.
|
||||
*/
|
||||
public CurrencyUnit getCurrency();
|
||||
|
||||
/** The name of the command being checked. */
|
||||
public CommandName getCommandName();
|
||||
|
||||
|
||||
/** The unparse name of the command being checked, for use in error strings. */
|
||||
public String getUnparsedCommandName();
|
||||
|
||||
|
||||
/** The phase of the command being checked. */
|
||||
public String getPhase();
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ public class FeeCheckCommandExtensionItemV06
|
|||
String name;
|
||||
|
||||
CurrencyUnit currency;
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isDomainNameSupported() {
|
||||
return true;
|
||||
|
@ -40,11 +40,6 @@ public class FeeCheckCommandExtensionItemV06
|
|||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCurrencySupported() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CurrencyUnit getCurrency() {
|
||||
return currency;
|
||||
|
|
|
@ -32,18 +32,13 @@ public class FeeCheckCommandExtensionV06 extends ImmutableObject
|
|||
implements FeeCheckCommandExtension<
|
||||
FeeCheckCommandExtensionItemV06,
|
||||
FeeCheckResponseExtensionV06> {
|
||||
|
||||
|
||||
@XmlElement(name = "domain")
|
||||
Set<FeeCheckCommandExtensionItemV06> items;
|
||||
|
||||
@Override
|
||||
public boolean isCurrencySupported() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CurrencyUnit getCurrency() {
|
||||
throw new UnsupportedOperationException("Currency not supported");
|
||||
return null; // This version of the fee extension doesn't specify a top-level currency.
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -25,15 +25,10 @@ import org.joda.money.CurrencyUnit;
|
|||
@XmlType(propOrder = {"currency", "command", "period"})
|
||||
public class FeeInfoCommandExtensionV06
|
||||
extends FeeQueryCommandExtensionItemImpl implements CommandExtension {
|
||||
|
||||
|
||||
/** A three-character ISO4217 currency code. */
|
||||
CurrencyUnit currency;
|
||||
|
||||
@Override
|
||||
public boolean isCurrencySupported() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CurrencyUnit getCurrency() {
|
||||
return currency;
|
||||
|
|
|
@ -52,22 +52,20 @@ public class FeeCheckCommandExtensionV11 extends ImmutableObject
|
|||
|
||||
/** Three-letter currency code in which results should be returned. */
|
||||
CurrencyUnit currency;
|
||||
|
||||
|
||||
/** The period to check. */
|
||||
Period period;
|
||||
|
||||
/** The class to check. */
|
||||
@XmlElement(name = "class")
|
||||
String feeClass;
|
||||
|
||||
@Override
|
||||
public boolean isCurrencySupported() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CurrencyUnit getCurrency() {
|
||||
throw new UnsupportedOperationException("Currency not supported");
|
||||
// This version of the fee extension does not have any items, and although the currency is
|
||||
// specified at the top level we've modeled it as a single fake item with the currency inside,
|
||||
// so there's no top level currency to return here.
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -96,13 +94,13 @@ public class FeeCheckCommandExtensionV11 extends ImmutableObject
|
|||
public CommandName getCommandName() {
|
||||
return command.getCommand();
|
||||
}
|
||||
|
||||
|
||||
/** The command name before being parsed into an enum, for use in error strings. */
|
||||
@Override
|
||||
public String getUnparsedCommandName() {
|
||||
return command.getUnparsedCommandName();
|
||||
}
|
||||
|
||||
|
||||
/** The phase of the command being checked. */
|
||||
@Override
|
||||
public String getPhase() {
|
||||
|
@ -119,22 +117,17 @@ public class FeeCheckCommandExtensionV11 extends ImmutableObject
|
|||
public Period getPeriod() {
|
||||
return Optional.fromNullable(period).or(DEFAULT_PERIOD);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isDomainNameSupported() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getDomainName() {
|
||||
throw new UnsupportedOperationException("Domain not supported");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCurrencySupported() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CurrencyUnit getCurrency() {
|
||||
return currency;
|
||||
|
|
|
@ -30,13 +30,13 @@ import org.joda.time.DateTime;
|
|||
/**
|
||||
* An individual price check item in version 0.12 of the fee extension on domain check commands.
|
||||
* Items look like:
|
||||
*
|
||||
*
|
||||
* <fee:command name="renew" phase="sunrise" subphase="hello">
|
||||
* <fee:period unit="y">1</fee:period>
|
||||
* <fee:class>premium</fee:class>
|
||||
* <fee:date>2017-05-17T13:22:21.0Z</fee:date>
|
||||
* </fee:command>
|
||||
*
|
||||
*
|
||||
* In a change from previous versions of the extension, items do not contain domain names; instead,
|
||||
* the names from the non-extension check element are used.
|
||||
*/
|
||||
|
@ -49,7 +49,7 @@ public class FeeCheckCommandExtensionItemV12
|
|||
|
||||
@XmlAttribute(name = "name")
|
||||
String commandName;
|
||||
|
||||
|
||||
@XmlAttribute
|
||||
String phase;
|
||||
|
||||
|
@ -58,10 +58,10 @@ public class FeeCheckCommandExtensionItemV12
|
|||
|
||||
@XmlElement
|
||||
Period period;
|
||||
|
||||
|
||||
@XmlElement(name = "class")
|
||||
String feeClass;
|
||||
|
||||
|
||||
@XmlElement(name = "date")
|
||||
DateTime feeDate;
|
||||
|
||||
|
@ -75,22 +75,17 @@ public class FeeCheckCommandExtensionItemV12
|
|||
public String getDomainName() {
|
||||
throw new UnsupportedOperationException("Domain not supported");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCurrencySupported() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CurrencyUnit getCurrency() {
|
||||
throw new UnsupportedOperationException("Currency not supported");
|
||||
return null; // This version of the fee extension doesn't specify currency per-item.
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getUnparsedCommandName() {
|
||||
return commandName;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CommandName getCommandName() {
|
||||
// Require the xml string to be lowercase.
|
||||
|
@ -108,7 +103,7 @@ public class FeeCheckCommandExtensionItemV12
|
|||
public String getPhase() {
|
||||
return phase;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getSubphase() {
|
||||
return subphase;
|
||||
|
|
|
@ -36,17 +36,12 @@ public class FeeCheckCommandExtensionV12 extends ImmutableObject
|
|||
FeeCheckResponseExtensionV12> {
|
||||
|
||||
CurrencyUnit currency;
|
||||
|
||||
@Override
|
||||
public boolean isCurrencySupported() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CurrencyUnit getCurrency() {
|
||||
return currency;
|
||||
}
|
||||
|
||||
|
||||
@XmlElement(name = "command")
|
||||
Set<FeeCheckCommandExtensionItemV12> items;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue