public class StringPropertyType extends PropertyType<String>
Constructor Example | Comments | ||
---|---|---|---|
Property<String> A_PROPERTY = new Property<String>("name", new StringPropertyType()); |
Default value is null . |
||
Property<String> A_PROPERTY = new Property<String>("name", new StringPropertyType("def")); |
Default value is def . |
||
Property<String> A_PROPERTY = new Property<String>("name", new StringPropertyType(80)); |
Default value is null . Max length is 80. |
||
Property<String> A_PROPERTY = new Property<String>("name", new StringPropertyType("def",80)); |
Default value is def .Max length is 80. |
||
Property<String> A_PROPERTY = new Property<String>("name", new StringPropertyType(5,69)); |
Default value is null . Min length is 5, max length is 69. |
||
Property<String> A_PROPERTY = new Property<String>("name", new StringPropertyType("def",5,69)); |
Default value is def . Min length is 5, max length is 69. |
||
Type of value(s) | Examples | Result | Comments |
Valid | cow | new String("cow") | Validate successfully. The string value is trimmed and lower cased before conversion. |
Invalid | null |
defaultValue OR null |
Validate will throw an exception. Return default value if set, otherwise null . |
Modifier and Type | Field and Description |
---|---|
static String |
TYPE
The type name string constant of StringPropertyType.
|
Constructor and Description |
---|
StringPropertyType()
Creates a string property type.
|
StringPropertyType(int maxLength)
Creates a string property type.
|
StringPropertyType(Integer minLength,
Integer maxLength)
Creates a string property type.
|
StringPropertyType(Pattern pattern)
Creates a string property type.
|
StringPropertyType(String defaultValue)
Creates a string property type.
|
StringPropertyType(String defaultValue,
int maxLength)
Creates a string property type.
|
StringPropertyType(String defaultValue,
Integer minLength,
Integer maxLength)
Creates a string property type.
|
StringPropertyType(String defaultValue,
Integer minLength,
Integer maxLength,
Pattern pattern)
Creates a string property type.
|
Modifier and Type | Method and Description |
---|---|
Integer |
getMaxLength()
The maximum length of the string.
|
Integer |
getMinLength()
The minimum length of the string.
|
Pattern |
getPattern()
Gets the regular expression pattern which the string shall validates to.
|
String |
getPatternString()
Gets the pattern string if any,
|
List<String> |
getRestrictions()
Gets a detailed description of the PropertyType with any constraints that might influence the validation.
|
boolean |
isUseMaxLength()
Determines if there is maximum length restrictions on the string.
|
boolean |
isUseMinLength()
Determines if there is minimum length restrictions on the string.
|
void |
setMaxLength(Integer maxLength)
Sets the max length of the string.
|
void |
setMinLength(Integer minLength)
Sets the min length of the string.
|
void |
setPattern(Pattern pattern)
Set the pattern which the string shall validates to.
|
void |
setPatternString(String patternString)
Sets a pattern string which the string shall validates to.
|
String |
toString(String propertyName,
String t)
Converts a typed to the string representation.
|
void |
validateConstraints(String propertyName)
A PropertyType can have some constraints here is where they are
validated.
|
String |
validateValue(String propertyName,
String value)
Converts the string representation of to a typed value.
|
equals, getDefaultValue, getDefaultValueAsString, getDefaultValueDescription, getDescription, getDescription, getInitializationPriority, getIo, getLogger, getTypeName, hasDefaultValue, isDefaultValueValid, postGetValueProcessing, setDefaultValue, setInitializationPriority, setIo, setTypedValue, setTypeName, toType, validate, validateNullType
public static final String TYPE
public StringPropertyType()
null
and no minimum or maximum length restrictions og no pattern restrictions.public StringPropertyType(Pattern pattern)
null
and no minimum or maximum length restrictions.pattern
- the regular expression pattern which the string must match. If null
, it is ignored.public StringPropertyType(String defaultValue)
defaultValue
- default value returned if property value is undefined.public StringPropertyType(int maxLength)
null
and no minimum length restrictions.maxLength
- public StringPropertyType(String defaultValue, int maxLength)
null
and no minimum length restrictions. The pattern is default null
.defaultValue
- the default value if the value do not parse validation.maxLength
- the maximum length of the string (inclusive). Input null
for no maximum length restrictions.public StringPropertyType(Integer minLength, Integer maxLength)
null
. The pattern is default null
.minLength
- the minimum length of the string (inclusive). Input null
for no minimum length restrictions.maxLength
- the maximum length of the string (inclusive). Input null
for no maximum length restrictions.public StringPropertyType(String defaultValue, Integer minLength, Integer maxLength)
defaultValue
- the default value if the value do not parse validation.minLength
- the minimum length of the string (inclusive). Input null
for no minimum length restrictions.maxLength
- the maximum length of the string (inclusive). Input null
for no maximum length restrictions.public StringPropertyType(String defaultValue, Integer minLength, Integer maxLength, Pattern pattern)
defaultValue
- the default value if the value do not parse validation.minLength
- the minimum length of the string (inclusive). Input null
for no minimum length restrictions.maxLength
- the maximum length of the string (inclusive). Input null
for no maximum length restrictions.pattern
- the regular expression pattern which the string must match. If null
, it is ignored.public String toString(String propertyName, String t) throws PropertyException
PropertyType
toString
in class PropertyType<String>
propertyName
- the name of the property used for logging purposes.t
- the type T.PropertyException
- if conversion failed in validation.PropertyType.validate(String, String)
public String validateValue(String propertyName, String value) throws PropertyException
PropertyType
validateValue
in class PropertyType<String>
propertyName
- the name of the property used for logging purposes. To uniquely identify the Property with validation issues.value
- the string representation of the propertyPropertyException
- if the conversion failed.public void validateConstraints(String propertyName) throws PropertyException
PropertyType
validateConstraints
in class PropertyType<String>
propertyName
- the name of the property used for logging purposes, to
identify the unique property which PropertyType has constraint
issues.PropertyException
- if the constraints have invalid/conflicting values.Property.validate()
public List<String> getRestrictions()
PropertyType
getRestrictions
in class PropertyType<String>
public boolean isUseMaxLength()
true
if there are maximum length restrictions, otherwise false
.public boolean isUseMinLength()
true
if there are minimum length restrictions, otherwise false
.public Integer getMaxLength()
null
no restrictions is enforced.public Integer getMinLength()
null
no restrictions is enforced.public void setMinLength(Integer minLength)
null
no restrictions is enforced.minLength
- the min length of the string. (inclusive), if null
no restrictions is enforced.public void setMaxLength(Integer maxLength)
null
no restrictions is enforced.maxLength
- the max length of the string. (inclusive), if null
no restrictions is enforced.public Pattern getPattern()
null
is returned.public void setPattern(Pattern pattern)
pattern
- the pattern, if null
than no pattern is enforced.public void setPatternString(String patternString) throws PropertyException
patternString
- the pattern stringPropertyException
- if the pattern string is not valid.public String getPatternString()
null
is returned.