Skip to content

Commit

Permalink
OAP-000 add: BlobData.BlobDataBuilder
Browse files Browse the repository at this point in the history
  • Loading branch information
nofateg authored Dec 4, 2024
1 parent 08b5c19 commit 9cfc518
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
package oap.storage.cloud;

import lombok.Builder;
import lombok.ToString;

import java.io.File;
import java.io.InputStream;
import java.io.Serial;
import java.io.Serializable;
import java.nio.ByteBuffer;
import java.nio.file.Path;
import java.util.LinkedHashMap;
import java.util.Map;

@ToString
@Builder
public class BlobData implements Serializable {
@Serial
private static final long serialVersionUID = -3448280826165820410L;
Expand All @@ -18,4 +21,82 @@ public class BlobData implements Serializable {
public Map<String, String> tags;
public String contentType;
public Long contentLength;

public static BlobDataBuilder builder() {
return new BlobDataBuilder();
}

public static class BlobDataBuilder {
private final BlobData blobData = new BlobData();

private BlobDataBuilder() {
}

public BlobDataBuilder contentLength( long contentLength ) {
blobData.contentLength = contentLength;

return this;
}

public BlobDataBuilder contentType( String contentType ) {
blobData.contentType = contentType;

return this;
}

public BlobDataBuilder content( Path path ) {
blobData.content = path;

return this;
}

public BlobDataBuilder content( File file ) {
blobData.content = file;

return this;
}

public BlobDataBuilder content( String str ) {
blobData.content = str;

return this;
}

public BlobDataBuilder content( byte[] bytes ) {
blobData.content = bytes;

return this;
}

public BlobDataBuilder content( ByteBuffer byteBuffer ) {
blobData.content = byteBuffer;

return this;
}

public BlobDataBuilder content( InputStream inputStream ) {
blobData.content = inputStream;

return this;
}

public BlobDataBuilder tags( Map<String, String> tags ) {
blobData.tags = new LinkedHashMap<>( tags );

return this;
}

public BlobDataBuilder tag( String tag, String value ) {
if( blobData.tags == null ) {
blobData.tags = new LinkedHashMap<>();
}
blobData.tags.put( tag, value );

return this;
}

public BlobData build() {
return blobData;
}
}
}
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
</distributionManagement>

<properties>
<oap.project.version>22.6.4</oap.project.version>
<oap.project.version>22.6.5</oap.project.version>

<oap.deps.config.version>21.0.0</oap.deps.config.version>
<oap.deps.oap-teamcity.version>21.0.1</oap.deps.oap-teamcity.version>
Expand Down

0 comments on commit 9cfc518

Please sign in to comment.