Class UniqueNameValidator
java.lang.Object
net.mcreator.ui.validation.validators.UniqueNameValidator
- All Implemented Interfaces:
Validator
- Direct Known Subclasses:
ModElementNameValidator
While serving as a wrapper for the main component validator (if specified), a unique name validator also checks
if that component provides a non-empty identifier that has no duplicates in the given elements list.
-
Nested Class Summary
Nested classes/interfaces inherited from interface net.mcreator.ui.validation.Validator
Validator.ValidationResult, Validator.ValidationResultType
-
Constructor Summary
ConstructorDescriptionUniqueNameValidator
(String name, Supplier<String> uniqueNameGetter, Supplier<Stream<String>> otherNames, Collection<String> forbiddenNames, Validator extraValidator) UniqueNameValidator
(String name, Supplier<String> uniqueNameGetter, Supplier<Stream<String>> otherNames, Validator extraValidator) -
Method Summary
Modifier and TypeMethodDescriptionReturns the main validator for the validated element.setIgnoreCase
(boolean ignoreCase) Use this method to define if case of validated name doesn't have to match case ofotherNames
.setIsPresentOnList
(boolean isPresentOnList) Use this method to define if the validated name is present onotherNames
list.setIsPresentOnList
(Supplier<Boolean> isPresentOnList) Use this method to define if the validated name is present onotherNames
list.validate()
wrapValidator
(Validator extraValidator) Returns a copy of this UniqueNameValidator with main validator changed to the passed one.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface net.mcreator.ui.validation.Validator
validateIfEnabled
-
Constructor Details
-
UniqueNameValidator
public UniqueNameValidator(String name, Supplier<String> uniqueNameGetter, Supplier<Stream<String>> otherNames, Validator extraValidator) - Parameters:
name
- The text used to describe the purpose of the holder.uniqueNameGetter
- Supplier to get unique name from the holder's text.otherNames
- Supplier of names of other elements in the same list. Those must all be unique names.extraValidator
- The main validator for the holder.
-
UniqueNameValidator
public UniqueNameValidator(String name, Supplier<String> uniqueNameGetter, Supplier<Stream<String>> otherNames, Collection<String> forbiddenNames, Validator extraValidator) - Parameters:
name
- The text used to describe the purpose of the holder.uniqueNameGetter
- Supplier to get unique name from the holder's text.otherNames
- Supplier of names of other elements in the same list. Those must all be unique names.forbiddenNames
- List of strings that must not be used as a name, e.g. names of built-in properties.extraValidator
- The main validator for the holder.
-
-
Method Details
-
setIsPresentOnList
Use this method to define if the validated name is present onotherNames
list.- Parameters:
isPresentOnList
- Whether the validated name is present onotherNames
list.- Returns:
- This validator instance with
isPresentOnList
parameter set to passed value.
-
setIsPresentOnList
Use this method to define if the validated name is present onotherNames
list.- Parameters:
isPresentOnList
- Supplier that controls whether the validated name is present onotherNames
list.- Returns:
- This validator instance with
isPresentOnList
parameter set to passed value.
-
setIgnoreCase
Use this method to define if case of validated name doesn't have to match case ofotherNames
.- Parameters:
ignoreCase
- Whether case of validated name doesn't have to match case ofotherNames
.- Returns:
- This validator instance with
ignoreCase
parameter set to passed value.
-
wrapValidator
Returns a copy of this UniqueNameValidator with main validator changed to the passed one.- Parameters:
extraValidator
- The new main validator for the validated element.
-
getExtraValidator
Returns the main validator for the validated element.- Returns:
- The main validator for the validated element.
-
validate
-