Skip to content
Permalink
Browse files
fix: check for not null input for Id classes (#159)
Fixes #145
  • Loading branch information
olavloite committed Apr 21, 2020
1 parent 63a6bd8 commit ecf582670818f32e85f534ec400d0b8d31cf9ca6
@@ -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. */
@@ -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);
@@ -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. */
@@ -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);
@@ -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. */
@@ -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);
@@ -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. */
@@ -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);
@@ -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);

0 comments on commit ecf5826

Please sign in to comment.