|
20 | 20 |
|
21 | 21 | package io.spine.server.storage.datastore; |
22 | 22 |
|
| 23 | +import com.google.cloud.datastore.Blob; |
| 24 | +import com.google.cloud.datastore.BlobValue; |
23 | 25 | import com.google.cloud.datastore.BooleanValue; |
24 | 26 | import com.google.cloud.datastore.DoubleValue; |
25 | 27 | import com.google.cloud.datastore.LongValue; |
26 | 28 | import com.google.cloud.datastore.StringValue; |
27 | 29 | import com.google.cloud.datastore.TimestampValue; |
28 | 30 | import com.google.cloud.datastore.Value; |
29 | 31 | import com.google.common.collect.ImmutableSortedMap; |
| 32 | +import com.google.protobuf.ByteString; |
30 | 33 | import com.google.protobuf.Message; |
31 | 34 | import com.google.protobuf.Timestamp; |
32 | 35 | import io.spine.core.Version; |
@@ -80,6 +83,7 @@ private static ImmutableSortedMap<Class<?>, PersistenceStrategy<?>> defaultPolic |
80 | 83 | policies.put(Double.class, new DefaultDoublePersistenceStrategy()); |
81 | 84 | policies.put(Float.class, new DefaultFloatPersistenceStrategy()); |
82 | 85 | policies.put(Boolean.class, new DefaultBooleanPersistenceStrategy()); |
| 86 | + policies.put(ByteString.class, new DefaultByteStringPersistenceStrategy()); |
83 | 87 | policies.put(Timestamp.class, new DefaultTimestampPersistenceStrategy()); |
84 | 88 | policies.put(Version.class, new DefaultVersionPersistenceStrategy()); |
85 | 89 | policies.put(Enum.class, new DefaultEnumPersistenceStrategy()); |
@@ -161,6 +165,16 @@ public Value<?> apply(Boolean aBoolean) { |
161 | 165 | } |
162 | 166 | } |
163 | 167 |
|
| 168 | + private static class DefaultByteStringPersistenceStrategy |
| 169 | + implements PersistenceStrategy<ByteString> { |
| 170 | + |
| 171 | + @Override |
| 172 | + public Value<?> apply(ByteString bytes) { |
| 173 | + Blob blob = Blob.copyFrom(bytes.asReadOnlyByteBuffer()); |
| 174 | + return BlobValue.of(blob); |
| 175 | + } |
| 176 | + } |
| 177 | + |
164 | 178 | private static class DefaultTimestampPersistenceStrategy |
165 | 179 | implements PersistenceStrategy<Timestamp> { |
166 | 180 |
|
|
0 commit comments