public final class CoalesceConstraint extends CorrectConstraint<String>
CorrectConstraint
implementation that
replaces all whitespaces with single character in a string.Coalesce
,
ConstraintFactory.coalesce()
,
ConstraintFactory.coalesce(char, boolean)
Modifier and Type | Field and Description |
---|---|
static CoalesceConstraint |
DEFAULT
CoalesceConstraint default instance initialized with
' ' whitespaces replacement character. |
Modifier and Type | Method and Description |
---|---|
char |
getReplacement()
Returns whitespaces replacement character.
|
Class<?> |
getType()
Returns
java.lang.String type. |
boolean |
isMultiline()
Flag determines if new line characters should be preserved.
|
<T> String |
validate(String value,
ValidationContext<T> context)
Replaces all whitespaces with replacement character in the specified
string.
|
getMessageTemplate
appendMessageArguments
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
appendMessageArguments
public static final CoalesceConstraint DEFAULT
CoalesceConstraint
default instance initialized with
' '
whitespaces replacement character.public char getReplacement()
public boolean isMultiline()
true
if new line characters should be preserved;
false
otherwise.public Class<?> getType()
java.lang.String
type.java.lang.String
type.public <T> String validate(String value, ValidationContext<T> context)
T
- The type of validated entity.value
- String to be coalesced.context
- Validation context.Copyright © 2011–2020 FoxLabs. All rights reserved.