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

org.opennms.features.geolocation.api.AddressInfo Maven / Gradle / Ivy

There is a newer version: 33.0.10
Show newest version
/*
 * Licensed to The OpenNMS Group, Inc (TOG) under one or more
 * contributor license agreements.  See the LICENSE.md file
 * distributed with this work for additional information
 * regarding copyright ownership.
 *
 * TOG licenses this file to You under the GNU Affero General
 * Public License Version 3 (the "License") or (at your option)
 * any later version.  You may not use this file except in
 * compliance with the License.  You may obtain a copy of the
 * License at:
 *
 *      https://www.gnu.org/licenses/agpl-3.0.txt
 *
 * 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 org.opennms.features.geolocation.api;

import java.util.Arrays;
import java.util.stream.Collectors;

public class AddressInfo {
    private String address1;
    private String address2;
    private String city;
    private String state;
    private String zip;
    private String country;

    public String getAddress1() {
        return address1;
    }

    public void setAddress1(String address1) {
        this.address1 = address1;
    }

    public String getAddress2() {
        return address2;
    }

    public void setAddress2(String address2) {
        this.address2 = address2;
    }

    public String getCity() {
        return city;
    }

    public void setCity(String city) {
        this.city = city;
    }

    public String getState() {
        return state;
    }

    public void setState(String state) {
        this.state = state;
    }

    public String getZip() {
        return zip;
    }

    public void setZip(String zip) {
        this.zip = zip;
    }

    public String getCountry() {
        return country;
    }

    public void setCountry(String country) {
        this.country = country;
    }

    public String toAddressString() {
        return join(", ",
            join(" ", getAddress1(), getAddress2()),
            getCity(),
            join(" ", getState(), getZip()),
            getCountry());
    }

    private static String join(String delimiter, String... chunks) {
        return Arrays.stream(chunks)
                .filter(c -> c != null && !c.isEmpty() && !c.trim().isEmpty())
                .collect(Collectors.joining(delimiter));
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy