This is an automated email from the ASF dual-hosted git repository.

ahuber pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/isis.git


The following commit(s) were added to refs/heads/master by this push:
     new e64c29c989 ISIS-3293: update java-doc
e64c29c989 is described below

commit e64c29c989e973be120a3b48c6a5522d3ba5db19
Author: Andi Huber <ahu...@apache.org>
AuthorDate: Thu Nov 24 16:55:17 2022 +0100

    ISIS-3293: update java-doc
---
 .../java/org/apache/causeway/applib/ViewModel.java |  9 ++++----
 .../ViewModelFacetForViewModelInterface.java       | 26 ++++++++++------------
 2 files changed, 17 insertions(+), 18 deletions(-)

diff --git a/api/applib/src/main/java/org/apache/causeway/applib/ViewModel.java 
b/api/applib/src/main/java/org/apache/causeway/applib/ViewModel.java
index 8b1bd3bd83..7005deda65 100644
--- a/api/applib/src/main/java/org/apache/causeway/applib/ViewModel.java
+++ b/api/applib/src/main/java/org/apache/causeway/applib/ViewModel.java
@@ -32,13 +32,14 @@ import 
org.apache.causeway.applib.services.registry.ServiceRegistry;
  * <p>
  * Contract:
  * <ul>
- * <li>there is a single public constructor</li>
- * <li>it may have arbitrary many arguments of arbitrary type</li>
+ * <li>there is either exactly one public constructor or if there are more 
than one,
+ * then only one of these is annotated with any of {@code @Inject} or {@code 
@Autowired(required=true)}
+ * (meta-annotations are also considered)</li>
+ * <li>the constructor may have arbitrary many arguments of arbitrary type</li>
  * <li>first {@link String} argument found is passed in the view-model's 
memento</li>
  * <li>any other arguments are resolved via the {@link ServiceRegistry} -
  *      if no <i>Bean</i> can be found a {@link NoSuchElementException} is 
thrown</li>
- * <li>@Inject or @Autowired annotations are not required on the 
constructor</li>
- * <li>there is no support for Spring programming model specific annotations 
on constructor arguments (perhaps future work)</li>
+ * <li>there is no support for <i>Spring</i> programming model specific 
annotations on constructor arguments (perhaps future work)</li>
  * </ul>
  * Naturally this also allows for the idiom of passing in the {@link 
ServiceInjector} as an argument
  * and programmatically resolve any field-style injection points via {@link 
ServiceInjector#injectServicesInto(Object)},
diff --git 
a/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/facets/object/viewmodel/ViewModelFacetForViewModelInterface.java
 
b/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/facets/object/viewmodel/ViewModelFacetForViewModelInterface.java
index 4b3da2b6bc..cb7bebce29 100644
--- 
a/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/facets/object/viewmodel/ViewModelFacetForViewModelInterface.java
+++ 
b/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/facets/object/viewmodel/ViewModelFacetForViewModelInterface.java
@@ -68,22 +68,20 @@ extends ViewModelFacetAbstract {
             val publicConstructors = 
ProgrammingModelConstants.ViewmodelConstructor.PUBLIC_ANY.getAll(cls);
 
             if(explicitInjectConstructors.getCardinality().isMultiple()) {
-                if(!explicitInjectConstructors.getCardinality().isOne()) {
-                    ValidationFailure.raiseFormatted(holder,
-                            
ProgrammingModelConstants.Validation.VIEWMODEL_MULTIPLE_CONSTRUCTORS_WITH_INJECT_SEMANTICS
-                                .getMessage(Map.of(
-                                        "type", cls.getName(),
-                                        "found", 
explicitInjectConstructors.getCardinality().isMultiple()
-                                            ? "{" + 
explicitInjectConstructors.stream()
-                                                    .map(Constructor::toString)
-                                                    
.collect(Collectors.joining(", ")) + "}"
-                                            : "none")));
 
-                    return Optional.empty();
-                }
-            }
+                ValidationFailure.raiseFormatted(holder,
+                        
ProgrammingModelConstants.Validation.VIEWMODEL_MULTIPLE_CONSTRUCTORS_WITH_INJECT_SEMANTICS
+                            .getMessage(Map.of(
+                                    "type", cls.getName(),
+                                    "found", 
explicitInjectConstructors.getCardinality().isMultiple()
+                                        ? "{" + 
explicitInjectConstructors.stream()
+                                                .map(Constructor::toString)
+                                                .collect(Collectors.joining(", 
")) + "}"
+                                        : "none")));
+
+                return Optional.empty();
 
-            if(explicitInjectConstructors.getCardinality().isZero()) {
+            } else if(explicitInjectConstructors.getCardinality().isZero()) {
 
                 // in absence of a constructor with inject semantics there 
must be exactly one public to pick instead
 

Reply via email to