- java.lang.Object
-
- aeonics.template.Parameter
-
- All Implemented Interfaces:
Documented
,Exportable
public class Parameter extends java.lang.Object implements Documented
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Parameter.Format
This class provides default values that can be used informat(String)
.static class
Parameter.Rule
This class provides default values that can be used inrule(Predicate)
.
-
Constructor Summary
Constructors Constructor Description Parameter(java.lang.String name)
Creates a new parameter
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
bindable()
Returns whether or not this parameter is bindable.<P extends Parameter>
Pbindable(boolean value)
Sets whether or not this parameter is bindable.Data
defaultValue()
Returns the default value of this parameter<P extends Parameter>
PdefaultValue(java.lang.Object value)
Defines an optional default value for this parameter.java.lang.String
description()
Returns the parameter description<P extends Parameter>
Pdescription(java.lang.String value)
Sets the parameter descriptionData
export()
Renders this class instance to a simple data structure for rendering client-side.java.lang.String
format()
Returns the parameter expected format.<P extends Parameter>
Pformat(java.lang.String value)
Sets the parameter expected format.int
max()
Returns the maximum length of this parameterParameter
max(int value)
Sets the maximum length of this parameterint
min()
Returns the minimum length of this parameterParameter
min(int value)
Sets the minimum length of this parameterjava.lang.String
name()
Returns the parameter nameboolean
optional()
Returns whether or not this parameter allows empty valuesParameter
optional(boolean value)
Sets whether or not this parameter allows empty valuesjava.util.function.Predicate<java.lang.String>
rule()
Returns the validation rule for this parameterParameter
rule(java.lang.String value)
Sets the validation rule for this parameter as the specified character listParameter
rule(java.util.function.Predicate<java.lang.String> value)
Sets the validation rule for this parameterjava.lang.String
summary()
Returns the parameter summary<P extends Parameter>
Psummary(java.lang.String value)
Sets the parameter summaryboolean
validate(Data value)
Validates the provided value against thevalidator()
of this parameterjava.util.function.Predicate<Data>
validator()
Returns the validator for this parameter.<P extends Parameter>
Pvalidator(java.util.function.Predicate<Data> value)
Sets the validator for this parameter.java.util.Set<java.lang.String>
values()
Returns the set of acceptable valuesParameter
values(java.lang.String... values)
Sets the acceptable values.
-
-
-
Method Detail
-
name
public java.lang.String name()
Returns the parameter name- Specified by:
name
in interfaceDocumented
- Returns:
- the parameter name
-
summary
public java.lang.String summary()
Returns the parameter summary- Specified by:
summary
in interfaceDocumented
- Returns:
- the parameter summary
-
summary
public <P extends Parameter> P summary(java.lang.String value)
Sets the parameter summary- Type Parameters:
P
- this parameter type- Parameters:
value
- the summary- Returns:
- this
-
format
public java.lang.String format()
Returns the parameter expected format. The parameter format is just an indication on how the parameter should be formatted and/or displayed to the user. There is no automaticrule()
that match the format, you should set both.- Returns:
- the parameter expected format
-
format
public <P extends Parameter> P format(java.lang.String value)
Sets the parameter expected format. The parameter format is just an indication on how the parameter should be formatted and/or displayed to the user. There is no automaticrule()
that match the format, you should set both.- Type Parameters:
P
- this parameter type- Parameters:
value
- the expected format- Returns:
- this
-
description
public java.lang.String description()
Returns the parameter description- Specified by:
description
in interfaceDocumented
- Returns:
- the parameter description
-
description
public <P extends Parameter> P description(java.lang.String value)
Sets the parameter description- Type Parameters:
P
- this parameter type- Parameters:
value
- the description- Returns:
- this
-
bindable
public boolean bindable()
Returns whether or not this parameter is bindable.- Returns:
- whether or not this parameter is bindable
- See Also:
bindable(boolean)
-
bindable
public <P extends Parameter> P bindable(boolean value)
Sets whether or not this parameter is bindable. Bindable parameters may contain${...}
constructs that will be substituted at runtime depending on the context, or the configuration.- Type Parameters:
P
- this parameter type- Parameters:
value
- whether or not to perform binding at runtime- Returns:
- this
-
validate
public boolean validate(Data value)
Validates the provided value against thevalidator()
of this parameter- Parameters:
value
- the value to validate- Returns:
- true if the value is valid for this parameter, false otherwise
-
validator
public java.util.function.Predicate<Data> validator()
Returns the validator for this parameter.The default validator is checking the
toString()
representation with regard to thedefaultValue()
,optional()
,min()
,max()
,values()
andrule()
.If you need a custom validation, then you should set one using
validator(Predicate)
.- Returns:
- the validator for this parameter
-
validator
public <P extends Parameter> P validator(java.util.function.Predicate<Data> value)
Sets the validator for this parameter.This method will replace the default validator so no other checks other than the one provided will be performed.
- Type Parameters:
P
- this parameter type- Parameters:
value
- the validator for this parameter- Returns:
- this
-
defaultValue
public Data defaultValue()
Returns the default value of this parameter- Returns:
- the default value of this parameter
-
defaultValue
public <P extends Parameter> P defaultValue(java.lang.Object value)
Defines an optional default value for this parameter.- Type Parameters:
P
- this parameter type- Parameters:
value
- the default value- Returns:
- this
-
optional
public boolean optional()
Returns whether or not this parameter allows empty values- Returns:
- true if this parameter allows empty values
-
optional
public Parameter optional(boolean value)
Sets whether or not this parameter allows empty values- Parameters:
value
- whether or not this parameter allows empty values- Returns:
- this
-
min
public int min()
Returns the minimum length of this parameter- Returns:
- the minimum length of this parameter
-
min
public Parameter min(int value)
Sets the minimum length of this parameter- Parameters:
value
- the minimum length of this parameter- Returns:
- this
-
max
public int max()
Returns the maximum length of this parameter- Returns:
- the maximum length of this parameter
-
max
public Parameter max(int value)
Sets the maximum length of this parameter- Parameters:
value
- the maximum length of this parameter- Returns:
- this
-
values
public java.util.Set<java.lang.String> values()
Returns the set of acceptable values- Returns:
- the set of acceptable values
-
values
public Parameter values(java.lang.String... values)
Sets the acceptable values. This method overrides the existing acceptables values with the ones provided.- Parameters:
values
- the acceptable values- Returns:
- this
-
rule
public java.util.function.Predicate<java.lang.String> rule()
Returns the validation rule for this parameter- Returns:
- the validation rule for this parameter
-
rule
public Parameter rule(java.util.function.Predicate<java.lang.String> value)
Sets the validation rule for this parameter- Parameters:
value
- the validation rule for this parameter- Returns:
- this
-
rule
public Parameter rule(java.lang.String value)
Sets the validation rule for this parameter as the specified character list- Parameters:
value
- the list of allowed characters- Returns:
- this
-
export
public Data export()
Description copied from interface:Exportable
Renders this class instance to a simple data structure for rendering client-side.- Specified by:
export
in interfaceDocumented
- Specified by:
export
in interfaceExportable
- Returns:
- a public data representation of this class instance
-
-