|
11 | 11 |
|
12 | 12 | package com.sap.ai.sdk.core.model; |
13 | 13 |
|
14 | | -import com.fasterxml.jackson.annotation.JsonAnyGetter; |
15 | | -import com.fasterxml.jackson.annotation.JsonAnySetter; |
16 | | -import com.fasterxml.jackson.annotation.JsonIgnore; |
17 | 14 | import com.google.common.annotations.Beta; |
18 | | -import java.util.LinkedHashMap; |
19 | | -import java.util.Map; |
20 | | -import java.util.NoSuchElementException; |
21 | | -import java.util.Objects; |
22 | | -import java.util.Set; |
23 | 15 | import javax.annotation.Nonnull; |
24 | | -import javax.annotation.Nullable; |
25 | 16 |
|
26 | 17 | /** TrckTagName */ |
27 | | -@Beta // CHECKSTYLE:OFF |
28 | | -public class TrckTagName |
29 | | -// CHECKSTYLE:ON |
30 | | -{ |
31 | | - @JsonAnySetter @JsonAnyGetter |
32 | | - private final Map<String, Object> cloudSdkCustomFields = new LinkedHashMap<>(); |
33 | | - |
34 | | - /** Default constructor for TrckTagName. */ |
35 | | - protected TrckTagName() {} |
36 | | - |
37 | | - /** |
38 | | - * Get the names of the unrecognizable properties of the {@link TrckTagName}. |
39 | | - * |
40 | | - * @return The set of properties names |
41 | | - */ |
42 | | - @JsonIgnore |
43 | | - @Nonnull |
44 | | - public Set<String> getCustomFieldNames() { |
45 | | - return cloudSdkCustomFields.keySet(); |
46 | | - } |
47 | | - |
48 | | - /** |
49 | | - * Get the value of an unrecognizable property of this {@link TrckTagName} instance. |
50 | | - * |
51 | | - * @deprecated Use {@link #toMap()} instead. |
52 | | - * @param name The name of the property |
53 | | - * @return The value of the property |
54 | | - * @throws NoSuchElementException If no property with the given name could be found. |
55 | | - */ |
56 | | - @Nullable |
57 | | - @Deprecated |
58 | | - public Object getCustomField(@Nonnull final String name) throws NoSuchElementException { |
59 | | - if (!cloudSdkCustomFields.containsKey(name)) { |
60 | | - throw new NoSuchElementException("TrckTagName has no field with name '" + name + "'."); |
61 | | - } |
62 | | - return cloudSdkCustomFields.get(name); |
63 | | - } |
64 | | - |
65 | | - /** |
66 | | - * Get the value of all properties of this {@link TrckTagName} instance including unrecognized |
67 | | - * properties. |
68 | | - * |
69 | | - * @return The map of all properties |
70 | | - */ |
71 | | - @JsonIgnore |
72 | | - @Nonnull |
73 | | - public Map<String, Object> toMap() { |
74 | | - final Map<String, Object> declaredFields = new LinkedHashMap<>(cloudSdkCustomFields); |
75 | | - return declaredFields; |
76 | | - } |
| 18 | +@Beta |
| 19 | +public interface TrckTagName { |
| 20 | + /** Helper class to create a String that implements {@link TrckTagName}. */ |
| 21 | + record InnerString(@com.fasterxml.jackson.annotation.JsonValue @Nonnull String value) |
| 22 | + implements TrckTagName {} |
77 | 23 |
|
78 | 24 | /** |
79 | | - * Set an unrecognizable property of this {@link TrckTagName} instance. If the map previously |
80 | | - * contained a mapping for the key, the old value is replaced by the specified value. |
| 25 | + * Creator to enable deserialization of a String. |
81 | 26 | * |
82 | | - * @param customFieldName The name of the property |
83 | | - * @param customFieldValue The value of the property |
| 27 | + * @param val the value to use |
| 28 | + * @return a new instance of {@link InnerString}. |
84 | 29 | */ |
85 | | - @JsonIgnore |
86 | | - public void setCustomField(@Nonnull String customFieldName, @Nullable Object customFieldValue) { |
87 | | - cloudSdkCustomFields.put(customFieldName, customFieldValue); |
88 | | - } |
89 | | - |
90 | | - @Override |
91 | | - public boolean equals(@Nullable final java.lang.Object o) { |
92 | | - if (this == o) { |
93 | | - return true; |
94 | | - } |
95 | | - if (o == null || getClass() != o.getClass()) { |
96 | | - return false; |
97 | | - } |
98 | | - final TrckTagName trckTagName = (TrckTagName) o; |
99 | | - return Objects.equals(this.cloudSdkCustomFields, trckTagName.cloudSdkCustomFields); |
100 | | - } |
101 | | - |
102 | | - @Override |
103 | | - public int hashCode() { |
104 | | - return Objects.hash(cloudSdkCustomFields); |
105 | | - } |
106 | | - |
107 | | - @Override |
| 30 | + @com.fasterxml.jackson.annotation.JsonCreator |
108 | 31 | @Nonnull |
109 | | - public String toString() { |
110 | | - final StringBuilder sb = new StringBuilder(); |
111 | | - sb.append("class TrckTagName {\n"); |
112 | | - cloudSdkCustomFields.forEach( |
113 | | - (k, v) -> |
114 | | - sb.append(" ").append(k).append(": ").append(toIndentedString(v)).append("\n")); |
115 | | - sb.append("}"); |
116 | | - return sb.toString(); |
117 | | - } |
118 | | - |
119 | | - /** |
120 | | - * Convert the given object to string with each line indented by 4 spaces (except the first line). |
121 | | - */ |
122 | | - private String toIndentedString(final java.lang.Object o) { |
123 | | - if (o == null) { |
124 | | - return "null"; |
125 | | - } |
126 | | - return o.toString().replace("\n", "\n "); |
127 | | - } |
128 | | - |
129 | | - /** Create a new {@link TrckTagName} instance. No arguments are required. */ |
130 | | - public static TrckTagName create() { |
131 | | - return new TrckTagName(); |
| 32 | + static InnerString create(@Nonnull final String val) { |
| 33 | + return new InnerString(val); |
132 | 34 | } |
133 | 35 | } |
0 commit comments