public class SearchTypeValidator extends Object
Modifier and Type | Field and Description |
---|---|
static String |
SIMPLE_ISO_YEAR_MONTH_PATTERN |
Modifier and Type | Method and Description |
---|---|
static boolean |
isDateRange(String value)
Determines whether the value given is a valid date range or low precision (year, year-month) date, delimiting two values by a comma.
|
static boolean |
isNumericRange(String value)
Determines whether the value given is a valid numeric range, delimiting two values by a comma.
|
static Range<LocalDate> |
parseDateRange(String value)
Parses a range of ISO dates.
|
static Range<Double> |
parseDecimalRange(String value)
Parses a decimal range in the format 123.1,456.
|
static DistanceUnit.Distance |
parseDistance(String distance) |
static Range<DistanceUnit.Distance> |
parseDistanceRange(String value)
Parses a distance range in the format 123m,456km.
|
static Range<Integer> |
parseIntegerRange(String value)
Parses an integer range in the format 123,456
|
static void |
validate(SearchParameter param,
String value)
Validates that a given parameter value matches the expected type of the parameter as defined by
SearchParameter.type() and throws an IllegalArgumentException otherwise. |
static void |
validateGeoDistance(String latitude,
String longitude,
String distance) |
public static final String SIMPLE_ISO_YEAR_MONTH_PATTERN
public static boolean isNumericRange(String value)
public static boolean isDateRange(String value)
public static Range<LocalDate> parseDateRange(String value)
IllegalArgumentException
- if value is invalid or nullpublic static Range<Double> parseDecimalRange(String value)
IllegalArgumentException
- if value is invalid or nullpublic static Range<Integer> parseIntegerRange(String value)
IllegalArgumentException
- if value is invalid or nullpublic static void validate(SearchParameter param, String value) throws IllegalArgumentException
SearchParameter.type()
and throws an IllegalArgumentException otherwise.param
- the search parameter defining the expected typevalue
- the parameter value to be validatedIllegalArgumentException
- if the value cannot be converted to the expected typepublic static void validateGeoDistance(String latitude, String longitude, String distance)
public static Range<DistanceUnit.Distance> parseDistanceRange(String value)
IllegalArgumentException
- if value is invalid or nullpublic static DistanceUnit.Distance parseDistance(String distance)
Copyright © 2024 Global Biodiversity Information Facility (GBIF). All rights reserved.