|
| 1 | +/* |
| 2 | + * Licensed to Elasticsearch 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 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 org.elasticsearch.client.core; |
| 21 | + |
| 22 | +import org.elasticsearch.common.ParseField; |
| 23 | +import org.elasticsearch.common.xcontent.ConstructingObjectParser; |
| 24 | +import org.elasticsearch.common.xcontent.XContentParser; |
| 25 | + |
| 26 | +import java.util.Objects; |
| 27 | + |
| 28 | +public class MainResponse { |
| 29 | + |
| 30 | + @SuppressWarnings("unchecked") |
| 31 | + private static ConstructingObjectParser<MainResponse, Void> PARSER = |
| 32 | + new ConstructingObjectParser<>(MainResponse.class.getName(), true, |
| 33 | + args -> { |
| 34 | + return new MainResponse((String) args[0], (Version) args[1], (String) args[2], (String) args[3], (String) args[4]); |
| 35 | + } |
| 36 | + ); |
| 37 | + |
| 38 | + static { |
| 39 | + PARSER.declareString(ConstructingObjectParser.constructorArg(), new ParseField("name")); |
| 40 | + PARSER.declareObject(ConstructingObjectParser.constructorArg(), Version.PARSER, new ParseField("version")); |
| 41 | + PARSER.declareString(ConstructingObjectParser.constructorArg(), new ParseField("cluster_name")); |
| 42 | + PARSER.declareString(ConstructingObjectParser.constructorArg(), new ParseField("cluster_uuid")); |
| 43 | + PARSER.declareString(ConstructingObjectParser.constructorArg(), new ParseField("tagline")); |
| 44 | + |
| 45 | + } |
| 46 | + |
| 47 | + private final String nodeName; |
| 48 | + private final Version version; |
| 49 | + private final String clusterName; |
| 50 | + private final String clusterUuid; |
| 51 | + private final String tagline; |
| 52 | + |
| 53 | + public MainResponse(String nodeName, Version version, String clusterName, String clusterUuid, String tagline) { |
| 54 | + this.nodeName = nodeName; |
| 55 | + this.version = version; |
| 56 | + this.clusterName = clusterName; |
| 57 | + this.clusterUuid = clusterUuid; |
| 58 | + this.tagline = tagline; |
| 59 | + } |
| 60 | + |
| 61 | + public String getNodeName() { |
| 62 | + return nodeName; |
| 63 | + } |
| 64 | + |
| 65 | + public Version getVersion() { |
| 66 | + return version; |
| 67 | + } |
| 68 | + |
| 69 | + public String getClusterName() { |
| 70 | + return clusterName; |
| 71 | + } |
| 72 | + |
| 73 | + public String getClusterUuid() { |
| 74 | + return clusterUuid; |
| 75 | + } |
| 76 | + |
| 77 | + public String getTagline() { |
| 78 | + return tagline; |
| 79 | + } |
| 80 | + |
| 81 | + public static MainResponse fromXContent(XContentParser parser) { |
| 82 | + return PARSER.apply(parser, null); |
| 83 | + } |
| 84 | + |
| 85 | + @Override |
| 86 | + public boolean equals(Object o) { |
| 87 | + if (this == o) return true; |
| 88 | + if (o == null || getClass() != o.getClass()) return false; |
| 89 | + MainResponse that = (MainResponse) o; |
| 90 | + return nodeName.equals(that.nodeName) && |
| 91 | + version.equals(that.version) && |
| 92 | + clusterName.equals(that.clusterName) && |
| 93 | + clusterUuid.equals(that.clusterUuid) && |
| 94 | + tagline.equals(that.tagline); |
| 95 | + } |
| 96 | + |
| 97 | + @Override |
| 98 | + public int hashCode() { |
| 99 | + return Objects.hash(nodeName, version, clusterName, clusterUuid, tagline); |
| 100 | + } |
| 101 | + |
| 102 | + public static class Version { |
| 103 | + @SuppressWarnings("unchecked") |
| 104 | + private static ConstructingObjectParser<Version, Void> PARSER = |
| 105 | + new ConstructingObjectParser<>(Version.class.getName(), true, |
| 106 | + args -> { |
| 107 | + return new Version((String) args[0], (String) args[1], (String) args[2], (String) args[3], (String) args[4], |
| 108 | + (Boolean) args[5], (String) args[6], (String) args[7], (String) args[8]); |
| 109 | + } |
| 110 | + ); |
| 111 | + |
| 112 | + static { |
| 113 | + PARSER.declareString(ConstructingObjectParser.constructorArg(), new ParseField("number")); |
| 114 | + PARSER.declareString(ConstructingObjectParser.optionalConstructorArg(), new ParseField("build_flavor")); |
| 115 | + PARSER.declareString(ConstructingObjectParser.optionalConstructorArg(), new ParseField("build_type")); |
| 116 | + PARSER.declareString(ConstructingObjectParser.constructorArg(), new ParseField("build_hash")); |
| 117 | + PARSER.declareString(ConstructingObjectParser.constructorArg(), new ParseField("build_date")); |
| 118 | + PARSER.declareBoolean(ConstructingObjectParser.constructorArg(), new ParseField("build_snapshot")); |
| 119 | + PARSER.declareString(ConstructingObjectParser.constructorArg(), new ParseField("lucene_version")); |
| 120 | + PARSER.declareString(ConstructingObjectParser.constructorArg(), new ParseField("minimum_wire_compatibility_version")); |
| 121 | + PARSER.declareString(ConstructingObjectParser.constructorArg(), new ParseField("minimum_index_compatibility_version")); |
| 122 | + } |
| 123 | + private final String number; |
| 124 | + private final String buildFlavor; |
| 125 | + private final String buildType; |
| 126 | + private final String buildHash; |
| 127 | + private final String buildDate; |
| 128 | + private final boolean isSnapshot; |
| 129 | + private final String luceneVersion; |
| 130 | + private final String minimumWireCompatibilityVersion; |
| 131 | + private final String minimumIndexCompatibilityVersion; |
| 132 | + |
| 133 | + public Version(String number, String buildFlavor, String buildType, String buildHash, String buildDate, boolean isSnapshot, |
| 134 | + String luceneVersion, String minimumWireCompatibilityVersion, String minimumIndexCompatibilityVersion) { |
| 135 | + this.number = number; |
| 136 | + this.buildFlavor = buildFlavor; |
| 137 | + this.buildType = buildType; |
| 138 | + this.buildHash = buildHash; |
| 139 | + this.buildDate = buildDate; |
| 140 | + this.isSnapshot = isSnapshot; |
| 141 | + this.luceneVersion = luceneVersion; |
| 142 | + this.minimumWireCompatibilityVersion = minimumWireCompatibilityVersion; |
| 143 | + this.minimumIndexCompatibilityVersion = minimumIndexCompatibilityVersion; |
| 144 | + } |
| 145 | + |
| 146 | + public String getNumber() { |
| 147 | + return number; |
| 148 | + } |
| 149 | + |
| 150 | + public String getBuildFlavor() { |
| 151 | + return buildFlavor; |
| 152 | + } |
| 153 | + |
| 154 | + public String getBuildType() { |
| 155 | + return buildType; |
| 156 | + } |
| 157 | + |
| 158 | + public String getBuildHash() { |
| 159 | + return buildHash; |
| 160 | + } |
| 161 | + |
| 162 | + public String getBuildDate() { |
| 163 | + return buildDate; |
| 164 | + } |
| 165 | + |
| 166 | + public boolean isSnapshot() { |
| 167 | + return isSnapshot; |
| 168 | + } |
| 169 | + |
| 170 | + public String getLuceneVersion() { |
| 171 | + return luceneVersion; |
| 172 | + } |
| 173 | + |
| 174 | + public String getMinimumWireCompatibilityVersion() { |
| 175 | + return minimumWireCompatibilityVersion; |
| 176 | + } |
| 177 | + |
| 178 | + public String getMinimumIndexCompatibilityVersion() { |
| 179 | + return minimumIndexCompatibilityVersion; |
| 180 | + } |
| 181 | + |
| 182 | + @Override |
| 183 | + public boolean equals(Object o) { |
| 184 | + if (this == o) return true; |
| 185 | + if (o == null || getClass() != o.getClass()) return false; |
| 186 | + Version version = (Version) o; |
| 187 | + return isSnapshot == version.isSnapshot && |
| 188 | + number.equals(version.number) && |
| 189 | + Objects.equals(buildFlavor, version.buildFlavor) && |
| 190 | + Objects.equals(buildType, version.buildType) && |
| 191 | + buildHash.equals(version.buildHash) && |
| 192 | + buildDate.equals(version.buildDate) && |
| 193 | + luceneVersion.equals(version.luceneVersion) && |
| 194 | + minimumWireCompatibilityVersion.equals(version.minimumWireCompatibilityVersion) && |
| 195 | + minimumIndexCompatibilityVersion.equals(version.minimumIndexCompatibilityVersion); |
| 196 | + } |
| 197 | + |
| 198 | + @Override |
| 199 | + public int hashCode() { |
| 200 | + return Objects.hash(number, buildFlavor, buildType, buildHash, buildDate, isSnapshot, luceneVersion, |
| 201 | + minimumWireCompatibilityVersion, minimumIndexCompatibilityVersion); |
| 202 | + } |
| 203 | + } |
| 204 | +} |
0 commit comments