31
31
* @see <a href="https://cloud.google.com/storage/docs/xml-api/post-object">POST Object</a>
32
32
*/
33
33
public final class PostPolicyV4 {
34
- private String url ;
35
- private Map <String , String > fields ;
34
+ private final String url ;
35
+ private final Map <String , String > fields ;
36
36
37
37
private PostPolicyV4 (String url , Map <String , String > fields ) {
38
38
this .url = url ;
@@ -58,7 +58,7 @@ public Map<String, String> getFields() {
58
58
* Object Form fields</a>
59
59
*/
60
60
public static final class PostFieldsV4 {
61
- private Map <String , String > fieldsMap ;
61
+ private final Map <String , String > fieldsMap ;
62
62
63
63
private PostFieldsV4 (Builder builder ) {
64
64
this .fieldsMap = builder .fieldsMap ;
@@ -81,10 +81,11 @@ public Map<String, String> getFieldsMap() {
81
81
}
82
82
83
83
public static class Builder {
84
- private Map <String , String > fieldsMap ;
84
+ private static final String CUSTOM_FIELD_PREFIX = "x-goog-meta-" ;
85
+ private final Map <String , String > fieldsMap ;
85
86
86
87
private Builder () {
87
- fieldsMap = new HashMap <>();
88
+ this . fieldsMap = new HashMap <>();
88
89
}
89
90
90
91
public PostFieldsV4 build () {
@@ -121,7 +122,13 @@ public Builder setContentType(String contentType) {
121
122
return this ;
122
123
}
123
124
125
+ /** @deprecated use {@link #setExpires(String)} */
126
+ @ Deprecated
124
127
public Builder Expires (String expires ) {
128
+ return setExpires (expires );
129
+ }
130
+
131
+ public Builder setExpires (String expires ) {
125
132
fieldsMap .put ("expires" , expires );
126
133
return this ;
127
134
}
@@ -136,8 +143,17 @@ public Builder setSuccessActionStatus(int successActionStatus) {
136
143
return this ;
137
144
}
138
145
146
+ /** @deprecated use {@link #setCustomMetadataField(String, String)} */
147
+ @ Deprecated
139
148
public Builder AddCustomMetadataField (String field , String value ) {
140
- fieldsMap .put ("x-goog-meta-" + field , value );
149
+ return setCustomMetadataField (field , value );
150
+ }
151
+
152
+ public Builder setCustomMetadataField (String field , String value ) {
153
+ if (!field .startsWith (CUSTOM_FIELD_PREFIX )) {
154
+ field = CUSTOM_FIELD_PREFIX + value ;
155
+ }
156
+ fieldsMap .put (field , value );
141
157
return this ;
142
158
}
143
159
}
@@ -270,8 +286,8 @@ Builder addCustomCondition(ConditionV4Type type, String field, String value) {
270
286
* Policy document</a>
271
287
*/
272
288
public static final class PostPolicyV4Document {
273
- private String expiration ;
274
- private PostConditionsV4 conditions ;
289
+ private final String expiration ;
290
+ private final PostConditionsV4 conditions ;
275
291
276
292
private PostPolicyV4Document (String expiration , PostConditionsV4 conditions ) {
277
293
this .expiration = expiration ;
@@ -363,9 +379,9 @@ public enum ConditionV4Type {
363
379
* Policy document</a>
364
380
*/
365
381
static final class ConditionV4 {
366
- ConditionV4Type type ;
367
- String operand1 ;
368
- String operand2 ;
382
+ final ConditionV4Type type ;
383
+ final String operand1 ;
384
+ final String operand2 ;
369
385
370
386
private ConditionV4 (ConditionV4Type type , String operand1 , String operand2 ) {
371
387
this .type = type ;
0 commit comments