Skip to content

Commit 9608e61

Browse files
committed
Add javadoc to Cors
1 parent e2a4500 commit 9608e61

1 file changed

Lines changed: 53 additions & 0 deletions

File tree

  • gcloud-java-storage/src/main/java/com/google/gcloud/storage

gcloud-java-storage/src/main/java/com/google/gcloud/storage/Cors.java

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@
3333

3434
/**
3535
* Cross-Origin Resource Sharing (CORS) configuration for a bucket.
36+
*
37+
* @see <a href="https://cloud.google.com/storage/docs/cross-origin">
38+
* Cross-Origin Resource Sharing (CORS)</a>
3639
*/
3740
public final class Cors implements Serializable {
3841

@@ -57,6 +60,9 @@ public Bucket.Cors apply(Cors cors) {
5760
private final ImmutableList<Origin> origins;
5861
private final ImmutableList<String> responseHeaders;
5962

63+
/**
64+
* Class for a CORS origin.
65+
*/
6066
public static final class Origin implements Serializable {
6167

6268
private static final long serialVersionUID = -4447958124895577993L;
@@ -69,10 +75,16 @@ private Origin(String value) {
6975
this.value = checkNotNull(value);
7076
}
7177

78+
/**
79+
* Returns an {@code Origin} object for all possible origins.
80+
*/
7281
public static Origin any() {
7382
return ANY;
7483
}
7584

85+
/**
86+
* Returns an {@code Origin} object for the given scheme, host and port.
87+
*/
7688
public static Origin of(String scheme, String host, int port) {
7789
try {
7890
return of(new URI(scheme, null, host, port, null, null, null).toString());
@@ -81,6 +93,9 @@ public static Origin of(String scheme, String host, int port) {
8193
}
8294
}
8395

96+
/**
97+
* Creates an {@code Origin} object for the provided value.
98+
*/
8499
public static Origin of(String value) {
85100
if (ANY_URI.equals(value)) {
86101
return any();
@@ -111,6 +126,9 @@ public String value() {
111126
}
112127
}
113128

129+
/**
130+
* CORS configuration builder.
131+
*/
114132
public static final class Builder {
115133

116134
private Integer maxAgeSeconds;
@@ -120,26 +138,42 @@ public static final class Builder {
120138

121139
private Builder() {}
122140

141+
/**
142+
* Sets the max time in seconds in which a client can issue requests before sending a new
143+
* preflight request.
144+
*/
123145
public Builder maxAgeSeconds(Integer maxAgeSeconds) {
124146
this.maxAgeSeconds = maxAgeSeconds;
125147
return this;
126148
}
127149

150+
/**
151+
* Sets the HTTP methods supported by this CORS configuration.
152+
*/
128153
public Builder methods(Iterable<HttpMethod> methods) {
129154
this.methods = methods != null ? ImmutableList.copyOf(methods) : null;
130155
return this;
131156
}
132157

158+
/**
159+
* Sets the origins for this CORS configuration.
160+
*/
133161
public Builder origins(Iterable<Origin> origins) {
134162
this.origins = origins != null ? ImmutableList.copyOf(origins) : null;
135163
return this;
136164
}
137165

166+
/**
167+
* Sets the response headers supported by this CORS configuration.
168+
*/
138169
public Builder responseHeaders(Iterable<String> headers) {
139170
this.responseHeaders = headers != null ? ImmutableList.copyOf(headers) : null;
140171
return this;
141172
}
142173

174+
/**
175+
* Creates a CORS configuration.
176+
*/
143177
public Cors build() {
144178
return new Cors(this);
145179
}
@@ -152,22 +186,38 @@ private Cors(Builder builder) {
152186
this.responseHeaders = builder.responseHeaders;
153187
}
154188

189+
/**
190+
* Returns the max time in seconds in which a client can issue requests before sending a new
191+
* preflight request.
192+
*/
155193
public Integer maxAgeSeconds() {
156194
return maxAgeSeconds;
157195
}
158196

197+
/**
198+
* Returns the HTTP methods supported by this CORS configuration.
199+
*/
159200
public List<HttpMethod> methods() {
160201
return methods;
161202
}
162203

204+
/**
205+
* Returns the origins in this CORS configuration.
206+
*/
163207
public List<Origin> origins() {
164208
return origins;
165209
}
166210

211+
/**
212+
* Returns the response headers supported by this CORS configuration.
213+
*/
167214
public List<String> responseHeaders() {
168215
return responseHeaders;
169216
}
170217

218+
/**
219+
* Returns a builder for this CORS configuration.
220+
*/
171221
public Builder toBuilder() {
172222
return builder()
173223
.maxAgeSeconds(maxAgeSeconds)
@@ -193,6 +243,9 @@ public boolean equals(Object obj) {
193243
&& Objects.equals(responseHeaders, other.responseHeaders);
194244
}
195245

246+
/**
247+
* Returns a CORS configuration builder.
248+
*/
196249
public static Builder builder() {
197250
return new Builder();
198251
}

0 commit comments

Comments
 (0)