Skip to content

Commit

Permalink
Rename setters/getters/builders for Logging classes to meet proto con…
Browse files Browse the repository at this point in the history
…ventions
  • Loading branch information
mziccard committed Oct 11, 2016
1 parent 513ca70 commit aede65b
Show file tree
Hide file tree
Showing 38 changed files with 1,933 additions and 614 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,21 +66,43 @@ public static class Builder {
* {@link MonitoredResourceDescriptor#type()} of a {@code MonitoredResourceDescriptor} object.
* For example, the type {@code cloudsql_database} represent databases in Google Cloud SQL.
*/
@Deprecated
public Builder type(String type) {
this.type = type;
return this;
}

/**
* Sets the monitored resource type. This value must match the one of
* {@link MonitoredResourceDescriptor#type()} of a {@code MonitoredResourceDescriptor} object.
* For example, the type {@code cloudsql_database} represent databases in Google Cloud SQL.
*/
public Builder setType(String type) {
this.type = type;
return this;
}

/**
* Sets the values for all the labels required by the corresponding monitored resource
* descriptor (see {@link MonitoredResourceDescriptor#labels()}. For example, Google Compute
* Engine VM instances use the labels {@code instance_id} and {@code zone}.
*/
@Deprecated
public Builder labels(Map<String, String> labels) {
this.labels = new HashMap<>(checkNotNull(labels));
return this;
}

/**
* Sets the values for all the labels required by the corresponding monitored resource
* descriptor (see {@link MonitoredResourceDescriptor#labels()}. For example, Google Compute
* Engine VM instances use the labels {@code instance_id} and {@code zone}.
*/
public Builder setLabels(Map<String, String> labels) {
this.labels = new HashMap<>(checkNotNull(labels));
return this;
}

/**
* Adds a label to the labels of the monitored resource.
*/
Expand Down Expand Up @@ -112,19 +134,39 @@ public MonitoredResource build() {
* {@link MonitoredResourceDescriptor#type()} of a {@code MonitoredResourceDescriptor} object.
* For example, the type {@code cloudsql_database} represent databases in Google Cloud SQL.
*/
@Deprecated
public String type() {
return type;
}

/**
* Returns the monitored resource type. This value must match the one of
* {@link MonitoredResourceDescriptor#type()} of a {@code MonitoredResourceDescriptor} object.
* For example, the type {@code cloudsql_database} represent databases in Google Cloud SQL.
*/
public String getType() {
return type;
}

/**
* Returns the values for all the labels required by the corresponding monitored resource
* descriptor (see {@link MonitoredResourceDescriptor#labels()}. For example, Google Compute
* Engine VM instances use the labels {@code instance_id} and {@code zone}.
*/
@Deprecated
public Map<String, String> labels() {
return labels;
}

/**
* Returns the values for all the labels required by the corresponding monitored resource
* descriptor (see {@link MonitoredResourceDescriptor#labels()}. For example, Google Compute
* Engine VM instances use the labels {@code instance_id} and {@code zone}.
*/
public Map<String, String> getLabels() {
return labels;
}

@Override
public int hashCode() {
return Objects.hash(type, labels);
Expand Down Expand Up @@ -167,18 +209,26 @@ public Builder toBuilder() {
/**
* Returns a builder for {@code MonitoredResource} objects given the resource's type.
*/
@Deprecated
public static Builder builder(String type) {
return new Builder(type);
}

/**
* Returns a builder for {@code MonitoredResource} objects given the resource's type.
*/
public static Builder newBuilder(String type) {
return new Builder(type);
}

/**
* Creates a {@code MonitoredResource} object given the resource's type and labels.
*/
public static MonitoredResource of(String type, Map<String, String> labels) {
return builder(type).labels(labels).build();
return newBuilder(type).setLabels(labels).build();
}

public static MonitoredResource fromPb(com.google.api.MonitoredResource descriptorPb) {
return new Builder(descriptorPb.getType()).labels(descriptorPb.getLabels()).build();
return new Builder(descriptorPb.getType()).setLabels(descriptorPb.getLabelsMap()).build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -120,25 +120,50 @@ static ValueType fromPb(com.google.api.LabelDescriptor.ValueType typePb) {
/**
* Returns the key associated to this label.
*/
@Deprecated
public String key() {
return key;
}

/**
* Returns the key associated to this label.
*/
public String getKey() {
return key;
}

/**
* Returns the type of data that can be assigned to this label.
*/
@Deprecated
public ValueType valueType() {
return valueType;
}

/**
* Returns the type of data that can be assigned to this label.
*/
public ValueType getValueType() {
return valueType;
}

/**
* Returns the optional human-readable description for this label. If not set, this method
* returns {@code null}.
*/
@Deprecated
public String description() {
return description;
}

/**
* Returns the optional human-readable description for this label. If not set, this method
* returns {@code null}.
*/
public String getDescription() {
return description;
}

@Override
public final int hashCode() {
return Objects.hash(key, valueType, description);
Expand Down Expand Up @@ -199,22 +224,22 @@ static class Builder {
this.type = type;
}

Builder name(String name) {
Builder setName(String name) {
this.name = name;
return this;
}

Builder displayName(String displayName) {
Builder setDisplayName(String displayName) {
this.displayName = displayName;
return this;
}

Builder description(String description) {
Builder setDescription(String description) {
this.description = description;
return this;
}

Builder labels(List<LabelDescriptor> labels) {
Builder setLabels(List<LabelDescriptor> labels) {
this.labels = labels;
return this;
}
Expand All @@ -236,44 +261,91 @@ MonitoredResourceDescriptor build() {
* Returns the monitored resource type. For example, the type {@code cloudsql_database} represents
* databases in Google Cloud SQL.
*/
@Deprecated
public String type() {
return type;
}

/**
* Returns the monitored resource type. For example, the type {@code cloudsql_database} represents
* databases in Google Cloud SQL.
*/
public String getType() {
return type;
}

/**
* Returns an optional name for the monitored resource descriptor. If not set, this method returns
* {@code null}.
*/
@Deprecated
public String name() {
return name;
}

/**
* Returns an optional name for the monitored resource descriptor. If not set, this method returns
* {@code null}.
*/
public String getName() {
return name;
}

/**
* Returns an optional concise name for the monitored resource type. This value might be displayed
* in user interfaces. For example, {@code Google Cloud SQL Database}. If not set, this method
* returns {@code null}.
*/
@Deprecated
public String displayName() {
return displayName;
}

/**
* Returns an optional concise name for the monitored resource type. This value might be displayed
* in user interfaces. For example, {@code Google Cloud SQL Database}. If not set, this method
* returns {@code null}.
*/
public String getDisplayName() {
return displayName;
}

/**
* Returns an optional detailed description of the monitored resource type. This value might be
* used in documentation. If not set, this method returns {@code null}.
*/
@Deprecated
public String description() {
return description;
}

/**
* Returns an optional detailed description of the monitored resource type. This value might be
* used in documentation. If not set, this method returns {@code null}.
*/
public String getDescription() {
return description;
}

/**
* Returns a list of labels used to describe instances of this monitored resource type. For
* example, an individual Google Cloud SQL database is identified by values for the labels
* {@code database_id} and {@code region}.
*/
@Deprecated
public List<LabelDescriptor> labels() {
return labels;
}

/**
* Returns a list of labels used to describe instances of this monitored resource type. For
* example, an individual Google Cloud SQL database is identified by values for the labels
* {@code database_id} and {@code region}.
*/
public List<LabelDescriptor> getLabels() {
return labels;
}

@Override
public final int hashCode() {
return Objects.hash(type, name, displayName, description, labels);
Expand Down Expand Up @@ -323,23 +395,24 @@ public com.google.api.MonitoredResourceDescriptor toPb() {
return builder.build();
}

static Builder builder(String type) {
static Builder newBuilder(String type) {
return new Builder(type);
}

public static MonitoredResourceDescriptor fromPb(
com.google.api.MonitoredResourceDescriptor descriptorPb) {
Builder builder = builder(descriptorPb.getType());
Builder builder = newBuilder(descriptorPb.getType());
if (descriptorPb.getName() != null && !descriptorPb.getName().equals("")) {
builder.name(descriptorPb.getName());
builder.setName(descriptorPb.getName());
}
if (descriptorPb.getDisplayName() != null && !descriptorPb.getDisplayName().equals("")) {
builder.displayName(descriptorPb.getDisplayName());
builder.setDisplayName(descriptorPb.getDisplayName());
}
if (descriptorPb.getDescription() != null && !descriptorPb.getDescription().equals("")) {
builder.description(descriptorPb.getDescription());
builder.setDescription(descriptorPb.getDescription());
}
builder.labels(Lists.transform(descriptorPb.getLabelsList(), LabelDescriptor.FROM_PB_FUNCTION));
builder.setLabels(Lists.transform(descriptorPb.getLabelsList(),
LabelDescriptor.FROM_PB_FUNCTION));
return builder.build();
}
}
Loading

0 comments on commit aede65b

Please sign in to comment.