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:
mcilwain 2017-11-28 10:35:57 -08:00 committed by jianglai
parent 0935ba6450
commit e2db3f914e
109 changed files with 286 additions and 379 deletions

View file

@ -33,7 +33,7 @@ public interface Buildable {
*
* <p>This can be used without implementing {@link Buildable}.
*/
public abstract static class Builder<S> {
abstract class Builder<S> {
private S instance;
@ -77,7 +77,7 @@ public interface Buildable {
}
/** Boilerplate for abstract immutable builders that need to be able to cast "this". */
public abstract class GenericBuilder<S, B extends GenericBuilder<?, ?>> extends Builder<S> {
abstract class GenericBuilder<S, B extends GenericBuilder<?, ?>> extends Builder<S> {
protected GenericBuilder() {}
protected GenericBuilder(S instance) {
@ -100,7 +100,7 @@ public interface Buildable {
*
* @param <T> the derived type
*/
public interface Overlayable<T> extends Buildable {
interface Overlayable<T> extends Buildable {
/** Return an overlay of this object using non-null fields from the source. */
T overlay(T source);
}

View file

@ -165,22 +165,22 @@ public abstract class EppResource extends BackupGroupRoot implements Buildable {
/** An interface for resources that have transfer data. */
public interface ResourceWithTransferData {
public TransferData getTransferData();
TransferData getTransferData();
/**
* The time that this resource was last transferred.
*
* <p>Can be null if the resource has never been transferred.
*/
public DateTime getLastTransferTime();
DateTime getLastTransferTime();
}
/** An interface for builders of resources that have transfer data. */
public interface BuilderWithTransferData<B extends BuilderWithTransferData<B>> {
public B setTransferData(TransferData transferData);
B setTransferData(TransferData transferData);
/** Set the time when this resource was transferred. */
public B setLastTransferTime(DateTime lastTransferTime);
B setLastTransferTime(DateTime lastTransferTime);
}
/** Abstract builder for {@link EppResource} types. */

View file

@ -66,7 +66,7 @@ public final class EppResourceUtils {
/** Helper to call {@link EppResource#cloneProjectedAtTime} without warnings. */
@SuppressWarnings("unchecked")
private static final <T extends EppResource> T cloneProjectedAtTime(T resource, DateTime now) {
private static <T extends EppResource> T cloneProjectedAtTime(T resource, DateTime now) {
return (T) resource.cloneProjectedAtTime(now);
}

View file

@ -52,7 +52,7 @@ public abstract class ImmutableObject implements Cloneable {
@Documented
@Retention(RUNTIME)
@Target(FIELD)
public static @interface DoNotHydrate {}
public @interface DoNotHydrate {}
@Ignore
@XmlTransient

View file

@ -30,7 +30,7 @@ public @interface NotBackedUp {
Reason reason();
/** Reasons why a given entity does not need to be be backed up. */
public enum Reason {
enum Reason {
/** This entity is transient by design and has only a short-term useful lifetime. */
TRANSIENT,

View file

@ -83,7 +83,7 @@ public class Cursor extends ImmutableObject {
/** See the definition of scope on {@link #getScopeClass}. */
private final Class<? extends ImmutableObject> scope;
private CursorType(Class<? extends ImmutableObject> scope) {
CursorType(Class<? extends ImmutableObject> scope) {
this.scope = scope;
}

View file

@ -40,7 +40,7 @@ public class EntityGroupRoot extends BackupGroupRoot {
private String id;
/** The root key for cross-tld resources such as registrars. */
public static final Key<EntityGroupRoot> getCrossTldKey() {
public static Key<EntityGroupRoot> getCrossTldKey() {
return Key.create(EntityGroupRoot.class, "cross-tld");
}
}

View file

@ -67,7 +67,7 @@ public class DomainCommand {
*/
public interface CreateOrUpdate<T extends CreateOrUpdate<T>> extends SingleResourceCommand {
/** Creates a copy of this command with hard links to hosts and contacts. */
public T cloneAndLinkReferences(DateTime now) throws InvalidReferencesException;
T cloneAndLinkReferences(DateTime now) throws InvalidReferencesException;
}
/** The fields on "chgType" from {@link "http://tools.ietf.org/html/rfc5731"}. */

View file

@ -38,9 +38,9 @@ public interface FeeCheckCommandExtension<
*
* <p>Returns null if this version of the fee extension doesn't specify currency at the top level.
*/
public CurrencyUnit getCurrency();
CurrencyUnit getCurrency();
public ImmutableSet<C> getItems();
ImmutableSet<C> getItems();
public R createResponse(ImmutableList<? extends FeeCheckResponseExtensionItem> items);
R createResponse(ImmutableList<? extends FeeCheckResponseExtensionItem> items);
}

View file

@ -31,7 +31,7 @@ public interface FeeCheckResponseExtension<F extends FeeCheckResponseExtensionIt
* If currency is not supported at the top level of Check responses for this version of the fee
* extension, this function has not effect.
*/
public void setCurrencyIfSupported(CurrencyUnit currency);
void setCurrencyIfSupported(CurrencyUnit currency);
public ImmutableList<F> getItems();
ImmutableList<F> getItems();
}

View file

@ -68,7 +68,7 @@ public class LaunchPhase extends ImmutableObject {
/**
* Returns a map of the static final fields to their values, case-converted.
*/
private static final ImmutableMap<String, LaunchPhase> initEnumMapping() {
private static ImmutableMap<String, LaunchPhase> initEnumMapping() {
ImmutableMap.Builder<String, LaunchPhase> builder = new ImmutableMap.Builder<>();
for (Entry<String, LaunchPhase> entry : getTypesafeEnumMapping(LaunchPhase.class).entrySet()) {
builder.put(UPPER_UNDERSCORE.to(LOWER_CAMEL, entry.getKey()), entry.getValue());

View file

@ -95,8 +95,11 @@ public class ProtocolDefinition {
}
}
/** Converts a service extension enum to its URI. */
/** This stores a map from URI back to the service extension enum. */
/**
* Converts a service extension enum to its URI.
*
* <p>This stores a map from URI back to the service extension enum.
*/
private static final ImmutableMap<String, ServiceExtension> serviceExtensionByUri =
uniqueIndex(EnumSet.allOf(ServiceExtension.class), ServiceExtension::getUri);

View file

@ -139,12 +139,12 @@ public enum StatusValue implements EppEnum {
private final ImmutableSet<Class<? extends EppResource>> classes;
@SafeVarargs
private AllowedOn(Class<? extends EppResource>... classes) {
AllowedOn(Class<? extends EppResource>... classes) {
this.classes = ImmutableSet.copyOf(classes);
}
}
private StatusValue(AllowedOn allowedOn) {
StatusValue(AllowedOn allowedOn) {
this.allowedOn = allowedOn;
}

View file

@ -42,7 +42,7 @@ public interface ResourceCommand {
* a base class that gives them all of the resource's fields. The domain "Info" command also can't
* do that since it's "name" field is overloaded with a "hosts" attribute.
*/
public interface SingleResourceCommand extends ResourceCommand {
interface SingleResourceCommand extends ResourceCommand {
String getTargetId();
AuthInfo getAuthInfo();
@ -50,7 +50,7 @@ public interface ResourceCommand {
/** Abstract implementation of {@link ResourceCommand}. */
@XmlTransient
public abstract static class AbstractSingleResourceCommand extends ImmutableObject
abstract class AbstractSingleResourceCommand extends ImmutableObject
implements SingleResourceCommand {
@XmlElements({
@XmlElement(name = "id"),
@ -70,7 +70,7 @@ public interface ResourceCommand {
/** A check command for an {@link EppResource}. */
@XmlTransient
public static class ResourceCheck extends ImmutableObject implements ResourceCommand {
class ResourceCheck extends ImmutableObject implements ResourceCommand {
@XmlElements({
@XmlElement(name = "id"),
@XmlElement(name = "name") })
@ -82,7 +82,7 @@ public interface ResourceCommand {
}
/** A create command, or the inner change (as opposed to add or remove) part of an update. */
public interface ResourceCreateOrChange<B extends Builder<?>> {}
interface ResourceCreateOrChange<B extends Builder<?>> {}
/**
* An update command for an {@link EppResource}.
@ -91,7 +91,7 @@ public interface ResourceCommand {
* @param <C> the change type
*/
@XmlTransient
public abstract static class ResourceUpdate
abstract class ResourceUpdate
<A extends ResourceUpdate.AddRemove,
B extends EppResource.Builder<?, ?>,
C extends ResourceCreateOrChange<B>> extends AbstractSingleResourceCommand {

View file

@ -32,14 +32,14 @@ public interface PremiumPricingEngine {
* <p>Note that the fullyQualifiedDomainName must only contain a single part left of the TLD, i.e.
* subdomains are not allowed, but multi-part TLDs are.
*/
public DomainPrices getDomainPrices(String fullyQualifiedDomainName, DateTime priceTime);
DomainPrices getDomainPrices(String fullyQualifiedDomainName, DateTime priceTime);
/**
* A class containing information on premium prices for a specific domain name.
*
* <p>Any implementation of PremiumPricingEngine is responsible for determining all of these.
*/
public static class DomainPrices {
class DomainPrices {
private boolean isPremium;
// TODO(b/26901539): Refactor return values to support an arbitrary list of costs for each of

View file

@ -133,7 +133,7 @@ public class Registrar extends ImmutableObject implements Buildable, Jsonifiable
*/
private final Predicate<Long> ianaIdValidator;
private Type(Predicate<Long> ianaIdValidator) {
Type(Predicate<Long> ianaIdValidator) {
this.ianaIdValidator = ianaIdValidator;
}

View file

@ -84,7 +84,7 @@ public class RegistrarContact extends ImmutableObject implements Jsonifiable {
return required;
}
private Type(String display, boolean required) {
Type(String display, boolean required) {
this.displayName = display;
this.required = required;
}

View file

@ -174,8 +174,7 @@ public final class PremiumListUtils {
"PremiumList was concurrently edited");
PremiumList newList = premiumList.asBuilder()
.setLastUpdateTime(now)
.setCreationTime(
oldPremiumList.isPresent() ? oldPremiumList.get().creationTime : now)
.setCreationTime(oldPremiumList.isPresent() ? oldPremiumList.get().creationTime : now)
.setRevision(newRevisionKey)
.build();
ofy().save().entities(newList, newRevision);
@ -184,9 +183,7 @@ public final class PremiumListUtils {
// Update the cache.
cachePremiumLists.put(premiumList.getName(), updated);
// Delete the entities under the old PremiumList.
if (oldPremiumList.isPresent()) {
deleteRevisionAndEntriesOfPremiumList(oldPremiumList.get());
}
oldPremiumList.ifPresent(PremiumListUtils::deleteRevisionAndEntriesOfPremiumList);
return updated;
}

View file

@ -39,7 +39,7 @@ public enum TransferStatus {
private final String message;
private TransferStatus(String message) {
TransferStatus(String message) {
this.message = message;
}