Skip to content

Commit cdb801f

Browse files
committed
---
yaml --- r: 1597 b: refs/heads/master c: 3f7626d h: refs/heads/master i: 1595: 1b81683
1 parent d75f018 commit cdb801f

12 files changed

Lines changed: 59 additions & 49 deletions

File tree

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 55ee5aa0aaeb0d4adcb9228119f6239e6e5442e4
2+
refs/heads/master: 3f7626d529dc7788d46e4d54fba6898a994f5f1c
33
refs/heads/travis: e21ee7b88a5edc3f3d8c71f90c3fc32abf7e8dd6
44
refs/heads/gh-pages: d1b373c30c176edc08692348167bec3a244bb823
55
refs/heads/bigquery: 762fa5830e6c398c0396177e3e7fd243bd62cfc3

trunk/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/Acl.java

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -370,22 +370,11 @@ Access toPb() {
370370
}
371371
}
372372

373-
/**
374-
* Build an ACL for an {@code entity} and a {@code role}.
375-
*/
376-
public Acl(Entity entity, Role role) {
373+
private Acl(Entity entity, Role role) {
377374
this.entity = checkNotNull(entity);
378375
this.role = role;
379376
}
380377

381-
/**
382-
* Build an ACL for a view entity.
383-
*/
384-
public Acl(View view) {
385-
this.entity = checkNotNull(view);
386-
this.role = null;
387-
}
388-
389378
/**
390379
* Returns the entity for this ACL.
391380
*/
@@ -400,6 +389,23 @@ public Role role() {
400389
return role;
401390
}
402391

392+
/**
393+
* Returns an Acl object.
394+
*
395+
* @param entity the entity for this ACL object
396+
* @param role the role to associate to the {@code entity} object
397+
*/
398+
public static Acl of(Entity entity, Role role) {
399+
return new Acl(entity, role);
400+
}
401+
402+
/**
403+
* Returns an Acl object for a view entity.
404+
*/
405+
public static Acl of(View view) {
406+
return new Acl(view, null);
407+
}
408+
403409
@Override
404410
public int hashCode() {
405411
return Objects.hash(entity, role);
@@ -432,7 +438,7 @@ Access toPb() {
432438
}
433439

434440
static Acl fromPb(Access access) {
435-
return new Acl(Entity.fromPb(access),
441+
return Acl.of(Entity.fromPb(access),
436442
access.getRole() != null ? Role.valueOf(access.getRole()) : null);
437443
}
438444
}

trunk/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/BigQueryImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,7 @@ private DatasetInfo setProjectId(DatasetInfo dataset) {
621621
if (viewReferencePb.getProjectId() == null) {
622622
viewReferencePb.setProjectId(options().projectId());
623623
}
624-
acls.add(new Acl(new Acl.View(TableId.fromPb(viewReferencePb))));
624+
acls.add(Acl.of(new Acl.View(TableId.fromPb(viewReferencePb))));
625625
} else {
626626
acls.add(acl);
627627
}

trunk/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/AclTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,14 @@ public void testViewEntity() {
8181
}
8282

8383
@Test
84-
public void testAcl() {
85-
Acl acl = new Acl(Group.ofAllAuthenticatedUsers(), Role.READER);
84+
public void testOf() {
85+
Acl acl = Acl.of(Group.ofAllAuthenticatedUsers(), Role.READER);
8686
assertEquals(Group.ofAllAuthenticatedUsers(), acl.entity());
8787
assertEquals(Role.READER, acl.role());
8888
Dataset.Access pb = acl.toPb();
8989
assertEquals(acl, Acl.fromPb(pb));
9090
View view = new View(TableId.of("project", "dataset", "view"));
91-
acl = new Acl(view);
91+
acl = Acl.of(view);
9292
assertEquals(view, acl.entity());
9393
assertEquals(null, acl.role());
9494
}

trunk/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/BigQueryImplTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,11 @@ public class BigQueryImplTest {
6868
private static final String OTHER_TABLE = "otherTable";
6969
private static final String OTHER_DATASET = "otherDataset";
7070
private static final List<Acl> ACCESS_RULES = ImmutableList.of(
71-
new Acl(Acl.Group.ofAllAuthenticatedUsers(), Acl.Role.READER),
72-
new Acl(new Acl.View(TableId.of("dataset", "table")), Acl.Role.WRITER));
71+
Acl.of(Acl.Group.ofAllAuthenticatedUsers(), Acl.Role.READER),
72+
Acl.of(new Acl.View(TableId.of("dataset", "table")), Acl.Role.WRITER));
7373
private static final List<Acl> ACCESS_RULES_WITH_PROJECT = ImmutableList.of(
74-
new Acl(Acl.Group.ofAllAuthenticatedUsers(), Acl.Role.READER),
75-
new Acl(new Acl.View(TableId.of(PROJECT, "dataset", "table"))));
74+
Acl.of(Acl.Group.ofAllAuthenticatedUsers(), Acl.Role.READER),
75+
Acl.of(new Acl.View(TableId.of(PROJECT, "dataset", "table"))));
7676
private static final DatasetInfo DATASET_INFO = DatasetInfo.builder(DATASET)
7777
.acl(ACCESS_RULES)
7878
.description("description")

trunk/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/DatasetInfoTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
public class DatasetInfoTest {
2929

3030
private static final List<Acl> ACCESS_RULES = ImmutableList.of(
31-
new Acl(Acl.Group.ofAllAuthenticatedUsers(), Acl.Role.READER),
32-
new Acl(new Acl.View(TableId.of("project", "dataset", "table")), Acl.Role.WRITER));
31+
Acl.of(Acl.Group.ofAllAuthenticatedUsers(), Acl.Role.READER),
32+
Acl.of(new Acl.View(TableId.of("project", "dataset", "table")), Acl.Role.WRITER));
3333
private static final Long CREATION_TIME = System.currentTimeMillis();
3434
private static final Long DEFAULT_TABLE_EXPIRATION = CREATION_TIME + 100;
3535
private static final String DESCRIPTION = "description";

trunk/gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/SerializationTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,12 @@
4242
public class SerializationTest {
4343

4444
private static final Acl DOMAIN_ACCESS =
45-
new Acl(new Acl.Domain("domain"), Acl.Role.WRITER);
45+
Acl.of(new Acl.Domain("domain"), Acl.Role.WRITER);
4646
private static final Acl GROUP_ACCESS =
47-
new Acl(Acl.Group.ofAllAuthenticatedUsers(), Acl.Role.READER);
48-
private static final Acl USER_ACCESS = new Acl(new Acl.User("user"), Acl.Role.OWNER);
47+
Acl.of(Acl.Group.ofAllAuthenticatedUsers(), Acl.Role.READER);
48+
private static final Acl USER_ACCESS = Acl.of(new Acl.User("user"), Acl.Role.OWNER);
4949
private static final Acl VIEW_ACCESS =
50-
new Acl(new Acl.View(TableId.of("project", "dataset", "table")), Acl.Role.WRITER);
50+
Acl.of(new Acl.View(TableId.of("project", "dataset", "table")), Acl.Role.WRITER);
5151
private static final List<Acl> ACCESS_RULES = ImmutableList.of(DOMAIN_ACCESS, GROUP_ACCESS,
5252
VIEW_ACCESS, USER_ACCESS);
5353
private static final Long CREATION_TIME = System.currentTimeMillis() - 10;

trunk/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Acl.java

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -274,13 +274,7 @@ String toPb() {
274274
}
275275
}
276276

277-
/**
278-
* Creates an ACL object.
279-
*
280-
* @param entity the entity for this ACL object
281-
* @param role the role to associate to the {@code entity} object
282-
*/
283-
public Acl(Entity entity, Role role) {
277+
private Acl(Entity entity, Role role) {
284278
this.entity = entity;
285279
this.role = role;
286280
}
@@ -299,6 +293,16 @@ public Role role() {
299293
return role;
300294
}
301295

296+
/**
297+
* Returns an Acl object.
298+
*
299+
* @param entity the entity for this ACL object
300+
* @param role the role to associate to the {@code entity} object
301+
*/
302+
public static Acl of(Entity entity, Role role) {
303+
return new Acl(entity, role);
304+
}
305+
302306
@Override
303307
public int hashCode() {
304308
return Objects.hash(entity, role);
@@ -333,11 +337,11 @@ ObjectAccessControl toObjectPb() {
333337

334338
static Acl fromPb(ObjectAccessControl objectAccessControl) {
335339
Role role = Role.valueOf(objectAccessControl.getRole());
336-
return new Acl(Entity.fromPb(objectAccessControl.getEntity()), role);
340+
return Acl.of(Entity.fromPb(objectAccessControl.getEntity()), role);
337341
}
338342

339343
static Acl fromPb(BucketAccessControl bucketAccessControl) {
340344
Role role = Role.valueOf(bucketAccessControl.getRole());
341-
return new Acl(Entity.fromPb(bucketAccessControl.getEntity()), role);
345+
return Acl.of(Entity.fromPb(bucketAccessControl.getEntity()), role);
342346
}
343347
}

trunk/gcloud-java-storage/src/test/java/com/google/gcloud/storage/AclTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ public void testRawEntity() {
8282

8383

8484
@Test
85-
public void testAcl() {
86-
Acl acl = new Acl(User.ofAllUsers(), Role.READER);
85+
public void testOf() {
86+
Acl acl = Acl.of(User.ofAllUsers(), Role.READER);
8787
assertEquals(User.ofAllUsers(), acl.entity());
8888
assertEquals(Role.READER, acl.role());
8989
ObjectAccessControl objectPb = acl.toObjectPb();

trunk/gcloud-java-storage/src/test/java/com/google/gcloud/storage/BlobInfoTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@
3434
public class BlobInfoTest {
3535

3636
private static final List<Acl> ACL = ImmutableList.of(
37-
new Acl(User.ofAllAuthenticatedUsers(), READER),
38-
new Acl(new Project(VIEWERS, "p1"), WRITER));
37+
Acl.of(User.ofAllAuthenticatedUsers(), READER),
38+
Acl.of(new Project(VIEWERS, "p1"), WRITER));
3939
private static final Integer COMPONENT_COUNT = 2;
4040
private static final String CONTENT_TYPE = "text/html";
4141
private static final String CACHE_CONTROL = "cache";

0 commit comments

Comments
 (0)