io.sphere.sdk.zones.Location Maven / Gradle / Ivy
package io.sphere.sdk.zones;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.neovisionaries.i18n.CountryCode;
import io.sphere.sdk.models.Base;
import java.util.Optional;
/**
* A geographical location representing a country with an optional state.
*/
public class Location extends Base {
private final CountryCode country;
@JsonInclude(JsonInclude.Include.NON_EMPTY)
private final Optional state;
@JsonCreator
private Location(final CountryCode country, final Optional state) {
this.country = country;
this.state = state;
}
public CountryCode getCountry() {
return country;
}
public Optional getState() {
return state;
}
@JsonIgnore
public static Location of(final CountryCode countryCode, final Optional state) {
return new Location(countryCode, state);
}
@JsonIgnore
public static Location of(final CountryCode countryCode, final String state) {
return new Location(countryCode, Optional.of(state));
}
@JsonIgnore
public static Location of(final CountryCode countryCode) {
return of(countryCode, Optional.empty());
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy