public class LongPropertyType extends PropertyType<Long> implements Range<Long>
java.lang.Long
. Long.parseLong(string)
.
Constructor Example | Comments | ||
---|---|---|---|
Property<Long> A_PROPERTY = new Property<Long>("name", new LongPropertyType()); |
No default value, no minimum or maximum constraints. | ||
Property<Long> A_PROPERTY = |
Default value is "25", no minimum or maximum constraints. | ||
Property<Long> A_PROPERTY = |
No default value,minimum is "0" and maximum is "50", both inclusive.. | ||
Property<Long> A_PROPERTY = |
Default value is "25",minimum is "0" and maximum is "50", both inclusive. | ||
Type of value(s) | Examples | Result | Comments |
Valid | -25 | new Long(-25) | Validate successfully. |
Valid | 34 | new Long(34) | Validate successfully. |
Invalid | cow | null |
Validate will throw an exception. The resulting value is null . |
Invalid | 3.23 | null |
|
Invalid | «empty string» | null |
|
Invalid | «empty string after trim» | null |
|
Invalid | null |
defaultValue OR null |
Validate will throw an exception. Return default value if set, otherwise null . |
Long.parseLong(String)
,
Serialized FormModifier and Type | Field and Description |
---|---|
static String |
TYPE
The type name string constant of LongPropertyType
|
Constructor and Description |
---|
LongPropertyType()
Default constructor, no minimum, maximum or default value.
|
LongPropertyType(long defaultValue)
Constructor with default value.
|
LongPropertyType(Long defaultValue)
Constructor with default value.
|
LongPropertyType(long minValue,
long maxValue)
Constructor with minimum and maximum value.
|
LongPropertyType(Long minValue,
Long maxValue)
Constructor with minimum and maximum value.
|
LongPropertyType(long defaultValue,
long minValue,
long maxValue)
Constructor with minimum, maximum and default value.
|
LongPropertyType(Long defaultValue,
Long minValue,
Long maxValue)
Constructor with minimum and maximum value.
|
Modifier and Type | Method and Description |
---|---|
Long |
getMaxValue()
Gets the max value (inclusive) a value may be.
|
Long |
getMinValue()
Gets the min value (inclusive) a value may be.
|
List<String> |
getRestrictions()
Gets a detailed description of the PropertyType with any constraints that might influence the validation.
|
boolean |
isUseMaxValue()
Determines if max value restriction is used.
|
boolean |
isUseMinValue()
Determines if min value restriction is used.
|
void |
setMaxValue(Long maxValue)
Sets the max value (inclusive) a value may be.
|
void |
setMinValue(Long minValue)
Sets the min value (inclusive) a value may be.
|
void |
validateConstraints(String propertyName)
A PropertyType can have some constraints here is where they are
validated.
|
void |
validateIsInRange(String propertyName,
Long value)
Validates that a value is inside the valid range of min and max value if defined.
|
void |
validateMinMaxValues(String propertyName)
Validates that minValue is less or equal to maxValue, must be called by validateConstraints, and if there is a default value that is inside the valid range.
|
Long |
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, toString, toType, validate, validateNullType
public static final String TYPE
public LongPropertyType()
public LongPropertyType(long defaultValue)
defaultValue
- default value returned if property value is undefined.public LongPropertyType(Long defaultValue)
defaultValue
- default value returned if property value is undefined.public LongPropertyType(long defaultValue, long minValue, long maxValue)
defaultValue
- default value returned if property value is undefined.minValue
- minimum value, inclusive.maxValue
- maximum value, inclusive.public LongPropertyType(long minValue, long maxValue)
minValue
- minimum value, inclusive.maxValue
- maximum value, inclusive.public LongPropertyType(Long minValue, Long maxValue)
minValue
- minimum value, inclusive, if is null
than it means no default value.maxValue
- maximum value, inclusive, if is null
than it means no default value.public LongPropertyType(Long defaultValue, Long minValue, Long maxValue)
defaultValue
- default value returned if property value is undefined.minValue
- minimum value, inclusive, if is null
than it means no default value.maxValue
- maximum value, inclusive, if is null
than it means no default value.public List<String> getRestrictions()
PropertyType
getRestrictions
in class PropertyType<Long>
public Long validateValue(String propertyName, String value) throws PropertyException
PropertyType
validateValue
in class PropertyType<Long>
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<Long>
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 void validateIsInRange(String propertyName, Long value) throws PropertyException
Range
validateIsInRange
in interface Range<Long>
propertyName
- the propertyvalue
- the valuePropertyException
- if minValue is not null
and value is less than, or maxValue is not null
and value is greather than.PropertyType.validateValue(String, String)
public void validateMinMaxValues(String propertyName) throws PropertyException
Range
validateMinMaxValues
in interface Range<Long>
propertyName
- the name of the property.PropertyException
- if minValue is greather than maxValue.PropertyType.validateConstraints(String)
public Long getMaxValue()
getMaxValue
in interface Range<Long>
public Long getMinValue()
getMinValue
in interface Range<Long>
public void setMinValue(Long minValue)
setMinValue
in interface Range<Long>
minValue
- the min value.public void setMaxValue(Long maxValue)
setMaxValue
in interface Range<Long>
maxValue
- the max value.public boolean isUseMinValue()
isUseMinValue
in interface Range<Long>
true
if min value is not null
, otherwise false
.public boolean isUseMaxValue()
isUseMaxValue
in interface Range<Long>
true
if max value is not null
, otherwise false
.