|
| 1 | +/* |
| 2 | + * SPDX-License-Identifier: Apache-2.0 |
| 3 | + * |
| 4 | + * The OpenSearch Contributors require contributions made to |
| 5 | + * this file be licensed under the Apache-2.0 license or a |
| 6 | + * compatible open source license. |
| 7 | + */ |
| 8 | + |
| 9 | +/* |
| 10 | + * Licensed to Elasticsearch B.V. under one or more contributor |
| 11 | + * license agreements. See the NOTICE file distributed with |
| 12 | + * this work for additional information regarding copyright |
| 13 | + * ownership. Elasticsearch B.V. licenses this file to you under |
| 14 | + * the Apache License, Version 2.0 (the "License"); you may |
| 15 | + * not use this file except in compliance with the License. |
| 16 | + * You may obtain a copy of the License at |
| 17 | + * |
| 18 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 19 | + * |
| 20 | + * Unless required by applicable law or agreed to in writing, |
| 21 | + * software distributed under the License is distributed on an |
| 22 | + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 23 | + * KIND, either express or implied. See the License for the |
| 24 | + * specific language governing permissions and limitations |
| 25 | + * under the License. |
| 26 | + */ |
| 27 | + |
| 28 | +/* |
| 29 | + * Modifications Copyright OpenSearch Contributors. See |
| 30 | + * GitHub history for details. |
| 31 | + */ |
| 32 | + |
| 33 | +//---------------------------------------------------- |
| 34 | +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. |
| 35 | +//---------------------------------------------------- |
| 36 | + |
| 37 | +package org.opensearch.client.opensearch._types.analysis; |
| 38 | + |
| 39 | +import jakarta.json.stream.JsonGenerator; |
| 40 | +import java.util.Objects; |
| 41 | +import java.util.function.Function; |
| 42 | +import javax.annotation.Generated; |
| 43 | +import javax.annotation.Nullable; |
| 44 | +import org.opensearch.client.json.JsonpDeserializable; |
| 45 | +import org.opensearch.client.json.JsonpDeserializer; |
| 46 | +import org.opensearch.client.json.JsonpMapper; |
| 47 | +import org.opensearch.client.json.ObjectBuilderDeserializer; |
| 48 | +import org.opensearch.client.json.ObjectDeserializer; |
| 49 | +import org.opensearch.client.json.PlainJsonSerializable; |
| 50 | +import org.opensearch.client.util.ObjectBuilder; |
| 51 | +import org.opensearch.client.util.ObjectBuilderBase; |
| 52 | + |
| 53 | +// typedef: _types.analysis.PhoneAnalyzer |
| 54 | + |
| 55 | +@JsonpDeserializable |
| 56 | +@Generated("org.opensearch.client.codegen.CodeGenerator") |
| 57 | +public class PhoneAnalyzer implements AnalyzerVariant, PlainJsonSerializable { |
| 58 | + |
| 59 | + @Nullable |
| 60 | + private final String phoneRegion; |
| 61 | + |
| 62 | + // --------------------------------------------------------------------------------------------- |
| 63 | + |
| 64 | + private PhoneAnalyzer(Builder builder) { |
| 65 | + this.phoneRegion = builder.phoneRegion; |
| 66 | + } |
| 67 | + |
| 68 | + public static PhoneAnalyzer of(Function<PhoneAnalyzer.Builder, ObjectBuilder<PhoneAnalyzer>> fn) { |
| 69 | + return fn.apply(new Builder()).build(); |
| 70 | + } |
| 71 | + |
| 72 | + /** |
| 73 | + * {@link Analyzer} variant kind. |
| 74 | + */ |
| 75 | + @Override |
| 76 | + public Analyzer.Kind _analyzerKind() { |
| 77 | + return Analyzer.Kind.Phone; |
| 78 | + } |
| 79 | + |
| 80 | + /** |
| 81 | + * Optional ISO 3166 country code, defaults to "ZZ" (unknown region). |
| 82 | + * <p> |
| 83 | + * API name: {@code phone-region} |
| 84 | + * </p> |
| 85 | + */ |
| 86 | + @Nullable |
| 87 | + public final String phoneRegion() { |
| 88 | + return this.phoneRegion; |
| 89 | + } |
| 90 | + |
| 91 | + /** |
| 92 | + * Serialize this object to JSON. |
| 93 | + */ |
| 94 | + @Override |
| 95 | + public void serialize(JsonGenerator generator, JsonpMapper mapper) { |
| 96 | + generator.writeStartObject(); |
| 97 | + serializeInternal(generator, mapper); |
| 98 | + generator.writeEnd(); |
| 99 | + } |
| 100 | + |
| 101 | + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { |
| 102 | + generator.write("type", "phone"); |
| 103 | + if (this.phoneRegion != null) { |
| 104 | + generator.writeKey("phone-region"); |
| 105 | + generator.write(this.phoneRegion); |
| 106 | + } |
| 107 | + } |
| 108 | + |
| 109 | + // --------------------------------------------------------------------------------------------- |
| 110 | + |
| 111 | + /** |
| 112 | + * Builder for {@link PhoneAnalyzer}. |
| 113 | + */ |
| 114 | + public static class Builder extends ObjectBuilderBase implements ObjectBuilder<PhoneAnalyzer> { |
| 115 | + @Nullable |
| 116 | + private String phoneRegion; |
| 117 | + |
| 118 | + /** |
| 119 | + * Optional ISO 3166 country code, defaults to "ZZ" (unknown region). |
| 120 | + * <p> |
| 121 | + * API name: {@code phone-region} |
| 122 | + * </p> |
| 123 | + */ |
| 124 | + public final Builder phoneRegion(@Nullable String value) { |
| 125 | + this.phoneRegion = value; |
| 126 | + return this; |
| 127 | + } |
| 128 | + |
| 129 | + /** |
| 130 | + * Builds a {@link PhoneAnalyzer}. |
| 131 | + * |
| 132 | + * @throws NullPointerException if some of the required fields are null. |
| 133 | + */ |
| 134 | + public PhoneAnalyzer build() { |
| 135 | + _checkSingleUse(); |
| 136 | + |
| 137 | + return new PhoneAnalyzer(this); |
| 138 | + } |
| 139 | + } |
| 140 | + |
| 141 | + // --------------------------------------------------------------------------------------------- |
| 142 | + |
| 143 | + /** |
| 144 | + * Json deserializer for {@link PhoneAnalyzer} |
| 145 | + */ |
| 146 | + public static final JsonpDeserializer<PhoneAnalyzer> _DESERIALIZER = ObjectBuilderDeserializer.lazy( |
| 147 | + Builder::new, |
| 148 | + PhoneAnalyzer::setupPhoneAnalyzerDeserializer |
| 149 | + ); |
| 150 | + |
| 151 | + protected static void setupPhoneAnalyzerDeserializer(ObjectDeserializer<PhoneAnalyzer.Builder> op) { |
| 152 | + op.add(Builder::phoneRegion, JsonpDeserializer.stringDeserializer(), "phone-region"); |
| 153 | + |
| 154 | + op.ignore("type"); |
| 155 | + } |
| 156 | + |
| 157 | + @Override |
| 158 | + public int hashCode() { |
| 159 | + int result = 17; |
| 160 | + result = 31 * result + Objects.hashCode(this.phoneRegion); |
| 161 | + return result; |
| 162 | + } |
| 163 | + |
| 164 | + @Override |
| 165 | + public boolean equals(Object o) { |
| 166 | + if (this == o) return true; |
| 167 | + if (o == null || this.getClass() != o.getClass()) return false; |
| 168 | + PhoneAnalyzer other = (PhoneAnalyzer) o; |
| 169 | + return Objects.equals(this.phoneRegion, other.phoneRegion); |
| 170 | + } |
| 171 | +} |
0 commit comments