mirror of
https://github.com/google/nomulus.git
synced 2025-05-12 22:38:16 +02:00
Switch from Guava Optionals to Java 8 Optionals
This was a surprisingly involved change. Some of the difficulties included java.util.Optional purposely not being Serializable (so I had to move a few Optionals in mapreduce classes to @Nullable) and having to add the Truth Java8 extension library for assertion support. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=171863777
This commit is contained in:
parent
184b2b56ac
commit
c0f8da0c6e
581 changed files with 1325 additions and 932 deletions
|
@ -23,13 +23,13 @@ import com.google.appengine.api.datastore.Text;
|
|||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.base.Ascii;
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import google.registry.util.Clock;
|
||||
import google.registry.util.NonFinalForTesting;
|
||||
import google.registry.util.SystemClock;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.Duration;
|
||||
|
||||
|
@ -71,9 +71,9 @@ public class DatastoreBackupInfo {
|
|||
|
||||
kinds = ImmutableSet.copyOf(rawKinds);
|
||||
startTime = new DateTime(rawStartTime).withZone(UTC);
|
||||
completeTime = Optional.fromNullable(
|
||||
completeTime = Optional.ofNullable(
|
||||
rawCompleteTime == null ? null : new DateTime(rawCompleteTime).withZone(UTC));
|
||||
gcsFilename = Optional.fromNullable(
|
||||
gcsFilename = Optional.ofNullable(
|
||||
rawGcsFilename == null ? null : gcsPathToUri(rawGcsFilename.getValue()));
|
||||
}
|
||||
|
||||
|
@ -126,7 +126,7 @@ public class DatastoreBackupInfo {
|
|||
* backup started (if it has not completed).
|
||||
*/
|
||||
public Duration getRunningTime() {
|
||||
return new Duration(startTime, completeTime.or(clock.nowUtc()));
|
||||
return new Duration(startTime, completeTime.orElse(clock.nowUtc()));
|
||||
}
|
||||
|
||||
public Optional<String> getGcsFilename() {
|
||||
|
@ -140,9 +140,9 @@ public class DatastoreBackupInfo {
|
|||
"Backup name: " + backupName,
|
||||
"Status: " + getStatus(),
|
||||
"Started: " + startTime,
|
||||
"Ended: " + completeTime.orNull(),
|
||||
"Ended: " + completeTime.orElse(null),
|
||||
"Duration: " + Ascii.toLowerCase(getRunningTime().toPeriod().toString().substring(2)),
|
||||
"GCS: " + gcsFilename.orNull(),
|
||||
"GCS: " + gcsFilename.orElse(null),
|
||||
"Kinds: " + kinds,
|
||||
"");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue