mirror of
https://github.com/google/nomulus.git
synced 2025-05-14 00:17:20 +02:00
Temporarily revert phase two of migration away from ReferenceUnions
*** Reason for rollback *** This code is fine, and I will be resurrecting it unaltered next week. It's only being rolled back for operational reasons related to the timing of our internal pushes. *** Original change description *** Switch over to non-ReferenceUnion fields on DomainBase This is the second phase of a three phase migration to remove ReferenceUnions. As of the end of this phase, ReferenceUnions are no longer read from in any active code paths, but are still written to in case a rollback to the previous version is necessary. The third and final phase will remove the ReferenceUnions entirely. *** ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=136642759
This commit is contained in:
parent
0f8e398c00
commit
0b4c3e56d6
6 changed files with 34 additions and 25 deletions
|
@ -183,7 +183,11 @@ public abstract class DomainBase extends EppResource {
|
|||
}
|
||||
|
||||
public ImmutableSet<Key<HostResource>> getNameservers() {
|
||||
return nullToEmptyImmutableCopy(nsHosts);
|
||||
ImmutableSet.Builder<Key<HostResource>> builder = new ImmutableSet.Builder<>();
|
||||
for (ReferenceUnion<HostResource> union : nullToEmptyImmutableCopy(nameservers)) {
|
||||
builder.add(union.getLinked());
|
||||
}
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
/** Loads and returns the fully qualified host names of all linked nameservers. */
|
||||
|
@ -238,13 +242,13 @@ public abstract class DomainBase extends EppResource {
|
|||
@OnSave
|
||||
void dualSaveReferenceUnions() {
|
||||
for (DesignatedContact contact : nullToEmptyImmutableCopy(allContacts)) {
|
||||
contact.contactId = ReferenceUnion.create(contact.contact);
|
||||
contact.contact = contact.contactId.getLinked();
|
||||
}
|
||||
ImmutableSet.Builder<ReferenceUnion<HostResource>> hosts = new ImmutableSet.Builder<>();
|
||||
for (Key<HostResource> hostKey : nullToEmptyImmutableCopy(nsHosts)) {
|
||||
hosts.add(ReferenceUnion.create(hostKey));
|
||||
ImmutableSet.Builder<Key<HostResource>> hostKeys = new ImmutableSet.Builder<>();
|
||||
for (ReferenceUnion<HostResource> refUnion : nullToEmptyImmutableCopy(nameservers)) {
|
||||
hostKeys.add(refUnion.getLinked());
|
||||
}
|
||||
nameservers = hosts.build();
|
||||
nsHosts = hostKeys.build();
|
||||
}
|
||||
|
||||
/** Predicate to determine if a given {@link DesignatedContact} is the registrant. */
|
||||
|
@ -303,7 +307,11 @@ public abstract class DomainBase extends EppResource {
|
|||
}
|
||||
|
||||
public B setNameservers(ImmutableSet<Key<HostResource>> nameservers) {
|
||||
getInstance().nsHosts = nameservers;
|
||||
ImmutableSet.Builder<ReferenceUnion<HostResource>> builder = new ImmutableSet.Builder<>();
|
||||
for (Key<HostResource> key : nullToEmpty(nameservers)) {
|
||||
builder.add(ReferenceUnion.create(key));
|
||||
}
|
||||
getInstance().nameservers = builder.build();
|
||||
return thisCastToDerived();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue