io.sphere.sdk.zones.ZoneDraft Maven / Gradle / Ivy
package io.sphere.sdk.zones;
import com.neovisionaries.i18n.CountryCode;
import java.util.Optional;
import java.util.Set;
import static java.util.stream.Collectors.toSet;
public class ZoneDraft {
private final String name;
private final Optional description;
private final Set locations;
private ZoneDraft(final String name, final Set locations, final Optional description) {
this.description = description;
this.name = name;
this.locations = locations;
}
public Optional getDescription() {
return description;
}
public Set getLocations() {
return locations;
}
public String getName() {
return name;
}
public static ZoneDraft of(final String name, final Set locations) {
return of(name, locations, Optional.empty());
}
public static ZoneDraft of(final String name, final Set locations, final String description) {
return of(name, locations, Optional.of(description));
}
public static ZoneDraft ofCountries(final String name, final Set countries, final String description) {
return ofCountries(name, countries, Optional.of(description));
}
public static ZoneDraft ofCountries(final String name, final Set countries, final Optional description) {
final Set locations = countries.stream().map(country -> Location.of(country)).collect(toSet());
return new ZoneDraft(name, locations, description);
}
public static ZoneDraft of(final String name, final Set locations, final Optional description) {
return new ZoneDraft(name, locations, description);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy