|
| 1 | +/* |
| 2 | + * Copyright 2021 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.dialogflow.v2; |
| 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 | +import java.util.Objects; |
| 27 | +import javax.annotation.Generated; |
| 28 | + |
| 29 | +// AUTO-GENERATED DOCUMENTATION AND CLASS. |
| 30 | +@Generated("by gapic-generator-java") |
| 31 | +public class ConversationModelName implements ResourceName { |
| 32 | + private static final PathTemplate PROJECT_LOCATION_CONVERSATION_MODEL = |
| 33 | + PathTemplate.createWithoutUrlEncoding( |
| 34 | + "projects/{project}/locations/{location}/conversationModels/{conversation_model}"); |
| 35 | + private volatile Map<String, String> fieldValuesMap; |
| 36 | + private final String project; |
| 37 | + private final String location; |
| 38 | + private final String conversationModel; |
| 39 | + |
| 40 | + @Deprecated |
| 41 | + protected ConversationModelName() { |
| 42 | + project = null; |
| 43 | + location = null; |
| 44 | + conversationModel = null; |
| 45 | + } |
| 46 | + |
| 47 | + private ConversationModelName(Builder builder) { |
| 48 | + project = Preconditions.checkNotNull(builder.getProject()); |
| 49 | + location = Preconditions.checkNotNull(builder.getLocation()); |
| 50 | + conversationModel = Preconditions.checkNotNull(builder.getConversationModel()); |
| 51 | + } |
| 52 | + |
| 53 | + public String getProject() { |
| 54 | + return project; |
| 55 | + } |
| 56 | + |
| 57 | + public String getLocation() { |
| 58 | + return location; |
| 59 | + } |
| 60 | + |
| 61 | + public String getConversationModel() { |
| 62 | + return conversationModel; |
| 63 | + } |
| 64 | + |
| 65 | + public static Builder newBuilder() { |
| 66 | + return new Builder(); |
| 67 | + } |
| 68 | + |
| 69 | + public Builder toBuilder() { |
| 70 | + return new Builder(this); |
| 71 | + } |
| 72 | + |
| 73 | + public static ConversationModelName of( |
| 74 | + String project, String location, String conversationModel) { |
| 75 | + return newBuilder() |
| 76 | + .setProject(project) |
| 77 | + .setLocation(location) |
| 78 | + .setConversationModel(conversationModel) |
| 79 | + .build(); |
| 80 | + } |
| 81 | + |
| 82 | + public static String format(String project, String location, String conversationModel) { |
| 83 | + return newBuilder() |
| 84 | + .setProject(project) |
| 85 | + .setLocation(location) |
| 86 | + .setConversationModel(conversationModel) |
| 87 | + .build() |
| 88 | + .toString(); |
| 89 | + } |
| 90 | + |
| 91 | + public static ConversationModelName parse(String formattedString) { |
| 92 | + if (formattedString.isEmpty()) { |
| 93 | + return null; |
| 94 | + } |
| 95 | + Map<String, String> matchMap = |
| 96 | + PROJECT_LOCATION_CONVERSATION_MODEL.validatedMatch( |
| 97 | + formattedString, "ConversationModelName.parse: formattedString not in valid format"); |
| 98 | + return of( |
| 99 | + matchMap.get("project"), matchMap.get("location"), matchMap.get("conversation_model")); |
| 100 | + } |
| 101 | + |
| 102 | + public static List<ConversationModelName> parseList(List<String> formattedStrings) { |
| 103 | + List<ConversationModelName> list = new ArrayList<>(formattedStrings.size()); |
| 104 | + for (String formattedString : formattedStrings) { |
| 105 | + list.add(parse(formattedString)); |
| 106 | + } |
| 107 | + return list; |
| 108 | + } |
| 109 | + |
| 110 | + public static List<String> toStringList(List<ConversationModelName> values) { |
| 111 | + List<String> list = new ArrayList<>(values.size()); |
| 112 | + for (ConversationModelName value : values) { |
| 113 | + if (value == null) { |
| 114 | + list.add(""); |
| 115 | + } else { |
| 116 | + list.add(value.toString()); |
| 117 | + } |
| 118 | + } |
| 119 | + return list; |
| 120 | + } |
| 121 | + |
| 122 | + public static boolean isParsableFrom(String formattedString) { |
| 123 | + return PROJECT_LOCATION_CONVERSATION_MODEL.matches(formattedString); |
| 124 | + } |
| 125 | + |
| 126 | + @Override |
| 127 | + public Map<String, String> getFieldValuesMap() { |
| 128 | + if (fieldValuesMap == null) { |
| 129 | + synchronized (this) { |
| 130 | + if (fieldValuesMap == null) { |
| 131 | + ImmutableMap.Builder<String, String> fieldMapBuilder = ImmutableMap.builder(); |
| 132 | + if (project != null) { |
| 133 | + fieldMapBuilder.put("project", project); |
| 134 | + } |
| 135 | + if (location != null) { |
| 136 | + fieldMapBuilder.put("location", location); |
| 137 | + } |
| 138 | + if (conversationModel != null) { |
| 139 | + fieldMapBuilder.put("conversation_model", conversationModel); |
| 140 | + } |
| 141 | + fieldValuesMap = fieldMapBuilder.build(); |
| 142 | + } |
| 143 | + } |
| 144 | + } |
| 145 | + return fieldValuesMap; |
| 146 | + } |
| 147 | + |
| 148 | + public String getFieldValue(String fieldName) { |
| 149 | + return getFieldValuesMap().get(fieldName); |
| 150 | + } |
| 151 | + |
| 152 | + @Override |
| 153 | + public String toString() { |
| 154 | + return PROJECT_LOCATION_CONVERSATION_MODEL.instantiate( |
| 155 | + "project", project, "location", location, "conversation_model", conversationModel); |
| 156 | + } |
| 157 | + |
| 158 | + @Override |
| 159 | + public boolean equals(Object o) { |
| 160 | + if (o == this) { |
| 161 | + return true; |
| 162 | + } |
| 163 | + if (o != null || getClass() == o.getClass()) { |
| 164 | + ConversationModelName that = ((ConversationModelName) o); |
| 165 | + return Objects.equals(this.project, that.project) |
| 166 | + && Objects.equals(this.location, that.location) |
| 167 | + && Objects.equals(this.conversationModel, that.conversationModel); |
| 168 | + } |
| 169 | + return false; |
| 170 | + } |
| 171 | + |
| 172 | + @Override |
| 173 | + public int hashCode() { |
| 174 | + int h = 1; |
| 175 | + h *= 1000003; |
| 176 | + h ^= Objects.hashCode(project); |
| 177 | + h *= 1000003; |
| 178 | + h ^= Objects.hashCode(location); |
| 179 | + h *= 1000003; |
| 180 | + h ^= Objects.hashCode(conversationModel); |
| 181 | + return h; |
| 182 | + } |
| 183 | + |
| 184 | + /** |
| 185 | + * Builder for projects/{project}/locations/{location}/conversationModels/{conversation_model}. |
| 186 | + */ |
| 187 | + public static class Builder { |
| 188 | + private String project; |
| 189 | + private String location; |
| 190 | + private String conversationModel; |
| 191 | + |
| 192 | + protected Builder() {} |
| 193 | + |
| 194 | + public String getProject() { |
| 195 | + return project; |
| 196 | + } |
| 197 | + |
| 198 | + public String getLocation() { |
| 199 | + return location; |
| 200 | + } |
| 201 | + |
| 202 | + public String getConversationModel() { |
| 203 | + return conversationModel; |
| 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 setConversationModel(String conversationModel) { |
| 217 | + this.conversationModel = conversationModel; |
| 218 | + return this; |
| 219 | + } |
| 220 | + |
| 221 | + private Builder(ConversationModelName conversationModelName) { |
| 222 | + project = conversationModelName.project; |
| 223 | + location = conversationModelName.location; |
| 224 | + conversationModel = conversationModelName.conversationModel; |
| 225 | + } |
| 226 | + |
| 227 | + public ConversationModelName build() { |
| 228 | + return new ConversationModelName(this); |
| 229 | + } |
| 230 | + } |
| 231 | +} |
0 commit comments