Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: check for null input for Id classes #159

Merged
merged 1 commit into from Apr 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -30,8 +30,8 @@ public final class BackupId {
private final String backup;

BackupId(InstanceId instanceId, String backup) {
this.instanceId = instanceId;
this.backup = backup;
this.instanceId = Preconditions.checkNotNull(instanceId);
this.backup = Preconditions.checkNotNull(backup);
}

/** Returns the instance id for this backup. */
Expand Down Expand Up @@ -81,6 +81,7 @@ public String toString() {
* @throws IllegalArgumentException if {@code name} does not conform to the expected pattern
*/
static BackupId of(String name) {
Preconditions.checkNotNull(name);
Map<String, String> parts = NAME_TEMPLATE.match(name);
Preconditions.checkArgument(
parts != null, "Name should conform to pattern %s: %s", NAME_TEMPLATE, name);
Expand Down
Expand Up @@ -31,8 +31,8 @@ public final class DatabaseId {
private final String database;

DatabaseId(InstanceId instanceId, String database) {
this.instanceId = instanceId;
this.database = database;
this.instanceId = Preconditions.checkNotNull(instanceId);
this.database = Preconditions.checkNotNull(database);
}

/** Returns the instance id for this databse. */
Expand Down Expand Up @@ -82,6 +82,7 @@ public String toString() {
* @throws IllegalArgumentException if {@code name} does not conform to the expected pattern
*/
static DatabaseId of(String name) {
Preconditions.checkNotNull(name);
Map<String, String> parts = NAME_TEMPLATE.match(name);
Preconditions.checkArgument(
parts != null, "Name should conform to pattern %s: %s", NAME_TEMPLATE, name);
Expand Down
Expand Up @@ -30,8 +30,8 @@ public final class InstanceConfigId {
private final String instanceConfig;

InstanceConfigId(String project, String instanceConfig) {
this.project = project;
this.instanceConfig = instanceConfig;
this.project = Preconditions.checkNotNull(project);
this.instanceConfig = Preconditions.checkNotNull(instanceConfig);
}

/** Returns project of this instane config. */
Expand Down Expand Up @@ -80,6 +80,7 @@ public String toString() {
* pattern.
*/
static InstanceConfigId of(String name) {
Preconditions.checkNotNull(name);
Map<String, String> parts = NAME_TEMPLATE.match(name);
Preconditions.checkArgument(
parts != null, "Name should confirm to pattern %s: %s", NAME_TEMPLATE, name);
Expand Down
Expand Up @@ -30,8 +30,8 @@ public final class InstanceId {
private final String instance;

InstanceId(String project, String instance) {
this.project = project;
this.instance = instance;
this.project = Preconditions.checkNotNull(project);
this.instance = Preconditions.checkNotNull(instance);
}

/** Returns the instance ID. */
Expand Down Expand Up @@ -79,6 +79,7 @@ public String toString() {
* pattern.
*/
static InstanceId of(String name) {
Preconditions.checkNotNull(name);
Map<String, String> parts = NAME_TEMPLATE.match(name);
Preconditions.checkArgument(
parts != null, "Name should conform to pattern %s: %s", NAME_TEMPLATE, name);
Expand Down
Expand Up @@ -44,11 +44,12 @@ static class SessionId {
private final String name;

private SessionId(DatabaseId db, String name) {
this.db = db;
this.name = name;
this.db = Preconditions.checkNotNull(db);
this.name = Preconditions.checkNotNull(name);
}

static SessionId of(String name) {
Preconditions.checkNotNull(name);
Map<String, String> parts = NAME_TEMPLATE.match(name);
Preconditions.checkArgument(
parts != null, "Name should conform to pattern %s: %s", NAME_TEMPLATE, name);
Expand Down