mirror of
https://github.com/google/nomulus.git
synced 2025-05-15 08:57:12 +02:00
Fix various Error Prone errors that were found by the FOSS build
Most common: - Unnecessary parentheses and operator precedence clarify (self-explanatory) - Reference equality--there were a few instances of using == or != improperly - Qualification of Builder (and similar) imports so that it's clear which type of Builder we're referring to - Marking some immutable classes with @Immutable since EP desires that all enums be deeply immutable - String.split() having "surprising behavior" ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=230971531
This commit is contained in:
parent
9cd37189c2
commit
3cf26ff9b6
52 changed files with 155 additions and 133 deletions
|
@ -28,7 +28,6 @@ import com.googlecode.objectify.Result;
|
|||
import com.googlecode.objectify.cmd.Query;
|
||||
import com.googlecode.objectify.util.ResultNow;
|
||||
import google.registry.config.RegistryConfig;
|
||||
import google.registry.model.EppResource.Builder;
|
||||
import google.registry.model.EppResource.BuilderWithTransferData;
|
||||
import google.registry.model.EppResource.ForeignKeyedEppResource;
|
||||
import google.registry.model.EppResource.ResourceWithTransferData;
|
||||
|
@ -222,7 +221,7 @@ public final class EppResourceUtils {
|
|||
}
|
||||
|
||||
/** Process an automatic transfer on a resource. */
|
||||
public static <B extends Builder<?, B> & BuilderWithTransferData<B>>
|
||||
public static <B extends EppResource.Builder<?, B> & BuilderWithTransferData<B>>
|
||||
void setAutomaticTransferSuccessProperties(B builder, TransferData transferData) {
|
||||
checkArgument(TransferStatus.PENDING.equals(transferData.getTransferStatus()));
|
||||
builder.removeStatusValue(StatusValue.PENDING_TRANSFER)
|
||||
|
@ -239,14 +238,15 @@ public final class EppResourceUtils {
|
|||
|
||||
/**
|
||||
* Perform common operations for projecting an {@link EppResource} at a given time:
|
||||
*
|
||||
* <ul>
|
||||
* <li>Process an automatic transfer.
|
||||
* </ul>
|
||||
*/
|
||||
public static <
|
||||
T extends EppResource & ResourceWithTransferData,
|
||||
B extends Builder<?, B> & BuilderWithTransferData<B>>
|
||||
void projectResourceOntoBuilderAtTime(T resource, B builder, DateTime now) {
|
||||
T extends EppResource & ResourceWithTransferData,
|
||||
B extends EppResource.Builder<?, B> & BuilderWithTransferData<B>>
|
||||
void projectResourceOntoBuilderAtTime(T resource, B builder, DateTime now) {
|
||||
TransferData transferData = resource.getTransferData();
|
||||
// If there's a pending transfer that has expired, process it.
|
||||
DateTime expirationTime = transferData.getPendingTransferExpirationTime();
|
||||
|
@ -289,7 +289,7 @@ public final class EppResourceUtils {
|
|||
// and returns it projected forward to exactly the desired timestamp, or null if the resource is
|
||||
// deleted at that timestamp.
|
||||
final Result<T> loadResult =
|
||||
(isAtOrAfter(timestamp, resource.getUpdateAutoTimestamp().getTimestamp()))
|
||||
isAtOrAfter(timestamp, resource.getUpdateAutoTimestamp().getTimestamp())
|
||||
? new ResultNow<>(resource)
|
||||
: loadMostRecentRevisionAtTime(resource, timestamp);
|
||||
return () -> {
|
||||
|
|
|
@ -23,7 +23,6 @@ import static google.registry.model.ofy.ObjectifyService.ofy;
|
|||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Sets;
|
||||
import google.registry.model.EppResource.Builder;
|
||||
import google.registry.model.EppResource.BuilderWithTransferData;
|
||||
import google.registry.model.EppResource.ForeignKeyedEppResource;
|
||||
import google.registry.model.EppResource.ResourceWithTransferData;
|
||||
|
@ -170,7 +169,7 @@ public final class ResourceTransferUtils {
|
|||
*/
|
||||
public static <
|
||||
R extends EppResource & ResourceWithTransferData,
|
||||
B extends Builder<R, B> & BuilderWithTransferData<B>>
|
||||
B extends EppResource.Builder<R, B> & BuilderWithTransferData<B>>
|
||||
R approvePendingTransfer(R resource, TransferStatus transferStatus, DateTime now) {
|
||||
checkArgument(transferStatus.isApproved(), "Not an approval transfer status");
|
||||
B builder = resolvePendingTransfer(resource, transferStatus, now);
|
||||
|
|
|
@ -100,7 +100,8 @@ public class GracePeriod extends ImmutableObject {
|
|||
@Nullable Key<BillingEvent.Recurring> billingEventRecurring) {
|
||||
checkArgument((billingEventOneTime == null) || (billingEventRecurring == null),
|
||||
"A grace period can have at most one billing event");
|
||||
checkArgument((billingEventRecurring != null) == (GracePeriodStatus.AUTO_RENEW.equals(type)),
|
||||
checkArgument(
|
||||
(billingEventRecurring != null) == GracePeriodStatus.AUTO_RENEW.equals(type),
|
||||
"Recurring billing events must be present on (and only on) autorenew grace periods");
|
||||
GracePeriod instance = new GracePeriod();
|
||||
instance.type = checkArgumentNotNull(type);
|
||||
|
|
|
@ -19,7 +19,7 @@ import static google.registry.util.CollectionUtils.nullToEmptyImmutableCopy;
|
|||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import google.registry.model.Buildable.Builder;
|
||||
import google.registry.model.Buildable;
|
||||
import google.registry.model.EppResource;
|
||||
import google.registry.model.ImmutableObject;
|
||||
import google.registry.model.eppcommon.AuthInfo;
|
||||
|
@ -82,7 +82,7 @@ public interface ResourceCommand {
|
|||
}
|
||||
|
||||
/** A create command, or the inner change (as opposed to add or remove) part of an update. */
|
||||
interface ResourceCreateOrChange<B extends Builder<?>> {}
|
||||
interface ResourceCreateOrChange<B extends Buildable.Builder<?>> {}
|
||||
|
||||
/**
|
||||
* An update command for an {@link EppResource}.
|
||||
|
|
|
@ -149,7 +149,7 @@ public class HostResource extends EppResource implements ForeignKeyedEppResource
|
|||
Optional.ofNullable(getLastSuperordinateChange()).orElse(getCreationTime());
|
||||
DateTime lastTransferOfCurrentSuperordinate =
|
||||
Optional.ofNullable(superordinateDomain.getLastTransferTime()).orElse(START_OF_TIME);
|
||||
return (lastSuperordinateChange.isBefore(lastTransferOfCurrentSuperordinate))
|
||||
return lastSuperordinateChange.isBefore(lastTransferOfCurrentSuperordinate)
|
||||
? superordinateDomain.getLastTransferTime()
|
||||
: getLastTransferTime();
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ public class EppResourceIndexBucket extends ImmutableObject {
|
|||
private static long getBucketIdFromEppResource(Key<? extends EppResource> resourceKey) {
|
||||
int numBuckets = getEppResourceIndexBucketCount();
|
||||
// IDs can't be 0, so add 1 to the hash.
|
||||
return Hashing.consistentHash(resourceKey.getName().hashCode(), numBuckets) + 1;
|
||||
return Hashing.consistentHash(resourceKey.getName().hashCode(), numBuckets) + 1L;
|
||||
}
|
||||
|
||||
/** Gets a bucket key as a function of an EppResource to be indexed. */
|
||||
|
|
|
@ -130,8 +130,10 @@ public class Registrar extends ImmutableObject implements Buildable, Jsonifiable
|
|||
/**
|
||||
* Predicate for validating IANA IDs for this type of registrar.
|
||||
*
|
||||
* @see <a href="http://www.iana.org/assignments/registrar-ids/registrar-ids.txt">Registrar IDs</a>
|
||||
* @see <a href="http://www.iana.org/assignments/registrar-ids/registrar-ids.txt">Registrar
|
||||
* IDs</a>
|
||||
*/
|
||||
@SuppressWarnings("ImmutableEnumChecker")
|
||||
private final Predicate<Long> ianaIdValidator;
|
||||
|
||||
Type(Predicate<Long> ianaIdValidator) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue