Skip to content

Commit 8f0624d

Browse files
committed
---
yaml --- r: 39 b: refs/heads/master c: 5a2398b h: refs/heads/master i: 37: 6a9fb21 35: cc08ab5 31: c5787e1 v: v3
1 parent 8ccff4a commit 8f0624d

7 files changed

Lines changed: 32 additions & 39 deletions

File tree

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: e9f8f4918cfa7ff3ab7800a9fee47c9397d697c0
2+
refs/heads/master: 5a2398b0e7519a38375d8fefd4171498167a741d

trunk/.classpath

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,5 @@
2323
</attributes>
2424
</classpathentry>
2525
<classpathentry kind="var" path="ECLIPSE_HOME"/>
26-
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
27-
<attributes>
28-
<attribute name="maven.pomderived" value="true"/>
29-
</attributes>
30-
</classpathentry>
31-
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
32-
<attributes>
33-
<attribute name="maven.pomderived" value="true"/>
34-
</attributes>
35-
</classpathentry>
3626
<classpathentry kind="output" path="target/classes"/>
3727
</classpath>

trunk/src/main/java/com/google/gcloud/datastore/DateAndTime.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
import java.util.Date;
99

1010
/**
11-
* A Google Cloud Datastore timestamp.
12-
* A Datastore timestamp is represented in micro-seconds.
11+
* A Google Cloud Datastore timestamp (represented in micro-seconds).
1312
* This class is immutable.
1413
*
1514
* @see <a href="https://cloud.google.com/datastore/docs/concepts/entities">Google Cloud Datastore Entities, Properties, and Keys</a>

trunk/src/main/java/com/google/gcloud/datastore/Key.java

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
/**
1515
* A key that is guaranteed to be complete and could be used to reference a
1616
* Google Cloud Datastore {@link Entity}.
17-
* This class is immutable.
17+
* This class is immutable. To edit (a copy) use {@link #builder()}.
1818
*
1919
* @see <a href="https://cloud.google.com/datastore/docs/concepts/entities">Google Cloud Datastore Entities, Properties, and Keys</a>
2020
*/
@@ -47,15 +47,6 @@ public Builder(Key parent, String kind, long id) {
4747
this.id = id;
4848
}
4949

50-
public Builder(Key from) {
51-
super(from);
52-
if (from.hasId()) {
53-
id = from.id();
54-
} else {
55-
name = from.name();
56-
}
57-
}
58-
5950
@Override
6051
public Builder addAncestor(String kind, long id) {
6152
super.addAncestor(kind, id);
@@ -131,6 +122,13 @@ private Key(PartialKey key, long id) {
131122
super(key.dataset(), key.namespace(), newPath(key, id));
132123
}
133124

125+
@Override
126+
public Builder builder() {
127+
Builder builder =
128+
hasId() ? new Builder(dataset(), kind(), id()) : new Builder(dataset(), kind(), name());
129+
return builder.namespace(namespace()).addAncestors(ancestors());
130+
}
131+
134132
public boolean hasId() {
135133
return id() != null;
136134
}

trunk/src/main/java/com/google/gcloud/datastore/ListValue.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,20 @@
1010
import java.util.List;
1111

1212
public final class ListValue extends
13-
Value<List<Value<?, ?, ?>>, ListValue, ListValue.Builder> {
13+
Value<List<? extends Value<?, ?, ?>>, ListValue, ListValue.Builder> {
1414

1515
private static final long serialVersionUID = -5461475706792576395L;
1616

17-
static final BaseMarshaller<List<Value<?, ?, ?>>, ListValue, Builder> MARSHALLER =
18-
new BaseMarshaller<List<Value<?, ?, ?>>, ListValue, Builder>() {
17+
static final BaseMarshaller<List<? extends Value<?, ?, ?>>, ListValue, Builder> MARSHALLER =
18+
new BaseMarshaller<List<? extends Value<?, ?, ?>>, ListValue, Builder>() {
1919

2020
@Override
2121
public int getProtoFieldId() {
2222
return LIST_VALUE_FIELD_NUMBER;
2323
}
2424

2525
@Override
26-
public Builder newBuilder(List<Value<?, ?, ?>> values) {
26+
public Builder newBuilder(List<? extends Value<?, ?, ?>> values) {
2727
return new Builder().set(values);
2828
}
2929

@@ -45,7 +45,7 @@ protected void setValue(ListValue from, DatastoreV1.Value.Builder to) {
4545
};
4646

4747
public static final class Builder extends
48-
Value.BaseBuilder<List<Value<?, ?, ?>>, ListValue, Builder> {
48+
Value.BaseBuilder<List<? extends Value<?, ?, ?>>, ListValue, Builder> {
4949

5050
private ImmutableList.Builder<Value<?, ?, ?>> listBuilder = ImmutableList.builder();
5151

@@ -74,7 +74,7 @@ public Builder addValue(Value<?, ?, ?> first, Value<?, ?, ?>... other) {
7474
* @see com.google.gcloud.datastore.Value.BaseBuilder#set(java.lang.Object)
7575
*/
7676
@Override
77-
public Builder set(List<Value<?, ?, ?>> properties) {
77+
public Builder set(List<? extends Value<?, ?, ?>> properties) {
7878
listBuilder = ImmutableList.<Value<?, ?, ?>>builder();
7979
for (Value<?, ?, ?> property : properties) {
8080
addValue(property);
@@ -83,7 +83,7 @@ public Builder set(List<Value<?, ?, ?>> properties) {
8383
}
8484

8585
@Override
86-
public List<Value<?, ?, ?>> get() {
86+
public List<? extends Value<?, ?, ?>> get() {
8787
return listBuilder.build();
8888
}
8989

@@ -94,7 +94,7 @@ public ListValue build() {
9494
}
9595
}
9696

97-
public ListValue(List<Value<?, ?, ?>> properties) {
97+
public ListValue(List<? extends Value<?, ?, ?>> properties) {
9898
this(new Builder().set(properties));
9999
}
100100

trunk/src/main/java/com/google/gcloud/datastore/PartialKey.java

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
/**
1919
* A partial key (without a name or id).
2020
* Could be used as metadata for {@link PartialEntity}.
21-
* This class is immutable.
21+
* This class is immutable. To edit (a copy) use {@link #builder()}.
2222
*/
2323
public class PartialKey extends Serializable<DatastoreV1.Key> {
2424

@@ -142,13 +142,6 @@ public Builder(Key parent, String kind) {
142142
this.kind = kind;
143143
}
144144

145-
public Builder(PartialKey from) {
146-
dataset = from.dataset();
147-
namespace = from.namespace();
148-
kind = from.kind();
149-
ancestors.addAll(from.ancestors());
150-
}
151-
152145
public Builder addAncestor(String kind, long id) {
153146
checkArgument(id != 0, "id must not be equal to zero");
154147
return addAncestor(new Ancestor(kind, id));
@@ -245,6 +238,10 @@ public String kind() {
245238
return getLeaf().kind();
246239
}
247240

241+
public Builder builder() {
242+
return new Builder(dataset(), kind()).namespace(namespace()).addAncestors(ancestors());
243+
}
244+
248245
public Key newKey(String name) {
249246
return new Key.Builder(dataset(), kind(), name)
250247
.namespace(namespace())

trunk/src/test/java/com/google/gcloud/datastore/DatastoreServiceTest.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import org.junit.Before;
1212
import org.junit.Test;
1313

14+
import java.util.Collections;
1415
import java.util.HashMap;
1516
import java.util.Iterator;
1617
import java.util.Map;
@@ -29,14 +30,22 @@ public class DatastoreServiceTest {
2930
private static final Key KEY1 = PARTIAL_KEY1.newKey("name");
3031
private static final Key KEY2 = new Key.Builder(KEY1, KIND2, 1).build();
3132
private static final Key KEY3 = KEY2.builder().name("bla").build();
33+
private static final KeyValue KEY_VALUE = new KeyValue(KEY1);
34+
private static final ListValue LIST_VALUE1 = new ListValue.Builder()
35+
.addValue(NULL_VALUE)
36+
.addValue(STR_VALUE, BOOL_VALUE)
37+
.build();
38+
private static final ListValue LIST_VALUE2 = new ListValue(Collections.singletonList(KEY_VALUE));
3239
private static final PartialEntity PARTIAL_ENTITY1 = new PartialEntity.Builder(PARTIAL_KEY2)
3340
.setProperty("str", STR_VALUE)
3441
.setProperty("bool", BOOL_VALUE)
42+
.setProperty("list", LIST_VALUE1)
3543
.build();
3644
private static final Entity ENTITY1 = new Entity.Builder(KEY1)
3745
.setProperty("str", STR_VALUE)
3846
.setProperty("bool", BOOL_VALUE)
3947
.setProperty("partial1", new PartialEntityValue(PARTIAL_ENTITY1))
48+
.setProperty("list", LIST_VALUE2)
4049
.build();
4150
private static final Entity ENTITY2 = new Entity.Builder(KEY2, ENTITY1)
4251
.removeProperty("str")

0 commit comments

Comments
 (0)