3131 * @see <a href="https://cloud.google.com/storage/docs/xml-api/post-object">POST Object</a>
3232 */
3333public 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 ;
3636
3737 private PostPolicyV4 (String url , Map <String , String > fields ) {
3838 this .url = url ;
@@ -58,7 +58,7 @@ public Map<String, String> getFields() {
5858 * Object Form fields</a>
5959 */
6060 public static final class PostFieldsV4 {
61- private Map <String , String > fieldsMap ;
61+ private final Map <String , String > fieldsMap ;
6262
6363 private PostFieldsV4 (Builder builder ) {
6464 this .fieldsMap = builder .fieldsMap ;
@@ -81,10 +81,11 @@ public Map<String, String> getFieldsMap() {
8181 }
8282
8383 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 ;
8586
8687 private Builder () {
87- fieldsMap = new HashMap <>();
88+ this . fieldsMap = new HashMap <>();
8889 }
8990
9091 public PostFieldsV4 build () {
@@ -121,7 +122,13 @@ public Builder setContentType(String contentType) {
121122 return this ;
122123 }
123124
125+ /** @deprecated use {@link #setExpires(String)} */
126+ @ Deprecated
124127 public Builder Expires (String expires ) {
128+ return setExpires (expires );
129+ }
130+
131+ public Builder setExpires (String expires ) {
125132 fieldsMap .put ("expires" , expires );
126133 return this ;
127134 }
@@ -136,8 +143,17 @@ public Builder setSuccessActionStatus(int successActionStatus) {
136143 return this ;
137144 }
138145
146+ /** @deprecated use {@link #setCustomMetadataField(String, String)} */
147+ @ Deprecated
139148 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 );
141157 return this ;
142158 }
143159 }
@@ -270,8 +286,8 @@ Builder addCustomCondition(ConditionV4Type type, String field, String value) {
270286 * Policy document</a>
271287 */
272288 public static final class PostPolicyV4Document {
273- private String expiration ;
274- private PostConditionsV4 conditions ;
289+ private final String expiration ;
290+ private final PostConditionsV4 conditions ;
275291
276292 private PostPolicyV4Document (String expiration , PostConditionsV4 conditions ) {
277293 this .expiration = expiration ;
@@ -363,9 +379,9 @@ public enum ConditionV4Type {
363379 * Policy document</a>
364380 */
365381 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 ;
369385
370386 private ConditionV4 (ConditionV4Type type , String operand1 , String operand2 ) {
371387 this .type = type ;
0 commit comments