You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by da...@apache.org on 2017/10/09 19:33:50 UTC
[isis] 02/02: ISIS-1742: adds documentation for @Pattern annotation.
This is an automated email from the ASF dual-hosted git repository.
danhaywood pushed a commit to branch dev/2.0.0/ISIS-1742-remove-deprecations
in repository https://gitbox.apache.org/repos/asf/isis.git
commit 5d5e6771750c3d8cb6e426c5c43b9bd4b8da8927
Author: Dan Haywood <da...@haywood-associates.co.uk>
AuthorDate: Mon Oct 9 20:31:11 2017 +0100
ISIS-1742: adds documentation for @Pattern annotation.
---
.../main/asciidoc/guides/rgant/_rgant-Pattern.adoc | 43 ++++++++++++----------
.../src/main/asciidoc/guides/rgant/_rgant_aaa.adoc | 1 -
.../main/asciidoc/guides/rgant/_rgant_aaa_jee.adoc | 7 ++++
.../src/main/asciidoc/guides/rgant/rgant.adoc | 3 +-
.../ugfun/_ugfun_programming-model_actions.adoc | 4 +-
5 files changed, 34 insertions(+), 24 deletions(-)
diff --git a/adocs/documentation/src/main/asciidoc/guides/rgant/_rgant-Pattern.adoc b/adocs/documentation/src/main/asciidoc/guides/rgant/_rgant-Pattern.adoc
index 16a8a42..a2ed03c 100644
--- a/adocs/documentation/src/main/asciidoc/guides/rgant/_rgant-Pattern.adoc
+++ b/adocs/documentation/src/main/asciidoc/guides/rgant/_rgant-Pattern.adoc
@@ -1,35 +1,38 @@
-[[_rgant-Digits]]
-= `@Digits` (`javax`)
+[[_rgant-Pattern]]
+= `@Pattern` (`javax`)
: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 ag [...]
:_basedir: ../../
:_imagesdir: images/
-The `@javax.validation.constraints.Digits` annotation is recognized by Apache Isis as a means to specify the precision for properties and action parameters of type `java.math.BigDecimal`.
+The `@javax.validation.constraints.Pattern` annotation is recognized by Apache Isis as a means to specify a regular expression constraint for properties and action parameters of type `java.lang.String`.
-For example (taken from the (non-ASF) http://github.com/isisaddons/isis-app-todoapp[Isis addons' todoapp]):
+For example:
[source,java]
----
-@javax.jdo.annotations.Column(
- scale=2 // <1>
+@javax.validation.constraints.Pattern(
+ regexp="[A-Z].+"
+ message="Must begin with a capital."
)
-@javax.validation.constraints.Digits(
- integer=10,
- fraction=2 // <2>
-)
-public BigDecimal getCost() {
- return cost;
-}
-public void setCost(final BigDecimal cost) {
- this.cost = cost!=null
- ? cost.setScale(2, BigDecimal.ROUND_HALF_EVEN) // <3>
- :null;
+public String getName() {
+ return name;
}
+...
----
-<1> the xref:../rgant/rgant.adoc#_rgant-Column[`@Column#scale()`] attribute must be ...
-<2> ... consistent with `@Digits#fraction()`
-<3> the correct idiom when setting a new value is to normalized to the correct scale
+It is also possible to specify against a field if Lombok is being used:
+
+
+[source,java]
+----
+@javax.validation.constraints.Pattern(
+ regexp="[A-Z].+"
+ message="Must begin with a capital."
+)
+@lombok.Getter @lombok.Setter
+private String name;
+----
+
diff --git a/adocs/documentation/src/main/asciidoc/guides/rgant/_rgant_aaa.adoc b/adocs/documentation/src/main/asciidoc/guides/rgant/_rgant_aaa.adoc
index 838ceef..93635ea 100644
--- a/adocs/documentation/src/main/asciidoc/guides/rgant/_rgant_aaa.adoc
+++ b/adocs/documentation/src/main/asciidoc/guides/rgant/_rgant_aaa.adoc
@@ -11,7 +11,6 @@ include::_rgant_aaa_main.adoc[leveloffset=+1]
include::_rgant_aaa_other.adoc[leveloffset=+1]
include::_rgant_aaa_jdo.adoc[leveloffset=+1]
include::_rgant_aaa_jee.adoc[leveloffset=+1]
-include::_rgant_aaa_deprecated.adoc[leveloffset=+1]
include::_rgant_aaa_partial.adoc[leveloffset=+1]
diff --git a/adocs/documentation/src/main/asciidoc/guides/rgant/_rgant_aaa_jee.adoc b/adocs/documentation/src/main/asciidoc/guides/rgant/_rgant_aaa_jee.adoc
index 4a95c21..625206c 100644
--- a/adocs/documentation/src/main/asciidoc/guides/rgant/_rgant_aaa_jee.adoc
+++ b/adocs/documentation/src/main/asciidoc/guides/rgant/_rgant_aaa_jee.adoc
@@ -25,6 +25,13 @@ The table below lists the JEE annotations currently recognized. Expect to see m
|Domain
|
+|xref:../rgant/rgant.adoc#_rgant-Pattern[`@javax.validation.` +
+`constraints.` +
+`Pattern`]
+|Regular expressions for strings
+|Domain
+|
+
|xref:../rgant/rgant.adoc#_rgant-Inject[`@javax.inject.` +
`Inject`]
|Inject domain service into a domain object (entity or view model) or another domain service.
diff --git a/adocs/documentation/src/main/asciidoc/guides/rgant/rgant.adoc b/adocs/documentation/src/main/asciidoc/guides/rgant/rgant.adoc
index aaf5833..8c1f7bb 100644
--- a/adocs/documentation/src/main/asciidoc/guides/rgant/rgant.adoc
+++ b/adocs/documentation/src/main/asciidoc/guides/rgant/rgant.adoc
@@ -82,11 +82,12 @@ include::_rgant-Inject.adoc[leveloffset=+1]
include::_rgant-MemberGroupLayout.adoc[leveloffset=+1]
include::_rgant-MemberOrder.adoc[leveloffset=+1]
include::_rgant-Mixin.adoc[leveloffset=+1]
-include::_rgant-Nullable.adoc[leveloffset=+1]
include::_rgant-NotPersistent.adoc[leveloffset=+1]
+include::_rgant-Nullable.adoc[leveloffset=+1]
include::_rgant-MinLength.adoc[leveloffset=+1]
include::_rgant-Parameter.adoc[leveloffset=+1]
include::_rgant-ParameterLayout.adoc[leveloffset=+1]
+include::_rgant-Pattern.adoc[leveloffset=+1]
include::_rgant-PersistenceCapable.adoc[leveloffset=+1]
include::_rgant-PostConstruct.adoc[leveloffset=+1]
include::_rgant-PreDestroy.adoc[leveloffset=+1]
diff --git a/adocs/documentation/src/main/asciidoc/guides/ugfun/_ugfun_programming-model_actions.adoc b/adocs/documentation/src/main/asciidoc/guides/ugfun/_ugfun_programming-model_actions.adoc
index d6d9b49..8a391b2 100644
--- a/adocs/documentation/src/main/asciidoc/guides/ugfun/_ugfun_programming-model_actions.adoc
+++ b/adocs/documentation/src/main/asciidoc/guides/ugfun/_ugfun_programming-model_actions.adoc
@@ -237,7 +237,7 @@ See also xref:../ugfun/ugfun.adoc#_ugfun_programming-model_properties-vs-paramet
== ``BigDecimal``s (Precision)
Whereas the xref:../ugfun/ugfun.adoc#__ugfun_programming-model_properties_datatypes_bigdecimals[precision of BigDecimal properties] is defined using xref:../rgant/rgant.adoc#_rgant_Column_scale[`@javax.jdo.annotations.Column#scale()`], that JDO annotation cannot be applied to parameter types.
-Instead, the xref:../rgant/rgant.adoc#_rgant_Digits_fraction[`@javax.validation.constraints.Digits#fraction()`] annotation/attribute is used.
+Instead, the xref:../rgant/rgant.adoc#_rgant-Digits[`@javax.validation.constraints.Digits#fraction()`] annotation/attribute is used.
For example:
@@ -256,7 +256,7 @@ public Order updateDiscount(
}
----
<1> Specifies the property precision using xref:../rgant/rgant.adoc#_rgant_Column_scale[`@Column#scale()`]
-<2> Specifies the corresponding parameter precision using xref:../rgant/rgant.adoc#_rgant_Digits_fraction[`@Digits#fraction()`].
+<2> Specifies the corresponding parameter precision using xref:../rgant/rgant.adoc#_rgant-Digits[`@Digits#fraction()`].
See also xref:../ugfun/ugfun.adoc#_ugfun_programming-model_properties-vs-parameters[properties vs parameters].
--
To stop receiving notification emails like this one, please contact
"commits@isis.apache.org" <co...@isis.apache.org>.