Class PropertySpec<V>
java.lang.Object
com.github.jh3nd3rs0n.jargyle.client.PropertySpec<V>
- Type Parameters:
V
- the specified value type
The specification of a
Property
of the specified value type.-
Constructor Summary
ConstructorDescriptionPropertySpec
(String n, Class<V> valType, V defaultVal) Constructs aPropertySpec
with the provided name, the provided value type, and the provided default value. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Returns the defaultProperty
.final String
getName()
Returns the name of theProperty
.Returns the value type of theProperty
.int
hashCode()
newProperty
(V value) Returns a newProperty
with the provided value.newPropertyWithParsedValue
(String value) Returns a newProperty
with the parsed value from the providedString
value.protected abstract V
Returns the parsed value from the providedString
value.final String
toString()
Returns theString
representation of thisPropertySpec
.protected V
Returns the valid provided value.
-
Constructor Details
-
PropertySpec
Constructs aPropertySpec
with the provided name, the provided value type, and the provided default value.- Parameters:
n
- the provided namevalType
- the provided value typedefaultVal
- the provided default value (can benull
)
-
-
Method Details
-
equals
-
getDefaultProperty
Returns the defaultProperty
.- Returns:
- the default
Property
-
getName
Returns the name of theProperty
.- Returns:
- the name of the
Property
-
getValueType
Returns the value type of theProperty
.- Returns:
- the value type of the
Property
-
hashCode
public int hashCode() -
newProperty
Returns a newProperty
with the provided value. AnIllegalArgumentException
is thrown if the provided value is invalid.- Parameters:
value
- the provided value- Returns:
- a new
Property
with the provided value
-
newPropertyWithParsedValue
Returns a newProperty
with the parsed value from the providedString
value. AnIllegalArgumentException
is thrown if the providedString
value to be parsed is invalid or if the parsed value is invalid.- Parameters:
value
- the providedString
value to be parsed- Returns:
- a new
Property
with the parsed value from the providedString
value
-
parse
Returns the parsed value from the providedString
value. AnIllegalArgumentException
is thrown if the providedString
value to be parsed is invalid.- Parameters:
value
- theString
value to be parsed- Returns:
- the parsed value from the provided
String
value
-
toString
Returns theString
representation of thisPropertySpec
. -
validate
Returns the valid provided value. Implementations can override this method to throw anIllegalArgumentException
if the provided value is invalid.- Parameters:
value
- the provided value- Returns:
- the valid provided value
-