Skip to content

Make protobuf methods package protected #498

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 22, 2015
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ protected DatastoreException newInvalidRequest(String msg, Object... params) {
return DatastoreException.throwInvalidRequest(String.format(msg, params));
}

protected DatastoreV1.Mutation.Builder toMutationPb() {
DatastoreV1.Mutation.Builder toMutationPb() {
DatastoreV1.Mutation.Builder mutationPb = DatastoreV1.Mutation.newBuilder();
for (FullEntity<IncompleteKey> entity : toAddAutoId()) {
mutationPb.addInsertAutoId(entity.toPb());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ private B self() {
}

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

@Override
protected Object fromPb(byte[] bytesPb) throws InvalidProtocolBufferException {
Object fromPb(byte[] bytesPb) throws InvalidProtocolBufferException {
Builder<?, ?> builder = emptyBuilder();
builder.fill(DatastoreV1.Entity.parseFrom(bytesPb));
return builder.build();
Expand All @@ -384,7 +384,7 @@ protected Object fromPb(byte[] bytesPb) throws InvalidProtocolBufferException {
protected abstract Builder<?, ?> emptyBuilder();

@Override
protected final DatastoreV1.Entity toPb() {
final DatastoreV1.Entity toPb() {
DatastoreV1.Entity.Builder entityPb = DatastoreV1.Entity.newBuilder();
for (Map.Entry<String, Value<?>> entry : properties.entrySet()) {
DatastoreV1.Property.Builder propertyPb = DatastoreV1.Property.newBuilder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ public boolean equals(Object obj) {
}

@Override
protected DatastoreV1.Key toPb() {
DatastoreV1.Key toPb() {
DatastoreV1.Key.Builder keyPb = DatastoreV1.Key.newBuilder();
DatastoreV1.PartitionId.Builder partitionIdPb = DatastoreV1.PartitionId.newBuilder();
if (projectId != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,12 @@ public static Blob copyFrom(InputStream input) throws IOException {
}

@Override
protected Value toPb() {
Value toPb() {
return DatastoreV1.Value.newBuilder().setBlobValue(byteString).build();
}

@Override
protected Object fromPb(byte[] bytesPb) throws InvalidProtocolBufferException {
Object fromPb(byte[] bytesPb) throws InvalidProtocolBufferException {
return new Blob(DatastoreV1.Value.parseFrom(bytesPb).getBlobValue());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ public Builder newBuilder(Blob value) {
}

@Override
protected Blob getValue(DatastoreV1.Value from) {
Blob getValue(DatastoreV1.Value from) {
return new Blob(from.getBlobValue());
}

@Override
protected void setValue(BlobValue from, DatastoreV1.Value.Builder to) {
void setValue(BlobValue from, DatastoreV1.Value.Builder to) {
to.setBlobValue(from.get().byteString());
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ public Builder newBuilder(Boolean value) {
}

@Override
protected Boolean getValue(DatastoreV1.Value from) {
Boolean getValue(DatastoreV1.Value from) {
return from.getBooleanValue();
}

@Override
protected void setValue(BooleanValue from, DatastoreV1.Value.Builder to) {
void setValue(BooleanValue from, DatastoreV1.Value.Builder to) {
to.setBooleanValue(from.get());
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,12 @@ public static Cursor copyFrom(byte[] bytes) {
}

@Override
protected Value toPb() {
Value toPb() {
return DatastoreV1.Value.newBuilder().setBlobValue(byteString).build();
}

@Override
protected Object fromPb(byte[] bytesPb) throws InvalidProtocolBufferException {
Object fromPb(byte[] bytesPb) throws InvalidProtocolBufferException {
return fromPb(DatastoreV1.Value.parseFrom(bytesPb));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,12 @@ public static DateTime copyFrom(Calendar calendar) {
}

@Override
protected Value toPb() {
Value toPb() {
return DatastoreV1.Value.newBuilder().setIntegerValue(timestampMicroseconds).build();
}

@Override
protected Object fromPb(byte[] bytesPb) throws InvalidProtocolBufferException {
Object fromPb(byte[] bytesPb) throws InvalidProtocolBufferException {
return new DateTime(DatastoreV1.Value.parseFrom(bytesPb).getIntegerValue());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ public Builder newBuilder(DateTime value) {
}

@Override
protected DateTime getValue(DatastoreV1.Value from) {
DateTime getValue(DatastoreV1.Value from) {
return new DateTime(from.getTimestampMicrosecondsValue());
}

@Override
protected void setValue(DateTimeValue from, DatastoreV1.Value.Builder to) {
void setValue(DateTimeValue from, DatastoreV1.Value.Builder to) {
to.setTimestampMicrosecondsValue(from.get().timestampMicroseconds());
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ public Builder newBuilder(Double value) {
}

@Override
protected Double getValue(DatastoreV1.Value from) {
Double getValue(DatastoreV1.Value from) {
return from.getDoubleValue();
}

@Override
protected void setValue(DoubleValue from, DatastoreV1.Value.Builder to) {
void setValue(DoubleValue from, DatastoreV1.Value.Builder to) {
to.setDoubleValue(from.get());
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ public Builder newBuilder(FullEntity<?> value) {
}

@Override
protected FullEntity<?> getValue(DatastoreV1.Value from) {
FullEntity<?> getValue(DatastoreV1.Value from) {
return FullEntity.fromPb(from.getEntityValue());
}

@Override
protected void setValue(EntityValue from, DatastoreV1.Value.Builder to) {
void setValue(EntityValue from, DatastoreV1.Value.Builder to) {
to.setEntityValue(from.get().toPb());
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public boolean equals(Object obj) {
}

@Override
protected DatastoreV1.GqlQueryArg toPb() {
DatastoreV1.GqlQueryArg toPb() {
DatastoreV1.GqlQueryArg.Builder argPb = DatastoreV1.GqlQueryArg.newBuilder();
if (name != null) {
argPb.setName(name);
Expand All @@ -141,7 +141,7 @@ protected DatastoreV1.GqlQueryArg toPb() {
}

@Override
protected Object fromPb(byte[] bytesPb) throws InvalidProtocolBufferException {
Object fromPb(byte[] bytesPb) throws InvalidProtocolBufferException {
return fromPb(DatastoreV1.GqlQueryArg.parseFrom(bytesPb));
}

Expand Down Expand Up @@ -370,7 +370,7 @@ public boolean equals(Object obj) {
}

@Override
protected DatastoreV1.GqlQuery toPb() {
DatastoreV1.GqlQuery toPb() {
DatastoreV1.GqlQuery.Builder queryPb = DatastoreV1.GqlQuery.newBuilder();
queryPb.setQueryString(queryString);
queryPb.setAllowLiteral(allowLiteral);
Expand All @@ -384,18 +384,18 @@ protected DatastoreV1.GqlQuery toPb() {
}

@Override
protected void populatePb(DatastoreV1.RunQueryRequest.Builder requestPb) {
void populatePb(DatastoreV1.RunQueryRequest.Builder requestPb) {
requestPb.setGqlQuery(toPb());
}

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

@Override
protected Object fromPb(ResultType<V> resultType, String namespace, byte[] bytesPb)
Object fromPb(ResultType<V> resultType, String namespace, byte[] bytesPb)
throws InvalidProtocolBufferException {
return fromPb(resultType, namespace, DatastoreV1.GqlQuery.parseFrom(bytesPb));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public IncompleteKey build() {
}

@Override
protected Object fromPb(byte[] bytesPb) throws InvalidProtocolBufferException {
Object fromPb(byte[] bytesPb) throws InvalidProtocolBufferException {
return fromPb(DatastoreV1.Key.parseFrom(bytesPb));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public static Key fromUrlSafe(String urlSafe) {
}

@Override
protected Object fromPb(byte[] bytesPb) throws InvalidProtocolBufferException {
Object fromPb(byte[] bytesPb) throws InvalidProtocolBufferException {
return fromPb(DatastoreV1.Key.parseFrom(bytesPb));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ public Builder newBuilder(Key key) {
}

@Override
protected Key getValue(DatastoreV1.Value from) {
Key getValue(DatastoreV1.Value from) {
return Key.fromPb(from.getKeyValue());
}

@Override
protected void setValue(KeyValue from, DatastoreV1.Value.Builder to) {
void setValue(KeyValue from, DatastoreV1.Value.Builder to) {
to.setKeyValue(from.get().toPb());
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public Builder newBuilder(List<? extends Value<?>> values) {
}

@Override
protected List<Value<?>> getValue(DatastoreV1.Value from) {
List<Value<?>> getValue(DatastoreV1.Value from) {
List<Value<?>> properties = new ArrayList<>(from.getListValueCount());
for (DatastoreV1.Value valuePb : from.getListValueList()) {
properties.add(Value.fromPb(valuePb));
Expand All @@ -54,7 +54,7 @@ protected List<Value<?>> getValue(DatastoreV1.Value from) {
}

@Override
protected void setValue(ListValue from, DatastoreV1.Value.Builder to) {
void setValue(ListValue from, DatastoreV1.Value.Builder to) {
for (Value<?> property : from.get()) {
to.addListValue(property.toPb());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ public Builder newBuilder(Long value) {
}

@Override
protected Long getValue(DatastoreV1.Value from) {
Long getValue(DatastoreV1.Value from) {
return from.getIntegerValue();
}

@Override
protected void setValue(LongValue from, DatastoreV1.Value.Builder to) {
void setValue(LongValue from, DatastoreV1.Value.Builder to) {
to.setIntegerValue(from.get());
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ public int getProtoFieldId() {
}

@Override
protected Void getValue(DatastoreV1.Value from) {
Void getValue(DatastoreV1.Value from) {
return null;
}

@Override
protected void setValue(NullValue from, DatastoreV1.Value.Builder to) {
void setValue(NullValue from, DatastoreV1.Value.Builder to) {
// nothing to set
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public boolean equals(Object obj) {
}

@Override
protected DatastoreV1.Key.PathElement toPb() {
DatastoreV1.Key.PathElement toPb() {
DatastoreV1.Key.PathElement.Builder pathElementPb = DatastoreV1.Key.PathElement.newBuilder();
pathElementPb.setKind(kind);
if (id != null) {
Expand All @@ -98,7 +98,7 @@ protected DatastoreV1.Key.PathElement toPb() {
}

@Override
protected Object fromPb(byte[] bytesPb) throws InvalidProtocolBufferException {
Object fromPb(byte[] bytesPb) throws InvalidProtocolBufferException {
return fromPb(DatastoreV1.Key.PathElement.parseFrom(bytesPb));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ public abstract static class ResultType<V> implements java.io.Serializable {

private static final long serialVersionUID = 1602329532153860907L;

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

private static final long serialVersionUID = 7712959777507168274L;

@Override protected Entity convert(DatastoreV1.Entity entityPb) {
@Override
Entity convert(DatastoreV1.Entity entityPb) {
return Entity.fromPb(entityPb);
}
};
Expand All @@ -91,7 +93,8 @@ public abstract static class ResultType<V> implements java.io.Serializable {

private static final long serialVersionUID = -8514289244104446252L;

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

private static final long serialVersionUID = -7591409419690650246L;

@Override protected ProjectionEntity convert(DatastoreV1.Entity entityPb) {
@Override
ProjectionEntity convert(DatastoreV1.Entity entityPb) {
return ProjectionEntity.fromPb(entityPb);
}
};
Expand Down Expand Up @@ -151,7 +155,7 @@ boolean isAssignableFrom(ResultType<?> otherResultType) {
return resultClass.isAssignableFrom(otherResultType.resultClass);
}

protected abstract V convert(DatastoreV1.Entity entityPb);
abstract V convert(DatastoreV1.Entity entityPb);

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

@Override
protected Object fromPb(byte[] bytesPb) throws InvalidProtocolBufferException {
Object fromPb(byte[] bytesPb) throws InvalidProtocolBufferException {
return fromPb(resultType, namespace, bytesPb);
}

protected abstract Object fromPb(ResultType<V> resultType, String namespace, byte[] bytesPb)
abstract Object fromPb(ResultType<V> resultType, String namespace, byte[] bytesPb)
throws InvalidProtocolBufferException;

protected abstract void populatePb(DatastoreV1.RunQueryRequest.Builder requestPb);
abstract void populatePb(DatastoreV1.RunQueryRequest.Builder requestPb);

protected abstract Query<V> nextQuery(DatastoreV1.QueryResultBatch responsePb);
abstract Query<V> nextQuery(DatastoreV1.QueryResultBatch responsePb);

/**
* Returns a new {@link GqlQuery} builder.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ public int getProtoFieldId() {
}

@Override
protected DatastoreV1.Value getValue(DatastoreV1.Value from) {
DatastoreV1.Value getValue(DatastoreV1.Value from) {
return from;
}

@Override
protected void setValue(RawValue from, DatastoreV1.Value.Builder to) {
void setValue(RawValue from, DatastoreV1.Value.Builder to) {
to.mergeFrom(from.get());
}
};
Expand Down
Loading