Skip to content

Commit 8cfb312

Browse files
authored
Run google-java-format on all artifacts (#4121)
* Run google-java-format on all artifats * Format some missed files * Add more missed files * Fix formatting issues from the merge
1 parent 2cdb258 commit 8cfb312

File tree

157 files changed

+12635
-9398
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

157 files changed

+12635
-9398
lines changed

google-cloud-datastore/src/main/java/com/google/cloud/datastore/BaseDatastoreBatchWriter.java

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import com.google.common.base.Preconditions;
2020
import com.google.common.collect.Iterables;
2121
import com.google.common.collect.Lists;
22-
2322
import java.util.ArrayList;
2423
import java.util.Collections;
2524
import java.util.Iterator;
@@ -30,9 +29,7 @@
3029
import java.util.Map;
3130
import java.util.Set;
3231

33-
/**
34-
* Base class for DatastoreBatchWriter.
35-
*/
32+
/** Base class for DatastoreBatchWriter. */
3633
public abstract class BaseDatastoreBatchWriter implements DatastoreBatchWriter {
3734

3835
private final String name;
@@ -65,8 +62,8 @@ public final void addWithDeferredIdAllocation(FullEntity<?>... entities) {
6562
private void addInternal(FullEntity<Key> entity) {
6663
Key key = entity.getKey();
6764
if (toAdd.containsKey(key) || toUpdate.containsKey(key) || toPut.containsKey(key)) {
68-
throw newInvalidRequest("Entity with the key %s was already added or updated in this %s",
69-
entity.getKey(), name);
65+
throw newInvalidRequest(
66+
"Entity with the key %s was already added or updated in this %s", entity.getKey(), name);
7067
}
7168
if (toDelete.remove(key)) {
7269
toPut.put(key, entity);
@@ -120,8 +117,8 @@ public final void update(Entity... entities) {
120117
for (Entity entity : entities) {
121118
Key key = entity.getKey();
122119
if (toDelete.contains(key)) {
123-
throw newInvalidRequest("Entity with the key %s was already deleted in this %s",
124-
entity.getKey(), name);
120+
throw newInvalidRequest(
121+
"Entity with the key %s was already deleted in this %s", entity.getKey(), name);
125122
}
126123
if (toAdd.remove(key) != null || toPut.containsKey(key)) {
127124
toPut.put(key, entity);
@@ -203,7 +200,6 @@ public final void delete(Key... keys) {
203200
}
204201
}
205202

206-
207203
@Override
208204
public boolean isActive() {
209205
return active;
@@ -271,6 +267,5 @@ protected List<com.google.datastore.v1.Mutation> toMutationPbList() {
271267
return mutationsPb;
272268
}
273269

274-
275270
protected abstract Datastore getDatastore();
276271
}

google-cloud-datastore/src/main/java/com/google/cloud/datastore/BaseEntity.java

Lines changed: 14 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
import static com.google.cloud.datastore.BlobValue.of;
2020
import static com.google.cloud.datastore.BooleanValue.of;
21-
import static com.google.cloud.datastore.TimestampValue.of;
2221
import static com.google.cloud.datastore.DoubleValue.of;
2322
import static com.google.cloud.datastore.EntityValue.of;
2423
import static com.google.cloud.datastore.KeyValue.of;
@@ -27,12 +26,12 @@
2726
import static com.google.cloud.datastore.LongValue.of;
2827
import static com.google.cloud.datastore.NullValue.of;
2928
import static com.google.cloud.datastore.StringValue.of;
29+
import static com.google.cloud.datastore.TimestampValue.of;
3030

3131
import com.google.cloud.Timestamp;
3232
import com.google.common.base.MoreObjects;
3333
import com.google.common.collect.ImmutableSortedMap;
3434
import com.google.common.collect.Maps;
35-
3635
import java.io.Serializable;
3736
import java.util.HashMap;
3837
import java.util.LinkedList;
@@ -42,11 +41,10 @@
4241
import java.util.Set;
4342

4443
/**
45-
* A base class for entities (key and properties).
46-
* An entity is a Google Cloud Datastore persistent data object.
47-
* An entity holds one or more properties, represented by a name (as {@link String})
48-
* and a value (as {@link com.google.cloud.datastore.Value}), and may be associated with a
49-
* key. For a list of possible values see {@link ValueType}.
44+
* A base class for entities (key and properties). An entity is a Google Cloud Datastore persistent
45+
* data object. An entity holds one or more properties, represented by a name (as {@link String})
46+
* and a value (as {@link com.google.cloud.datastore.Value}), and may be associated with a key. For
47+
* a list of possible values see {@link ValueType}.
5048
*
5149
* @see <a href="https://cloud.google.com/datastore/docs/concepts/entities">Google Cloud Datastore
5250
* Entities, Properties, and Keys</a>
@@ -62,8 +60,7 @@ public abstract static class Builder<K extends IncompleteKey, B extends Builder<
6260
private K key;
6361
private final Map<String, Value<?>> properties = new HashMap<>();
6462

65-
Builder() {
66-
}
63+
Builder() {}
6764

6865
Builder(K key) {
6966
setKey(key);
@@ -110,26 +107,19 @@ protected B setProperties(Map<String, Value<?>> properties) {
110107
return self();
111108
}
112109

113-
114-
/**
115-
* Sets the key for the entity.
116-
*/
110+
/** Sets the key for the entity. */
117111
public B setKey(K key) {
118112
this.key = key;
119113
return self();
120114
}
121115

122-
/**
123-
* Clears all the properties.
124-
*/
116+
/** Clears all the properties. */
125117
public B clear() {
126118
properties.clear();
127119
return self();
128120
}
129121

130-
/**
131-
* Removes a property with the given {@code name}.
132-
*/
122+
/** Removes a property with the given {@code name}. */
133123
public B remove(String name) {
134124
properties.remove(name);
135125
return self();
@@ -485,28 +475,20 @@ public boolean equals(Object obj) {
485475
return false;
486476
}
487477
BaseEntity<?> other = (BaseEntity<?>) obj;
488-
return Objects.equals(key, other.key)
489-
&& Objects.equals(properties, other.properties);
478+
return Objects.equals(key, other.key) && Objects.equals(properties, other.properties);
490479
}
491480

492-
/**
493-
* Returns true if entity has a non-null key.
494-
*/
481+
/** Returns true if entity has a non-null key. */
495482
public boolean hasKey() {
496483
return key != null;
497484
}
498485

499-
500-
/**
501-
* Returns the associated key or null if it does not have one.
502-
*/
486+
/** Returns the associated key or null if it does not have one. */
503487
public K getKey() {
504488
return key;
505489
}
506490

507-
/**
508-
* Returns {@code true} if the entity contains a property with the given {@code name}.
509-
*/
491+
/** Returns {@code true} if the entity contains a property with the given {@code name}. */
510492
public boolean contains(String name) {
511493
return properties.containsKey(name);
512494
}
@@ -534,7 +516,6 @@ public boolean isNull(String name) {
534516
return getValue(name) instanceof NullValue;
535517
}
536518

537-
538519
/**
539520
* Returns the property value as a string.
540521
*
@@ -645,10 +626,7 @@ public Blob getBlob(String name) {
645626
return ((Value<Blob>) getValue(name)).get();
646627
}
647628

648-
649-
/**
650-
* Returns the properties name.
651-
*/
629+
/** Returns the properties name. */
652630
public Set<String> getNames() {
653631
return properties.keySet();
654632
}

google-cloud-datastore/src/main/java/com/google/cloud/datastore/BaseKey.java

Lines changed: 14 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,12 @@
2323
import com.google.common.base.MoreObjects;
2424
import com.google.common.base.Preconditions;
2525
import com.google.common.collect.ImmutableList;
26-
2726
import java.io.Serializable;
2827
import java.util.LinkedList;
2928
import java.util.List;
3029
import java.util.Objects;
3130

32-
/**
33-
* Base class for keys.
34-
*/
31+
/** Base class for keys. */
3532
public abstract class BaseKey implements Serializable {
3633

3734
private static final long serialVersionUID = -5897863400209818325L;
@@ -76,58 +73,40 @@ B self() {
7673
return (B) this;
7774
}
7875

79-
80-
/**
81-
* Adds an ancestor for this key.
82-
*/
76+
/** Adds an ancestor for this key. */
8377
public B addAncestor(PathElement ancestor) {
8478
Preconditions.checkState(ancestors.size() < MAX_PATH, "path can have at most 100 elements");
8579
ancestors.add(ancestor);
8680
return self();
8781
}
8882

89-
90-
/**
91-
* Adds the provided ancestors to the key.
92-
*/
83+
/** Adds the provided ancestors to the key. */
9384
public B addAncestors(PathElement ancestor, PathElement... other) {
9485
return addAncestors(ImmutableList.<PathElement>builder().add(ancestor).add(other).build());
9586
}
9687

97-
98-
/**
99-
* Adds the provided ancestors to the key.
100-
*/
88+
/** Adds the provided ancestors to the key. */
10189
public B addAncestors(Iterable<PathElement> ancestors) {
10290
ImmutableList<PathElement> list = ImmutableList.copyOf(ancestors);
103-
Preconditions.checkState(this.ancestors.size() + list.size() < MAX_PATH,
104-
"path can have at most 100 elements");
91+
Preconditions.checkState(
92+
this.ancestors.size() + list.size() < MAX_PATH, "path can have at most 100 elements");
10593
this.ancestors.addAll(list);
10694
return self();
10795
}
10896

109-
110-
/**
111-
* Sets the kind of the key.
112-
*/
97+
/** Sets the kind of the key. */
11398
public B setKind(String kind) {
11499
this.kind = validateKind(kind);
115100
return self();
116101
}
117102

118-
119-
/**
120-
* Sets the project ID of the key.
121-
*/
103+
/** Sets the project ID of the key. */
122104
public B setProjectId(String projectId) {
123105
this.projectId = validateDatabase(projectId);
124106
return self();
125107
}
126108

127-
128-
/**
129-
* Sets the namespace of the key.
130-
*/
109+
/** Sets the namespace of the key. */
131110
public B setNamespace(String namespace) {
132111
this.namespace = validateNamespace(namespace);
133112
return self();
@@ -143,34 +122,22 @@ public B setNamespace(String namespace) {
143122
this.path = path;
144123
}
145124

146-
147-
/**
148-
* Returns the key's projectId.
149-
*/
125+
/** Returns the key's projectId. */
150126
public String getProjectId() {
151127
return projectId;
152128
}
153129

154-
155-
/**
156-
* Returns the key's namespace or {@code null} if not provided.
157-
*/
130+
/** Returns the key's namespace or {@code null} if not provided. */
158131
public String getNamespace() {
159132
return namespace;
160133
}
161134

162-
163-
/**
164-
* Returns an immutable list with the key's ancestors.
165-
*/
135+
/** Returns an immutable list with the key's ancestors. */
166136
public List<PathElement> getAncestors() {
167137
return getPath().subList(0, getPath().size() - 1);
168138
}
169139

170-
171-
/**
172-
* Returns an immutable list of the key's path (ancestors + self).
173-
*/
140+
/** Returns an immutable list of the key's path (ancestors + self). */
174141
List<PathElement> getPath() {
175142
return path;
176143
}
@@ -179,15 +146,11 @@ PathElement getLeaf() {
179146
return getPath().get(getPath().size() - 1);
180147
}
181148

182-
183-
/**
184-
* Returns the key's kind.
185-
*/
149+
/** Returns the key's kind. */
186150
public String getKind() {
187151
return getLeaf().getKind();
188152
}
189153

190-
191154
abstract BaseKey getParent();
192155

193156
@Override

google-cloud-datastore/src/main/java/com/google/cloud/datastore/Batch.java

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,10 @@
1919
import java.util.List;
2020

2121
/**
22-
* An interface to represent a batch of write operations.
23-
* Any write operation that is applied on a batch will only be sent
24-
* to the Datastore upon {@link #submit}.
25-
* A usage example:
26-
* <pre> {@code
22+
* An interface to represent a batch of write operations. Any write operation that is applied on a
23+
* batch will only be sent to the Datastore upon {@link #submit}. A usage example:
24+
*
25+
* <pre>{@code
2726
* Entity entity1 = datastore.get(key1);
2827
* Batch batch = datastore.newBatch();
2928
* Entity entity2 = Entity.newBuilder(key2).set("name", "John").build();
@@ -32,24 +31,22 @@
3231
* batch.update(entity1);
3332
* batch.add(entity2, entity3);
3433
* batch.submit();
35-
* } </pre>
34+
* }</pre>
3635
*/
3736
public interface Batch extends DatastoreBatchWriter {
3837

3938
interface Response {
4039

41-
/**
42-
* Returns a list of keys generated by a batch.
43-
*/
40+
/** Returns a list of keys generated by a batch. */
4441
List<Key> getGeneratedKeys();
4542
}
4643

4744
/**
4845
* {@inheritDoc}
4946
*
5047
* <p>If an entity for {@code entity.getKey()} does not exists, {@code entity} is inserted.
51-
* Otherwise, {@link #submit()} will throw a {@link DatastoreException} with
52-
* {@link DatastoreException#getReason()} equal to {@code "ALREADY_EXISTS"}.
48+
* Otherwise, {@link #submit()} will throw a {@link DatastoreException} with {@link
49+
* DatastoreException#getReason()} equal to {@code "ALREADY_EXISTS"}.
5350
*/
5451
@Override
5552
Entity add(FullEntity<?> entity);
@@ -58,9 +55,9 @@ interface Response {
5855
* {@inheritDoc}
5956
*
6057
* <p>If none of entities' keys exist, all entities are inserted. If any of entities' keys already
61-
* exists, {@link #submit()} will throw a {@link DatastoreException} with
62-
* {@link DatastoreException#getReason()} equal to {@code "ALREADY_EXISTS"}. All entities in
63-
* {@code entities} whose key did not exist are inserted.
58+
* exists, {@link #submit()} will throw a {@link DatastoreException} with {@link
59+
* DatastoreException#getReason()} equal to {@code "ALREADY_EXISTS"}. All entities in {@code
60+
* entities} whose key did not exist are inserted.
6461
*/
6562
@Override
6663
List<Entity> add(FullEntity<?>... entities);
@@ -72,9 +69,6 @@ interface Response {
7269
*/
7370
Response submit();
7471

75-
76-
/**
77-
* Returns the batch associated {@link Datastore}.
78-
*/
72+
/** Returns the batch associated {@link Datastore}. */
7973
Datastore getDatastore();
8074
}

0 commit comments

Comments
 (0)