Skip to content
This repository was archived by the owner on Sep 9, 2023. It is now read-only.

Commit 7835807

Browse files
feat: add enhanced types for library (#74)
This PR was generated using Autosynth. 🌈 Synth log will be available here: https://source.cloud.google.com/results/invocations/ffd44120-5a95-4fa3-8daf-5288f5fc3a5f/targets - [ ] To automatically regenerate this PR, check this box. PiperOrigin-RevId: 342967619 Source-Link: googleapis/googleapis@e3e7e7d
1 parent accad72 commit 7835807

File tree

268 files changed

+115046
-7
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

268 files changed

+115046
-7
lines changed

.github/workflows/formatting.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
with:
1919
java-version: 11
2020
- run: "mvn com.coveo:fmt-maven-plugin:format"
21-
- uses: googleapis/code-suggester@v1.8.1
21+
- uses: googleapis/code-suggester@v1.8.0
2222
with:
2323
command: review
2424
pull_number: ${{ github.event.pull_request.number }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,277 @@
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.cloud.aiplatform.v1beta1.schema;
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 AnnotationName implements ResourceName {
30+
31+
private static final PathTemplate PATH_TEMPLATE =
32+
PathTemplate.createWithoutUrlEncoding(
33+
"projects/{project}/locations/{location}/datasets/{dataset}/dataItems/{data_item}/annotations/{annotation}");
34+
35+
private volatile Map<String, String> fieldValuesMap;
36+
37+
private final String project;
38+
private final String location;
39+
private final String dataset;
40+
private final String dataItem;
41+
private final String annotation;
42+
43+
public String getProject() {
44+
return project;
45+
}
46+
47+
public String getLocation() {
48+
return location;
49+
}
50+
51+
public String getDataset() {
52+
return dataset;
53+
}
54+
55+
public String getDataItem() {
56+
return dataItem;
57+
}
58+
59+
public String getAnnotation() {
60+
return annotation;
61+
}
62+
63+
public static Builder newBuilder() {
64+
return new Builder();
65+
}
66+
67+
public Builder toBuilder() {
68+
return new Builder(this);
69+
}
70+
71+
private AnnotationName(Builder builder) {
72+
project = Preconditions.checkNotNull(builder.getProject());
73+
location = Preconditions.checkNotNull(builder.getLocation());
74+
dataset = Preconditions.checkNotNull(builder.getDataset());
75+
dataItem = Preconditions.checkNotNull(builder.getDataItem());
76+
annotation = Preconditions.checkNotNull(builder.getAnnotation());
77+
}
78+
79+
public static AnnotationName of(
80+
String project, String location, String dataset, String dataItem, String annotation) {
81+
return newBuilder()
82+
.setProject(project)
83+
.setLocation(location)
84+
.setDataset(dataset)
85+
.setDataItem(dataItem)
86+
.setAnnotation(annotation)
87+
.build();
88+
}
89+
90+
public static String format(
91+
String project, String location, String dataset, String dataItem, String annotation) {
92+
return newBuilder()
93+
.setProject(project)
94+
.setLocation(location)
95+
.setDataset(dataset)
96+
.setDataItem(dataItem)
97+
.setAnnotation(annotation)
98+
.build()
99+
.toString();
100+
}
101+
102+
public static AnnotationName parse(String formattedString) {
103+
if (formattedString.isEmpty()) {
104+
return null;
105+
}
106+
Map<String, String> matchMap =
107+
PATH_TEMPLATE.validatedMatch(
108+
formattedString, "AnnotationName.parse: formattedString not in valid format");
109+
return of(
110+
matchMap.get("project"),
111+
matchMap.get("location"),
112+
matchMap.get("dataset"),
113+
matchMap.get("data_item"),
114+
matchMap.get("annotation"));
115+
}
116+
117+
public static List<AnnotationName> parseList(List<String> formattedStrings) {
118+
List<AnnotationName> list = new ArrayList<>(formattedStrings.size());
119+
for (String formattedString : formattedStrings) {
120+
list.add(parse(formattedString));
121+
}
122+
return list;
123+
}
124+
125+
public static List<String> toStringList(List<AnnotationName> values) {
126+
List<String> list = new ArrayList<String>(values.size());
127+
for (AnnotationName value : values) {
128+
if (value == null) {
129+
list.add("");
130+
} else {
131+
list.add(value.toString());
132+
}
133+
}
134+
return list;
135+
}
136+
137+
public static boolean isParsableFrom(String formattedString) {
138+
return PATH_TEMPLATE.matches(formattedString);
139+
}
140+
141+
public Map<String, String> getFieldValuesMap() {
142+
if (fieldValuesMap == null) {
143+
synchronized (this) {
144+
if (fieldValuesMap == null) {
145+
ImmutableMap.Builder<String, String> fieldMapBuilder = ImmutableMap.builder();
146+
fieldMapBuilder.put("project", project);
147+
fieldMapBuilder.put("location", location);
148+
fieldMapBuilder.put("dataset", dataset);
149+
fieldMapBuilder.put("dataItem", dataItem);
150+
fieldMapBuilder.put("annotation", annotation);
151+
fieldValuesMap = fieldMapBuilder.build();
152+
}
153+
}
154+
}
155+
return fieldValuesMap;
156+
}
157+
158+
public String getFieldValue(String fieldName) {
159+
return getFieldValuesMap().get(fieldName);
160+
}
161+
162+
@Override
163+
public String toString() {
164+
return PATH_TEMPLATE.instantiate(
165+
"project",
166+
project,
167+
"location",
168+
location,
169+
"dataset",
170+
dataset,
171+
"data_item",
172+
dataItem,
173+
"annotation",
174+
annotation);
175+
}
176+
177+
/** Builder for AnnotationName. */
178+
public static class Builder {
179+
180+
private String project;
181+
private String location;
182+
private String dataset;
183+
private String dataItem;
184+
private String annotation;
185+
186+
public String getProject() {
187+
return project;
188+
}
189+
190+
public String getLocation() {
191+
return location;
192+
}
193+
194+
public String getDataset() {
195+
return dataset;
196+
}
197+
198+
public String getDataItem() {
199+
return dataItem;
200+
}
201+
202+
public String getAnnotation() {
203+
return annotation;
204+
}
205+
206+
public Builder setProject(String project) {
207+
this.project = project;
208+
return this;
209+
}
210+
211+
public Builder setLocation(String location) {
212+
this.location = location;
213+
return this;
214+
}
215+
216+
public Builder setDataset(String dataset) {
217+
this.dataset = dataset;
218+
return this;
219+
}
220+
221+
public Builder setDataItem(String dataItem) {
222+
this.dataItem = dataItem;
223+
return this;
224+
}
225+
226+
public Builder setAnnotation(String annotation) {
227+
this.annotation = annotation;
228+
return this;
229+
}
230+
231+
private Builder() {}
232+
233+
private Builder(AnnotationName annotationName) {
234+
project = annotationName.project;
235+
location = annotationName.location;
236+
dataset = annotationName.dataset;
237+
dataItem = annotationName.dataItem;
238+
annotation = annotationName.annotation;
239+
}
240+
241+
public AnnotationName build() {
242+
return new AnnotationName(this);
243+
}
244+
}
245+
246+
@Override
247+
public boolean equals(Object o) {
248+
if (o == this) {
249+
return true;
250+
}
251+
if (o instanceof AnnotationName) {
252+
AnnotationName that = (AnnotationName) o;
253+
return (this.project.equals(that.project))
254+
&& (this.location.equals(that.location))
255+
&& (this.dataset.equals(that.dataset))
256+
&& (this.dataItem.equals(that.dataItem))
257+
&& (this.annotation.equals(that.annotation));
258+
}
259+
return false;
260+
}
261+
262+
@Override
263+
public int hashCode() {
264+
int h = 1;
265+
h *= 1000003;
266+
h ^= project.hashCode();
267+
h *= 1000003;
268+
h ^= location.hashCode();
269+
h *= 1000003;
270+
h ^= dataset.hashCode();
271+
h *= 1000003;
272+
h ^= dataItem.hashCode();
273+
h *= 1000003;
274+
h ^= annotation.hashCode();
275+
return h;
276+
}
277+
}

0 commit comments

Comments
 (0)