|
| 1 | +/* |
| 2 | + * Licensed to Elasticsearch B.V. under one or more contributor |
| 3 | + * license agreements. See the NOTICE file distributed with |
| 4 | + * this work for additional information regarding copyright |
| 5 | + * ownership. Elasticsearch B.V. licenses this file to you under |
| 6 | + * the Apache License, Version 2.0 (the "License"); you may |
| 7 | + * not use this file except in compliance with the License. |
| 8 | + * You may obtain a copy of the License at |
| 9 | + * |
| 10 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | + * |
| 12 | + * Unless required by applicable law or agreed to in writing, |
| 13 | + * software distributed under the License is distributed on an |
| 14 | + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | + * KIND, either express or implied. See the License for the |
| 16 | + * specific language governing permissions and limitations |
| 17 | + * under the License. |
| 18 | + */ |
| 19 | + |
| 20 | +package co.elastic.clients.elasticsearch._types; |
| 21 | + |
| 22 | +import co.elastic.clients.json.JsonpDeserializable; |
| 23 | +import co.elastic.clients.json.JsonpDeserializer; |
| 24 | +import co.elastic.clients.json.JsonpMapper; |
| 25 | +import co.elastic.clients.json.JsonpSerializable; |
| 26 | +import co.elastic.clients.json.JsonpUtils; |
| 27 | +import co.elastic.clients.json.ObjectBuilderDeserializer; |
| 28 | +import co.elastic.clients.json.ObjectDeserializer; |
| 29 | +import co.elastic.clients.util.ApiTypeHelper; |
| 30 | +import co.elastic.clients.util.ObjectBuilder; |
| 31 | +import co.elastic.clients.util.WithJsonObjectBuilderBase; |
| 32 | +import jakarta.json.stream.JsonGenerator; |
| 33 | +import java.lang.Float; |
| 34 | +import java.util.Objects; |
| 35 | +import java.util.function.Function; |
| 36 | +import javax.annotation.Nullable; |
| 37 | + |
| 38 | +//---------------------------------------------------------------- |
| 39 | +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. |
| 40 | +//---------------------------------------------------------------- |
| 41 | +// |
| 42 | +// This code is generated from the Elasticsearch API specification |
| 43 | +// at https://github.com/elastic/elasticsearch-specification |
| 44 | +// |
| 45 | +// Manual updates to this file will be lost when the code is |
| 46 | +// re-generated. |
| 47 | +// |
| 48 | +// If you find a property that is missing or wrongly typed, please |
| 49 | +// open an issue or a PR on the API specification repository. |
| 50 | +// |
| 51 | +//---------------------------------------------------------------- |
| 52 | + |
| 53 | +// typedef: _types.InnerRetriever |
| 54 | + |
| 55 | +/** |
| 56 | + * |
| 57 | + * @see <a href="../doc-files/api-spec.html#_types.InnerRetriever">API |
| 58 | + * specification</a> |
| 59 | + */ |
| 60 | +@JsonpDeserializable |
| 61 | +public class InnerRetriever implements JsonpSerializable { |
| 62 | + private final Retriever retriever; |
| 63 | + |
| 64 | + private final float weight; |
| 65 | + |
| 66 | + private final ScoreNormalizer normalizer; |
| 67 | + |
| 68 | + // --------------------------------------------------------------------------------------------- |
| 69 | + |
| 70 | + private InnerRetriever(Builder builder) { |
| 71 | + |
| 72 | + this.retriever = ApiTypeHelper.requireNonNull(builder.retriever, this, "retriever"); |
| 73 | + this.weight = ApiTypeHelper.requireNonNull(builder.weight, this, "weight", 0); |
| 74 | + this.normalizer = ApiTypeHelper.requireNonNull(builder.normalizer, this, "normalizer"); |
| 75 | + |
| 76 | + } |
| 77 | + |
| 78 | + public static InnerRetriever of(Function<Builder, ObjectBuilder<InnerRetriever>> fn) { |
| 79 | + return fn.apply(new Builder()).build(); |
| 80 | + } |
| 81 | + |
| 82 | + /** |
| 83 | + * Required - API name: {@code retriever} |
| 84 | + */ |
| 85 | + public final Retriever retriever() { |
| 86 | + return this.retriever; |
| 87 | + } |
| 88 | + |
| 89 | + /** |
| 90 | + * Required - API name: {@code weight} |
| 91 | + */ |
| 92 | + public final float weight() { |
| 93 | + return this.weight; |
| 94 | + } |
| 95 | + |
| 96 | + /** |
| 97 | + * Required - API name: {@code normalizer} |
| 98 | + */ |
| 99 | + public final ScoreNormalizer normalizer() { |
| 100 | + return this.normalizer; |
| 101 | + } |
| 102 | + |
| 103 | + /** |
| 104 | + * Serialize this object to JSON. |
| 105 | + */ |
| 106 | + public void serialize(JsonGenerator generator, JsonpMapper mapper) { |
| 107 | + generator.writeStartObject(); |
| 108 | + serializeInternal(generator, mapper); |
| 109 | + generator.writeEnd(); |
| 110 | + } |
| 111 | + |
| 112 | + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { |
| 113 | + |
| 114 | + generator.writeKey("retriever"); |
| 115 | + this.retriever.serialize(generator, mapper); |
| 116 | + |
| 117 | + generator.writeKey("weight"); |
| 118 | + generator.write(this.weight); |
| 119 | + |
| 120 | + generator.writeKey("normalizer"); |
| 121 | + this.normalizer.serialize(generator, mapper); |
| 122 | + |
| 123 | + } |
| 124 | + |
| 125 | + @Override |
| 126 | + public String toString() { |
| 127 | + return JsonpUtils.toString(this); |
| 128 | + } |
| 129 | + |
| 130 | + // --------------------------------------------------------------------------------------------- |
| 131 | + |
| 132 | + /** |
| 133 | + * Builder for {@link InnerRetriever}. |
| 134 | + */ |
| 135 | + |
| 136 | + public static class Builder extends WithJsonObjectBuilderBase<Builder> implements ObjectBuilder<InnerRetriever> { |
| 137 | + private Retriever retriever; |
| 138 | + |
| 139 | + private Float weight; |
| 140 | + |
| 141 | + private ScoreNormalizer normalizer; |
| 142 | + |
| 143 | + /** |
| 144 | + * Required - API name: {@code retriever} |
| 145 | + */ |
| 146 | + public final Builder retriever(Retriever value) { |
| 147 | + this.retriever = value; |
| 148 | + return this; |
| 149 | + } |
| 150 | + |
| 151 | + /** |
| 152 | + * Required - API name: {@code retriever} |
| 153 | + */ |
| 154 | + public final Builder retriever(Function<Retriever.Builder, ObjectBuilder<Retriever>> fn) { |
| 155 | + return this.retriever(fn.apply(new Retriever.Builder()).build()); |
| 156 | + } |
| 157 | + |
| 158 | + /** |
| 159 | + * Required - API name: {@code retriever} |
| 160 | + */ |
| 161 | + public final Builder retriever(RetrieverVariant value) { |
| 162 | + this.retriever = value._toRetriever(); |
| 163 | + return this; |
| 164 | + } |
| 165 | + |
| 166 | + /** |
| 167 | + * Required - API name: {@code weight} |
| 168 | + */ |
| 169 | + public final Builder weight(float value) { |
| 170 | + this.weight = value; |
| 171 | + return this; |
| 172 | + } |
| 173 | + |
| 174 | + /** |
| 175 | + * Required - API name: {@code normalizer} |
| 176 | + */ |
| 177 | + public final Builder normalizer(ScoreNormalizer value) { |
| 178 | + this.normalizer = value; |
| 179 | + return this; |
| 180 | + } |
| 181 | + |
| 182 | + @Override |
| 183 | + protected Builder self() { |
| 184 | + return this; |
| 185 | + } |
| 186 | + |
| 187 | + /** |
| 188 | + * Builds a {@link InnerRetriever}. |
| 189 | + * |
| 190 | + * @throws NullPointerException |
| 191 | + * if some of the required fields are null. |
| 192 | + */ |
| 193 | + public InnerRetriever build() { |
| 194 | + _checkSingleUse(); |
| 195 | + |
| 196 | + return new InnerRetriever(this); |
| 197 | + } |
| 198 | + } |
| 199 | + |
| 200 | + // --------------------------------------------------------------------------------------------- |
| 201 | + |
| 202 | + /** |
| 203 | + * Json deserializer for {@link InnerRetriever} |
| 204 | + */ |
| 205 | + public static final JsonpDeserializer<InnerRetriever> _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, |
| 206 | + InnerRetriever::setupInnerRetrieverDeserializer); |
| 207 | + |
| 208 | + protected static void setupInnerRetrieverDeserializer(ObjectDeserializer<InnerRetriever.Builder> op) { |
| 209 | + |
| 210 | + op.add(Builder::retriever, Retriever._DESERIALIZER, "retriever"); |
| 211 | + op.add(Builder::weight, JsonpDeserializer.floatDeserializer(), "weight"); |
| 212 | + op.add(Builder::normalizer, ScoreNormalizer._DESERIALIZER, "normalizer"); |
| 213 | + |
| 214 | + } |
| 215 | + |
| 216 | +} |
0 commit comments