- 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 classParameter.FormatThis class provides default values that can be used informat(String).static classParameter.RuleThis 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 booleanbindable()Returns whether or not this parameter is bindable.<P extends Parameter>
Pbindable(boolean value)Sets whether or not this parameter is bindable.DatadefaultValue()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.Stringdescription()Returns the parameter description<P extends Parameter>
Pdescription(java.lang.String value)Sets the parameter descriptionDataexport()Renders this class instance to a simple data structure for rendering client-side.java.lang.Stringformat()Returns the parameter expected format.<P extends Parameter>
Pformat(java.lang.String value)Sets the parameter expected format.intmax()Returns the maximum length of this parameterParametermax(int value)Sets the maximum length of this parameterintmin()Returns the minimum length of this parameterParametermin(int value)Sets the minimum length of this parameterjava.lang.Stringname()Returns the parameter namebooleanoptional()Returns whether or not this parameter allows empty valuesParameteroptional(boolean value)Sets whether or not this parameter allows empty valuesjava.util.function.Predicate<java.lang.String>rule()Returns the validation rule for this parameterParameterrule(java.lang.String value)Sets the validation rule for this parameter as the specified character listParameterrule(java.util.function.Predicate<java.lang.String> value)Sets the validation rule for this parameterjava.lang.Stringsummary()Returns the parameter summary<P extends Parameter>
Psummary(java.lang.String value)Sets the parameter summarybooleanvalidate(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 valuesParametervalues(java.lang.String... values)Sets the acceptable values.
-
-
-
Method Detail
-
name
public java.lang.String name()
Returns the parameter name- Specified by:
namein interfaceDocumented- Returns:
- the parameter name
-
summary
public java.lang.String summary()
Returns the parameter summary- Specified by:
summaryin 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:
descriptionin 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:ExportableRenders this class instance to a simple data structure for rendering client-side.- Specified by:
exportin interfaceDocumented- Specified by:
exportin interfaceExportable- Returns:
- a public data representation of this class instance
-
-