Skip to content

Commit aede65b

Browse files
committed
Rename setters/getters/builders for Logging classes to meet proto conventions
1 parent 513ca70 commit aede65b

38 files changed

+1933
-614
lines changed

google-cloud-core/src/main/java/com/google/cloud/MonitoredResource.java

Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,21 +66,43 @@ public static class Builder {
6666
* {@link MonitoredResourceDescriptor#type()} of a {@code MonitoredResourceDescriptor} object.
6767
* For example, the type {@code cloudsql_database} represent databases in Google Cloud SQL.
6868
*/
69+
@Deprecated
6970
public Builder type(String type) {
7071
this.type = type;
7172
return this;
7273
}
7374

75+
/**
76+
* Sets the monitored resource type. This value must match the one of
77+
* {@link MonitoredResourceDescriptor#type()} of a {@code MonitoredResourceDescriptor} object.
78+
* For example, the type {@code cloudsql_database} represent databases in Google Cloud SQL.
79+
*/
80+
public Builder setType(String type) {
81+
this.type = type;
82+
return this;
83+
}
84+
7485
/**
7586
* Sets the values for all the labels required by the corresponding monitored resource
7687
* descriptor (see {@link MonitoredResourceDescriptor#labels()}. For example, Google Compute
7788
* Engine VM instances use the labels {@code instance_id} and {@code zone}.
7889
*/
90+
@Deprecated
7991
public Builder labels(Map<String, String> labels) {
8092
this.labels = new HashMap<>(checkNotNull(labels));
8193
return this;
8294
}
8395

96+
/**
97+
* Sets the values for all the labels required by the corresponding monitored resource
98+
* descriptor (see {@link MonitoredResourceDescriptor#labels()}. For example, Google Compute
99+
* Engine VM instances use the labels {@code instance_id} and {@code zone}.
100+
*/
101+
public Builder setLabels(Map<String, String> labels) {
102+
this.labels = new HashMap<>(checkNotNull(labels));
103+
return this;
104+
}
105+
84106
/**
85107
* Adds a label to the labels of the monitored resource.
86108
*/
@@ -112,19 +134,39 @@ public MonitoredResource build() {
112134
* {@link MonitoredResourceDescriptor#type()} of a {@code MonitoredResourceDescriptor} object.
113135
* For example, the type {@code cloudsql_database} represent databases in Google Cloud SQL.
114136
*/
137+
@Deprecated
115138
public String type() {
116139
return type;
117140
}
118141

142+
/**
143+
* Returns the monitored resource type. This value must match the one of
144+
* {@link MonitoredResourceDescriptor#type()} of a {@code MonitoredResourceDescriptor} object.
145+
* For example, the type {@code cloudsql_database} represent databases in Google Cloud SQL.
146+
*/
147+
public String getType() {
148+
return type;
149+
}
150+
119151
/**
120152
* Returns the values for all the labels required by the corresponding monitored resource
121153
* descriptor (see {@link MonitoredResourceDescriptor#labels()}. For example, Google Compute
122154
* Engine VM instances use the labels {@code instance_id} and {@code zone}.
123155
*/
156+
@Deprecated
124157
public Map<String, String> labels() {
125158
return labels;
126159
}
127160

161+
/**
162+
* Returns the values for all the labels required by the corresponding monitored resource
163+
* descriptor (see {@link MonitoredResourceDescriptor#labels()}. For example, Google Compute
164+
* Engine VM instances use the labels {@code instance_id} and {@code zone}.
165+
*/
166+
public Map<String, String> getLabels() {
167+
return labels;
168+
}
169+
128170
@Override
129171
public int hashCode() {
130172
return Objects.hash(type, labels);
@@ -167,18 +209,26 @@ public Builder toBuilder() {
167209
/**
168210
* Returns a builder for {@code MonitoredResource} objects given the resource's type.
169211
*/
212+
@Deprecated
170213
public static Builder builder(String type) {
171214
return new Builder(type);
172215
}
173216

217+
/**
218+
* Returns a builder for {@code MonitoredResource} objects given the resource's type.
219+
*/
220+
public static Builder newBuilder(String type) {
221+
return new Builder(type);
222+
}
223+
174224
/**
175225
* Creates a {@code MonitoredResource} object given the resource's type and labels.
176226
*/
177227
public static MonitoredResource of(String type, Map<String, String> labels) {
178-
return builder(type).labels(labels).build();
228+
return newBuilder(type).setLabels(labels).build();
179229
}
180230

181231
public static MonitoredResource fromPb(com.google.api.MonitoredResource descriptorPb) {
182-
return new Builder(descriptorPb.getType()).labels(descriptorPb.getLabels()).build();
232+
return new Builder(descriptorPb.getType()).setLabels(descriptorPb.getLabelsMap()).build();
183233
}
184234
}

google-cloud-core/src/main/java/com/google/cloud/MonitoredResourceDescriptor.java

Lines changed: 83 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -120,25 +120,50 @@ static ValueType fromPb(com.google.api.LabelDescriptor.ValueType typePb) {
120120
/**
121121
* Returns the key associated to this label.
122122
*/
123+
@Deprecated
123124
public String key() {
124125
return key;
125126
}
126127

128+
/**
129+
* Returns the key associated to this label.
130+
*/
131+
public String getKey() {
132+
return key;
133+
}
134+
127135
/**
128136
* Returns the type of data that can be assigned to this label.
129137
*/
138+
@Deprecated
130139
public ValueType valueType() {
131140
return valueType;
132141
}
133142

143+
/**
144+
* Returns the type of data that can be assigned to this label.
145+
*/
146+
public ValueType getValueType() {
147+
return valueType;
148+
}
149+
134150
/**
135151
* Returns the optional human-readable description for this label. If not set, this method
136152
* returns {@code null}.
137153
*/
154+
@Deprecated
138155
public String description() {
139156
return description;
140157
}
141158

159+
/**
160+
* Returns the optional human-readable description for this label. If not set, this method
161+
* returns {@code null}.
162+
*/
163+
public String getDescription() {
164+
return description;
165+
}
166+
142167
@Override
143168
public final int hashCode() {
144169
return Objects.hash(key, valueType, description);
@@ -199,22 +224,22 @@ static class Builder {
199224
this.type = type;
200225
}
201226

202-
Builder name(String name) {
227+
Builder setName(String name) {
203228
this.name = name;
204229
return this;
205230
}
206231

207-
Builder displayName(String displayName) {
232+
Builder setDisplayName(String displayName) {
208233
this.displayName = displayName;
209234
return this;
210235
}
211236

212-
Builder description(String description) {
237+
Builder setDescription(String description) {
213238
this.description = description;
214239
return this;
215240
}
216241

217-
Builder labels(List<LabelDescriptor> labels) {
242+
Builder setLabels(List<LabelDescriptor> labels) {
218243
this.labels = labels;
219244
return this;
220245
}
@@ -236,44 +261,91 @@ MonitoredResourceDescriptor build() {
236261
* Returns the monitored resource type. For example, the type {@code cloudsql_database} represents
237262
* databases in Google Cloud SQL.
238263
*/
264+
@Deprecated
239265
public String type() {
240266
return type;
241267
}
242268

269+
/**
270+
* Returns the monitored resource type. For example, the type {@code cloudsql_database} represents
271+
* databases in Google Cloud SQL.
272+
*/
273+
public String getType() {
274+
return type;
275+
}
276+
243277
/**
244278
* Returns an optional name for the monitored resource descriptor. If not set, this method returns
245279
* {@code null}.
246280
*/
281+
@Deprecated
247282
public String name() {
248283
return name;
249284
}
250285

286+
/**
287+
* Returns an optional name for the monitored resource descriptor. If not set, this method returns
288+
* {@code null}.
289+
*/
290+
public String getName() {
291+
return name;
292+
}
293+
251294
/**
252295
* Returns an optional concise name for the monitored resource type. This value might be displayed
253296
* in user interfaces. For example, {@code Google Cloud SQL Database}. If not set, this method
254297
* returns {@code null}.
255298
*/
299+
@Deprecated
256300
public String displayName() {
257301
return displayName;
258302
}
259303

304+
/**
305+
* Returns an optional concise name for the monitored resource type. This value might be displayed
306+
* in user interfaces. For example, {@code Google Cloud SQL Database}. If not set, this method
307+
* returns {@code null}.
308+
*/
309+
public String getDisplayName() {
310+
return displayName;
311+
}
312+
260313
/**
261314
* Returns an optional detailed description of the monitored resource type. This value might be
262315
* used in documentation. If not set, this method returns {@code null}.
263316
*/
317+
@Deprecated
264318
public String description() {
265319
return description;
266320
}
267321

322+
/**
323+
* Returns an optional detailed description of the monitored resource type. This value might be
324+
* used in documentation. If not set, this method returns {@code null}.
325+
*/
326+
public String getDescription() {
327+
return description;
328+
}
329+
268330
/**
269331
* Returns a list of labels used to describe instances of this monitored resource type. For
270332
* example, an individual Google Cloud SQL database is identified by values for the labels
271333
* {@code database_id} and {@code region}.
272334
*/
335+
@Deprecated
273336
public List<LabelDescriptor> labels() {
274337
return labels;
275338
}
276339

340+
/**
341+
* Returns a list of labels used to describe instances of this monitored resource type. For
342+
* example, an individual Google Cloud SQL database is identified by values for the labels
343+
* {@code database_id} and {@code region}.
344+
*/
345+
public List<LabelDescriptor> getLabels() {
346+
return labels;
347+
}
348+
277349
@Override
278350
public final int hashCode() {
279351
return Objects.hash(type, name, displayName, description, labels);
@@ -323,23 +395,24 @@ public com.google.api.MonitoredResourceDescriptor toPb() {
323395
return builder.build();
324396
}
325397

326-
static Builder builder(String type) {
398+
static Builder newBuilder(String type) {
327399
return new Builder(type);
328400
}
329401

330402
public static MonitoredResourceDescriptor fromPb(
331403
com.google.api.MonitoredResourceDescriptor descriptorPb) {
332-
Builder builder = builder(descriptorPb.getType());
404+
Builder builder = newBuilder(descriptorPb.getType());
333405
if (descriptorPb.getName() != null && !descriptorPb.getName().equals("")) {
334-
builder.name(descriptorPb.getName());
406+
builder.setName(descriptorPb.getName());
335407
}
336408
if (descriptorPb.getDisplayName() != null && !descriptorPb.getDisplayName().equals("")) {
337-
builder.displayName(descriptorPb.getDisplayName());
409+
builder.setDisplayName(descriptorPb.getDisplayName());
338410
}
339411
if (descriptorPb.getDescription() != null && !descriptorPb.getDescription().equals("")) {
340-
builder.description(descriptorPb.getDescription());
412+
builder.setDescription(descriptorPb.getDescription());
341413
}
342-
builder.labels(Lists.transform(descriptorPb.getLabelsList(), LabelDescriptor.FROM_PB_FUNCTION));
414+
builder.setLabels(Lists.transform(descriptorPb.getLabelsList(),
415+
LabelDescriptor.FROM_PB_FUNCTION));
343416
return builder.build();
344417
}
345418
}

0 commit comments

Comments
 (0)