Skip to content

Commit 221448b

Browse files
committed
rename property to value
1 parent 4a74348 commit 221448b

14 files changed

Lines changed: 229 additions & 219 deletions

File tree

.classpath

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,17 @@
2121
<attributes>
2222
<attribute name="maven.pomderived" value="true"/>
2323
</attributes>
24-
<accessrules>
25-
<accessrule kind="nonaccessible" pattern="**/repackaged/**"/>
26-
<accessrule kind="nonaccessible" pattern="com/google/api/client/util/**"/>
27-
</accessrules>
2824
</classpathentry>
2925
<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>
3036
<classpathentry kind="output" path="target/classes"/>
3137
</classpath>

.project

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
</arguments>
1717
</buildCommand>
1818
<buildCommand>
19-
<name>org.eclipse.m2e.core.maven2Builder</name>
19+
<name>edu.umd.cs.findbugs.plugin.eclipse.findbugsBuilder</name>
2020
<arguments>
2121
</arguments>
2222
</buildCommand>
@@ -26,7 +26,7 @@
2626
</arguments>
2727
</buildCommand>
2828
<buildCommand>
29-
<name>edu.umd.cs.findbugs.plugin.eclipse.findbugsBuilder</name>
29+
<name>org.eclipse.m2e.core.maven2Builder</name>
3030
<arguments>
3131
</arguments>
3232
</buildCommand>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
eclipse.preferences.version=1
2+
encoding//src/main/java=UTF-8
3+
encoding//src/test/java=UTF-8

.settings/org.eclipse.jdt.core.prefs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,7 @@
22
<<<<<<<=HEAD
33
>>>>>>>=ef72daa81c73f99e2156f5bfe8127591fc6358e9
44
eclipse.preferences.version=1
5+
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
6+
org.eclipse.jdt.core.compiler.compliance=1.7
7+
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
8+
org.eclipse.jdt.core.compiler.source=1.7

src/main/java/com/google/gcloud/datastore/EmbeddedEntity.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ public final class EmbeddedEntity implements Serializable {
1818
private static final long serialVersionUID = 6492561268709192891L;
1919

2020
private final transient IncompleteKey key;
21-
private final transient ImmutableSortedMap<String, Property<?, ?, ?>> properties;
21+
private final transient ImmutableSortedMap<String, Value<?, ?, ?>> properties;
2222
private transient DatastoreV1.Entity tempEntityPb; // only for deserialization
2323

2424
public static final class Builder {
2525

2626
private IncompleteKey key;
27-
private Map<String, Property<?, ?, ?>> properties = new HashMap<>();
27+
private Map<String, Value<?, ?, ?>> properties = new HashMap<>();
2828

2929
public Builder() {
3030
}
@@ -54,8 +54,8 @@ public Builder removeProperty(String name) {
5454
return this;
5555
}
5656

57-
public Builder setProperty(String name, Property<?, ?, ?> property) {
58-
properties.put(name, property);
57+
public Builder setProperty(String name, Value<?, ?, ?> value) {
58+
properties.put(name, value);
5959
return this;
6060
}
6161

@@ -85,7 +85,7 @@ public boolean hasProperty(String name) {
8585
return properties.containsKey(name);
8686
}
8787

88-
public Property<?, ?, ?> getProperty(String name) {
88+
public Value<?, ?, ?> getProperty(String name) {
8989
return properties.get(name);
9090
}
9191

@@ -119,7 +119,7 @@ static EmbeddedEntity fromPb(DatastoreV1.Entity entityPb) {
119119
builder.setKey(IncompleteKey.fromPb(entityPb.getKey()));
120120
}
121121
for (DatastoreV1.Property property : entityPb.getPropertyList()) {
122-
builder.setProperty(property.getName(), Property.fromPb(property.getValue()));
122+
builder.setProperty(property.getName(), Value.fromPb(property.getValue()));
123123
}
124124
return builder.build();
125125
}
@@ -129,7 +129,7 @@ DatastoreV1.Entity toPb() {
129129
if (key != null) {
130130
entityPb.setKey(key.toPb());
131131
}
132-
for (Map.Entry<String, Property<?, ?, ?>> entry : properties.entrySet()) {
132+
for (Map.Entry<String, Value<?, ?, ?>> entry : properties.entrySet()) {
133133
DatastoreV1.Property.Builder propertyPb = DatastoreV1.Property.newBuilder();
134134
propertyPb.setName(entry.getKey());
135135
propertyPb.setValue(entry.getValue().toPb());

src/main/java/com/google/gcloud/datastore/EmbeddedEntityProperty.java renamed to src/main/java/com/google/gcloud/datastore/EmbeddedEntityValue.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44

55
import com.google.api.services.datastore.DatastoreV1;
66

7-
public final class EmbeddedEntityProperty extends
8-
Property<EmbeddedEntity, EmbeddedEntityProperty, EmbeddedEntityProperty.Builder> {
7+
public final class EmbeddedEntityValue extends
8+
Value<EmbeddedEntity, EmbeddedEntityValue, EmbeddedEntityValue.Builder> {
99

1010
private static final long serialVersionUID = -5461475706792576395L;
1111

12-
static final BaseMarshaller<EmbeddedEntity, EmbeddedEntityProperty, Builder> MARSHALLER =
13-
new BaseMarshaller<EmbeddedEntity, EmbeddedEntityProperty, Builder>() {
12+
static final BaseMarshaller<EmbeddedEntity, EmbeddedEntityValue, Builder> MARSHALLER =
13+
new BaseMarshaller<EmbeddedEntity, EmbeddedEntityValue, Builder>() {
1414

1515
@Override
1616
public int getProtoFieldId() {
@@ -28,13 +28,13 @@ protected EmbeddedEntity getValue(DatastoreV1.Value from) {
2828
}
2929

3030
@Override
31-
protected void setValue(EmbeddedEntityProperty from, DatastoreV1.Value.Builder to) {
31+
protected void setValue(EmbeddedEntityValue from, DatastoreV1.Value.Builder to) {
3232
to.setEntityValue(from.get().toPb());
3333
}
3434
};
3535

3636
public static final class Builder extends
37-
Property.BaseBuilder<EmbeddedEntity, EmbeddedEntityProperty, Builder> {
37+
Value.BaseBuilder<EmbeddedEntity, EmbeddedEntityValue, Builder> {
3838

3939
public Builder(EmbeddedEntity entity) {
4040
super(Type.EMBEDDED_ENTITY);
@@ -43,16 +43,16 @@ public Builder(EmbeddedEntity entity) {
4343
}
4444

4545
@Override
46-
public EmbeddedEntityProperty build() {
47-
return new EmbeddedEntityProperty(this);
46+
public EmbeddedEntityValue build() {
47+
return new EmbeddedEntityValue(this);
4848
}
4949
}
5050

51-
public EmbeddedEntityProperty(EmbeddedEntity entity) {
51+
public EmbeddedEntityValue(EmbeddedEntity entity) {
5252
this(new Builder(entity));
5353
}
5454

55-
EmbeddedEntityProperty(Builder builder) {
55+
EmbeddedEntityValue(Builder builder) {
5656
super(builder);
5757
}
5858
}

src/main/java/com/google/gcloud/datastore/Entity.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ public final class Entity implements Serializable {
2121
private static final long serialVersionUID = 432961565733066915L;
2222

2323
private final transient Key key;
24-
private final transient ImmutableSortedMap<String, Property<?, ?, ?>> properties;
24+
private final transient ImmutableSortedMap<String, Value<?, ?, ?>> properties;
2525
private transient DatastoreV1.Entity tempEntityPb; // only for deserialization
2626

2727
public static final class Builder {
2828

2929
private Key key;
30-
private Map<String, Property<?, ?, ?>> properties;
30+
private Map<String, Value<?, ?, ?>> properties;
3131

3232
public Builder(Key key) {
3333
this.key = checkNotNull(key);
@@ -49,8 +49,8 @@ public Builder removeProperty(String name) {
4949
return this;
5050
}
5151

52-
public Builder setProperty(String name, Property<?, ?, ?> property) {
53-
properties.put(name, property);
52+
public Builder setProperty(String name, Value<?, ?, ?> value) {
53+
properties.put(name, value);
5454
return this;
5555
}
5656

@@ -72,15 +72,15 @@ public boolean hasProperty(String name) {
7272
return properties.containsKey(name);
7373
}
7474

75-
public Property<?, ?, ?> getProperty(String name) {
75+
public Value<?, ?, ?> getProperty(String name) {
7676
return properties.get(name);
7777
}
7878

7979
public Set<String> getPropertyNames() {
8080
return properties.keySet();
8181
}
8282

83-
ImmutableSortedMap<String, Property<?, ?, ?>> getProperties() {
83+
ImmutableSortedMap<String, Value<?, ?, ?>> getProperties() {
8484
return properties;
8585
}
8686

@@ -108,15 +108,15 @@ static Entity fromPb(DatastoreV1.Entity entityPb) {
108108
Preconditions.checkArgument(entityPb.hasKey());
109109
Builder builder = new Builder(Key.fromPb(entityPb.getKey()));
110110
for (DatastoreV1.Property property : entityPb.getPropertyList()) {
111-
builder.setProperty(property.getName(), Property.fromPb(property.getValue()));
111+
builder.setProperty(property.getName(), Value.fromPb(property.getValue()));
112112
}
113113
return builder.build();
114114
}
115115

116116
DatastoreV1.Entity toPb() {
117117
DatastoreV1.Entity.Builder entityPb = DatastoreV1.Entity.newBuilder();
118118
entityPb.setKey(key.toPb());
119-
for (Map.Entry<String, Property<?, ?, ?>> entry : properties.entrySet()) {
119+
for (Map.Entry<String, Value<?, ?, ?>> entry : properties.entrySet()) {
120120
DatastoreV1.Property.Builder propertyPb = DatastoreV1.Property.newBuilder();
121121
propertyPb.setName(entry.getKey());
122122
propertyPb.setValue(entry.getValue().toPb());

src/main/java/com/google/gcloud/datastore/KeyProperty.java renamed to src/main/java/com/google/gcloud/datastore/KeyValue.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44

55
import com.google.api.services.datastore.DatastoreV1;
66

7-
public final class KeyProperty extends Property<Key, KeyProperty, KeyProperty.Builder> {
7+
public final class KeyValue extends Value<Key, KeyValue, KeyValue.Builder> {
88

99
private static final long serialVersionUID = -1318353707326704821L;
1010

11-
static final BaseMarshaller<Key, KeyProperty, Builder> MARSHALLER =
12-
new BaseMarshaller<Key, KeyProperty, Builder>() {
11+
static final BaseMarshaller<Key, KeyValue, Builder> MARSHALLER =
12+
new BaseMarshaller<Key, KeyValue, Builder>() {
1313

1414
@Override
1515
public int getProtoFieldId() {
@@ -27,29 +27,29 @@ protected Key getValue(DatastoreV1.Value from) {
2727
}
2828

2929
@Override
30-
protected void setValue(KeyProperty from, DatastoreV1.Value.Builder to) {
30+
protected void setValue(KeyValue from, DatastoreV1.Value.Builder to) {
3131
to.setKeyValue(from.get().toPb());
3232
}
3333
};
3434

35-
public static final class Builder extends Property.BaseBuilder<Key, KeyProperty, Builder> {
35+
public static final class Builder extends Value.BaseBuilder<Key, KeyValue, Builder> {
3636

3737
public Builder(Key value) {
3838
super(Type.KEY);
3939
set(value);
4040
}
4141

4242
@Override
43-
public KeyProperty build() {
44-
return new KeyProperty(this);
43+
public KeyValue build() {
44+
return new KeyValue(this);
4545
}
4646
}
4747

48-
public KeyProperty(Key key) {
48+
public KeyValue(Key key) {
4949
this(new Builder(key));
5050
}
5151

52-
KeyProperty(Builder builder) {
52+
KeyValue(Builder builder) {
5353
super(builder);
5454
}
5555
}
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
package com.google.gcloud.datastore;
2+
3+
import static com.google.api.services.datastore.DatastoreV1.Value.LIST_VALUE_FIELD_NUMBER;
4+
5+
import com.google.api.services.datastore.DatastoreV1;
6+
import com.google.common.base.Preconditions;
7+
import com.google.common.collect.ImmutableList;
8+
9+
import java.util.ArrayList;
10+
import java.util.List;
11+
12+
public final class ListValue extends
13+
Value<List<Value<?, ?, ?>>, ListValue, ListValue.Builder> {
14+
15+
private static final long serialVersionUID = -5461475706792576395L;
16+
17+
static final BaseMarshaller<List<Value<?, ?, ?>>, ListValue, Builder> MARSHALLER =
18+
new BaseMarshaller<List<Value<?, ?, ?>>, ListValue, Builder>() {
19+
20+
@Override
21+
public int getProtoFieldId() {
22+
return LIST_VALUE_FIELD_NUMBER;
23+
}
24+
25+
@Override
26+
public Builder newBuilder(List<Value<?, ?, ?>> values) {
27+
return new Builder().set(values);
28+
}
29+
30+
@Override
31+
protected List<Value<?, ?, ?>> getValue(DatastoreV1.Value from) {
32+
List<Value<?, ?, ?>> properties = new ArrayList<>(from.getListValueCount());
33+
for (DatastoreV1.Value valuePb : from.getListValueList()) {
34+
properties.add(Value.fromPb(valuePb));
35+
}
36+
return properties;
37+
}
38+
39+
@Override
40+
protected void setValue(ListValue from, DatastoreV1.Value.Builder to) {
41+
for (Value<?, ?, ?> property : from.get()) {
42+
to.addListValue(property.toPb());
43+
}
44+
}
45+
};
46+
47+
public static final class Builder extends
48+
Value.BaseBuilder<List<Value<?, ?, ?>>, ListValue, Builder> {
49+
50+
private ImmutableList.Builder<Value<?, ?, ?>> listBuilder = ImmutableList.builder();
51+
52+
public Builder() {
53+
super(Type.LIST);
54+
indexed(false);
55+
}
56+
57+
public Builder addValue(Value<?, ?, ?> value) {
58+
Preconditions.checkArgument(value.getType() != Type.LIST, "Cannot contain another list");
59+
listBuilder.add(value);
60+
return this;
61+
}
62+
63+
public Builder addValue(Value<?, ?, ?> first, Value<?, ?, ?>... other) {
64+
addValue(first);
65+
for (Value<?, ?, ?> value : other) {
66+
addValue(value);
67+
}
68+
return this;
69+
}
70+
71+
@Override
72+
public Builder set(List<Value<?, ?, ?>> properties) {
73+
listBuilder = ImmutableList.<Value<?, ?, ?>>builder();
74+
for (Value<?, ?, ?> property : properties) {
75+
addValue(property);
76+
}
77+
return this;
78+
}
79+
80+
@Override
81+
public List<Value<?, ?, ?>> get() {
82+
return listBuilder.build();
83+
}
84+
85+
@Override
86+
public ListValue build() {
87+
Preconditions.checkState(!get().isEmpty(), "value list could not be empty");
88+
return new ListValue(this);
89+
}
90+
}
91+
92+
public ListValue(List<Value<?, ?, ?>> properties) {
93+
this(new Builder().set(properties));
94+
}
95+
96+
public ListValue(Value<?, ?, ?> first, Value<?, ?, ?>... other) {
97+
this(new Builder().addValue(first, other));
98+
}
99+
100+
ListValue(Builder builder) {
101+
super(builder);
102+
}
103+
}

0 commit comments

Comments
 (0)