public class LegalCharsetConstraint extends CheckConstraint<String>
CheckConstraint
implementation that checks
whether a string contains allowed characters only.LegalCharset
,
ConstraintFactory.legalCharset(String)
,
ConstraintFactory.legalCharset(UnicodeSet)
Modifier and Type | Field and Description |
---|---|
protected org.foxlabs.util.UnicodeSet |
charset
Allowed character set.
|
Modifier | Constructor and Description |
---|---|
protected |
LegalCharsetConstraint(org.foxlabs.util.UnicodeSet charset)
Constructs a new
LegalCharsetConstraint with the specified
allowed character set. |
Modifier and Type | Method and Description |
---|---|
boolean |
appendMessageArguments(ValidationContext<?> context,
Map<String,Object> arguments)
Appends
charset argument that contains allowed character
set. |
protected <T> boolean |
check(String value,
ValidationContext<T> context)
Checks whether the specified string contains allowed characters only.
|
org.foxlabs.util.UnicodeSet |
getCharset()
Returns allowed character set.
|
Class<?> |
getType()
Returns
java.lang.String type. |
validate
getMessageTemplate
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getMessageTemplate
protected LegalCharsetConstraint(org.foxlabs.util.UnicodeSet charset)
LegalCharsetConstraint
with the specified
allowed character set.charset
- Allowed character set.IllegalArgumentException
- if the specified character set is
null
or empty.public final Class<?> getType()
java.lang.String
type.java.lang.String
type.public final org.foxlabs.util.UnicodeSet getCharset()
public boolean appendMessageArguments(ValidationContext<?> context, Map<String,Object> arguments)
charset
argument that contains allowed character
set.appendMessageArguments
in interface Constraint<String>
appendMessageArguments
in interface Validation<String>
appendMessageArguments
in class AbstractValidation<String>
context
- Validation context.arguments
- Arguments to be substituted into the error message
template.true
.protected <T> boolean check(String value, ValidationContext<T> context)
check
in class CheckConstraint<String>
T
- The type of validated entity.value
- String to be checked.context
- Validation context.true
if the specified string contains allowed
characters only; false
otherwise.Copyright © 2011–2020 FoxLabs. All rights reserved.