mirror of
https://github.com/google/nomulus
synced 2026-04-25 18:51:40 +00:00
Convert some more @AutoValues to records (#2334)
This commit is contained in:
@@ -21,7 +21,6 @@ import static org.apache.http.HttpStatus.SC_INTERNAL_SERVER_ERROR;
|
||||
import static org.apache.http.HttpStatus.SC_OK;
|
||||
import static org.joda.time.DateTimeZone.UTC;
|
||||
|
||||
import com.google.auto.value.AutoValue;
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
@@ -125,7 +124,7 @@ public class SendExpiringCertificateNotificationEmailAction implements Runnable
|
||||
return Streams.stream(Registrar.loadAllCached())
|
||||
.map(
|
||||
registrar ->
|
||||
RegistrarInfo.create(
|
||||
new RegistrarInfo(
|
||||
registrar,
|
||||
registrar.getClientCertificate().isPresent()
|
||||
&& certificateChecker.shouldReceiveExpiringNotification(
|
||||
@@ -333,19 +332,6 @@ public class SendExpiringCertificateNotificationEmailAction implements Runnable
|
||||
}
|
||||
}
|
||||
|
||||
@AutoValue
|
||||
public abstract static class RegistrarInfo {
|
||||
|
||||
static RegistrarInfo create(
|
||||
Registrar registrar, boolean isCertExpiring, boolean isFailOverCertExpiring) {
|
||||
return new AutoValue_SendExpiringCertificateNotificationEmailAction_RegistrarInfo(
|
||||
registrar, isCertExpiring, isFailOverCertExpiring);
|
||||
}
|
||||
|
||||
public abstract Registrar registrar();
|
||||
|
||||
public abstract boolean isCertExpiring();
|
||||
|
||||
public abstract boolean isFailOverCertExpiring();
|
||||
}
|
||||
record RegistrarInfo(
|
||||
Registrar registrar, boolean isCertExpiring, boolean isFailOverCertExpiring) {}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@ package google.registry.beam.spec11;
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||
|
||||
import com.google.auto.value.AutoValue;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import dagger.Component;
|
||||
import dagger.Module;
|
||||
@@ -199,7 +198,7 @@ public class Spec11Pipeline implements Serializable {
|
||||
(KV<DomainNameInfo, ThreatMatch> kv) ->
|
||||
KV.of(
|
||||
kv.getKey().registrarId(),
|
||||
EmailAndThreatMatch.create(
|
||||
new EmailAndThreatMatch(
|
||||
kv.getKey().registrarEmailAddress(), kv.getValue()))))
|
||||
.apply("Group by registrar client ID", GroupByKey.create())
|
||||
.apply(
|
||||
@@ -281,15 +280,5 @@ public class Spec11Pipeline implements Serializable {
|
||||
Spec11Pipeline spec11Pipeline();
|
||||
}
|
||||
|
||||
@AutoValue
|
||||
abstract static class EmailAndThreatMatch implements Serializable {
|
||||
|
||||
abstract String email();
|
||||
|
||||
abstract ThreatMatch threatMatch();
|
||||
|
||||
static EmailAndThreatMatch create(String email, ThreatMatch threatMatch) {
|
||||
return new AutoValue_Spec11Pipeline_EmailAndThreatMatch(email, threatMatch);
|
||||
}
|
||||
}
|
||||
record EmailAndThreatMatch(String email, ThreatMatch threatMatch) implements Serializable {}
|
||||
}
|
||||
|
||||
@@ -18,19 +18,13 @@ import static google.registry.bsa.BsaStringUtils.DOMAIN_JOINER;
|
||||
import static google.registry.bsa.BsaStringUtils.PROPERTY_JOINER;
|
||||
import static google.registry.bsa.BsaStringUtils.PROPERTY_SPLITTER;
|
||||
|
||||
import com.google.auto.value.AutoValue;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* A domain name whose second-level domain (SLD) matches a BSA label but is not blocked. It may be
|
||||
* already registered, or on the TLD's reserve list.
|
||||
*/
|
||||
// TODO(1/15/2024): rename to UnblockableDomain.
|
||||
@AutoValue
|
||||
public abstract class UnblockableDomain {
|
||||
public abstract String domainName();
|
||||
|
||||
public abstract Reason reason();
|
||||
public record UnblockableDomain(String domainName, Reason reason) {
|
||||
|
||||
/** Reasons why a valid domain name cannot be blocked. */
|
||||
public enum Reason {
|
||||
@@ -45,14 +39,10 @@ public abstract class UnblockableDomain {
|
||||
|
||||
public static UnblockableDomain deserialize(String text) {
|
||||
List<String> items = PROPERTY_SPLITTER.splitToList(text);
|
||||
return of(items.get(0), Reason.valueOf(items.get(1)));
|
||||
}
|
||||
|
||||
public static UnblockableDomain of(String domainName, Reason reason) {
|
||||
return new AutoValue_UnblockableDomain(domainName, reason);
|
||||
return new UnblockableDomain(items.get(0), Reason.valueOf(items.get(1)));
|
||||
}
|
||||
|
||||
public static UnblockableDomain of(String label, String tld, Reason reason) {
|
||||
return of(DOMAIN_JOINER.join(label, tld), reason);
|
||||
return new UnblockableDomain(DOMAIN_JOINER.join(label, tld), reason);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ public abstract class UnblockableDomainChange {
|
||||
@Memoized
|
||||
public UnblockableDomain newValue() {
|
||||
verify(newReason().isPresent(), "Removed unblockable does not have new value.");
|
||||
return UnblockableDomain.of(unblockable().domainName(), newReason().get());
|
||||
return new UnblockableDomain(unblockable().domainName(), newReason().get());
|
||||
}
|
||||
|
||||
public boolean isNewOrChange() {
|
||||
@@ -78,7 +78,7 @@ public abstract class UnblockableDomainChange {
|
||||
public static UnblockableDomainChange deserialize(String text) {
|
||||
List<String> items = BsaStringUtils.PROPERTY_SPLITTER.splitToList(text);
|
||||
return of(
|
||||
UnblockableDomain.of(items.get(0), Reason.valueOf(items.get(1))),
|
||||
new UnblockableDomain(items.get(0), Reason.valueOf(items.get(1))),
|
||||
Objects.equals(items.get(2), DELETE_REASON_PLACEHOLDER)
|
||||
? Optional.empty()
|
||||
: Optional.of(Reason.valueOf(items.get(2))));
|
||||
|
||||
@@ -239,10 +239,10 @@ public final class DomainsRefresher {
|
||||
|
||||
Streams.concat(
|
||||
newCreated.stream()
|
||||
.map(name -> UnblockableDomain.of(name, Reason.REGISTERED))
|
||||
.map(name -> new UnblockableDomain(name, Reason.REGISTERED))
|
||||
.map(UnblockableDomainChange::ofNew),
|
||||
reservedNotCreated.stream()
|
||||
.map(name -> UnblockableDomain.of(name, Reason.RESERVED))
|
||||
.map(name -> new UnblockableDomain(name, Reason.RESERVED))
|
||||
.map(UnblockableDomainChange::ofNew))
|
||||
.forEach(changes::add);
|
||||
return changes.build();
|
||||
|
||||
@@ -152,7 +152,7 @@ public final class LabelDiffUpdates {
|
||||
ImmutableSet<String> registeredDomainNames =
|
||||
ImmutableSet.copyOf(ForeignKeyUtils.load(Domain.class, validDomainNames, now).keySet());
|
||||
for (String domain : registeredDomainNames) {
|
||||
nonBlockedDomains.add(UnblockableDomain.of(domain, Reason.REGISTERED));
|
||||
nonBlockedDomains.add(new UnblockableDomain(domain, Reason.REGISTERED));
|
||||
tm().put(BsaUnblockableDomain.of(domain, BsaUnblockableDomain.Reason.REGISTERED));
|
||||
}
|
||||
|
||||
@@ -161,7 +161,7 @@ public final class LabelDiffUpdates {
|
||||
.filter(domain -> isReservedDomain(domain, now))
|
||||
.collect(toImmutableSet());
|
||||
for (String domain : reservedDomainNames) {
|
||||
nonBlockedDomains.add(UnblockableDomain.of(domain, Reason.RESERVED));
|
||||
nonBlockedDomains.add(new UnblockableDomain(domain, Reason.RESERVED));
|
||||
tm().put(BsaUnblockableDomain.of(domain, BsaUnblockableDomain.Reason.RESERVED));
|
||||
}
|
||||
return nonBlockedDomains.build();
|
||||
|
||||
@@ -14,25 +14,21 @@
|
||||
|
||||
package google.registry.flows;
|
||||
|
||||
import com.google.auto.value.AutoValue;
|
||||
import google.registry.model.ImmutableObject;
|
||||
import com.google.auto.value.AutoBuilder;
|
||||
|
||||
/** Object to hold metadata specific to a particular execution of a flow. */
|
||||
@AutoValue
|
||||
public abstract class FlowMetadata extends ImmutableObject {
|
||||
|
||||
public abstract boolean isSuperuser();
|
||||
public record FlowMetadata(boolean isSuperuser) {
|
||||
|
||||
public static Builder newBuilder() {
|
||||
return new AutoValue_FlowMetadata.Builder();
|
||||
return new AutoBuilder_FlowMetadata_Builder();
|
||||
}
|
||||
|
||||
/** Builder for {@link FlowMetadata} */
|
||||
@AutoValue.Builder
|
||||
public abstract static class Builder {
|
||||
@AutoBuilder
|
||||
public interface Builder {
|
||||
|
||||
public abstract Builder setSuperuser(boolean isSuperuser);
|
||||
Builder setIsSuperuser(boolean isSuperuser);
|
||||
|
||||
public abstract FlowMetadata build();
|
||||
FlowMetadata build();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -314,7 +314,7 @@ public class FlowModule {
|
||||
|
||||
@Provides
|
||||
static FlowMetadata provideFlowMetadata(@Superuser boolean isSuperuser) {
|
||||
return FlowMetadata.newBuilder().setSuperuser(isSuperuser).build();
|
||||
return FlowMetadata.newBuilder().setIsSuperuser(isSuperuser).build();
|
||||
}
|
||||
|
||||
/** Wrapper class to carry an {@link EppException} to the calling code. */
|
||||
|
||||
Reference in New Issue
Block a user