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 075aefb  ISIS-2877: fixes SchemaValueMarshallerAbstract.Context<T>
075aefb is described below

commit 075aefbd400147ee9ccf79fce58351f87d78c4cb
Author: Andi Huber <[email protected]>
AuthorDate: Fri Feb 4 14:16:10 2022 +0100

    ISIS-2877: fixes SchemaValueMarshallerAbstract.Context<T>
---
 .../schema/SchemaValueMarshallerAbstract.java      | 30 +++++++++++++---------
 1 file changed, 18 insertions(+), 12 deletions(-)

diff --git 
a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/schema/SchemaValueMarshallerAbstract.java
 
b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/schema/SchemaValueMarshallerAbstract.java
index 5d5e8b3..6a07d2f 100644
--- 
a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/schema/SchemaValueMarshallerAbstract.java
+++ 
b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/schema/SchemaValueMarshallerAbstract.java
@@ -21,6 +21,8 @@ package org.apache.isis.core.metamodel.services.schema;
 import java.util.ArrayList;
 import java.util.Optional;
 
+import org.springframework.lang.Nullable;
+
 import org.apache.isis.applib.Identifier;
 import org.apache.isis.applib.Identifier.Type;
 import org.apache.isis.applib.services.bookmark.Bookmark;
@@ -53,6 +55,7 @@ import org.apache.isis.schema.common.v2.ValueType;
 import org.apache.isis.schema.common.v2.ValueWithTypeDto;
 import org.apache.isis.schema.ixn.v2.ActionInvocationDto;
 
+import lombok.Getter;
 import lombok.NonNull;
 import lombok.Value;
 import lombok.val;
@@ -63,34 +66,37 @@ implements SchemaValueMarshaller {
     @Value(staticConstructor = "of")
     public static class Context<T> {
 
-        public static <T> Context<T> withoutSemantics(
+        public static <T> Context<T> forNonValue(
                 final Class<T> correspondingClass,
                 final ObjectFeature feature) {
-            return of(correspondingClass, feature, null);
+            return new Context<T>(correspondingClass, feature,
+                    feature.getFeatureType().isCollection()
+                        ? ValueType.COLLECTION
+                        : ValueType.REFERENCE,
+                    /*semantics*/null, Optional.empty());
         }
 
-        public static <T> Context<T> of(
+        public static <T> Context<T> forValue(
                 final Class<T> correspondingClass,
                 final ObjectFeature feature,
-                final ValueSemanticsProvider<T> semantics) {
+                final @NonNull ValueSemanticsProvider<T> semantics) {
 
-            return of(correspondingClass, feature, semantics,
+            return of(correspondingClass, feature,
+                    semantics.getSchemaValueType(),
+                    semantics,
                     Optional.ofNullable(semantics.getConverter()));
         }
 
         private final @NonNull Class<T> correspondingClass;
         private final @NonNull ObjectFeature feature;
-        private final @NonNull ValueSemanticsProvider<T> semantics;
+        @Getter private final @NonNull ValueType schemaValueType;
+        private final @Nullable ValueSemanticsProvider<T> semantics;
         private final @NonNull Optional<Converter<T, ?>> converter;
 
         public ObjectSpecification getElementType() {
             return feature.getElementType();
         }
 
-        public ValueType getSchemaValueType() {
-            return semantics.getSchemaValueType();
-        }
-
     }
 
     // -- RECORD DTOS
@@ -241,8 +247,8 @@ implements SchemaValueMarshaller {
         return getValueSemanticsResolver()
                 .selectValueSemantics(feature.getFeatureIdentifier(), valueCls)
                 .getFirst()
-                .map(valueSemantics->Context.of(valueCls, feature, 
valueSemantics))
-                .orElseGet(()->Context.withoutSemantics(valueCls, feature));
+                .map(valueSemantics->Context.forValue(valueCls, feature, 
valueSemantics))
+                .orElseGet(()->Context.forNonValue(valueCls, feature));
     }
 
     // -- LOW LEVEL IMPLEMENTATION - RECORDING

Reply via email to