Skip to content

Commit

Permalink
fix(resnames): Fix resname builder name conflicts in ctor with this a…
Browse files Browse the repository at this point in the history
…ssignment (#769)
  • Loading branch information
miraleung committed Jun 16, 2021
1 parent 4f187b1 commit edac844
Show file tree
Hide file tree
Showing 38 changed files with 84 additions and 83 deletions.
Expand Up @@ -1632,7 +1632,8 @@ private static ClassDefinition createNestedBuilderClass(
for (int i = 0; i < tokens.size(); i++) {
String token = tokens.get(i);
String lowerCamelTokenName = JavaStyle.toLowerCamelCase(token);
VariableExpr currClassTokenVarExpr = classMemberVarExprs.get(i);
VariableExpr currClassTokenVarExpr =
classMemberVarExprs.get(i).toBuilder().setExprReferenceExpr(thisExpr).build();
builderCtorBodyExprs.add(
AssignmentExpr.builder()
.setVariableExpr(currClassTokenVarExpr)
Expand Down
Expand Up @@ -217,8 +217,8 @@ public class AgentName implements ResourceName {
Preconditions.checkArgument(
Objects.equals(agentName.pathTemplate, PROJECT_LOCATION),
"toBuilder is only supported when AgentName has the pattern of projects/{project}/locations/{location}/agent");
project = agentName.project;
location = agentName.location;
this.project = agentName.project;
this.location = agentName.location;
}

public AgentName build() {
Expand Down
Expand Up @@ -168,8 +168,8 @@ public class BillingAccountLocationName implements ResourceName {
}

private Builder(BillingAccountLocationName billingAccountLocationName) {
billingAccount = billingAccountLocationName.billingAccount;
location = billingAccountLocationName.location;
this.billingAccount = billingAccountLocationName.billingAccount;
this.location = billingAccountLocationName.location;
}

public BillingAccountLocationName build() {
Expand Down
Expand Up @@ -317,8 +317,8 @@ public class FoobarName implements ResourceName {
Preconditions.checkArgument(
Objects.equals(foobarName.pathTemplate, PROJECT_FOOBAR),
"toBuilder is only supported when FoobarName has the pattern of projects/{project}/foobars/{foobar}");
project = foobarName.project;
foobar = foobarName.foobar;
this.project = foobarName.project;
this.foobar = foobarName.foobar;
}

public FoobarName build() {
Expand Down
Expand Up @@ -142,7 +142,7 @@ public class SessionName implements ResourceName {
}

private Builder(SessionName sessionName) {
session = sessionName.session;
this.session = sessionName.session;
}

public SessionName build() {
Expand Down
Expand Up @@ -194,9 +194,9 @@ public class TestName implements ResourceName {
}

private Builder(TestName testName) {
session = testName.session;
shardId = testName.shardId;
testId = testName.testId;
this.session = testName.session;
this.shardId = testName.shardId;
this.testId = testName.testId;
}

public TestName build() {
Expand Down
Expand Up @@ -295,8 +295,8 @@ private Builder(FeedName feedName) {
Preconditions.checkArgument(
Objects.equals(feedName.pathTemplate, PROJECT_FEED),
"toBuilder is only supported when FeedName has the pattern of projects/{project}/feeds/{feed}");
project = feedName.project;
feed = feedName.feed;
this.project = feedName.project;
this.feed = feedName.feed;
}

public FeedName build() {
Expand Down
Expand Up @@ -182,8 +182,8 @@ public Builder setServiceAccount(String serviceAccount) {
}

private Builder(ServiceAccountName serviceAccountName) {
project = serviceAccountName.project;
serviceAccount = serviceAccountName.serviceAccount;
this.project = serviceAccountName.project;
this.serviceAccount = serviceAccountName.serviceAccount;
}

public ServiceAccountName build() {
Expand Down
Expand Up @@ -248,10 +248,10 @@ public Builder setCryptoKey(String cryptoKey) {
}

private Builder(CryptoKeyName cryptoKeyName) {
project = cryptoKeyName.project;
location = cryptoKeyName.location;
keyRing = cryptoKeyName.keyRing;
cryptoKey = cryptoKeyName.cryptoKey;
this.project = cryptoKeyName.project;
this.location = cryptoKeyName.location;
this.keyRing = cryptoKeyName.keyRing;
this.cryptoKey = cryptoKeyName.cryptoKey;
}

public CryptoKeyName build() {
Expand Down
Expand Up @@ -284,11 +284,11 @@ public Builder setCryptoKeyVersion(String cryptoKeyVersion) {
}

private Builder(CryptoKeyVersionName cryptoKeyVersionName) {
project = cryptoKeyVersionName.project;
location = cryptoKeyVersionName.location;
keyRing = cryptoKeyVersionName.keyRing;
cryptoKey = cryptoKeyVersionName.cryptoKey;
cryptoKeyVersion = cryptoKeyVersionName.cryptoKeyVersion;
this.project = cryptoKeyVersionName.project;
this.location = cryptoKeyVersionName.location;
this.keyRing = cryptoKeyVersionName.keyRing;
this.cryptoKey = cryptoKeyVersionName.cryptoKey;
this.cryptoKeyVersion = cryptoKeyVersionName.cryptoKeyVersion;
}

public CryptoKeyVersionName build() {
Expand Down
Expand Up @@ -248,10 +248,10 @@ public Builder setImportJob(String importJob) {
}

private Builder(ImportJobName importJobName) {
project = importJobName.project;
location = importJobName.location;
keyRing = importJobName.keyRing;
importJob = importJobName.importJob;
this.project = importJobName.project;
this.location = importJobName.location;
this.keyRing = importJobName.keyRing;
this.importJob = importJobName.importJob;
}

public ImportJobName build() {
Expand Down
Expand Up @@ -211,9 +211,9 @@ public Builder setKeyRing(String keyRing) {
}

private Builder(KeyRingName keyRingName) {
project = keyRingName.project;
location = keyRingName.location;
keyRing = keyRingName.keyRing;
this.project = keyRingName.project;
this.location = keyRingName.location;
this.keyRing = keyRingName.keyRing;
}

public KeyRingName build() {
Expand Down
Expand Up @@ -181,8 +181,8 @@ public Builder setLocation(String location) {
}

private Builder(LocationName locationName) {
project = locationName.project;
location = locationName.location;
this.project = locationName.project;
this.location = locationName.location;
}

public LocationName build() {
Expand Down
Expand Up @@ -284,11 +284,11 @@ public Builder setCryptoKeyVersion(String cryptoKeyVersion) {
}

private Builder(PublicKeyName publicKeyName) {
project = publicKeyName.project;
location = publicKeyName.location;
keyRing = publicKeyName.keyRing;
cryptoKey = publicKeyName.cryptoKey;
cryptoKeyVersion = publicKeyName.cryptoKeyVersion;
this.project = publicKeyName.project;
this.location = publicKeyName.location;
this.keyRing = publicKeyName.keyRing;
this.cryptoKey = publicKeyName.cryptoKey;
this.cryptoKeyVersion = publicKeyName.cryptoKeyVersion;
}

public PublicKeyName build() {
Expand Down
Expand Up @@ -180,8 +180,8 @@ public Builder setBook(String book) {
}

private Builder(BookName bookName) {
shelf = bookName.shelf;
book = bookName.book;
this.shelf = bookName.shelf;
this.book = bookName.book;
}

public BookName build() {
Expand Down
Expand Up @@ -158,7 +158,7 @@ public Builder setShelfId(String shelfId) {
}

private Builder(ShelfName shelfName) {
shelfId = shelfName.shelfId;
this.shelfId = shelfName.shelfId;
}

public ShelfName build() {
Expand Down
Expand Up @@ -184,8 +184,8 @@ public Builder setLocation(String location) {
}

private Builder(BillingAccountLocationName billingAccountLocationName) {
billingAccount = billingAccountLocationName.billingAccount;
location = billingAccountLocationName.location;
this.billingAccount = billingAccountLocationName.billingAccount;
this.location = billingAccountLocationName.location;
}

public BillingAccountLocationName build() {
Expand Down
Expand Up @@ -158,7 +158,7 @@ public Builder setBillingAccount(String billingAccount) {
}

private Builder(BillingAccountName billingAccountName) {
billingAccount = billingAccountName.billingAccount;
this.billingAccount = billingAccountName.billingAccount;
}

public BillingAccountName build() {
Expand Down
Expand Up @@ -310,7 +310,7 @@ private Builder(CmekSettingsName cmekSettingsName) {
Preconditions.checkArgument(
Objects.equals(cmekSettingsName.pathTemplate, PROJECT),
"toBuilder is only supported when CmekSettingsName has the pattern of projects/{project}/cmekSettings");
project = cmekSettingsName.project;
this.project = cmekSettingsName.project;
}

public CmekSettingsName build() {
Expand Down
Expand Up @@ -181,8 +181,8 @@ public Builder setLocation(String location) {
}

private Builder(FolderLocationName folderLocationName) {
folder = folderLocationName.folder;
location = folderLocationName.location;
this.folder = folderLocationName.folder;
this.location = folderLocationName.location;
}

public FolderLocationName build() {
Expand Down
Expand Up @@ -158,7 +158,7 @@ public Builder setFolder(String folder) {
}

private Builder(FolderName folderName) {
folder = folderName.folder;
this.folder = folderName.folder;
}

public FolderName build() {
Expand Down
Expand Up @@ -181,8 +181,8 @@ public Builder setLocation(String location) {
}

private Builder(LocationName locationName) {
project = locationName.project;
location = locationName.location;
this.project = locationName.project;
this.location = locationName.location;
}

public LocationName build() {
Expand Down
Expand Up @@ -415,9 +415,9 @@ private Builder(LogBucketName logBucketName) {
Preconditions.checkArgument(
Objects.equals(logBucketName.pathTemplate, PROJECT_LOCATION_BUCKET),
"toBuilder is only supported when LogBucketName has the pattern of projects/{project}/locations/{location}/buckets/{bucket}");
project = logBucketName.project;
location = logBucketName.location;
bucket = logBucketName.bucket;
this.project = logBucketName.project;
this.location = logBucketName.location;
this.bucket = logBucketName.bucket;
}

public LogBucketName build() {
Expand Down
Expand Up @@ -354,8 +354,8 @@ private Builder(LogExclusionName logExclusionName) {
Preconditions.checkArgument(
Objects.equals(logExclusionName.pathTemplate, PROJECT_EXCLUSION),
"toBuilder is only supported when LogExclusionName has the pattern of projects/{project}/exclusions/{exclusion}");
project = logExclusionName.project;
exclusion = logExclusionName.exclusion;
this.project = logExclusionName.project;
this.exclusion = logExclusionName.exclusion;
}

public LogExclusionName build() {
Expand Down
Expand Up @@ -180,8 +180,8 @@ public Builder setMetric(String metric) {
}

private Builder(LogMetricName logMetricName) {
project = logMetricName.project;
metric = logMetricName.metric;
this.project = logMetricName.project;
this.metric = logMetricName.metric;
}

public LogMetricName build() {
Expand Down
Expand Up @@ -340,8 +340,8 @@ private Builder(LogName logName) {
Preconditions.checkArgument(
Objects.equals(logName.pathTemplate, PROJECT_LOG),
"toBuilder is only supported when LogName has the pattern of projects/{project}/logs/{log}");
project = logName.project;
log = logName.log;
this.project = logName.project;
this.log = logName.log;
}

public LogName build() {
Expand Down
Expand Up @@ -344,8 +344,8 @@ private Builder(LogSinkName logSinkName) {
Preconditions.checkArgument(
Objects.equals(logSinkName.pathTemplate, PROJECT_SINK),
"toBuilder is only supported when LogSinkName has the pattern of projects/{project}/sinks/{sink}");
project = logSinkName.project;
sink = logSinkName.sink;
this.project = logSinkName.project;
this.sink = logSinkName.sink;
}

public LogSinkName build() {
Expand Down
Expand Up @@ -472,10 +472,10 @@ private Builder(LogViewName logViewName) {
Preconditions.checkArgument(
Objects.equals(logViewName.pathTemplate, PROJECT_LOCATION_BUCKET_VIEW),
"toBuilder is only supported when LogViewName has the pattern of projects/{project}/locations/{location}/buckets/{bucket}/views/{view}");
project = logViewName.project;
location = logViewName.location;
bucket = logViewName.bucket;
view = logViewName.view;
this.project = logViewName.project;
this.location = logViewName.location;
this.bucket = logViewName.bucket;
this.view = logViewName.view;
}

public LogViewName build() {
Expand Down
Expand Up @@ -181,8 +181,8 @@ public Builder setLocation(String location) {
}

private Builder(OrganizationLocationName organizationLocationName) {
organization = organizationLocationName.organization;
location = organizationLocationName.location;
this.organization = organizationLocationName.organization;
this.location = organizationLocationName.location;
}

public OrganizationLocationName build() {
Expand Down
Expand Up @@ -158,7 +158,7 @@ public Builder setOrganization(String organization) {
}

private Builder(OrganizationName organizationName) {
organization = organizationName.organization;
this.organization = organizationName.organization;
}

public OrganizationName build() {
Expand Down
Expand Up @@ -158,7 +158,7 @@ public Builder setProject(String project) {
}

private Builder(ProjectName projectName) {
project = projectName.project;
this.project = projectName.project;
}

public ProjectName build() {
Expand Down
Expand Up @@ -158,7 +158,7 @@ public Builder setProject(String project) {
}

private Builder(ProjectName projectName) {
project = projectName.project;
this.project = projectName.project;
}

public ProjectName build() {
Expand Down
Expand Up @@ -180,8 +180,8 @@ public Builder setSchema(String schema) {
}

private Builder(SchemaName schemaName) {
project = schemaName.project;
schema = schemaName.schema;
this.project = schemaName.project;
this.schema = schemaName.schema;
}

public SchemaName build() {
Expand Down
Expand Up @@ -181,8 +181,8 @@ public Builder setSnapshot(String snapshot) {
}

private Builder(SnapshotName snapshotName) {
project = snapshotName.project;
snapshot = snapshotName.snapshot;
this.project = snapshotName.project;
this.snapshot = snapshotName.snapshot;
}

public SnapshotName build() {
Expand Down
Expand Up @@ -181,8 +181,8 @@ public Builder setSubscription(String subscription) {
}

private Builder(SubscriptionName subscriptionName) {
project = subscriptionName.project;
subscription = subscriptionName.subscription;
this.project = subscriptionName.project;
this.subscription = subscriptionName.subscription;
}

public SubscriptionName build() {
Expand Down

0 comments on commit edac844

Please sign in to comment.