1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.common.aws.s3.model;
17
18 import static com.google.common.base.Optional.absent;
19 import static org.kuali.common.aws.s3.model.CopyObjectResult.fromNullableSSE;
20 import static org.kuali.common.core.base.Optionals.fromNullableDate;
21 import static org.kuali.common.core.base.Optionals.fromTrimToNull;
22
23 import org.kuali.common.core.build.ValidatingBuilder;
24 import org.kuali.common.core.validate.annotation.IdiotProofImmutable;
25
26 import com.google.common.base.Optional;
27
28 @IdiotProofImmutable
29 public final class PutObjectResult {
30
31 private final String etag;
32 private final Optional<String> md5;
33 private final Optional<String> versionId;
34 private final Optional<Long> expirationTime;
35 private final Optional<String> expirationTimeRuleId;
36 private final Optional<SSEResult> sseResult;
37
38 private PutObjectResult(Builder builder) {
39 this.etag = builder.etag;
40 this.md5 = builder.md5;
41 this.versionId = builder.versionId;
42 this.expirationTime = builder.expirationTime;
43 this.expirationTimeRuleId = builder.expirationTimeRuleId;
44 this.sseResult = builder.sseResult;
45 }
46
47 public static PutObjectResult copyOf(com.amazonaws.services.s3.model.PutObjectResult mutable) {
48 Builder builder = builder();
49 builder.withEtag(mutable.getETag());
50 builder.withMd5(fromTrimToNull(mutable.getContentMd5()));
51 builder.withVersionId(fromTrimToNull(mutable.getVersionId()));
52 builder.withExpirationTime(fromNullableDate(mutable.getExpirationTime()));
53 builder.withExpirationTimeRuleId(fromTrimToNull(mutable.getExpirationTimeRuleId()));
54 builder.withSseResult(fromNullableSSE(mutable));
55 return builder.build();
56 }
57
58 public static Builder builder() {
59 return new Builder();
60 }
61
62 public static class Builder extends ValidatingBuilder<PutObjectResult> {
63
64 private String etag;
65 private Optional<String> md5;
66 private Optional<String> versionId = absent();
67 private Optional<Long> expirationTime = absent();
68 private Optional<String> expirationTimeRuleId = absent();
69 private Optional<SSEResult> sseResult = absent();
70
71 public Builder withSseResult(Optional<SSEResult> sseResult) {
72 this.sseResult = sseResult;
73 return this;
74 }
75
76 public Builder withEtag(String etag) {
77 this.etag = etag;
78 return this;
79 }
80
81 public Builder withMd5(Optional<String> md5) {
82 this.md5 = md5;
83 return this;
84 }
85
86 public Builder withVersionId(Optional<String> versionId) {
87 this.versionId = versionId;
88 return this;
89 }
90
91 public Builder withExpirationTime(Optional<Long> expirationTime) {
92 this.expirationTime = expirationTime;
93 return this;
94 }
95
96 public Builder withExpirationTimeRuleId(Optional<String> expirationTimeRuleId) {
97 this.expirationTimeRuleId = expirationTimeRuleId;
98 return this;
99 }
100
101 @Override
102 public PutObjectResult build() {
103 return validate(new PutObjectResult(this));
104 }
105 }
106
107 public String getEtag() {
108 return etag;
109 }
110
111 public Optional<String> getMd5() {
112 return md5;
113 }
114
115 public Optional<String> getVersionId() {
116 return versionId;
117 }
118
119 public Optional<Long> getExpirationTime() {
120 return expirationTime;
121 }
122
123 public Optional<String> getExpirationTimeRuleId() {
124 return expirationTimeRuleId;
125 }
126
127 public Optional<SSEResult> getSseResult() {
128 return sseResult;
129 }
130
131 }