@@ -52,7 +52,7 @@ protected BaseDatastoreBatchWriter(String name) {
5252 public final void addWithDeferredIdAllocation (FullEntity <?>... entities ) {
5353 validateActive ();
5454 for (FullEntity <?> entity : entities ) {
55- IncompleteKey key = entity .key ();
55+ IncompleteKey key = entity .getKey ();
5656 Preconditions .checkArgument (key != null , "Entity must have a key" );
5757 if (key instanceof Key ) {
5858 addInternal ((FullEntity <Key >) entity );
@@ -63,10 +63,10 @@ public final void addWithDeferredIdAllocation(FullEntity<?>... entities) {
6363 }
6464
6565 private void addInternal (FullEntity <Key > entity ) {
66- Key key = entity .key ();
66+ Key key = entity .getKey ();
6767 if (toAdd .containsKey (key ) || toUpdate .containsKey (key ) || toPut .containsKey (key )) {
6868 throw newInvalidRequest ("Entity with the key %s was already added or updated in this %s" ,
69- entity .key (), name );
69+ entity .getKey (), name );
7070 }
7171 if (toDelete .remove (key )) {
7272 toPut .put (key , entity );
@@ -86,7 +86,7 @@ public final List<Entity> add(FullEntity<?>... entities) {
8686 validateActive ();
8787 List <IncompleteKey > incompleteKeys = Lists .newArrayListWithExpectedSize (entities .length );
8888 for (FullEntity <?> entity : entities ) {
89- IncompleteKey key = entity .key ();
89+ IncompleteKey key = entity .getKey ();
9090 Preconditions .checkArgument (key != null , "Entity must have a key" );
9191 if (!(key instanceof Key )) {
9292 incompleteKeys .add (key );
@@ -95,17 +95,17 @@ public final List<Entity> add(FullEntity<?>... entities) {
9595 Iterator <Key > allocated ;
9696 if (!incompleteKeys .isEmpty ()) {
9797 IncompleteKey [] toAllocate = Iterables .toArray (incompleteKeys , IncompleteKey .class );
98- allocated = datastore ().allocateId (toAllocate ).iterator ();
98+ allocated = getDatastore ().allocateId (toAllocate ).iterator ();
9999 } else {
100100 allocated = Collections .emptyIterator ();
101101 }
102102 List <Entity > answer = Lists .newArrayListWithExpectedSize (entities .length );
103103 for (FullEntity <?> entity : entities ) {
104- if (entity .key () instanceof Key ) {
104+ if (entity .getKey () instanceof Key ) {
105105 addInternal ((FullEntity <Key >) entity );
106106 answer .add (Entity .convert ((FullEntity <Key >) entity ));
107107 } else {
108- Entity entityWithAllocatedId = Entity .builder (allocated .next (), entity ).build ();
108+ Entity entityWithAllocatedId = Entity .newBuilder (allocated .next (), entity ).build ();
109109 addInternal (entityWithAllocatedId );
110110 answer .add (entityWithAllocatedId );
111111 }
@@ -118,10 +118,10 @@ public final List<Entity> add(FullEntity<?>... entities) {
118118 public final void update (Entity ... entities ) {
119119 validateActive ();
120120 for (Entity entity : entities ) {
121- Key key = entity .key ();
121+ Key key = entity .getKey ();
122122 if (toDelete .contains (key )) {
123123 throw newInvalidRequest ("Entity with the key %s was already deleted in this %s" ,
124- entity .key (), name );
124+ entity .getKey (), name );
125125 }
126126 if (toAdd .remove (key ) != null || toPut .containsKey (key )) {
127127 toPut .put (key , entity );
@@ -132,7 +132,7 @@ public final void update(Entity... entities) {
132132 }
133133
134134 private void putInternal (FullEntity <Key > entity ) {
135- Key key = entity .key ();
135+ Key key = entity .getKey ();
136136 toAdd .remove (key );
137137 toUpdate .remove (key );
138138 toDelete .remove (key );
@@ -149,7 +149,7 @@ public final Entity put(FullEntity<?> entity) {
149149 public final void putWithDeferredIdAllocation (FullEntity <?>... entities ) {
150150 validateActive ();
151151 for (FullEntity <?> entity : entities ) {
152- IncompleteKey key = entity .key ();
152+ IncompleteKey key = entity .getKey ();
153153 Preconditions .checkArgument (key != null , "Entity must have a key" );
154154 if (key instanceof Key ) {
155155 putInternal (Entity .convert ((FullEntity <Key >) entity ));
@@ -165,7 +165,7 @@ public final List<Entity> put(FullEntity<?>... entities) {
165165 validateActive ();
166166 List <IncompleteKey > incompleteKeys = Lists .newArrayListWithExpectedSize (entities .length );
167167 for (FullEntity <?> entity : entities ) {
168- IncompleteKey key = entity .key ();
168+ IncompleteKey key = entity .getKey ();
169169 Preconditions .checkArgument (key != null , "Entity must have a key" );
170170 if (!(key instanceof Key )) {
171171 incompleteKeys .add (key );
@@ -174,17 +174,17 @@ public final List<Entity> put(FullEntity<?>... entities) {
174174 Iterator <Key > allocated ;
175175 if (!incompleteKeys .isEmpty ()) {
176176 IncompleteKey [] toAllocate = Iterables .toArray (incompleteKeys , IncompleteKey .class );
177- allocated = datastore ().allocateId (toAllocate ).iterator ();
177+ allocated = getDatastore ().allocateId (toAllocate ).iterator ();
178178 } else {
179179 allocated = Collections .emptyIterator ();
180180 }
181181 List <Entity > answer = Lists .newArrayListWithExpectedSize (entities .length );
182182 for (FullEntity <?> entity : entities ) {
183- if (entity .key () instanceof Key ) {
183+ if (entity .getKey () instanceof Key ) {
184184 putInternal ((FullEntity <Key >) entity );
185185 answer .add (Entity .convert ((FullEntity <Key >) entity ));
186186 } else {
187- Entity entityWithAllocatedId = Entity .builder (allocated .next (), entity ).build ();
187+ Entity entityWithAllocatedId = Entity .newBuilder (allocated .next (), entity ).build ();
188188 putInternal (entityWithAllocatedId );
189189 answer .add (entityWithAllocatedId );
190190 }
@@ -204,11 +204,17 @@ public final void delete(Key... keys) {
204204 }
205205
206206 @ Override
207+ @ Deprecated
207208 public boolean active () {
209+ return isActive ();
210+ }
211+
212+ @ Override
213+ public boolean isActive () {
208214 return active ;
209215 }
210216
211- protected String name () {
217+ protected String getName () {
212218 return name ;
213219 }
214220
@@ -270,5 +276,8 @@ protected List<com.google.datastore.v1.Mutation> toMutationPbList() {
270276 return mutationsPb ;
271277 }
272278
279+ @ Deprecated
273280 protected abstract Datastore datastore ();
281+
282+ protected abstract Datastore getDatastore ();
274283}
0 commit comments