java.lang.Object
org.elasticsearch.xpack.core.inference.InferenceUtils
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceInferenceUtils.EnumConstructor<E extends Enum<E>>Functional interface for creating an enum from a string. -
Method Summary
Modifier and TypeMethodDescriptionstatic <E extends Enum<E>>
EextractOptionalEnum(Map<String, Object> map, String settingName, String scope, InferenceUtils.EnumConstructor<E> constructor, EnumSet<E> validValues, ValidationException validationException) static <T> List<T> extractOptionalList(Map<String, Object> map, String settingName, Class<T> type, ValidationException validationException) static StringextractOptionalString(Map<String, Object> map, String settingName, String scope, ValidationException validationException) static IntegerextractRequiredPositiveInteger(Map<String, Object> map, String settingName, String scope, ValidationException validationException) static IntegerextractRequiredPositiveIntegerGreaterThanOrEqualToMin(Map<String, Object> map, String settingName, int minValue, String scope, ValidationException validationException) static IntegerextractRequiredPositiveIntegerLessThanOrEqualToMax(Map<String, Object> map, String settingName, int maxValue, String scope, ValidationException validationException) static StringinvalidTypeErrorMsg(String settingName, Object foundObject, String expectedType) static StringinvalidValue(String settingName, String scope, String invalidType, String[] requiredValues) static StringmissingSettingErrorMsg(String settingName, String scope) static StringmustBeAPositiveIntegerErrorMessage(String settingName, String scope, int value) static StringmustBeGreaterThanOrEqualNumberErrorMessage(String settingName, String scope, double value, double minValue) static StringmustBeLessThanOrEqualNumberErrorMessage(String settingName, String scope, double value, double maxValue) static StringmustBeNonEmptyString(String settingName, String scope) static <T> TremoveAsType(Map<String, Object> sourceMap, String key, Class<T> type, ValidationException validationException) Remove the object from the map and cast to the expected type.
-
Method Details
-
removeAsType
public static <T> T removeAsType(Map<String, Object> sourceMap, String key, Class<T> type, ValidationException validationException) Remove the object from the map and cast to the expected type. If the object cannot be cast to type and error is added to thevalidationExceptionparameter- Type Parameters:
T- The expected type- Parameters:
sourceMap- Map containing fieldskey- The key of the object to removetype- The expected type of the removed objectvalidationException- If the value is not of typetype- Returns:
nullif not present else the object cast to type T
-
extractOptionalString
-
extractRequiredPositiveInteger
-
extractRequiredPositiveIntegerGreaterThanOrEqualToMin
-
extractRequiredPositiveIntegerLessThanOrEqualToMax
-
extractOptionalList
-
extractOptionalEnum
public static <E extends Enum<E>> E extractOptionalEnum(Map<String, Object> map, String settingName, String scope, InferenceUtils.EnumConstructor<E> constructor, EnumSet<E> validValues, ValidationException validationException) -
mustBeNonEmptyString
-
invalidValue
-
invalidTypeErrorMsg
-
missingSettingErrorMsg
-
mustBeGreaterThanOrEqualNumberErrorMessage
-
mustBeLessThanOrEqualNumberErrorMessage
-
mustBeAPositiveIntegerErrorMessage
-