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

global.maplink.tracking.schema.errors.GeoPointValidator Maven / Gradle / Ivy

package global.maplink.tracking.schema.errors;

import global.maplink.geocode.schema.GeoPoint;
import global.maplink.validations.ValidationViolation;
import lombok.NoArgsConstructor;

import java.util.List;

import static java.util.Collections.emptyList;
import static java.util.Collections.singletonList;
import static java.util.Objects.isNull;
import static lombok.AccessLevel.PRIVATE;

@NoArgsConstructor(access = PRIVATE)
public class GeoPointValidator {

    public static List validateGeoPoint(
            GeoPoint geoPoint,
            ValidationErrorType nullLocationError,
            ValidationErrorType nullLatLonError
    ) {
        if (isNull(geoPoint)) {
            return singletonList(nullLocationError);
        }
        if (isNull(geoPoint.getLat()) || isNull(geoPoint.getLon())) {
            return singletonList(nullLatLonError);
        }
        return emptyList();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy