= @Parameter
:Notice: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at. http://www.apache.org/licenses/LICENSE-2.0 . Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR  CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Collects together all domain semantics of an action parameter within a single annotation.

== API

[source,java]
.Parameter.java
----
@interface Parameter {
  String fileAccept() default "";     // <.>
  int maxLength() default -1;     // <.>
  Class<? extends Specification>[] mustSatisfy() default {};     // <.>
  Optionality optionality() default Optionality.NOT_SPECIFIED;     // <.>
  String regexPattern() default "";     // <.>
  int regexPatternFlags() default 0;     // <.>
  String regexPatternReplacement() default "Doesn't match pattern";     // <.>
  DependentDefaultsPolicy dependentDefaultsPolicy() default DependentDefaultsPolicy.AS_CONFIGURED;     // <.>
}
----

<.> xref:#fileAccept[fileAccept]
+
--
For uploading xref:refguide:applib:index/value/Blob.adoc[Blob] or xref:refguide:applib:index/value/Clob.adoc[Clob] , optionally restrict the files accepted (eg `.xslx` ).
--
<.> xref:#maxLength[maxLength]
+
--
The maximum entry length of a string parameter (it is ignored for other types).
--
<.> xref:#mustSatisfy[mustSatisfy]
+
--
The xref:refguide:applib:index/spec/Specification.adoc[Specification] (s) to be satisfied by this parameter.
--
<.> xref:#optionality[optionality]
+
--
Whether this parameter is optional or is mandatory (ie required).
--
<.> xref:#regexPattern[regexPattern]
+
--
Regular expression pattern that a value should conform to, and can be formatted as.
--
<.> xref:#regexPatternFlags[regexPatternFlags]
+
--
Pattern flags, as per _java.util.regex.Pattern#compile(String, int)_ .
--
<.> xref:#regexPatternReplacement[regexPatternReplacement]
+
--
Replacement text for the pattern in generated error message.
--
<.> xref:#dependentDefaultsPolicy[dependentDefaultsPolicy]
+
--
Whether this parameter should be reset to its default if an earlier parameter changes its value, or whether instead the parameter's value, once changed by the end-user, should never be overwritten even if the end-user changes an earlier parameter value.
--

== Members

[#fileAccept]
=== fileAccept

For uploading xref:refguide:applib:index/value/Blob.adoc[Blob] or xref:refguide:applib:index/value/Clob.adoc[Clob] , optionally restrict the files accepted (eg `.xslx` ).

The value should be of the form "file_extension|audio/*|video/*|image/*|media_type".

Note that this does not prevent the user from uploading some other file type; rather it merely defaults the file type in the file open dialog.

[#maxLength]
=== maxLength

The maximum entry length of a string parameter (it is ignored for other types).

The default value ( `-1` ) indicates that no maxLength has been specified.

[#mustSatisfy]
=== mustSatisfy

The xref:refguide:applib:index/spec/Specification.adoc[Specification] (s) to be satisfied by this parameter.

If more than one is provided, then all must be satisfied (in effect "AND"ed together).

[#optionality]
=== optionality

Whether this parameter is optional or is mandatory (ie required).

For parameters the default value, _org.apache.isis.applib.annotation.Optionality#DEFAULT_ , is taken to mean that the parameter is required.

[#regexPattern]
=== regexPattern

Regular expression pattern that a value should conform to, and can be formatted as.

[#regexPatternFlags]
=== regexPatternFlags

Pattern flags, as per _java.util.regex.Pattern#compile(String, int)_ .

The default value, `0` , means that no flags have been specified.

[#regexPatternReplacement]
=== regexPatternReplacement

Replacement text for the pattern in generated error message.

[#dependentDefaultsPolicy]
=== dependentDefaultsPolicy

Whether this parameter should be reset to its default if an earlier parameter changes its value, or whether instead the parameter's value, once changed by the end-user, should never be overwritten even if the end-user changes an earlier parameter value.

include::hooks/Parameter_010-examples-and-usage.adoc[]

include::hooks/Parameter_021-optionality.adoc[]

include::hooks/Parameter_022-maxLength.adoc[]

include::hooks/Parameter_023-mustSatisfy.adoc[]

include::hooks/Parameter_024-regexPattern.adoc[]

include::hooks/Parameter_025-fileAccept.adoc[]
