Skip to content

Commit 18bd90b

Browse files
committed
---
yaml --- r: 2191 b: refs/heads/pubsub-alpha c: c411b23 h: refs/heads/master i: 2189: 69183b4 2187: 8eea283 2183: cc34e4f 2175: 586a74e
1 parent 6a2ed6b commit 18bd90b

7 files changed

Lines changed: 34 additions & 28 deletions

File tree

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ refs/heads/master: 689bbb466df4b2d5d2483d6edb8ac5c7c7f7c6fa
33
refs/heads/travis: e21ee7b88a5edc3f3d8c71f90c3fc32abf7e8dd6
44
refs/heads/gh-pages: 4e0561bb4504bf647db669a14417b2b2c87ba45d
55
refs/heads/bigquery: 762fa5830e6c398c0396177e3e7fd243bd62cfc3
6-
refs/heads/pubsub-alpha: 973639a7b4092449106d5e300de16cc217da8eb1
6+
refs/heads/pubsub-alpha: c411b23813dc56e0d2a11271655cf6fb7717ca7c
77
refs/heads/resource-manager: ebf4adc5ee835cd2086c4ac5b4e78d01a5a005a7
88
refs/heads/update-datastore: 482954f2c5055231e5b3122ea91d2ba00ce8187c
99
refs/tags/0.0.9: 22f1839238f66c39e67ed4dfdcd273b1ae2e8444

branches/pubsub-alpha/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
}

branches/pubsub-alpha/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
}

branches/pubsub-alpha/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
}

branches/pubsub-alpha/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")

branches/pubsub-alpha/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";

branches/pubsub-alpha/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;

0 commit comments

Comments
 (0)