mirror of
https://github.com/google/nomulus.git
synced 2025-06-29 07:43:37 +02:00
Clean up some code quality issues
This removes some qualifiers that aren't necessary (e.g. public/abstract on interfaces, private on enum constructors, final on private methods, static on nested interfaces/enums), uses Java 8 lambdas and features where that's an improvement ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=177182945
This commit is contained in:
parent
0935ba6450
commit
e2db3f914e
109 changed files with 286 additions and 379 deletions
|
@ -64,32 +64,27 @@ final class AllocateDomainCommand extends MutatingEppToolCommand {
|
|||
|
||||
@Override
|
||||
protected String postExecute() throws Exception {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
// Check to see that we allocated everything.
|
||||
return builder
|
||||
.append(
|
||||
ofy()
|
||||
.transactNewReadOnly(
|
||||
() -> {
|
||||
String failureMessage =
|
||||
ofy()
|
||||
.load()
|
||||
.keys(applicationKeys)
|
||||
.values()
|
||||
.stream()
|
||||
.map(
|
||||
application ->
|
||||
application.getApplicationStatus()
|
||||
== ApplicationStatus.ALLOCATED
|
||||
? null
|
||||
: application.getFullyQualifiedDomainName())
|
||||
.filter(Objects::nonNull)
|
||||
.collect(joining("\n"));
|
||||
return failureMessage.isEmpty()
|
||||
? "ALL SUCCEEDED"
|
||||
: addHeader("FAILURES", failureMessage);
|
||||
}))
|
||||
.toString();
|
||||
return ofy()
|
||||
.transactNewReadOnly(
|
||||
() -> {
|
||||
String failureMessage =
|
||||
ofy()
|
||||
.load()
|
||||
.keys(applicationKeys)
|
||||
.values()
|
||||
.stream()
|
||||
.map(
|
||||
application ->
|
||||
application.getApplicationStatus()
|
||||
== ApplicationStatus.ALLOCATED
|
||||
? null
|
||||
: application.getFullyQualifiedDomainName())
|
||||
.filter(Objects::nonNull)
|
||||
.collect(joining("\n"));
|
||||
return failureMessage.isEmpty()
|
||||
? "ALL SUCCEEDED"
|
||||
: addHeader("FAILURES", failureMessage);
|
||||
});
|
||||
}
|
||||
|
||||
/** Extract the registration period from the XML used to create the domain application. */
|
||||
|
|
|
@ -26,5 +26,5 @@ public interface Command {
|
|||
* <p>Just implementing this is sufficient to use the remote api; {@link RegistryTool} will
|
||||
* install it as needed.
|
||||
*/
|
||||
public interface RemoteApiCommand extends Command {}
|
||||
interface RemoteApiCommand extends Command {}
|
||||
}
|
||||
|
|
|
@ -67,7 +67,7 @@ abstract class CreateOrUpdatePremiumListCommand extends ConfirmingCommand
|
|||
|
||||
abstract String getCommandPath();
|
||||
|
||||
ImmutableMap<String, ? extends Object> getParameterMap() {
|
||||
ImmutableMap<String, ?> getParameterMap() {
|
||||
return ImmutableMap.of();
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ public class CreatePremiumListCommand extends CreateOrUpdatePremiumListCommand {
|
|||
}
|
||||
|
||||
@Override
|
||||
ImmutableMap<String, ? extends Object> getParameterMap() {
|
||||
ImmutableMap<String, ?> getParameterMap() {
|
||||
if (override) {
|
||||
return ImmutableMap.of("override", override);
|
||||
} else {
|
||||
|
|
|
@ -133,7 +133,7 @@ abstract class EppToolCommand extends ConfirmingCommand implements ServerSideCom
|
|||
String prompt = addHeader("Command(s)", Joiner.on("\n").join(commands)
|
||||
+ (force ? "" : addHeader("Dry Run", Joiner.on("\n").join(processCommands(true)))));
|
||||
force = force || isDryRun();
|
||||
return prompt.toString();
|
||||
return prompt;
|
||||
}
|
||||
|
||||
private List<String> processCommands(boolean dryRun) throws IOException {
|
||||
|
|
|
@ -42,6 +42,8 @@ import google.registry.model.contact.ContactResource;
|
|||
import google.registry.model.contact.PostalInfo;
|
||||
import google.registry.model.domain.DomainApplication;
|
||||
import google.registry.model.domain.launch.ApplicationStatus;
|
||||
import google.registry.model.eppcommon.Address;
|
||||
import google.registry.model.eppcommon.PhoneNumber;
|
||||
import google.registry.model.registrar.Registrar;
|
||||
import google.registry.model.registrar.RegistrarAddress;
|
||||
import google.registry.model.registrar.RegistrarContact;
|
||||
|
@ -190,9 +192,8 @@ final class GenerateAuctionDataCommand implements RemoteApiCommand {
|
|||
Optional.ofNullable(registrant.getInternationalizedPostalInfo())
|
||||
.orElse(registrant.getLocalizedPostalInfo()));
|
||||
Optional<ContactAddress> address =
|
||||
Optional.ofNullable(postalInfo.isPresent() ? postalInfo.get().getAddress() : null);
|
||||
List<String> street =
|
||||
address.isPresent() ? address.get().getStreet() : ImmutableList.of();
|
||||
Optional.ofNullable(postalInfo.map(PostalInfo::getAddress).orElse(null));
|
||||
List<String> street = address.map(Address::getStreet).orElseGet(ImmutableList::of);
|
||||
Optional<ContactPhoneNumber> phoneNumber = Optional.ofNullable(registrant.getVoiceNumber());
|
||||
|
||||
// Each line containing an auction participant has the following format:
|
||||
|
@ -211,16 +212,16 @@ final class GenerateAuctionDataCommand implements RemoteApiCommand {
|
|||
? formatter.print(domainApplication.getLastEppUpdateTime())
|
||||
: "",
|
||||
domainApplication.getCurrentSponsorClientId(),
|
||||
nullToEmpty(postalInfo.isPresent() ? postalInfo.get().getName() : ""),
|
||||
nullToEmpty(postalInfo.isPresent() ? postalInfo.get().getOrg() : ""),
|
||||
nullToEmpty(postalInfo.map(PostalInfo::getName).orElse("")),
|
||||
nullToEmpty(postalInfo.map(PostalInfo::getOrg).orElse("")),
|
||||
Iterables.getFirst(street, ""),
|
||||
street.stream().skip(1).filter(Objects::nonNull).collect(joining(" ")),
|
||||
nullToEmpty(address.isPresent() ? address.get().getCity() : ""),
|
||||
nullToEmpty(address.isPresent() ? address.get().getState() : ""),
|
||||
nullToEmpty(address.isPresent() ? address.get().getZip() : ""),
|
||||
nullToEmpty(address.isPresent() ? address.get().getCountryCode() : ""),
|
||||
nullToEmpty(address.map(Address::getCity).orElse("")),
|
||||
nullToEmpty(address.map(Address::getState).orElse("")),
|
||||
nullToEmpty(address.map(Address::getZip).orElse("")),
|
||||
nullToEmpty(address.map(Address::getCountryCode).orElse("")),
|
||||
nullToEmpty(registrant.getEmailAddress()),
|
||||
nullToEmpty(phoneNumber.isPresent() ? phoneNumber.get().toPhoneString() : ""),
|
||||
nullToEmpty(phoneNumber.map(PhoneNumber::toPhoneString).orElse("")),
|
||||
"",
|
||||
domainApplication.getEncodedSignedMarks().isEmpty() ? "Landrush" : "Sunrise"));
|
||||
}
|
||||
|
@ -234,8 +235,7 @@ final class GenerateAuctionDataCommand implements RemoteApiCommand {
|
|||
Optional.ofNullable(
|
||||
Optional.ofNullable(registrar.getLocalizedAddress())
|
||||
.orElse(registrar.getInternationalizedAddress()));
|
||||
List<String> street =
|
||||
address.isPresent() ? address.get().getStreet() : ImmutableList.of();
|
||||
List<String> street = address.map(Address::getStreet).orElseGet(ImmutableList::of);
|
||||
|
||||
// Each line containing the registrar of an auction participant has the following format:
|
||||
//
|
||||
|
@ -244,14 +244,16 @@ final class GenerateAuctionDataCommand implements RemoteApiCommand {
|
|||
// Registrar Country|Registrar Email|Registrar Telephone
|
||||
return Joiner.on('|').join(ImmutableList.of(
|
||||
registrar.getClientId(),
|
||||
contact.isPresent() ? contact.get().getName() : "N/A",
|
||||
contact.map(RegistrarContact::getName).orElse("N/A"),
|
||||
nullToEmpty(registrar.getRegistrarName()),
|
||||
Iterables.getFirst(street, ""),
|
||||
Iterables.get(street, 1, ""),
|
||||
address.isPresent() ? nullToEmpty(address.get().getCity()) : "",
|
||||
address.isPresent() ? nullToEmpty(address.get().getState()) : "",
|
||||
address.isPresent() ? nullToEmpty(address.get().getZip()) : "",
|
||||
address.isPresent() ? nullToEmpty(address.get().getCountryCode()) : "",
|
||||
address.map(registrarAddress -> nullToEmpty(registrarAddress.getCity())).orElse(""),
|
||||
address.map(registrarAddress1 ->
|
||||
nullToEmpty(registrarAddress1.getState())).orElse(""),
|
||||
address.map(registrarAddress2 -> nullToEmpty(registrarAddress2.getZip())).orElse(""),
|
||||
address.map(registrarAddress3 ->
|
||||
nullToEmpty(registrarAddress3.getCountryCode())).orElse(""),
|
||||
nullToEmpty(registrar.getEmailAddress()),
|
||||
nullToEmpty(registrar.getPhoneNumber())));
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ public abstract class MutatingCommand extends ConfirmingCommand implements Remot
|
|||
private static class EntityChange {
|
||||
|
||||
/** The possible types of mutation that can be performed on an entity. */
|
||||
public static enum ChangeType {
|
||||
public enum ChangeType {
|
||||
CREATE, DELETE, UPDATE;
|
||||
|
||||
/** Return the ChangeType corresponding to the given combination of version existences. */
|
||||
|
|
|
@ -40,14 +40,14 @@ enum RegistryToolEnvironment {
|
|||
private final RegistryEnvironment actualEnvironment;
|
||||
private final ImmutableMap<String, String> extraProperties;
|
||||
|
||||
private RegistryToolEnvironment(
|
||||
RegistryToolEnvironment(
|
||||
RegistryEnvironment actualEnvironment,
|
||||
ImmutableMap<String, String> extraProperties) {
|
||||
this.actualEnvironment = actualEnvironment;
|
||||
this.extraProperties = extraProperties;
|
||||
}
|
||||
|
||||
private RegistryToolEnvironment(RegistryEnvironment actualEnvironment) {
|
||||
RegistryToolEnvironment(RegistryEnvironment actualEnvironment) {
|
||||
this(actualEnvironment, ImmutableMap.of());
|
||||
}
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ public enum EppResourceTypeParameter {
|
|||
|
||||
private final Class<? extends EppResource> type;
|
||||
|
||||
private EppResourceTypeParameter(Class<? extends EppResource> type) {
|
||||
EppResourceTypeParameter(Class<? extends EppResource> type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue