Skip to content

Commit ae16c9a

Browse files
fix(regen): undeprecate resourcenames until multi-pattern resource names are available (#108)
Source-Author: Yoshi Automation Bot <[email protected]> Source-Date: Mon Mar 2 09:14:38 2020 -0800 Source-Repo: googleapis/java-logging Source-Sha: 4ca5895 Source-Link: 4ca5895
1 parent 04991f0 commit ae16c9a

31 files changed

+13140
-0
lines changed
Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
/*
2+
* Copyright 2020 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.google.logging.type;
18+
19+
import com.google.api.pathtemplate.PathTemplate;
20+
import com.google.api.resourcenames.ResourceName;
21+
import com.google.common.base.Preconditions;
22+
import com.google.common.collect.ImmutableMap;
23+
import java.util.ArrayList;
24+
import java.util.List;
25+
import java.util.Map;
26+
27+
/** AUTO-GENERATED DOCUMENTATION AND CLASS */
28+
@javax.annotation.Generated("by GAPIC protoc plugin")
29+
public class BillingAccountLocationName implements ResourceName {
30+
31+
private static final PathTemplate PATH_TEMPLATE =
32+
PathTemplate.createWithoutUrlEncoding(
33+
"billingAccounts/{billing_account}/locations/{location}");
34+
35+
private volatile Map<String, String> fieldValuesMap;
36+
37+
private final String billingAccount;
38+
private final String location;
39+
40+
public String getBillingAccount() {
41+
return billingAccount;
42+
}
43+
44+
public String getLocation() {
45+
return location;
46+
}
47+
48+
public static Builder newBuilder() {
49+
return new Builder();
50+
}
51+
52+
public Builder toBuilder() {
53+
return new Builder(this);
54+
}
55+
56+
private BillingAccountLocationName(Builder builder) {
57+
billingAccount = Preconditions.checkNotNull(builder.getBillingAccount());
58+
location = Preconditions.checkNotNull(builder.getLocation());
59+
}
60+
61+
public static BillingAccountLocationName of(String billingAccount, String location) {
62+
return newBuilder().setBillingAccount(billingAccount).setLocation(location).build();
63+
}
64+
65+
public static String format(String billingAccount, String location) {
66+
return newBuilder().setBillingAccount(billingAccount).setLocation(location).build().toString();
67+
}
68+
69+
public static BillingAccountLocationName parse(String formattedString) {
70+
if (formattedString.isEmpty()) {
71+
return null;
72+
}
73+
Map<String, String> matchMap =
74+
PATH_TEMPLATE.validatedMatch(
75+
formattedString,
76+
"BillingAccountLocationName.parse: formattedString not in valid format");
77+
return of(matchMap.get("billing_account"), matchMap.get("location"));
78+
}
79+
80+
public static List<BillingAccountLocationName> parseList(List<String> formattedStrings) {
81+
List<BillingAccountLocationName> list = new ArrayList<>(formattedStrings.size());
82+
for (String formattedString : formattedStrings) {
83+
list.add(parse(formattedString));
84+
}
85+
return list;
86+
}
87+
88+
public static List<String> toStringList(List<BillingAccountLocationName> values) {
89+
List<String> list = new ArrayList<String>(values.size());
90+
for (BillingAccountLocationName value : values) {
91+
if (value == null) {
92+
list.add("");
93+
} else {
94+
list.add(value.toString());
95+
}
96+
}
97+
return list;
98+
}
99+
100+
public static boolean isParsableFrom(String formattedString) {
101+
return PATH_TEMPLATE.matches(formattedString);
102+
}
103+
104+
public Map<String, String> getFieldValuesMap() {
105+
if (fieldValuesMap == null) {
106+
synchronized (this) {
107+
if (fieldValuesMap == null) {
108+
ImmutableMap.Builder<String, String> fieldMapBuilder = ImmutableMap.builder();
109+
fieldMapBuilder.put("billingAccount", billingAccount);
110+
fieldMapBuilder.put("location", location);
111+
fieldValuesMap = fieldMapBuilder.build();
112+
}
113+
}
114+
}
115+
return fieldValuesMap;
116+
}
117+
118+
public String getFieldValue(String fieldName) {
119+
return getFieldValuesMap().get(fieldName);
120+
}
121+
122+
@Override
123+
public String toString() {
124+
return PATH_TEMPLATE.instantiate("billing_account", billingAccount, "location", location);
125+
}
126+
127+
/** Builder for BillingAccountLocationName. */
128+
public static class Builder {
129+
130+
private String billingAccount;
131+
private String location;
132+
133+
public String getBillingAccount() {
134+
return billingAccount;
135+
}
136+
137+
public String getLocation() {
138+
return location;
139+
}
140+
141+
public Builder setBillingAccount(String billingAccount) {
142+
this.billingAccount = billingAccount;
143+
return this;
144+
}
145+
146+
public Builder setLocation(String location) {
147+
this.location = location;
148+
return this;
149+
}
150+
151+
private Builder() {}
152+
153+
private Builder(BillingAccountLocationName billingAccountLocationName) {
154+
billingAccount = billingAccountLocationName.billingAccount;
155+
location = billingAccountLocationName.location;
156+
}
157+
158+
public BillingAccountLocationName build() {
159+
return new BillingAccountLocationName(this);
160+
}
161+
}
162+
163+
@Override
164+
public boolean equals(Object o) {
165+
if (o == this) {
166+
return true;
167+
}
168+
if (o instanceof BillingAccountLocationName) {
169+
BillingAccountLocationName that = (BillingAccountLocationName) o;
170+
return (this.billingAccount.equals(that.billingAccount))
171+
&& (this.location.equals(that.location));
172+
}
173+
return false;
174+
}
175+
176+
@Override
177+
public int hashCode() {
178+
int h = 1;
179+
h *= 1000003;
180+
h ^= billingAccount.hashCode();
181+
h *= 1000003;
182+
h ^= location.hashCode();
183+
return h;
184+
}
185+
}
Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
/*
2+
* Copyright 2020 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.google.logging.type;
18+
19+
import com.google.api.pathtemplate.PathTemplate;
20+
import com.google.api.resourcenames.ResourceName;
21+
import com.google.common.base.Preconditions;
22+
import com.google.common.collect.ImmutableMap;
23+
import java.util.ArrayList;
24+
import java.util.List;
25+
import java.util.Map;
26+
27+
/** AUTO-GENERATED DOCUMENTATION AND CLASS */
28+
@javax.annotation.Generated("by GAPIC protoc plugin")
29+
public class BillingAccountName implements ResourceName {
30+
31+
private static final PathTemplate PATH_TEMPLATE =
32+
PathTemplate.createWithoutUrlEncoding("billingAccounts/{billing_account}");
33+
34+
private volatile Map<String, String> fieldValuesMap;
35+
36+
private final String billingAccount;
37+
38+
public String getBillingAccount() {
39+
return billingAccount;
40+
}
41+
42+
public static Builder newBuilder() {
43+
return new Builder();
44+
}
45+
46+
public Builder toBuilder() {
47+
return new Builder(this);
48+
}
49+
50+
private BillingAccountName(Builder builder) {
51+
billingAccount = Preconditions.checkNotNull(builder.getBillingAccount());
52+
}
53+
54+
public static BillingAccountName of(String billingAccount) {
55+
return newBuilder().setBillingAccount(billingAccount).build();
56+
}
57+
58+
public static String format(String billingAccount) {
59+
return newBuilder().setBillingAccount(billingAccount).build().toString();
60+
}
61+
62+
public static BillingAccountName parse(String formattedString) {
63+
if (formattedString.isEmpty()) {
64+
return null;
65+
}
66+
Map<String, String> matchMap =
67+
PATH_TEMPLATE.validatedMatch(
68+
formattedString, "BillingAccountName.parse: formattedString not in valid format");
69+
return of(matchMap.get("billing_account"));
70+
}
71+
72+
public static List<BillingAccountName> parseList(List<String> formattedStrings) {
73+
List<BillingAccountName> list = new ArrayList<>(formattedStrings.size());
74+
for (String formattedString : formattedStrings) {
75+
list.add(parse(formattedString));
76+
}
77+
return list;
78+
}
79+
80+
public static List<String> toStringList(List<BillingAccountName> values) {
81+
List<String> list = new ArrayList<String>(values.size());
82+
for (BillingAccountName value : values) {
83+
if (value == null) {
84+
list.add("");
85+
} else {
86+
list.add(value.toString());
87+
}
88+
}
89+
return list;
90+
}
91+
92+
public static boolean isParsableFrom(String formattedString) {
93+
return PATH_TEMPLATE.matches(formattedString);
94+
}
95+
96+
public Map<String, String> getFieldValuesMap() {
97+
if (fieldValuesMap == null) {
98+
synchronized (this) {
99+
if (fieldValuesMap == null) {
100+
ImmutableMap.Builder<String, String> fieldMapBuilder = ImmutableMap.builder();
101+
fieldMapBuilder.put("billingAccount", billingAccount);
102+
fieldValuesMap = fieldMapBuilder.build();
103+
}
104+
}
105+
}
106+
return fieldValuesMap;
107+
}
108+
109+
public String getFieldValue(String fieldName) {
110+
return getFieldValuesMap().get(fieldName);
111+
}
112+
113+
@Override
114+
public String toString() {
115+
return PATH_TEMPLATE.instantiate("billing_account", billingAccount);
116+
}
117+
118+
/** Builder for BillingAccountName. */
119+
public static class Builder {
120+
121+
private String billingAccount;
122+
123+
public String getBillingAccount() {
124+
return billingAccount;
125+
}
126+
127+
public Builder setBillingAccount(String billingAccount) {
128+
this.billingAccount = billingAccount;
129+
return this;
130+
}
131+
132+
private Builder() {}
133+
134+
private Builder(BillingAccountName billingAccountName) {
135+
billingAccount = billingAccountName.billingAccount;
136+
}
137+
138+
public BillingAccountName build() {
139+
return new BillingAccountName(this);
140+
}
141+
}
142+
143+
@Override
144+
public boolean equals(Object o) {
145+
if (o == this) {
146+
return true;
147+
}
148+
if (o instanceof BillingAccountName) {
149+
BillingAccountName that = (BillingAccountName) o;
150+
return (this.billingAccount.equals(that.billingAccount));
151+
}
152+
return false;
153+
}
154+
155+
@Override
156+
public int hashCode() {
157+
int h = 1;
158+
h *= 1000003;
159+
h ^= billingAccount.hashCode();
160+
return h;
161+
}
162+
}

0 commit comments

Comments
 (0)