Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import java.util.Map;
import java.util.Map.Entry;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.threeten.bp.Duration;

/** Wrapper for {@link Table} protocol buffer object */
Expand Down Expand Up @@ -111,6 +112,7 @@ public static class AutomatedBackupPolicy {
@InternalApi
public static AutomatedBackupPolicy fromProto(
com.google.bigtable.admin.v2.Table.AutomatedBackupPolicy proto) {
Preconditions.checkNotNull(proto);
return new AutomatedBackupPolicy(proto);
}

Expand Down Expand Up @@ -143,7 +145,7 @@ public String viewConfig() {

private final Duration changeStreamRetention;
private final boolean deletionProtection;
private static AutomatedBackupPolicy automatedBackupPolicy;
@Nullable private final AutomatedBackupPolicy automatedBackupPolicy;

@InternalApi
public static Table fromProto(@Nonnull com.google.bigtable.admin.v2.Table proto) {
Expand All @@ -170,10 +172,9 @@ public static Table fromProto(@Nonnull com.google.bigtable.admin.v2.Table proto)
proto.getChangeStreamConfig().getRetentionPeriod().getNanos());
}

AutomatedBackupPolicy automatedBackupPolicy = null;
if (proto.hasAutomatedBackupPolicy()) {
automatedBackupPolicy = AutomatedBackupPolicy.fromProto(proto.getAutomatedBackupPolicy());
} else {
automatedBackupPolicy = null;
}

return new Table(
Expand All @@ -191,14 +192,14 @@ private Table(
List<ColumnFamily> columnFamilies,
Duration changeStreamRetention,
boolean deletionProtection,
AutomatedBackupPolicy automatedBackupPolicy) {
@Nullable AutomatedBackupPolicy automatedBackupPolicy) {
this.instanceId = tableName.getInstance();
this.id = tableName.getTable();
this.replicationStatesByClusterId = replicationStatesByClusterId;
this.columnFamilies = columnFamilies;
this.changeStreamRetention = changeStreamRetention;
this.deletionProtection = deletionProtection;
Table.automatedBackupPolicy = automatedBackupPolicy;
this.automatedBackupPolicy = automatedBackupPolicy;
}

/** Gets the table's id. */
Expand Down Expand Up @@ -230,10 +231,11 @@ public boolean isDeletionProtected() {

/** Returns whether this table has automated backups enabled. */
public boolean isAutomatedBackupEnabled() {
return automatedBackupPolicy == null ? false : true;
return automatedBackupPolicy != null;
}

/** Returns the automated backup policy config. */
@Nullable
public AutomatedBackupPolicy getAutomatedBackupPolicy() {
return automatedBackupPolicy;
}
Expand All @@ -253,7 +255,7 @@ public boolean equals(Object o) {
&& Objects.equal(columnFamilies, table.columnFamilies)
&& Objects.equal(changeStreamRetention, table.changeStreamRetention)
&& Objects.equal(deletionProtection, table.deletionProtection)
&& Objects.equal(automatedBackupPolicy, Table.automatedBackupPolicy);
&& Objects.equal(automatedBackupPolicy, table.automatedBackupPolicy);
}

@Override
Expand Down
Loading