mirror of
https://github.com/google/nomulus.git
synced 2025-07-20 17:56:08 +02:00
Simplify the fee extensions.
I added shared base classes to all of the Fee extension types that make it possible to fully ignore the version in the flows. (You ask for a FeeCreateCommandExtension, for example, and you get one without having to worry about which). This is an improvement over the old code that asked you to provide a list of possible fee extensions and then ask for the first one in preference order. As part of this I was able to make the Fee implementation a bit simpler as well. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=137992390
This commit is contained in:
parent
2dd703ef3a
commit
8256120b3a
66 changed files with 786 additions and 954 deletions
|
@ -17,10 +17,8 @@ package google.registry.model.domain.fee12;
|
|||
import com.google.common.base.Ascii;
|
||||
import com.google.common.base.CharMatcher;
|
||||
import com.google.common.base.Optional;
|
||||
import google.registry.model.ImmutableObject;
|
||||
import google.registry.model.domain.Period;
|
||||
import google.registry.model.domain.fee.FeeCheckCommandExtensionItem;
|
||||
import google.registry.model.domain.fee.FeeCheckResponseExtensionItem;
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
|
@ -41,8 +39,7 @@ import org.joda.time.DateTime;
|
|||
* the names from the non-extension check element are used.
|
||||
*/
|
||||
@XmlType(propOrder = {"period", "feeClass", "feeDate"})
|
||||
public class FeeCheckCommandExtensionItemV12
|
||||
extends ImmutableObject implements FeeCheckCommandExtensionItem {
|
||||
public class FeeCheckCommandExtensionItemV12 extends FeeCheckCommandExtensionItem {
|
||||
|
||||
/** The default validity period (if not specified) is 1 year for all operations. */
|
||||
static final Period DEFAULT_PERIOD = Period.create(1, Period.Unit.YEARS);
|
||||
|
@ -56,9 +53,6 @@ public class FeeCheckCommandExtensionItemV12
|
|||
@XmlAttribute
|
||||
String subphase;
|
||||
|
||||
@XmlElement
|
||||
Period period;
|
||||
|
||||
@XmlElement(name = "class")
|
||||
String feeClass;
|
||||
|
||||
|
@ -110,12 +104,7 @@ public class FeeCheckCommandExtensionItemV12
|
|||
}
|
||||
|
||||
@Override
|
||||
public Period getPeriod() {
|
||||
return Optional.fromNullable(period).or(DEFAULT_PERIOD);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FeeCheckResponseExtensionItem.Builder createResponseBuilder() {
|
||||
public FeeCheckResponseExtensionItemV12.Builder createResponseBuilder() {
|
||||
return new FeeCheckResponseExtensionItemV12.Builder();
|
||||
}
|
||||
|
||||
|
|
|
@ -17,24 +17,19 @@ package google.registry.model.domain.fee12;
|
|||
import static google.registry.util.CollectionUtils.forceEmptyToNull;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import google.registry.model.Buildable.GenericBuilder;
|
||||
import google.registry.model.ImmutableObject;
|
||||
import google.registry.model.domain.DomainObjectSpec;
|
||||
import google.registry.model.domain.Period;
|
||||
import google.registry.model.domain.fee.Fee;
|
||||
import google.registry.model.domain.fee.FeeCheckResponseExtensionItem;
|
||||
import google.registry.model.domain.fee.FeeQueryCommandExtensionItem.CommandName;
|
||||
import java.util.List;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
import org.joda.money.CurrencyUnit;
|
||||
import org.joda.time.DateTime;
|
||||
|
||||
/**
|
||||
* The version 0.12 response for a domain check on a single resource.
|
||||
*/
|
||||
@XmlType(propOrder = {"object", "command"})
|
||||
public class FeeCheckResponseExtensionItemV12
|
||||
extends ImmutableObject implements FeeCheckResponseExtensionItem {
|
||||
public class FeeCheckResponseExtensionItemV12 extends FeeCheckResponseExtensionItem {
|
||||
|
||||
/** The domain that was checked. */
|
||||
DomainObjectSpec object;
|
||||
|
@ -42,6 +37,28 @@ public class FeeCheckResponseExtensionItemV12
|
|||
/** The command that was checked. */
|
||||
FeeCheckResponseExtensionItemCommandV12 command;
|
||||
|
||||
/**
|
||||
* This method is overridden and not annotated for JAXB because this version of the extension
|
||||
* doesn't support "period".
|
||||
*/
|
||||
@Override
|
||||
public Period getPeriod() {
|
||||
return super.getPeriod();
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is overridden and not annotated for JAXB because this version of the extension
|
||||
* doesn't support "fee".
|
||||
*/
|
||||
@Override
|
||||
public ImmutableList<Fee> getFees() {
|
||||
return super.getFees();
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is not annotated for JAXB because this version of the extension doesn't support
|
||||
* "feeClass" and because the data comes off of the command object rather than a field.
|
||||
*/
|
||||
@Override
|
||||
public String getFeeClass() {
|
||||
return command.getFeeClass();
|
||||
|
@ -49,15 +66,10 @@ public class FeeCheckResponseExtensionItemV12
|
|||
|
||||
/** Builder for {@link FeeCheckResponseExtensionItemV12}. */
|
||||
public static class Builder
|
||||
extends GenericBuilder<FeeCheckResponseExtensionItemV12, Builder>
|
||||
implements FeeCheckResponseExtensionItem.Builder {
|
||||
extends FeeCheckResponseExtensionItem.Builder<FeeCheckResponseExtensionItemV12> {
|
||||
|
||||
final FeeCheckResponseExtensionItemCommandV12.Builder commandBuilder;
|
||||
|
||||
Builder() {
|
||||
super();
|
||||
commandBuilder = new FeeCheckResponseExtensionItemCommandV12.Builder();
|
||||
}
|
||||
final FeeCheckResponseExtensionItemCommandV12.Builder commandBuilder =
|
||||
new FeeCheckResponseExtensionItemCommandV12.Builder();
|
||||
|
||||
@Override
|
||||
public Builder setCommand(CommandName commandName, String phase, String subphase) {
|
||||
|
@ -74,7 +86,7 @@ public class FeeCheckResponseExtensionItemV12
|
|||
}
|
||||
|
||||
@Override
|
||||
public Builder setFees(List<Fee> fees) {
|
||||
public Builder setFees(ImmutableList<Fee> fees) {
|
||||
commandBuilder.setFee(forceEmptyToNull(ImmutableList.copyOf(fees)));
|
||||
return this;
|
||||
}
|
||||
|
@ -91,22 +103,6 @@ public class FeeCheckResponseExtensionItemV12
|
|||
return this;
|
||||
}
|
||||
|
||||
/** Version 0.12 does not support currency in check items. */
|
||||
@Override
|
||||
public Builder setCurrencyIfSupported(CurrencyUnit currency) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder setAvailIfSupported(boolean avail) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder setReasonIfSupported(String reason) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FeeCheckResponseExtensionItemV12 build() {
|
||||
getInstance().command = commandBuilder.build();
|
||||
|
|
|
@ -14,20 +14,32 @@
|
|||
|
||||
package google.registry.model.domain.fee12;
|
||||
|
||||
import google.registry.model.domain.fee.FeeTransformCommandExtension;
|
||||
import google.registry.model.domain.fee.FeeTransformCommandExtensionImpl;
|
||||
import static google.registry.util.CollectionUtils.nullToEmptyImmutableCopy;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import google.registry.model.domain.fee.Credit;
|
||||
import google.registry.model.domain.fee.FeeCreateCommandExtension;
|
||||
import google.registry.model.domain.fee.FeeTransformResponseExtension;
|
||||
import java.util.List;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
|
||||
/** A fee extension that may be present on domain create commands. */
|
||||
@XmlRootElement(name = "create")
|
||||
@XmlType(propOrder = {"currency", "fees", "credits"})
|
||||
public class FeeCreateCommandExtensionV12
|
||||
extends FeeTransformCommandExtensionImpl implements FeeTransformCommandExtension {
|
||||
public class FeeCreateCommandExtensionV12 extends FeeCreateCommandExtension {
|
||||
|
||||
@XmlElement(name = "credit")
|
||||
List<Credit> credits;
|
||||
|
||||
@Override
|
||||
public ImmutableList<Credit> getCredits() {
|
||||
return nullToEmptyImmutableCopy(credits);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FeeTransformResponseExtension.Builder createResponseBuilder() {
|
||||
return new FeeCreateResponseExtensionV12.Builder();
|
||||
return new FeeTransformResponseExtension.Builder(new FeeCreateResponseExtensionV12());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
package google.registry.model.domain.fee12;
|
||||
|
||||
import google.registry.model.domain.fee.FeeTransformResponseExtensionImpl;
|
||||
import google.registry.model.domain.fee.FeeTransformResponseExtension;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
|
||||
|
@ -24,8 +24,4 @@ import javax.xml.bind.annotation.XmlType;
|
|||
*/
|
||||
@XmlRootElement(name = "creData")
|
||||
@XmlType(propOrder = {"currency", "fees", "credits"})
|
||||
public class FeeCreateResponseExtensionV12 extends FeeTransformResponseExtensionImpl {
|
||||
/** A builder for {@link FeeCreateResponseExtensionV12}. */
|
||||
public static class Builder
|
||||
extends FeeTransformResponseExtensionImpl.Builder<FeeCreateResponseExtensionV12, Builder> {}
|
||||
}
|
||||
public class FeeCreateResponseExtensionV12 extends FeeTransformResponseExtension {}
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
package google.registry.model.domain.fee12;
|
||||
|
||||
import google.registry.model.domain.fee.FeeTransformResponseExtensionImpl;
|
||||
import google.registry.model.domain.fee.FeeTransformResponseExtension;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
|
||||
|
@ -24,9 +24,12 @@ import javax.xml.bind.annotation.XmlType;
|
|||
*/
|
||||
@XmlRootElement(name = "delData")
|
||||
@XmlType(propOrder = {"currency", "fees", "credits"})
|
||||
public class FeeDeleteResponseExtensionV12 extends FeeTransformResponseExtensionImpl {
|
||||
public class FeeDeleteResponseExtensionV12 extends FeeTransformResponseExtension {
|
||||
|
||||
/** Builder for {@link FeeDeleteResponseExtensionV12}. */
|
||||
public static class Builder
|
||||
extends FeeTransformResponseExtensionImpl.Builder<FeeDeleteResponseExtensionV12, Builder> {}
|
||||
public static class Builder extends FeeTransformResponseExtension.Builder {
|
||||
public Builder() {
|
||||
super(new FeeDeleteResponseExtensionV12());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,20 +14,32 @@
|
|||
|
||||
package google.registry.model.domain.fee12;
|
||||
|
||||
import google.registry.model.domain.fee.FeeTransformCommandExtension;
|
||||
import google.registry.model.domain.fee.FeeTransformCommandExtensionImpl;
|
||||
import static google.registry.util.CollectionUtils.nullToEmptyImmutableCopy;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import google.registry.model.domain.fee.Credit;
|
||||
import google.registry.model.domain.fee.FeeRenewCommandExtension;
|
||||
import google.registry.model.domain.fee.FeeTransformResponseExtension;
|
||||
import java.util.List;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
|
||||
/** A fee extension that may be present on domain renew commands. */
|
||||
@XmlRootElement(name = "renew")
|
||||
@XmlType(propOrder = {"currency", "fees", "credits"})
|
||||
public class FeeRenewCommandExtensionV12
|
||||
extends FeeTransformCommandExtensionImpl implements FeeTransformCommandExtension {
|
||||
public class FeeRenewCommandExtensionV12 extends FeeRenewCommandExtension {
|
||||
|
||||
@XmlElement(name = "credit")
|
||||
List<Credit> credits;
|
||||
|
||||
@Override
|
||||
public ImmutableList<Credit> getCredits() {
|
||||
return nullToEmptyImmutableCopy(credits);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FeeTransformResponseExtension.Builder createResponseBuilder() {
|
||||
return new FeeRenewResponseExtensionV12.Builder();
|
||||
return new FeeTransformResponseExtension.Builder(new FeeRenewResponseExtensionV12());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
package google.registry.model.domain.fee12;
|
||||
|
||||
import google.registry.model.domain.fee.FeeTransformResponseExtensionImpl;
|
||||
import google.registry.model.domain.fee.FeeTransformResponseExtension;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
|
||||
|
@ -24,8 +24,4 @@ import javax.xml.bind.annotation.XmlType;
|
|||
*/
|
||||
@XmlRootElement(name = "renData")
|
||||
@XmlType(propOrder = {"currency", "fees", "credits"})
|
||||
public class FeeRenewResponseExtensionV12 extends FeeTransformResponseExtensionImpl {
|
||||
/** A builder for {@link FeeRenewResponseExtensionV12}. */
|
||||
public static class Builder
|
||||
extends FeeTransformResponseExtensionImpl.Builder<FeeRenewResponseExtensionV12, Builder> {}
|
||||
}
|
||||
public class FeeRenewResponseExtensionV12 extends FeeTransformResponseExtension {}
|
||||
|
|
|
@ -14,20 +14,32 @@
|
|||
|
||||
package google.registry.model.domain.fee12;
|
||||
|
||||
import google.registry.model.domain.fee.FeeTransformCommandExtension;
|
||||
import google.registry.model.domain.fee.FeeTransformCommandExtensionImpl;
|
||||
import static google.registry.util.CollectionUtils.nullToEmptyImmutableCopy;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import google.registry.model.domain.fee.Credit;
|
||||
import google.registry.model.domain.fee.FeeTransferCommandExtension;
|
||||
import google.registry.model.domain.fee.FeeTransformResponseExtension;
|
||||
import java.util.List;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
|
||||
/** A fee extension that may be present on domain transfer requests. */
|
||||
@XmlRootElement(name = "transfer")
|
||||
@XmlType(propOrder = {"currency", "fees", "credits"})
|
||||
public class FeeTransferCommandExtensionV12
|
||||
extends FeeTransformCommandExtensionImpl implements FeeTransformCommandExtension {
|
||||
public class FeeTransferCommandExtensionV12 extends FeeTransferCommandExtension {
|
||||
|
||||
@XmlElement(name = "credit")
|
||||
List<Credit> credits;
|
||||
|
||||
@Override
|
||||
public ImmutableList<Credit> getCredits() {
|
||||
return nullToEmptyImmutableCopy(credits);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FeeTransformResponseExtension.Builder createResponseBuilder() {
|
||||
return new FeeTransferResponseExtensionV12.Builder();
|
||||
return new FeeTransformResponseExtension.Builder(new FeeTransferResponseExtensionV12());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
package google.registry.model.domain.fee12;
|
||||
|
||||
import google.registry.model.domain.fee.FeeTransformResponseExtensionImpl;
|
||||
import google.registry.model.domain.fee.FeeTransformResponseExtension;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
|
||||
|
@ -24,8 +24,4 @@ import javax.xml.bind.annotation.XmlType;
|
|||
*/
|
||||
@XmlRootElement(name = "trnData")
|
||||
@XmlType(propOrder = {"currency", "fees", "credits"})
|
||||
public class FeeTransferResponseExtensionV12 extends FeeTransformResponseExtensionImpl {
|
||||
/** A builder for {@link FeeTransferResponseExtensionV12}. */
|
||||
public static class Builder
|
||||
extends FeeTransformResponseExtensionImpl.Builder<FeeTransferResponseExtensionV12, Builder> {}
|
||||
}
|
||||
public class FeeTransferResponseExtensionV12 extends FeeTransformResponseExtension {}
|
||||
|
|
|
@ -14,20 +14,32 @@
|
|||
|
||||
package google.registry.model.domain.fee12;
|
||||
|
||||
import google.registry.model.domain.fee.FeeTransformCommandExtension;
|
||||
import google.registry.model.domain.fee.FeeTransformCommandExtensionImpl;
|
||||
import static google.registry.util.CollectionUtils.nullToEmptyImmutableCopy;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import google.registry.model.domain.fee.Credit;
|
||||
import google.registry.model.domain.fee.FeeTransformResponseExtension;
|
||||
import google.registry.model.domain.fee.FeeUpdateCommandExtension;
|
||||
import java.util.List;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
|
||||
/** A fee extension that may be present on domain update commands. */
|
||||
@XmlRootElement(name = "update")
|
||||
@XmlType(propOrder = {"currency", "fees", "credits"})
|
||||
public class FeeUpdateCommandExtensionV12
|
||||
extends FeeTransformCommandExtensionImpl implements FeeTransformCommandExtension {
|
||||
public class FeeUpdateCommandExtensionV12 extends FeeUpdateCommandExtension {
|
||||
|
||||
@XmlElement(name = "credit")
|
||||
List<Credit> credits;
|
||||
|
||||
@Override
|
||||
public ImmutableList<Credit> getCredits() {
|
||||
return nullToEmptyImmutableCopy(credits);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FeeTransformResponseExtension.Builder createResponseBuilder() {
|
||||
return new FeeUpdateResponseExtensionV12.Builder();
|
||||
return new FeeTransformResponseExtension.Builder(new FeeUpdateResponseExtensionV12());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
package google.registry.model.domain.fee12;
|
||||
|
||||
import google.registry.model.domain.fee.FeeTransformResponseExtensionImpl;
|
||||
import google.registry.model.domain.fee.FeeTransformResponseExtension;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
|
||||
|
@ -24,8 +24,4 @@ import javax.xml.bind.annotation.XmlType;
|
|||
*/
|
||||
@XmlRootElement(name = "updData")
|
||||
@XmlType(propOrder = {"currency", "fees", "credits"})
|
||||
public class FeeUpdateResponseExtensionV12 extends FeeTransformResponseExtensionImpl {
|
||||
/** A builder for {@link FeeUpdateResponseExtensionV12}. */
|
||||
public static class Builder
|
||||
extends FeeTransformResponseExtensionImpl.Builder<FeeUpdateResponseExtensionV12, Builder> {}
|
||||
}
|
||||
public class FeeUpdateResponseExtensionV12 extends FeeTransformResponseExtension {}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue