1616
1717package com .google .gcloud .datastore ;
1818
19- import static com .google .common .base .Preconditions .checkArgument ;
2019import static com .google .common .base .Preconditions .checkNotNull ;
2120
2221import com .google .api .services .datastore .DatastoreV1 ;
3433
3534/**
3635 * A Google Cloud Datastore Blob.
37- * A Datastore blob is limited to {@value #MAX_LENGTH} bytes.
3836 * This class is immutable.
3937 *
4038 * @see <a href="https://cloud.google.com/datastore/docs/concepts/entities">Google Cloud Datastore Entities, Properties, and Keys</a>
4139 */
4240public final class Blob extends Serializable <DatastoreV1 .Value > {
4341
4442 private static final long serialVersionUID = 3835421019618247721L ;
45- public static final int MAX_LENGTH = 1_000_000 ;
4643
4744 private final transient ByteString byteString ;
4845
49- Blob (ByteString byteString , boolean enforceLimits ) {
46+ Blob (ByteString byteString ) {
5047 this .byteString = checkNotNull (byteString );
51- if (enforceLimits ) {
52- checkArgument (byteString .size () <= MAX_LENGTH , "May be a maximum of %,d bytes" , MAX_LENGTH );
53- }
5448 }
5549
5650 @ Override
@@ -134,11 +128,11 @@ ByteString byteString() {
134128 }
135129
136130 public static Blob copyFrom (byte [] bytes ) {
137- return new Blob (ByteString .copyFrom (bytes ), true );
131+ return new Blob (ByteString .copyFrom (bytes ));
138132 }
139133
140134 public static Blob copyFrom (ByteBuffer bytes ) {
141- return new Blob (ByteString .copyFrom (bytes ), true );
135+ return new Blob (ByteString .copyFrom (bytes ));
142136 }
143137
144138 public static Blob copyFrom (InputStream input ) throws IOException {
@@ -158,6 +152,6 @@ protected Value toPb() {
158152
159153 @ Override
160154 protected Object fromPb (byte [] bytesPb ) throws InvalidProtocolBufferException {
161- return new Blob (DatastoreV1 .Value .parseFrom (bytesPb ).getBlobValue (), false );
155+ return new Blob (DatastoreV1 .Value .parseFrom (bytesPb ).getBlobValue ());
162156 }
163157}
0 commit comments