2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
7 * This program and the accompanying materials are made available under the
8 * terms of the Eclipse Public License 2.0 which is available at
9 * http://www.eclipse.org/legal/epl-2.0
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.fmiweather.internal.client;
15 import java.math.BigDecimal;
16 import java.util.Objects;
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19 import org.eclipse.jdt.annotation.Nullable;
24 * Note: For simplicity, location implements object equality and hashCode using only id.
26 * @author Sami Salonen - Initial contribution
30 public class Location {
32 public final String name;
33 public final String id;
34 public final BigDecimal latitude;
35 public final BigDecimal longitude;
39 * @param name name for the location
40 * @param id string identifying this location uniquely. Typically FMISID or latitude-longitude pair
41 * @param latitude latitude of the location
42 * @param longitude longitude of the location
44 public Location(String name, String id, BigDecimal latitude, BigDecimal longitude) {
47 this.latitude = latitude;
48 this.longitude = longitude;
52 public boolean equals(@Nullable Object obj) {
56 if (!(obj instanceof Location)) {
59 Location other = (Location) obj;
60 return Objects.equals(id, other.id);
64 public int hashCode() {
69 public String toString() {
70 return new StringBuilder("Location(name=\"").append(name).append("\", id=\"").append(id).append("\", latitude=")
71 .append(latitude).append(", longitude=").append(longitude).append(")").toString();