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
ConstructorsConstructorDescriptionPropertySpec(String n, Class<V> valType, V defaultVal) Constructs aPropertySpecwith the provided name, the provided value type, and the provided default value. -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns the defaultProperty.final StringgetName()Returns the name of theProperty.Returns the value type of theProperty.inthashCode()newProperty(V value) Returns a newPropertywith the provided value.newPropertyWithParsedValue(String value) Returns a newPropertywith the parsed value from the providedStringvalue.protected abstract VReturns the parsed value from the providedStringvalue.final StringtoString()Returns theStringrepresentation of thisPropertySpec.protected VReturns the valid provided value.
-
Constructor Details
-
PropertySpec
Constructs aPropertySpecwith 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 newPropertywith the provided value. AnIllegalArgumentExceptionis thrown if the provided value is invalid.- Parameters:
value- the provided value- Returns:
- a new
Propertywith the provided value
-
newPropertyWithParsedValue
Returns a newPropertywith the parsed value from the providedStringvalue. AnIllegalArgumentExceptionis thrown if the providedStringvalue to be parsed is invalid or if the parsed value is invalid.- Parameters:
value- the providedStringvalue to be parsed- Returns:
- a new
Propertywith the parsed value from the providedStringvalue
-
parse
Returns the parsed value from the providedStringvalue. AnIllegalArgumentExceptionis thrown if the providedStringvalue to be parsed is invalid.- Parameters:
value- theStringvalue to be parsed- Returns:
- the parsed value from the provided
Stringvalue
-
toString
Returns theStringrepresentation of thisPropertySpec. -
validate
Returns the valid provided value. Implementations can override this method to throw anIllegalArgumentExceptionif the provided value is invalid.- Parameters:
value- the provided value- Returns:
- the valid provided value
-