mirror of
https://github.com/google/nomulus.git
synced 2025-05-15 00:47:11 +02:00
Change value type class to @AutoValue to fix errorprone warning
AutoValue classes by default do not allow null parameters, so I've removed the unnecessary null checks. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=127870611
This commit is contained in:
parent
a879afa075
commit
5522135f5a
2 changed files with 27 additions and 27 deletions
|
@ -28,6 +28,7 @@ java_library(
|
||||||
"//java/com/google/common/io",
|
"//java/com/google/common/io",
|
||||||
"//java/com/google/common/net",
|
"//java/com/google/common/net",
|
||||||
"//third_party/java/appengine:appengine-api",
|
"//third_party/java/appengine:appengine-api",
|
||||||
|
"//third_party/java/auto:auto_value",
|
||||||
"//third_party/java/dagger",
|
"//third_party/java/dagger",
|
||||||
"//third_party/java/joda_time",
|
"//third_party/java/joda_time",
|
||||||
"//third_party/java/jsr305_annotations",
|
"//third_party/java/jsr305_annotations",
|
||||||
|
|
|
@ -25,6 +25,7 @@ import static java.util.concurrent.TimeUnit.SECONDS;
|
||||||
import com.google.appengine.api.taskqueue.Queue;
|
import com.google.appengine.api.taskqueue.Queue;
|
||||||
import com.google.appengine.api.taskqueue.TaskHandle;
|
import com.google.appengine.api.taskqueue.TaskHandle;
|
||||||
import com.google.appengine.api.taskqueue.TaskOptions;
|
import com.google.appengine.api.taskqueue.TaskOptions;
|
||||||
|
import com.google.auto.value.AutoValue;
|
||||||
import com.google.common.base.Optional;
|
import com.google.common.base.Optional;
|
||||||
import com.google.common.collect.ComparisonChain;
|
import com.google.common.collect.ComparisonChain;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
|
@ -79,20 +80,21 @@ public final class ReadDnsQueueAction implements Runnable {
|
||||||
@Inject ReadDnsQueueAction() {}
|
@Inject ReadDnsQueueAction() {}
|
||||||
|
|
||||||
/** Container for items we pull out of the DNS pull queue and process for fanout. */
|
/** Container for items we pull out of the DNS pull queue and process for fanout. */
|
||||||
private class RefreshItem implements Comparable<RefreshItem> {
|
@AutoValue
|
||||||
final TargetType type;
|
abstract static class RefreshItem implements Comparable<RefreshItem> {
|
||||||
final String name;
|
static RefreshItem create(TargetType type, String name) {
|
||||||
|
return new AutoValue_ReadDnsQueueAction_RefreshItem(type, name);
|
||||||
public RefreshItem(final TargetType type, final String name) {
|
|
||||||
this.type = type;
|
|
||||||
this.name = name;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
abstract TargetType type();
|
||||||
|
|
||||||
|
abstract String name();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(RefreshItem other) {
|
public int compareTo(RefreshItem other) {
|
||||||
return ComparisonChain.start()
|
return ComparisonChain.start()
|
||||||
.compare(this.type, other.type)
|
.compare(this.type(), other.type())
|
||||||
.compare(this.name, other.name)
|
.compare(this.name(), other.name())
|
||||||
.result();
|
.result();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -138,23 +140,19 @@ public final class ReadDnsQueueAction implements Runnable {
|
||||||
} else {
|
} else {
|
||||||
String typeString = params.get(DNS_TARGET_TYPE_PARAM);
|
String typeString = params.get(DNS_TARGET_TYPE_PARAM);
|
||||||
String name = params.get(DNS_TARGET_NAME_PARAM);
|
String name = params.get(DNS_TARGET_NAME_PARAM);
|
||||||
if (typeString == null) {
|
TargetType type = TargetType.valueOf(typeString);
|
||||||
logger.severe("discarding invalid DNS refresh request; no type specified");
|
switch (type) {
|
||||||
} else if (name == null) {
|
case DOMAIN:
|
||||||
logger.severe("discarding invalid DNS refresh request; no name specified");
|
case HOST:
|
||||||
} else {
|
refreshItemMultimap.put(tld, RefreshItem.create(type, name));
|
||||||
TargetType type = TargetType.valueOf(typeString);
|
break;
|
||||||
switch (type) {
|
default:
|
||||||
case DOMAIN:
|
logger.severefmt("discarding DNS refresh request of type %s", typeString);
|
||||||
case HOST:
|
break;
|
||||||
refreshItemMultimap.put(tld, new RefreshItem(type, name));
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
logger.severefmt("discarding DNS refresh request of type %s", typeString);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch (RuntimeException e) {
|
||||||
|
logger.severefmt(e, "discarding invalid DNS refresh request (task %s)", task);
|
||||||
} catch (UnsupportedEncodingException e) {
|
} catch (UnsupportedEncodingException e) {
|
||||||
logger.severefmt(e, "discarding invalid DNS refresh request (task %s)", task);
|
logger.severefmt(e, "discarding invalid DNS refresh request (task %s)", task);
|
||||||
}
|
}
|
||||||
|
@ -174,9 +172,10 @@ public final class ReadDnsQueueAction implements Runnable {
|
||||||
.param(RequestParameters.PARAM_TLD, tldRefreshItemsEntry.getKey());
|
.param(RequestParameters.PARAM_TLD, tldRefreshItemsEntry.getKey());
|
||||||
for (RefreshItem refreshItem : chunk) {
|
for (RefreshItem refreshItem : chunk) {
|
||||||
options.param(
|
options.param(
|
||||||
(refreshItem.type == TargetType.HOST)
|
(refreshItem.type() == TargetType.HOST)
|
||||||
? PublishDnsUpdatesAction.HOSTS_PARAM : PublishDnsUpdatesAction.DOMAINS_PARAM,
|
? PublishDnsUpdatesAction.HOSTS_PARAM
|
||||||
refreshItem.name);
|
: PublishDnsUpdatesAction.DOMAINS_PARAM,
|
||||||
|
refreshItem.name());
|
||||||
}
|
}
|
||||||
taskEnqueuer.enqueue(dnsPublishPushQueue, options);
|
taskEnqueuer.enqueue(dnsPublishPushQueue, options);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue