Skip to content

Commit 9bcebd3

Browse files
committed
Merge pull request #498 from ajkannan/hide-non-public-refs
Make protobuf methods package protected
2 parents 62a2d71 + b2d181f commit 9bcebd3

14 files changed

+49
-45
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ protected DatastoreException newInvalidRequest(String msg, Object... params) {
199199
return DatastoreException.throwInvalidRequest(String.format(msg, params));
200200
}
201201

202-
protected DatastoreV1.Mutation.Builder toMutationPb() {
202+
DatastoreV1.Mutation.Builder toMutationPb() {
203203
DatastoreV1.Mutation.Builder mutationPb = DatastoreV1.Mutation.newBuilder();
204204
for (FullEntity<IncompleteKey> entity : toAddAutoId()) {
205205
mutationPb.addInsertAutoId(entity.toPb());

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ private B self() {
9090
}
9191

9292
@SuppressWarnings("unchecked")
93-
protected B fill(DatastoreV1.Entity entityPb) {
93+
B fill(DatastoreV1.Entity entityPb) {
9494
Map<String, Value<?>> copiedProperties = Maps.newHashMap();
9595
for (DatastoreV1.Property property : entityPb.getPropertyList()) {
9696
copiedProperties.put(property.getName(), Value.fromPb(property.getValue()));
@@ -375,7 +375,7 @@ ImmutableSortedMap<String, Value<?>> properties() {
375375
}
376376

377377
@Override
378-
protected Object fromPb(byte[] bytesPb) throws InvalidProtocolBufferException {
378+
Object fromPb(byte[] bytesPb) throws InvalidProtocolBufferException {
379379
Builder<?, ?> builder = emptyBuilder();
380380
builder.fill(DatastoreV1.Entity.parseFrom(bytesPb));
381381
return builder.build();
@@ -384,7 +384,7 @@ protected Object fromPb(byte[] bytesPb) throws InvalidProtocolBufferException {
384384
protected abstract Builder<?, ?> emptyBuilder();
385385

386386
@Override
387-
protected final DatastoreV1.Entity toPb() {
387+
final DatastoreV1.Entity toPb() {
388388
DatastoreV1.Entity.Builder entityPb = DatastoreV1.Entity.newBuilder();
389389
for (Map.Entry<String, Value<?>> entry : properties.entrySet()) {
390390
DatastoreV1.Property.Builder propertyPb = DatastoreV1.Property.newBuilder();

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ public boolean equals(Object obj) {
172172
}
173173

174174
@Override
175-
protected DatastoreV1.Key toPb() {
175+
DatastoreV1.Key toPb() {
176176
DatastoreV1.Key.Builder keyPb = DatastoreV1.Key.newBuilder();
177177
DatastoreV1.PartitionId.Builder partitionIdPb = DatastoreV1.PartitionId.newBuilder();
178178
if (projectId != null) {

gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/Blob.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -147,12 +147,12 @@ public static Blob copyFrom(InputStream input) throws IOException {
147147
}
148148

149149
@Override
150-
protected Value toPb() {
150+
Value toPb() {
151151
return DatastoreV1.Value.newBuilder().setBlobValue(byteString).build();
152152
}
153153

154154
@Override
155-
protected Object fromPb(byte[] bytesPb) throws InvalidProtocolBufferException {
155+
Object fromPb(byte[] bytesPb) throws InvalidProtocolBufferException {
156156
return new Blob(DatastoreV1.Value.parseFrom(bytesPb).getBlobValue());
157157
}
158158
}

gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/Cursor.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,12 @@ public static Cursor copyFrom(byte[] bytes) {
102102
}
103103

104104
@Override
105-
protected Value toPb() {
105+
Value toPb() {
106106
return DatastoreV1.Value.newBuilder().setBlobValue(byteString).build();
107107
}
108108

109109
@Override
110-
protected Object fromPb(byte[] bytesPb) throws InvalidProtocolBufferException {
110+
Object fromPb(byte[] bytesPb) throws InvalidProtocolBufferException {
111111
return fromPb(DatastoreV1.Value.parseFrom(bytesPb));
112112
}
113113

gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/DateTime.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,12 @@ public static DateTime copyFrom(Calendar calendar) {
9898
}
9999

100100
@Override
101-
protected Value toPb() {
101+
Value toPb() {
102102
return DatastoreV1.Value.newBuilder().setIntegerValue(timestampMicroseconds).build();
103103
}
104104

105105
@Override
106-
protected Object fromPb(byte[] bytesPb) throws InvalidProtocolBufferException {
106+
Object fromPb(byte[] bytesPb) throws InvalidProtocolBufferException {
107107
return new DateTime(DatastoreV1.Value.parseFrom(bytesPb).getIntegerValue());
108108
}
109109
}

gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/GqlQuery.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ public boolean equals(Object obj) {
126126
}
127127

128128
@Override
129-
protected DatastoreV1.GqlQueryArg toPb() {
129+
DatastoreV1.GqlQueryArg toPb() {
130130
DatastoreV1.GqlQueryArg.Builder argPb = DatastoreV1.GqlQueryArg.newBuilder();
131131
if (name != null) {
132132
argPb.setName(name);
@@ -141,7 +141,7 @@ protected DatastoreV1.GqlQueryArg toPb() {
141141
}
142142

143143
@Override
144-
protected Object fromPb(byte[] bytesPb) throws InvalidProtocolBufferException {
144+
Object fromPb(byte[] bytesPb) throws InvalidProtocolBufferException {
145145
return fromPb(DatastoreV1.GqlQueryArg.parseFrom(bytesPb));
146146
}
147147

@@ -370,7 +370,7 @@ public boolean equals(Object obj) {
370370
}
371371

372372
@Override
373-
protected DatastoreV1.GqlQuery toPb() {
373+
DatastoreV1.GqlQuery toPb() {
374374
DatastoreV1.GqlQuery.Builder queryPb = DatastoreV1.GqlQuery.newBuilder();
375375
queryPb.setQueryString(queryString);
376376
queryPb.setAllowLiteral(allowLiteral);
@@ -384,18 +384,18 @@ protected DatastoreV1.GqlQuery toPb() {
384384
}
385385

386386
@Override
387-
protected void populatePb(DatastoreV1.RunQueryRequest.Builder requestPb) {
387+
void populatePb(DatastoreV1.RunQueryRequest.Builder requestPb) {
388388
requestPb.setGqlQuery(toPb());
389389
}
390390

391391
@Override
392-
protected GqlQuery<V> nextQuery(DatastoreV1.QueryResultBatch responsePb) {
392+
GqlQuery<V> nextQuery(DatastoreV1.QueryResultBatch responsePb) {
393393
// See issue #17
394394
throw new UnsupportedOperationException("paging for this query is not implemented yet");
395395
}
396396

397397
@Override
398-
protected Object fromPb(ResultType<V> resultType, String namespace, byte[] bytesPb)
398+
Object fromPb(ResultType<V> resultType, String namespace, byte[] bytesPb)
399399
throws InvalidProtocolBufferException {
400400
return fromPb(resultType, namespace, DatastoreV1.GqlQuery.parseFrom(bytesPb));
401401
}

gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/IncompleteKey.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public IncompleteKey build() {
5454
}
5555

5656
@Override
57-
protected Object fromPb(byte[] bytesPb) throws InvalidProtocolBufferException {
57+
Object fromPb(byte[] bytesPb) throws InvalidProtocolBufferException {
5858
return fromPb(DatastoreV1.Key.parseFrom(bytesPb));
5959
}
6060

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ public static Key fromUrlSafe(String urlSafe) {
164164
}
165165

166166
@Override
167-
protected Object fromPb(byte[] bytesPb) throws InvalidProtocolBufferException {
167+
Object fromPb(byte[] bytesPb) throws InvalidProtocolBufferException {
168168
return fromPb(DatastoreV1.Key.parseFrom(bytesPb));
169169
}
170170

gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/PathElement.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public boolean equals(Object obj) {
8686
}
8787

8888
@Override
89-
protected DatastoreV1.Key.PathElement toPb() {
89+
DatastoreV1.Key.PathElement toPb() {
9090
DatastoreV1.Key.PathElement.Builder pathElementPb = DatastoreV1.Key.PathElement.newBuilder();
9191
pathElementPb.setKind(kind);
9292
if (id != null) {
@@ -98,7 +98,7 @@ protected DatastoreV1.Key.PathElement toPb() {
9898
}
9999

100100
@Override
101-
protected Object fromPb(byte[] bytesPb) throws InvalidProtocolBufferException {
101+
Object fromPb(byte[] bytesPb) throws InvalidProtocolBufferException {
102102
return fromPb(DatastoreV1.Key.PathElement.parseFrom(bytesPb));
103103
}
104104

gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/Query.java

+13-9
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ public abstract static class ResultType<V> implements java.io.Serializable {
6565

6666
private static final long serialVersionUID = 1602329532153860907L;
6767

68-
@Override protected Object convert(DatastoreV1.Entity entityPb) {
68+
@Override
69+
Object convert(DatastoreV1.Entity entityPb) {
6970
if (entityPb.getPropertyCount() == 0) {
7071
if (!entityPb.hasKey()) {
7172
return null;
@@ -81,7 +82,8 @@ public abstract static class ResultType<V> implements java.io.Serializable {
8182

8283
private static final long serialVersionUID = 7712959777507168274L;
8384

84-
@Override protected Entity convert(DatastoreV1.Entity entityPb) {
85+
@Override
86+
Entity convert(DatastoreV1.Entity entityPb) {
8587
return Entity.fromPb(entityPb);
8688
}
8789
};
@@ -91,7 +93,8 @@ public abstract static class ResultType<V> implements java.io.Serializable {
9193

9294
private static final long serialVersionUID = -8514289244104446252L;
9395

94-
@Override protected Key convert(DatastoreV1.Entity entityPb) {
96+
@Override
97+
Key convert(DatastoreV1.Entity entityPb) {
9598
return Key.fromPb(entityPb.getKey());
9699
}
97100
};
@@ -102,7 +105,8 @@ public abstract static class ResultType<V> implements java.io.Serializable {
102105

103106
private static final long serialVersionUID = -7591409419690650246L;
104107

105-
@Override protected ProjectionEntity convert(DatastoreV1.Entity entityPb) {
108+
@Override
109+
ProjectionEntity convert(DatastoreV1.Entity entityPb) {
106110
return ProjectionEntity.fromPb(entityPb);
107111
}
108112
};
@@ -151,7 +155,7 @@ boolean isAssignableFrom(ResultType<?> otherResultType) {
151155
return resultClass.isAssignableFrom(otherResultType.resultClass);
152156
}
153157

154-
protected abstract V convert(DatastoreV1.Entity entityPb);
158+
abstract V convert(DatastoreV1.Entity entityPb);
155159

156160
static ResultType<?> fromPb(DatastoreV1.EntityResult.ResultType typePb) {
157161
return MoreObjects.firstNonNull(PB_TO_INSTANCE.get(typePb), UNKNOWN);
@@ -181,16 +185,16 @@ public String toString() {
181185
}
182186

183187
@Override
184-
protected Object fromPb(byte[] bytesPb) throws InvalidProtocolBufferException {
188+
Object fromPb(byte[] bytesPb) throws InvalidProtocolBufferException {
185189
return fromPb(resultType, namespace, bytesPb);
186190
}
187191

188-
protected abstract Object fromPb(ResultType<V> resultType, String namespace, byte[] bytesPb)
192+
abstract Object fromPb(ResultType<V> resultType, String namespace, byte[] bytesPb)
189193
throws InvalidProtocolBufferException;
190194

191-
protected abstract void populatePb(DatastoreV1.RunQueryRequest.Builder requestPb);
195+
abstract void populatePb(DatastoreV1.RunQueryRequest.Builder requestPb);
192196

193-
protected abstract Query<V> nextQuery(DatastoreV1.QueryResultBatch responsePb);
197+
abstract Query<V> nextQuery(DatastoreV1.QueryResultBatch responsePb);
194198

195199
/**
196200
* Returns a new {@link GqlQuery} builder.

gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/Serializable.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ private void readObject(ObjectInputStream input) throws IOException, ClassNotFou
4646
bytesPb = (byte[]) input.readObject();
4747
}
4848

49-
protected Object readResolve() throws ObjectStreamException {
49+
Object readResolve() throws ObjectStreamException {
5050
try {
5151
return fromPb(bytesPb);
5252
} catch (InvalidProtocolBufferException ex) {
@@ -58,7 +58,7 @@ protected Object readResolve() throws ObjectStreamException {
5858
}
5959
}
6060

61-
protected abstract M toPb();
61+
abstract M toPb();
6262

63-
protected abstract Object fromPb(byte[] bytesPb) throws InvalidProtocolBufferException;
63+
abstract Object fromPb(byte[] bytesPb) throws InvalidProtocolBufferException;
6464
}

gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/StructuredQuery.java

+10-10
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public abstract static class Filter implements Serializable {
103103
Filter() {
104104
}
105105

106-
protected abstract DatastoreV1.Filter toPb();
106+
abstract DatastoreV1.Filter toPb();
107107

108108
static Filter fromPb(DatastoreV1.Filter filterPb) {
109109
if (filterPb.hasCompositeFilter()) {
@@ -186,7 +186,7 @@ public static CompositeFilter and(Filter first, Filter... other) {
186186
}
187187

188188
@Override
189-
protected DatastoreV1.Filter toPb() {
189+
DatastoreV1.Filter toPb() {
190190
DatastoreV1.Filter.Builder filterPb = DatastoreV1.Filter.newBuilder();
191191
DatastoreV1.CompositeFilter.Builder compositeFilterPb = filterPb.getCompositeFilterBuilder();
192192
compositeFilterPb.setOperator(operator.toPb());
@@ -231,7 +231,7 @@ private PropertyFilter(String property, Operator operator, Value<?> value) {
231231
this.value = checkNotNull(value);
232232
}
233233

234-
public static PropertyFilter fromPb(DatastoreV1.PropertyFilter propertyFilterPb) {
234+
static PropertyFilter fromPb(DatastoreV1.PropertyFilter propertyFilterPb) {
235235
String property = propertyFilterPb.getProperty().getName();
236236
Operator operator = Operator.fromPb(propertyFilterPb.getOperator());
237237
Value<?> value = Value.fromPb(propertyFilterPb.getValue());
@@ -435,7 +435,7 @@ public static PropertyFilter isNull(String property) {
435435
}
436436

437437
@Override
438-
protected DatastoreV1.Filter toPb() {
438+
DatastoreV1.Filter toPb() {
439439
DatastoreV1.Filter.Builder filterPb = DatastoreV1.Filter.newBuilder();
440440
DatastoreV1.PropertyFilter.Builder propertyFilterPb = filterPb.getPropertyFilterBuilder();
441441
propertyFilterPb.getPropertyBuilder().setName(property);
@@ -587,7 +587,7 @@ DatastoreV1.PropertyExpression toPb() {
587587
return expressionPb.build();
588588
}
589589

590-
public static Projection fromPb(DatastoreV1.PropertyExpression propertyExpressionPb) {
590+
static Projection fromPb(DatastoreV1.PropertyExpression propertyExpressionPb) {
591591
String property = propertyExpressionPb.getProperty().getName();
592592
Aggregate aggregate = null;
593593
if (propertyExpressionPb.hasAggregationFunction()) {
@@ -795,7 +795,7 @@ public static final class KeyQueryBuilder extends BaseBuilder<Key, KeyQueryBuild
795795
}
796796

797797
@Override
798-
protected KeyQueryBuilder mergeFrom(DatastoreV1.Query queryPb) {
798+
KeyQueryBuilder mergeFrom(DatastoreV1.Query queryPb) {
799799
super.mergeFrom(queryPb);
800800
projection(Projection.property(KEY_PROPERTY_NAME));
801801
clearGroupBy();
@@ -948,12 +948,12 @@ public Integer limit() {
948948
}
949949

950950
@Override
951-
protected void populatePb(DatastoreV1.RunQueryRequest.Builder requestPb) {
951+
void populatePb(DatastoreV1.RunQueryRequest.Builder requestPb) {
952952
requestPb.setQuery(toPb());
953953
}
954954

955955
@Override
956-
protected StructuredQuery<V> nextQuery(DatastoreV1.QueryResultBatch responsePb) {
956+
StructuredQuery<V> nextQuery(DatastoreV1.QueryResultBatch responsePb) {
957957
Builder<V> builder = new Builder<>(type());
958958
builder.mergeFrom(toPb());
959959
builder.startCursor(new Cursor(responsePb.getEndCursor()));
@@ -969,7 +969,7 @@ protected StructuredQuery<V> nextQuery(DatastoreV1.QueryResultBatch responsePb)
969969
}
970970

971971
@Override
972-
protected DatastoreV1.Query toPb() {
972+
DatastoreV1.Query toPb() {
973973
DatastoreV1.Query.Builder queryPb = DatastoreV1.Query.newBuilder();
974974
if (kind != null) {
975975
queryPb.addKindBuilder().setName(kind);
@@ -1002,7 +1002,7 @@ protected DatastoreV1.Query toPb() {
10021002
}
10031003

10041004
@Override
1005-
protected Object fromPb(ResultType<V> resultType, String namespace, byte[] bytesPb)
1005+
Object fromPb(ResultType<V> resultType, String namespace, byte[] bytesPb)
10061006
throws InvalidProtocolBufferException {
10071007
return fromPb(resultType, namespace, DatastoreV1.Query.parseFrom(bytesPb));
10081008
}

gcloud-java-datastore/src/main/java/com/google/gcloud/datastore/Value.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ public boolean equals(Object obj) {
211211

212212
@Override
213213
@SuppressWarnings("unchecked")
214-
protected DatastoreV1.Value toPb() {
214+
DatastoreV1.Value toPb() {
215215
return type().getMarshaller().toProto(this);
216216
}
217217

@@ -231,7 +231,7 @@ static Value<?> fromPb(DatastoreV1.Value proto) {
231231
}
232232

233233
@Override
234-
protected Object fromPb(byte[] bytesPb) throws InvalidProtocolBufferException {
234+
Object fromPb(byte[] bytesPb) throws InvalidProtocolBufferException {
235235
return fromPb(DatastoreV1.Value.parseFrom(bytesPb));
236236
}
237237
}

0 commit comments

Comments
 (0)