All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.yelp.nrtsearch.clientlib.Node Maven / Gradle / Ivy

The newest version!
/*
 * Copyright 2020 Yelp Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.yelp.nrtsearch.clientlib;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.Objects;

public class Node {
  private final String host;
  private final int port;

  public Node(String host, int port) {
    this.host = host;
    this.port = port;
  }

  @JsonCreator
  public static Node fromJson(@JsonProperty("host") String host, @JsonProperty("port") int port) {
    return new Node(host, port);
  }

  public String getHost() {
    return host;
  }

  public int getPort() {
    return port;
  }

  @Override
  public boolean equals(Object o) {
    if (this == o) return true;
    if (o == null || getClass() != o.getClass()) return false;
    Node node = (Node) o;
    return port == node.port && Objects.equals(host, node.host);
  }

  @Override
  public int hashCode() {
    return Objects.hash(host, port);
  }

  @Override
  public String toString() {
    return "HostPort{" + "host='" + host + '\'' + ", port=" + port + '}';
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy