File tree Expand file tree Collapse file tree
gcloud-java-core/src/main/java/com/google/gcloud
gcloud-java-datastore/src/main/java/com/google/gcloud/datastore Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -122,7 +122,8 @@ protected B self() {
122122 }
123123
124124 public B projectId (String projectId ) {
125- this .projectId = projectId ;
125+ this .projectId =
126+ checkNotNull (projectId , "Project ID cannot be set to null. Leave unset for default." );
126127 return self ();
127128 }
128129
Original file line number Diff line number Diff line change 1616
1717package com .google .gcloud .datastore ;
1818
19- import com .google .common .base .MoreObjects ;
2019import com .google .common .collect .ImmutableList ;
2120
2221/**
@@ -29,14 +28,14 @@ public final class KeyFactory extends BaseKey.Builder<KeyFactory> {
2928 private final String ns ;
3029
3130 public KeyFactory (String projectId ) {
32- this (projectId , null );
31+ this (projectId , "" );
3332 }
3433
3534 public KeyFactory (String projectId , String namespace ) {
3635 super (projectId );
3736 namespace (namespace );
3837 this .pi = projectId ;
39- this .ns = MoreObjects . firstNonNull ( namespace , "" ) ;
38+ this .ns = namespace ;
4039 }
4140
4241 public IncompleteKey newKey () {
Original file line number Diff line number Diff line change @@ -45,9 +45,7 @@ static String validateDatabase(String projectId) {
4545 }
4646
4747 static String validateNamespace (String namespace ) {
48- if (Strings .isNullOrEmpty (namespace )) {
49- return "" ;
50- }
48+ checkArgument (namespace != null , "Namespace cannot be null. Leave unset for default." );
5149 checkArgument (namespace .length () <= MAX_NAMESPACE_LENGTH ,
5250 "namespace must not contain more than 100 characters" );
5351 checkArgument (NAMESPACE_PATTERN .matcher (namespace ).matches (),
You can’t perform that action at this time.
0 commit comments