1010/**
1111 * Adds some functionality to DatastoreService that should
1212 * be provided statically to the interface (Java 8).
13- *
1413 */
1514public class DatastoreHelper implements DatastoreService {
1615
@@ -26,8 +25,8 @@ public Entity get(Key key) {
2625 }
2726
2827 @ Override
29- public Iterator <Entity > get (Key key , Key ... others ) {
30- return delegate .get (key , others );
28+ public Iterator <Entity > get (Key ... key ) {
29+ return delegate .get (key );
3130 }
3231
3332 @ Override
@@ -56,8 +55,18 @@ public Key allocateId(PartialKey key) {
5655 }
5756
5857 @ Override
59- public Iterator <Key > allocateId (PartialKey key , PartialKey ... others ) {
60- return delegate .allocateId (key , others );
58+ public List <Key > allocateId (PartialKey ... key ) {
59+ return delegate .allocateId (key );
60+ }
61+
62+ @ Override
63+ public Entity add (PartialEntity entity ) {
64+ return delegate .add (entity );
65+ }
66+
67+ @ Override
68+ public List <Entity > add (PartialEntity ... entity ) {
69+ return delegate .add (entity );
6170 }
6271
6372 @ Override
@@ -91,17 +100,17 @@ public KeyFactory newKeyFactory() {
91100 * Returns a list with a value for each given key (ordered by input).
92101 * A {@code null} would be returned for non-existing keys.
93102 */
94- public List <Entity > fetch (Key key , Key ... others ) {
95- Iterator <Entity > entities = delegate .get (key , others );
96- Map <Key , Entity > map = Maps .newHashMapWithExpectedSize (1 + others .length );
103+ public List <Entity > fetch (Key ... keys ) {
104+ Iterator <Entity > entities = delegate .get (keys );
105+ Map <Key , Entity > map = Maps .newHashMapWithExpectedSize (keys .length );
97106 while (entities .hasNext ()) {
98107 Entity entity = entities .next ();
99108 map .put (entity .key (), entity );
100109 }
101- List <Entity > list = new ArrayList <>(1 + others .length );
102- list . add ( map . get ( key ));
103- for ( Key other : others ) {
104- list .add (map .get (other ));
110+ List <Entity > list = new ArrayList <>(keys .length );
111+ for ( Key key : keys ) {
112+ // this will include nulls for non-existing keys
113+ list .add (map .get (key ));
105114 }
106115 return list ;
107116 }
0 commit comments