001/*
002 *   Copyright 2024 Vonage
003 *
004 *   Licensed under the Apache License, Version 2.0 (the "License");
005 *   you may not use this file except in compliance with the License.
006 *   You may obtain a copy of the License at
007 *
008 *        http://www.apache.org/licenses/LICENSE-2.0
009 *
010 *   Unless required by applicable law or agreed to in writing, software
011 *   distributed under the License is distributed on an "AS IS" BASIS,
012 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 *   See the License for the specific language governing permissions and
014 *   limitations under the License.
015 */
016package com.vonage.client.conversations;
017
018import com.fasterxml.jackson.annotation.JsonProperty;
019import com.vonage.client.JsonableBaseObject;
020
021/**
022 * Describes parameters for a Location message in {@link MessageEvent#getLocation()}.
023 */
024public final class Location extends JsonableBaseObject {
025    private Double longitude, latitude;
026    private String name, address;
027
028    Location() {}
029
030    Location(Builder builder) {
031        longitude = builder.longitude;
032        latitude = builder.latitude;
033        name = builder.name;
034        address = builder.address;
035    }
036
037    /**
038     * Longitude of the location.
039     *
040     * @return The longitude as a Double, or {@code null} if unspecified.
041     */
042    @JsonProperty("longitude")
043    public Double getLongitude() {
044        return longitude;
045    }
046
047    /**
048     * Latitude of the location.
049     *
050     * @return The latitude as a Double, or {@code null} if unspecified.
051     */
052    @JsonProperty("latitude")
053    public Double getLatitude() {
054        return latitude;
055    }
056
057    /**
058     * Name of the location.
059     *
060     * @return The name, or {@code null} if unspecified.
061     */
062    @JsonProperty("name")
063    public String getName() {
064        return name;
065    }
066
067    /**
068     * Full location address.
069     *
070     * @return The address as a string, or {@code null} if unspecified.
071     */
072    @JsonProperty("address")
073    public String getAddress() {
074        return address;
075    }
076
077    /**
078     * Entry point for constructing an instance of this class.
079     *
080     * @return A new Builder.
081     */
082    public static Builder builder() {
083        return new Builder();
084    }
085
086    /**
087     * Builder for setting Location parameters.
088     */
089    public static final class Builder {
090        private Double longitude, latitude;
091        private String name, address;
092
093        private Builder() {}
094
095        /**
096         * Longitude of the location.
097         *
098         * @param longitude The longitude as a double.
099         *
100         * @return This builder.
101         */
102        public Builder longitude(double longitude) {
103            this.longitude = longitude;
104            return this;
105        }
106
107        /**
108         * Latitude of the location.
109         *
110         * @param latitude The latitude as a double.
111         *
112         * @return This builder.
113         */
114        public Builder latitude(double latitude) {
115            this.latitude = latitude;
116            return this;
117        }
118
119        /**
120         * Name of the location.
121         *
122         * @param name The name.
123         *
124         * @return This builder.
125         */
126        public Builder name(String name) {
127            this.name = name;
128            return this;
129        }
130
131        /**
132         * Full address.
133         *
134         * @param address The address as a string.
135         *
136         * @return This builder.
137         */
138        public Builder address(String address) {
139            this.address = address;
140            return this;
141        }
142
143        /**
144         * Builds the {@linkplain Location}.
145         *
146         * @return A new Location instance, populated with all fields from this builder.
147         */
148        public Location build() {
149            return new Location(this);
150        }
151    }
152}