• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2022 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.kms.v1;
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 ImportJobName implements ResourceName {
32   private static final PathTemplate PROJECT_LOCATION_KEY_RING_IMPORT_JOB =
33       PathTemplate.createWithoutUrlEncoding(
34           "projects/{project}/locations/{location}/keyRings/{key_ring}/importJobs/{import_job}");
35   private volatile Map<String, String> fieldValuesMap;
36   private final String project;
37   private final String location;
38   private final String keyRing;
39   private final String importJob;
40 
41   @Deprecated
ImportJobName()42   protected ImportJobName() {
43     project = null;
44     location = null;
45     keyRing = null;
46     importJob = null;
47   }
48 
ImportJobName(Builder builder)49   private ImportJobName(Builder builder) {
50     project = Preconditions.checkNotNull(builder.getProject());
51     location = Preconditions.checkNotNull(builder.getLocation());
52     keyRing = Preconditions.checkNotNull(builder.getKeyRing());
53     importJob = Preconditions.checkNotNull(builder.getImportJob());
54   }
55 
getProject()56   public String getProject() {
57     return project;
58   }
59 
getLocation()60   public String getLocation() {
61     return location;
62   }
63 
getKeyRing()64   public String getKeyRing() {
65     return keyRing;
66   }
67 
getImportJob()68   public String getImportJob() {
69     return importJob;
70   }
71 
newBuilder()72   public static Builder newBuilder() {
73     return new Builder();
74   }
75 
toBuilder()76   public Builder toBuilder() {
77     return new Builder(this);
78   }
79 
of( String project, String location, String keyRing, String importJob)80   public static ImportJobName of(
81       String project, String location, String keyRing, String importJob) {
82     return newBuilder()
83         .setProject(project)
84         .setLocation(location)
85         .setKeyRing(keyRing)
86         .setImportJob(importJob)
87         .build();
88   }
89 
format(String project, String location, String keyRing, String importJob)90   public static String format(String project, String location, String keyRing, String importJob) {
91     return newBuilder()
92         .setProject(project)
93         .setLocation(location)
94         .setKeyRing(keyRing)
95         .setImportJob(importJob)
96         .build()
97         .toString();
98   }
99 
parse(String formattedString)100   public static ImportJobName parse(String formattedString) {
101     if (formattedString.isEmpty()) {
102       return null;
103     }
104     Map<String, String> matchMap =
105         PROJECT_LOCATION_KEY_RING_IMPORT_JOB.validatedMatch(
106             formattedString, "ImportJobName.parse: formattedString not in valid format");
107     return of(
108         matchMap.get("project"),
109         matchMap.get("location"),
110         matchMap.get("key_ring"),
111         matchMap.get("import_job"));
112   }
113 
parseList(List<String> formattedStrings)114   public static List<ImportJobName> parseList(List<String> formattedStrings) {
115     List<ImportJobName> list = new ArrayList<>(formattedStrings.size());
116     for (String formattedString : formattedStrings) {
117       list.add(parse(formattedString));
118     }
119     return list;
120   }
121 
toStringList(List<ImportJobName> values)122   public static List<String> toStringList(List<ImportJobName> values) {
123     List<String> list = new ArrayList<>(values.size());
124     for (ImportJobName value : values) {
125       if (value == null) {
126         list.add("");
127       } else {
128         list.add(value.toString());
129       }
130     }
131     return list;
132   }
133 
isParsableFrom(String formattedString)134   public static boolean isParsableFrom(String formattedString) {
135     return PROJECT_LOCATION_KEY_RING_IMPORT_JOB.matches(formattedString);
136   }
137 
138   @Override
getFieldValuesMap()139   public Map<String, String> getFieldValuesMap() {
140     if (fieldValuesMap == null) {
141       synchronized (this) {
142         if (fieldValuesMap == null) {
143           ImmutableMap.Builder<String, String> fieldMapBuilder = ImmutableMap.builder();
144           if (project != null) {
145             fieldMapBuilder.put("project", project);
146           }
147           if (location != null) {
148             fieldMapBuilder.put("location", location);
149           }
150           if (keyRing != null) {
151             fieldMapBuilder.put("key_ring", keyRing);
152           }
153           if (importJob != null) {
154             fieldMapBuilder.put("import_job", importJob);
155           }
156           fieldValuesMap = fieldMapBuilder.build();
157         }
158       }
159     }
160     return fieldValuesMap;
161   }
162 
getFieldValue(String fieldName)163   public String getFieldValue(String fieldName) {
164     return getFieldValuesMap().get(fieldName);
165   }
166 
167   @Override
toString()168   public String toString() {
169     return PROJECT_LOCATION_KEY_RING_IMPORT_JOB.instantiate(
170         "project", project, "location", location, "key_ring", keyRing, "import_job", importJob);
171   }
172 
173   @Override
equals(Object o)174   public boolean equals(Object o) {
175     if (o == this) {
176       return true;
177     }
178     if (o != null || getClass() == o.getClass()) {
179       ImportJobName that = ((ImportJobName) o);
180       return Objects.equals(this.project, that.project)
181           && Objects.equals(this.location, that.location)
182           && Objects.equals(this.keyRing, that.keyRing)
183           && Objects.equals(this.importJob, that.importJob);
184     }
185     return false;
186   }
187 
188   @Override
hashCode()189   public int hashCode() {
190     int h = 1;
191     h *= 1000003;
192     h ^= Objects.hashCode(project);
193     h *= 1000003;
194     h ^= Objects.hashCode(location);
195     h *= 1000003;
196     h ^= Objects.hashCode(keyRing);
197     h *= 1000003;
198     h ^= Objects.hashCode(importJob);
199     return h;
200   }
201 
202   /**
203    * Builder for
204    * projects/{project}/locations/{location}/keyRings/{key_ring}/importJobs/{import_job}.
205    */
206   public static class Builder {
207     private String project;
208     private String location;
209     private String keyRing;
210     private String importJob;
211 
Builder()212     protected Builder() {}
213 
getProject()214     public String getProject() {
215       return project;
216     }
217 
getLocation()218     public String getLocation() {
219       return location;
220     }
221 
getKeyRing()222     public String getKeyRing() {
223       return keyRing;
224     }
225 
getImportJob()226     public String getImportJob() {
227       return importJob;
228     }
229 
setProject(String project)230     public Builder setProject(String project) {
231       this.project = project;
232       return this;
233     }
234 
setLocation(String location)235     public Builder setLocation(String location) {
236       this.location = location;
237       return this;
238     }
239 
setKeyRing(String keyRing)240     public Builder setKeyRing(String keyRing) {
241       this.keyRing = keyRing;
242       return this;
243     }
244 
setImportJob(String importJob)245     public Builder setImportJob(String importJob) {
246       this.importJob = importJob;
247       return this;
248     }
249 
Builder(ImportJobName importJobName)250     private Builder(ImportJobName importJobName) {
251       this.project = importJobName.project;
252       this.location = importJobName.location;
253       this.keyRing = importJobName.keyRing;
254       this.importJob = importJobName.importJob;
255     }
256 
build()257     public ImportJobName build() {
258       return new ImportJobName(this);
259     }
260   }
261 }
262