Skip to content

Commit 9782205

Browse files
author
Ajay Kannan
committed
---
yaml --- r: 4523 b: refs/heads/logging-alpha c: 274b9ae h: refs/heads/master i: 4521: 35b42a1 4519: 7ba0474
1 parent cc896c7 commit 9782205

6 files changed

Lines changed: 178 additions & 28 deletions

File tree

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ refs/heads/compute-alpha: 969cba2627f1d53d352cc4a5ffe0879dacf65e6c
1212
refs/heads/dns-alpha: 2f90e7e338349287ace33375896907af0f032ca1
1313
refs/heads/dns-alpha-batch: 17442b07867021b85d0452f5f3eda29a3413288f
1414
refs/heads/gcs-nio: 283aeaf15efdcf3621eb6859f05e55ad7764375d
15-
refs/heads/logging-alpha: c2f8952befa41581dcad9a9bd8951837d9c7d39f
15+
refs/heads/logging-alpha: 274b9ae5dfe0b8fc749dc5e55c38f574f09f8f0b
1616
refs/tags/v0.1.0: a615317f7424ed58621b1f65d5c4d8cbbe8a6ed8
1717
refs/tags/v0.1.1: 7a7f6985fe465e9dd6a075af55493f42b4933be0
1818
refs/tags/v0.1.2: 3eb3fe866ba22487686048f45d927b8c8638ea3f

branches/logging-alpha/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/BaseEntity.java

Lines changed: 139 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,16 +129,36 @@ public B remove(String name) {
129129
return self();
130130
}
131131

132+
/**
133+
* Sets a property.
134+
*
135+
* @param name name of the property
136+
* @param value value associated with the property
137+
*/
132138
public B set(String name, Value<?> value) {
133139
properties.put(name, value);
134140
return self();
135141
}
136142

143+
/**
144+
* Sets a property of type {@link StringValue}.
145+
*
146+
* @param name name of the property
147+
* @param value value associated with the property
148+
*/
137149
public B set(String name, String value) {
138150
properties.put(name, of(value));
139151
return self();
140152
}
141153

154+
/**
155+
* Sets a list property containing elements of type {@link StringValue}.
156+
*
157+
* @param name name of the property
158+
* @param first the first string in the list
159+
* @param second the second string in the list
160+
* @param others other strings in the list
161+
*/
142162
public B set(String name, String first, String second, String... others) {
143163
List<StringValue> values = new LinkedList<>();
144164
values.add(of(first));
@@ -150,11 +170,25 @@ public B set(String name, String first, String second, String... others) {
150170
return self();
151171
}
152172

173+
/**
174+
* Sets a property of type {@link LongValue}.
175+
*
176+
* @param name name of the property
177+
* @param value value associated with the property
178+
*/
153179
public B set(String name, long value) {
154180
properties.put(name, of(value));
155181
return self();
156182
}
157183

184+
/**
185+
* Sets a list property containing elements of type {@link LongValue}.
186+
*
187+
* @param name name of the property
188+
* @param first the first long in the list
189+
* @param second the second long in the list
190+
* @param others other longs in the list
191+
*/
158192
public B set(String name, long first, long second, long... others) {
159193
List<LongValue> values = new LinkedList<>();
160194
values.add(of(first));
@@ -166,11 +200,25 @@ public B set(String name, long first, long second, long... others) {
166200
return self();
167201
}
168202

203+
/**
204+
* Sets a property of type {@link DoubleValue}.
205+
*
206+
* @param name name of the property
207+
* @param value value associated with the property
208+
*/
169209
public B set(String name, double value) {
170210
properties.put(name, of(value));
171211
return self();
172212
}
173213

214+
/**
215+
* Sets a list property containing elements of type {@link DoubleValue}.
216+
*
217+
* @param name name of the property
218+
* @param first the first double in the list
219+
* @param second the second double in the list
220+
* @param others other doubles in the list
221+
*/
174222
public B set(String name, double first, double second, double... others) {
175223
List<DoubleValue> values = new LinkedList<>();
176224
values.add(of(first));
@@ -182,11 +230,25 @@ public B set(String name, double first, double second, double... others) {
182230
return self();
183231
}
184232

233+
/**
234+
* Sets a property of type {@link BooleanValue}.
235+
*
236+
* @param name name of the property
237+
* @param value value associated with the property
238+
*/
185239
public B set(String name, boolean value) {
186240
properties.put(name, of(value));
187241
return self();
188242
}
189243

244+
/**
245+
* Sets a list property containing elements of type {@link BooleanValue}.
246+
*
247+
* @param name name of the property
248+
* @param first the first boolean in the list
249+
* @param second the second boolean in the list
250+
* @param others other booleans in the list
251+
*/
190252
public B set(String name, boolean first, boolean second, boolean... others) {
191253
List<BooleanValue> values = new LinkedList<>();
192254
values.add(of(first));
@@ -198,11 +260,25 @@ public B set(String name, boolean first, boolean second, boolean... others) {
198260
return self();
199261
}
200262

263+
/**
264+
* Sets a property of type {@link DateTimeValue}.
265+
*
266+
* @param name name of the property
267+
* @param value value associated with the property
268+
*/
201269
public B set(String name, DateTime value) {
202270
properties.put(name, of(value));
203271
return self();
204272
}
205273

274+
/**
275+
* Sets a list property containing elements of type {@link DateTimeValue}.
276+
*
277+
* @param name name of the property
278+
* @param first the first {@link DateTime} in the list
279+
* @param second the second {@link DateTime} in the list
280+
* @param others other {@link DateTime}s in the list
281+
*/
206282
public B set(String name, DateTime first, DateTime second, DateTime... others) {
207283
List<DateTimeValue> values = new LinkedList<>();
208284
values.add(of(first));
@@ -214,11 +290,25 @@ public B set(String name, DateTime first, DateTime second, DateTime... others) {
214290
return self();
215291
}
216292

293+
/**
294+
* Sets a property of type {@link KeyValue}.
295+
*
296+
* @param name name of the property
297+
* @param value value associated with the property
298+
*/
217299
public B set(String name, Key value) {
218300
properties.put(name, of(value));
219301
return self();
220302
}
221303

304+
/**
305+
* Sets a list property containing elements of type {@link KeyValue}.
306+
*
307+
* @param name name of the property
308+
* @param first the first {@link Key} in the list
309+
* @param second the second {@link Key} in the list
310+
* @param others other {@link Key}s in the list
311+
*/
222312
public B set(String name, Key first, Key second, Key... others) {
223313
List<KeyValue> values = new LinkedList<>();
224314
values.add(of(first));
@@ -230,11 +320,25 @@ public B set(String name, Key first, Key second, Key... others) {
230320
return self();
231321
}
232322

323+
/**
324+
* Sets a property of type {@link EntityValue}.
325+
*
326+
* @param name name of the property
327+
* @param value value associated with the property
328+
*/
233329
public B set(String name, FullEntity<?> value) {
234330
properties.put(name, of(value));
235331
return self();
236332
}
237333

334+
/**
335+
* Sets a list property containing elements of type {@link EntityValue}.
336+
*
337+
* @param name name of the property
338+
* @param first the first {@link FullEntity} in the list
339+
* @param second the second {@link FullEntity} in the list
340+
* @param others other entities in the list
341+
*/
238342
public B set(String name, FullEntity<?> first, FullEntity<?> second, FullEntity<?>... others) {
239343
List<EntityValue> values = new LinkedList<>();
240344
values.add(of(first));
@@ -246,21 +350,49 @@ public B set(String name, FullEntity<?> first, FullEntity<?> second, FullEntity<
246350
return self();
247351
}
248352

353+
/**
354+
* Sets a property of type {@link ListValue}.
355+
*
356+
* @param name name of the property
357+
* @param values list of values associated with the property
358+
*/
249359
public B set(String name, List<? extends Value<?>> values) {
250360
properties.put(name, of(values));
251361
return self();
252362
}
253363

254-
public B set(String name, Value<?> first, Value<?> second, Value<?>... other) {
255-
properties.put(name, of(first, second, other));
364+
/**
365+
* Sets a property of type {@link ListValue}.
366+
*
367+
* @param name name of the property
368+
* @param first the first value in the list
369+
* @param second the second value in the list
370+
* @param others other values in the list
371+
*/
372+
public B set(String name, Value<?> first, Value<?> second, Value<?>... others) {
373+
properties.put(name, of(first, second, others));
256374
return self();
257375
}
258376

377+
/**
378+
* Sets a property of type {@link BlobValue}.
379+
*
380+
* @param name name of the property
381+
* @param value value associated with the property
382+
*/
259383
public B set(String name, Blob value) {
260384
properties.put(name, of(value));
261385
return self();
262386
}
263387

388+
/**
389+
* Sets a list property containing elements of type {@link BlobValue}.
390+
*
391+
* @param name name of the property
392+
* @param first the first {@link Blob} in the list
393+
* @param second the second {@link Blob} in the list
394+
* @param others other {@link Blob}s in the list
395+
*/
264396
public B set(String name, Blob first, Blob second, Blob... others) {
265397
List<BlobValue> values = new LinkedList<>();
266398
values.add(of(first));
@@ -272,6 +404,11 @@ public B set(String name, Blob first, Blob second, Blob... others) {
272404
return self();
273405
}
274406

407+
/**
408+
* Sets a property of type {@code NullValue}.
409+
*
410+
* @param name name of the property
411+
*/
275412
public B setNull(String name) {
276413
properties.put(name, of());
277414
return self();

branches/logging-alpha/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/IncompleteKey.java

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -90,17 +90,21 @@ static IncompleteKey fromPb(DatastoreV1.Key keyPb) {
9090
@Override
9191
public Key parent() {
9292
List<PathElement> ancestors = ancestors();
93-
if (!ancestors.isEmpty()) {
94-
PathElement parent = ancestors.get(ancestors.size() - 1);
95-
Key.Builder keyBuilder;
96-
if (parent.hasName()) {
97-
keyBuilder = Key.builder(projectId(), parent.kind(), parent.name());
98-
} else {
99-
keyBuilder = Key.builder(projectId(), parent.kind(), parent.id());
100-
}
101-
return keyBuilder.ancestors(ancestors.subList(0, ancestors.size() - 1)).build();
93+
if (ancestors.isEmpty()) {
94+
return null;
95+
}
96+
PathElement parent = ancestors.get(ancestors.size() - 1);
97+
Key.Builder keyBuilder;
98+
if (parent.hasName()) {
99+
keyBuilder = Key.builder(projectId(), parent.kind(), parent.name());
100+
} else {
101+
keyBuilder = Key.builder(projectId(), parent.kind(), parent.id());
102+
}
103+
String namespace = namespace();
104+
if (namespace != null) {
105+
keyBuilder.namespace(namespace);
102106
}
103-
return null;
107+
return keyBuilder.ancestors(ancestors.subList(0, ancestors.size() - 1)).build();
104108
}
105109

106110
public static Builder builder(String projectId, String kind) {

branches/logging-alpha/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/ListValue.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,8 @@ public Builder addValue(Value<?> value) {
7777
return this;
7878
}
7979

80-
public Builder addValue(Value<?> first, Value<?> second, Value<?>... other) {
80+
public Builder addValue(Value<?> first, Value<?>... other) {
8181
addValue(first);
82-
addValue(second);
8382
for (Value<?> value : other) {
8483
addValue(value);
8584
}
@@ -122,8 +121,12 @@ public ListValue(List<? extends Value<?>> values) {
122121
this(builder().set(values));
123122
}
124123

125-
public ListValue(Value<?> first, Value<?> second, Value<?>... other) {
126-
this(new Builder().addValue(first, second, other));
124+
public ListValue(Value<?> first, Value<?>... other) {
125+
this(new Builder().addValue(first, other));
126+
}
127+
128+
ListValue(Value<?> first, Value<?> second, Value<?>... other) {
129+
this(new Builder().addValue(first).addValue(second, other));
127130
}
128131

129132
private ListValue(Builder builder) {
@@ -139,7 +142,11 @@ public static ListValue of(List<? extends Value<?>> values) {
139142
return new ListValue(values);
140143
}
141144

142-
public static ListValue of(Value<?> first, Value<?> second, Value<?>... other) {
145+
public static ListValue of(Value<?> first, Value<?>... other) {
146+
return new ListValue(first, other);
147+
}
148+
149+
static ListValue of(Value<?> first, Value<?> second, Value<?>... other) {
143150
return new ListValue(first, second, other);
144151
}
145152

branches/logging-alpha/gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/testing/LocalGcdHelper.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -600,12 +600,11 @@ public static void main(String... args) throws IOException, InterruptedException
600600
String action = parsedArgs.get("action");
601601
int port =
602602
(parsedArgs.get("port") == null) ? DEFAULT_PORT : Integer.parseInt(parsedArgs.get("port"));
603-
double consistency =
604-
parsedArgs.get("consistency") == null
605-
? DEFAULT_CONSISTENCY : Double.parseDouble(parsedArgs.get("consistency"));
606603
switch (action) {
607604
case "START":
608605
if (!isActive(DEFAULT_PROJECT_ID, port)) {
606+
double consistency = parsedArgs.get("consistency") == null
607+
? DEFAULT_CONSISTENCY : Double.parseDouble(parsedArgs.get("consistency"));
609608
LocalGcdHelper helper = start(DEFAULT_PROJECT_ID, port, consistency);
610609
try (FileWriter writer = new FileWriter(".local_gcd_helper")) {
611610
writer.write(helper.gcdPath.toAbsolutePath().toString() + System.lineSeparator());

branches/logging-alpha/gcloud-java-datastore/src/test/java/com/google/gcloud/datastore/IncompleteKeyTest.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@
2525

2626
public class IncompleteKeyTest {
2727

28-
private static IncompleteKey pk1, pk2;
29-
private static Key parent;
28+
private static IncompleteKey pk1, pk2;
29+
private static Key parent1;
3030

3131
@Before
3232
public void setUp() {
3333
pk1 = IncompleteKey.builder("ds", "kind1").build();
34-
parent = Key.builder("ds", "kind2", 10).build();
35-
pk2 = IncompleteKey.builder(parent, "kind3").build();
34+
parent1 = Key.builder("ds", "kind2", 10).namespace("ns").build();
35+
pk2 = IncompleteKey.builder(parent1, "kind3").build();
3636
}
3737

3838
@Test
@@ -43,18 +43,21 @@ public void testBuilders() throws Exception {
4343

4444
assertEquals("ds", pk2.projectId());
4545
assertEquals("kind3", pk2.kind());
46-
assertEquals(parent.path(), pk2.ancestors());
46+
assertEquals(parent1.path(), pk2.ancestors());
4747

4848
assertEquals(pk2, IncompleteKey.builder(pk2).build());
4949
IncompleteKey pk3 = IncompleteKey.builder(pk2).kind("kind4").build();
5050
assertEquals("ds", pk3.projectId());
5151
assertEquals("kind4", pk3.kind());
52-
assertEquals(parent.path(), pk3.ancestors());
52+
assertEquals(parent1.path(), pk3.ancestors());
5353
}
5454

5555
@Test
5656
public void testParent() {
5757
assertNull(pk1.parent());
58-
assertEquals(parent, pk2.parent());
58+
assertEquals(parent1, pk2.parent());
59+
Key parent2 = Key.builder("ds", "kind3", "name").namespace("ns").build();
60+
IncompleteKey pk3 = IncompleteKey.builder(parent2, "kind3").build();
61+
assertEquals(parent2, pk3.parent());
5962
}
6063
}

0 commit comments

Comments
 (0)