Class IdValidator
- java.lang.Object
-
- org.eclipse.ditto.model.base.common.IdValidator
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Optional<String>
getReason()
Returns the reason why the validation failed.boolean
isValid()
Validates the ID which was provided to the static factory method of this class.static IdValidator
newInstance(CharSequence id, String regex)
Creates a newIdValidator
instance.
-
-
-
Method Detail
-
newInstance
public static IdValidator newInstance(@Nullable CharSequence id, String regex)
Creates a newIdValidator
instance.- Parameters:
id
- the ID to be validated.regex
- the regular expression to be validated against.- Returns:
- a new
IdValidator
object. - Throws:
NullPointerException
- ifregex
isnull
.
-
isValid
public boolean isValid()
Validates the ID which was provided to the static factory method of this class. Validation ensures that the ID complies to the provided regular expression.- Specified by:
isValid
in interfaceValidator
- Returns:
true
if the checked Thing ID is valid,false
else.- See Also:
Validator.getReason()
-
getReason
public Optional<String> getReason()
Description copied from interface:Validator
Returns the reason why the validation failed. The returned Optional only contains a reason ifValidator.isValid()
evaluates tofalse
.
-
-