global.maplink.place.schema.Place Maven / Gradle / Ivy
package global.maplink.place.schema;
import global.maplink.place.schema.exception.PlaceUpdateException;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.RequiredArgsConstructor;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import static lombok.AccessLevel.PRIVATE;
@Data
@Builder
@RequiredArgsConstructor(staticName = "of")
@NoArgsConstructor(force = true, access = PRIVATE)
public class Place {
private final String id;
private final String name;
private final String documentNumber;
private final String description;
private final String url;
private final String website;
private final String favicon;
private final OpeningHours openingHours;
private final Set payments;
private final Category category;
private final SubCategory subCategory;
private final Address address;
private final Set phones;
private final Map additionalInfo;
private final Set connections;
private final boolean active;
private final String clientId;
public void validate() {
if (isInvalid(id)) {
throw PlaceUpdateException.of("id");
}
if (isInvalid(name)) {
throw PlaceUpdateException.of("name");
}
if (Objects.isNull(category)) {
throw PlaceUpdateException.of("category");
}
if (Objects.isNull(subCategory)) {
throw PlaceUpdateException.of("subCategory");
}
if (Objects.isNull(address)) {
throw PlaceUpdateException.of("subCategory");
}
address.validate();
}
private boolean isInvalid(final String value) {
return Objects.isNull(value) || value.trim().isEmpty();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy