@ThreadSafe public final class ModelLengthLimiter<S extends CharSequence> extends AbstractWrapModel<S>
CharSequence,
Serialized Form| Constructor and Description |
|---|
ModelLengthLimiter(IModel<S> _wrappedModel,
int _maxLength)
Constructs a ModelLengthLimiter, or throws an IllegalArgumentException
if the current value of the wrapped model exceeds the constraint.
|
| Modifier and Type | Method and Description |
|---|---|
int |
getMaxLength()
The length constraint.
|
S |
getObject() |
IModel<S> |
getWrappedModel() |
static <S extends CharSequence> |
lengthConstrained(S s,
int maxLength)
Ensures that character sequence s does not exceed the specified maximum length.
|
void |
setObject(S o)
Sets the model object; or throws an IllegalArgumentException if the object's
string value is longer than the maximum length.
|
detachpublic ModelLengthLimiter(IModel<S> _wrappedModel, int _maxLength) throws ClassCastException
ClassCastException - if the current value is neither a CharSequence, nor nullgetWrappedModel(),
getMaxLength()public final int getMaxLength()
public static <S extends CharSequence> S lengthConstrained(S s, int maxLength)
IllegalArgumentException - if sequence s exceeds maxLengthpublic void setObject(S o) throws ClassCastException
setObject in interface IModel<S extends CharSequence>setObject in class AbstractWrapModel<S extends CharSequence>ClassCastException - if the object is neither a CharSequence, nor nullpublic S getObject()
getObject in interface IModel<S extends CharSequence>getObject in class AbstractWrapModel<S extends CharSequence>public IModel<S> getWrappedModel()