|
| 1 | +/* |
| 2 | + * Copyright 2018 Google LLC |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except |
| 5 | + * in compliance with the License. You may obtain a copy of the License at |
| 6 | + * |
| 7 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | + * |
| 9 | + * Unless required by applicable law or agreed to in writing, software distributed under the License |
| 10 | + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express |
| 11 | + * or implied. See the License for the specific language governing permissions and limitations under |
| 12 | + * the License. |
| 13 | + */ |
| 14 | + |
| 15 | +package com.google.containeranalysis.v1beta1; |
| 16 | + |
| 17 | +import com.google.common.base.Preconditions; |
| 18 | +import com.google.api.resourcenames.ResourceName; |
| 19 | +import com.google.common.collect.ImmutableMap; |
| 20 | +import java.util.ArrayList; |
| 21 | +import java.util.List; |
| 22 | +import java.util.Map; |
| 23 | + |
| 24 | +// AUTO-GENERATED DOCUMENTATION AND CLASS |
| 25 | +@javax.annotation.Generated("by GAPIC protoc plugin") |
| 26 | +public class UntypedIamResourceName extends IamResourceName { |
| 27 | + |
| 28 | + private final String rawValue; |
| 29 | + private Map<String, String> valueMap; |
| 30 | + |
| 31 | + private UntypedIamResourceName(String rawValue) { |
| 32 | + this.rawValue = Preconditions.checkNotNull(rawValue); |
| 33 | + this.valueMap = ImmutableMap.of("", rawValue); |
| 34 | + } |
| 35 | + |
| 36 | + public static UntypedIamResourceName from(ResourceName resourceName) { |
| 37 | + return new UntypedIamResourceName(resourceName.toString()); |
| 38 | + } |
| 39 | + |
| 40 | + public static UntypedIamResourceName parse(String formattedString) { |
| 41 | + return new UntypedIamResourceName(formattedString); |
| 42 | + } |
| 43 | + |
| 44 | + public static List<UntypedIamResourceName> parseList(List<String> formattedStrings) { |
| 45 | + List<UntypedIamResourceName> list = new ArrayList<>(formattedStrings.size()); |
| 46 | + for (String formattedString : formattedStrings) { |
| 47 | + list.add(parse(formattedString)); |
| 48 | + } |
| 49 | + return list; |
| 50 | + } |
| 51 | + |
| 52 | + public static List<String> toStringList(List<UntypedIamResourceName> values) { |
| 53 | + List<String> list = new ArrayList<String>(values.size()); |
| 54 | + for (UntypedIamResourceName value : values) { |
| 55 | + if (value == null) { |
| 56 | + list.add(""); |
| 57 | + } else { |
| 58 | + list.add(value.toString()); |
| 59 | + } |
| 60 | + } |
| 61 | + return list; |
| 62 | + } |
| 63 | + |
| 64 | + public static boolean isParsableFrom(String formattedString) { |
| 65 | + return true; |
| 66 | + } |
| 67 | + |
| 68 | + /** |
| 69 | + * Return a map with a single value rawValue keyed on an empty String "". |
| 70 | + */ |
| 71 | + public Map<String, String> getFieldValuesMap() { |
| 72 | + return valueMap; |
| 73 | + } |
| 74 | + |
| 75 | + /** |
| 76 | + * Return the initial rawValue if @param fieldName is an empty String, else return null. |
| 77 | + */ |
| 78 | + public String getFieldValue(String fieldName) { |
| 79 | + return valueMap.get(fieldName); |
| 80 | + } |
| 81 | + |
| 82 | + @Override |
| 83 | + public String toString() { |
| 84 | + return rawValue; |
| 85 | + } |
| 86 | + |
| 87 | + @Override |
| 88 | + public boolean equals(Object o) { |
| 89 | + if (o == this) { |
| 90 | + return true; |
| 91 | + } |
| 92 | + if (o instanceof UntypedIamResourceName) { |
| 93 | + UntypedIamResourceName that = (UntypedIamResourceName) o; |
| 94 | + return this.rawValue.equals(that.rawValue); |
| 95 | + } |
| 96 | + return false; |
| 97 | + } |
| 98 | + |
| 99 | + @Override |
| 100 | + public int hashCode() { |
| 101 | + return rawValue.hashCode(); |
| 102 | + } |
| 103 | +} |
0 commit comments