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

com.viber.bot.message.Location Maven / Gradle / Ivy

package com.viber.bot.message;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;

import javax.annotation.concurrent.Immutable;

@Immutable
public class Location {

    private final float latitude;
    private final float longitude;

    @JsonCreator
    public Location(final @JsonProperty("lat") float latitude,
                    final @JsonProperty("lon") float longitude) {
        this.latitude = latitude;
        this.longitude = longitude;
    }

    public float getLatitude() {
        return latitude;
    }

    public float getLongitude() {
        return longitude;
    }

    @Override
    public boolean equals(final Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        final Location location = (Location) o;

        if (Float.compare(location.latitude, latitude) != 0) return false;
        return Float.compare(location.longitude, longitude) == 0;
    }

    @Override
    public int hashCode() {
        int result = (latitude != +0.0f ? Float.floatToIntBits(latitude) : 0);
        result = 31 * result + (longitude != +0.0f ? Float.floatToIntBits(longitude) : 0);
        return result;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy