You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@causeway.apache.org by ah...@apache.org on 2025/02/18 15:30:26 UTC

(causeway) branch main updated: CAUSEWAY-3859: Java record refactoring (part 9)

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

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


The following commit(s) were added to refs/heads/main by this push:
     new 6d4ad8438bf CAUSEWAY-3859: Java record refactoring (part 9)
6d4ad8438bf is described below

commit 6d4ad8438bfe8ce5338d0713c920d154d93e58cc
Author: Andi Huber <ah...@apache.org>
AuthorDate: Tue Feb 18 16:30:23 2025 +0100

    CAUSEWAY-3859: Java record refactoring (part 9)
    
    - also removes DomainService#nature (deprecated for a while now)
    - cleaning up java-doc in applib
---
 .../causeway/applib/annotation/DomainObject.java   |  4 +--
 .../causeway/applib/annotation/DomainService.java  | 11 -------
 .../applib/annotation/InteractionScope.java        |  1 +
 .../applib/annotation/NatureOfService.java         | 30 ------------------
 .../applib/annotation/TransactionScope.java        |  1 +
 .../applib/log4j2/TruncatingMessageFactory.java    |  1 +
 .../metamodel/Object_downloadMetamodelXml.java     |  2 +-
 .../services/appfeat/ApplicationFeatureId.java     |  2 +-
 .../services/ascii/AsciiIdentifierService.java     |  2 +-
 .../applib/services/exceprecog/Category.java       |  2 +-
 .../applib/services/grid/GridSystemService.java    | 36 +++++++++++-----------
 .../keyvaluestore/KeyValueSessionStore.java        |  1 +
 .../services/metamodel/MetaModelServiceMenu.java   |  2 +-
 .../services/metamodel/objgraph/ObjectGraph.java   |  4 +--
 ...odifier.java => ObjectGraphObjectModifier.java} |  9 ++----
 ...nMerger.java => ObjectGraphRelationMerger.java} |  2 +-
 .../applib/services/registry/ServiceRegistry.java  | 12 +++-----
 .../services/wrapper/control/AsyncControl.java     |  3 +-
 18 files changed, 39 insertions(+), 86 deletions(-)

diff --git a/api/applib/src/main/java/org/apache/causeway/applib/annotation/DomainObject.java b/api/applib/src/main/java/org/apache/causeway/applib/annotation/DomainObject.java
index 6bf8969a6cf..182685897d5 100644
--- a/api/applib/src/main/java/org/apache/causeway/applib/annotation/DomainObject.java
+++ b/api/applib/src/main/java/org/apache/causeway/applib/annotation/DomainObject.java
@@ -73,7 +73,7 @@
     /**
      * Alternative logical type name(s) for the annotated type.
      * @see Bookmark
-     * @see Named
+     * @see jakarta.inject.Named
      */
     String[] aliased() default {};
 
@@ -197,8 +197,6 @@ String mixinMethod()
      * <p>
      *     The {@link Nature#BEAN} nature is for internally use, and should not normally be specified explicitly.
      * </p>
-     *
-     * @see DomainService#nature()
      */
     Nature nature()
             default Nature.NOT_SPECIFIED;
diff --git a/api/applib/src/main/java/org/apache/causeway/applib/annotation/DomainService.java b/api/applib/src/main/java/org/apache/causeway/applib/annotation/DomainService.java
index 5b249676ef8..08dfd668f65 100644
--- a/api/applib/src/main/java/org/apache/causeway/applib/annotation/DomainService.java
+++ b/api/applib/src/main/java/org/apache/causeway/applib/annotation/DomainService.java
@@ -63,15 +63,4 @@
      * @see Named
      */
     String[] aliased() default {};
-
-    /**
-     * The nature of this service, either in the UI or REST only
-     *
-     * @see DomainObject#nature()
-     * @deprecated has no scope limiting effect any longer, see [CAUSEWAY-3697]
-     */
-    @Deprecated(forRemoval = true, since = "2.0.0-RC4")
-    NatureOfService nature()
-            default NatureOfService.VIEW;
-
 }
diff --git a/api/applib/src/main/java/org/apache/causeway/applib/annotation/InteractionScope.java b/api/applib/src/main/java/org/apache/causeway/applib/annotation/InteractionScope.java
index 894b347fa05..a83435dd5ba 100644
--- a/api/applib/src/main/java/org/apache/causeway/applib/annotation/InteractionScope.java
+++ b/api/applib/src/main/java/org/apache/causeway/applib/annotation/InteractionScope.java
@@ -47,6 +47,7 @@
  * @see org.springframework.stereotype.Component
  * @see org.springframework.context.annotation.Bean
  */
+@SuppressWarnings("javadoc")
 @Target({ElementType.TYPE, ElementType.METHOD})
 @Retention(RetentionPolicy.RUNTIME)
 @Documented
diff --git a/api/applib/src/main/java/org/apache/causeway/applib/annotation/NatureOfService.java b/api/applib/src/main/java/org/apache/causeway/applib/annotation/NatureOfService.java
deleted file mode 100644
index 129ba103618..00000000000
--- a/api/applib/src/main/java/org/apache/causeway/applib/annotation/NatureOfService.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- *  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.
- */
-package org.apache.causeway.applib.annotation;
-
-/**
- * Corresponds to {@link DomainService#nature()}
- *
- * @deprecated has no scope limiting effect any longer, see [CAUSEWAY-3697]
- */
-@Deprecated(forRemoval = true, since = "2.0.0-RC4")
-public enum NatureOfService {
-    VIEW,
-    REST;
-}
diff --git a/api/applib/src/main/java/org/apache/causeway/applib/annotation/TransactionScope.java b/api/applib/src/main/java/org/apache/causeway/applib/annotation/TransactionScope.java
index 681a2c17c08..c930b190b7f 100644
--- a/api/applib/src/main/java/org/apache/causeway/applib/annotation/TransactionScope.java
+++ b/api/applib/src/main/java/org/apache/causeway/applib/annotation/TransactionScope.java
@@ -59,6 +59,7 @@
  * @see org.springframework.stereotype.Component
  * @see org.springframework.context.annotation.Bean
  */
+@SuppressWarnings("javadoc")
 @Target({ElementType.TYPE, ElementType.METHOD})
 @Retention(RetentionPolicy.RUNTIME)
 @Documented
diff --git a/api/applib/src/main/java/org/apache/causeway/applib/log4j2/TruncatingMessageFactory.java b/api/applib/src/main/java/org/apache/causeway/applib/log4j2/TruncatingMessageFactory.java
index fc1aa5948f2..18edd606540 100644
--- a/api/applib/src/main/java/org/apache/causeway/applib/log4j2/TruncatingMessageFactory.java
+++ b/api/applib/src/main/java/org/apache/causeway/applib/log4j2/TruncatingMessageFactory.java
@@ -30,6 +30,7 @@
  * </pre>
  */
 public class TruncatingMessageFactory extends AbstractMessageFactory {
+    private static final long serialVersionUID = 1L;
     private static final int MAX_LENGTH = 128;
 
     @Override
diff --git a/api/applib/src/main/java/org/apache/causeway/applib/mixins/metamodel/Object_downloadMetamodelXml.java b/api/applib/src/main/java/org/apache/causeway/applib/mixins/metamodel/Object_downloadMetamodelXml.java
index cc5eaf11139..ae0f7214067 100644
--- a/api/applib/src/main/java/org/apache/causeway/applib/mixins/metamodel/Object_downloadMetamodelXml.java
+++ b/api/applib/src/main/java/org/apache/causeway/applib/mixins/metamodel/Object_downloadMetamodelXml.java
@@ -82,7 +82,7 @@ public static class ActionDomainEvent
             messageService.warnUser("Unknown class, unable to export");
             return null;
         }
-        final String namespace = logicalTypeIfAny.get().getNamespace();
+        final String namespace = logicalTypeIfAny.get().namespace();
 
         var config = Config.builder()
                 .ignoreFallbackFacets(true)
diff --git a/api/applib/src/main/java/org/apache/causeway/applib/services/appfeat/ApplicationFeatureId.java b/api/applib/src/main/java/org/apache/causeway/applib/services/appfeat/ApplicationFeatureId.java
index e2ca0cd5024..e748deb42df 100644
--- a/api/applib/src/main/java/org/apache/causeway/applib/services/appfeat/ApplicationFeatureId.java
+++ b/api/applib/src/main/java/org/apache/causeway/applib/services/appfeat/ApplicationFeatureId.java
@@ -134,7 +134,7 @@ public static ApplicationFeatureId newNamespace(final String namespace) {
      * @param logicalType - from which the namespace is inferred.
      */
     public static ApplicationFeatureId newNamespace(final LogicalType logicalType) {
-        return newNamespace(logicalType.getNamespace());
+        return newNamespace(logicalType.namespace());
     }
 
     public static ApplicationFeatureId newType(final String logicalTypeName) {
diff --git a/api/applib/src/main/java/org/apache/causeway/applib/services/ascii/AsciiIdentifierService.java b/api/applib/src/main/java/org/apache/causeway/applib/services/ascii/AsciiIdentifierService.java
index f24c42a0ff1..2f58eea5555 100644
--- a/api/applib/src/main/java/org/apache/causeway/applib/services/ascii/AsciiIdentifierService.java
+++ b/api/applib/src/main/java/org/apache/causeway/applib/services/ascii/AsciiIdentifierService.java
@@ -27,7 +27,7 @@
  *     because feature Ids are used as GraphQL (field) names.
  * </p>
  *
- * @see <a href="https://spec.graphql.org/October2021/#sec-Names">GraphQL specification</a>.
+ * @see <a href="https://spec.graphql.org/October2021/#sec-Names">GraphQL specification</a>
  *
  * @since 2.x {@index}
  */
diff --git a/api/applib/src/main/java/org/apache/causeway/applib/services/exceprecog/Category.java b/api/applib/src/main/java/org/apache/causeway/applib/services/exceprecog/Category.java
index de7b595af31..4b728f4e23b 100644
--- a/api/applib/src/main/java/org/apache/causeway/applib/services/exceprecog/Category.java
+++ b/api/applib/src/main/java/org/apache/causeway/applib/services/exceprecog/Category.java
@@ -25,7 +25,7 @@
 
 /**
  * Categorises each exception that has been recognised, as per
- * {@link Recognition#getCategory()}.
+ * {@link Recognition#category()}.
  *
  * @since 1.x {@index}
  */
diff --git a/api/applib/src/main/java/org/apache/causeway/applib/services/grid/GridSystemService.java b/api/applib/src/main/java/org/apache/causeway/applib/services/grid/GridSystemService.java
index 1b73e0db50c..c9cfaaf1d12 100644
--- a/api/applib/src/main/java/org/apache/causeway/applib/services/grid/GridSystemService.java
+++ b/api/applib/src/main/java/org/apache/causeway/applib/services/grid/GridSystemService.java
@@ -84,15 +84,17 @@ public interface GridSystemService<G extends Grid> {
      * Validates and normalizes a grid, modifying the grid so that all of the
      * domain object's members (properties, collections, actions) are bound to
      * regions of the grid.
-     *
      * <p>
-     * This is done using existing metadata, most notably that of the
-     * {@link org.apache.causeway.applib.annotation.MemberOrder} annotation.
+     * E.g. for properties (and similar for collections and actions) the annotation attributes
+     * {@link org.apache.causeway.applib.annotation.PropertyLayout#sequence()} 
+     * and 
+     * {@link org.apache.causeway.applib.annotation.PropertyLayout#fieldSetId()}
+     * or
+     * {@link org.apache.causeway.applib.annotation.PropertyLayout#fieldSetName()}
+     * are used.
      * Such a grid, if persisted as the layout XML file for the domain class,
-     * allows the {@link org.apache.causeway.applib.annotation.MemberOrder}
-     * annotation to be removed from the source code of the domain class
-     * (but other annotations must be retained).
-     * </p>
+     * allows the various layout annotation attributes to be unspecified or removed from the source code
+     * of the domain class.
      */
     void normalize(G grid, Class<?> domainClass);
 
@@ -100,7 +102,6 @@ public interface GridSystemService<G extends Grid> {
      * Takes a normalized grid and enriches it with all the available metadata
      * (taken from Apache Causeway' internal metadata) that can be represented in
      * the layout XML.
-     *
      * <p>
      * Such a grid, if persisted as the layout XML file for the domain class,
      * allows all layout annotations
@@ -108,8 +109,6 @@ public interface GridSystemService<G extends Grid> {
      * {@link org.apache.causeway.applib.annotation.PropertyLayout},
      * {@link org.apache.causeway.applib.annotation.CollectionLayout}) to be
      * removed from the source code of the domain class.
-     *
-     * </p>
      * @param grid
      * @param domainClass
      */
@@ -118,15 +117,16 @@ public interface GridSystemService<G extends Grid> {
     /**
      * Takes a normalized grid and strips out removes all members, leaving only
      * the grid structure.
-     *
      * <p>
-     *     Such a grid, if persisted as the layout XML file for the domain
-     *     class, requires that the
-     *     {@link org.apache.causeway.applib.annotation.MemberOrder} annotation
-     *     is retained in the source code of said class in order to bind
-     *     members to the regions of the grid.
-     * </p>
-     *
+     * Such a grid, if persisted as the layout XML file for the domain class, 
+     * requires that e.g. for properties (and similar for collections and actions) the annotation attributes
+     * {@link org.apache.causeway.applib.annotation.PropertyLayout#sequence()} 
+     * and 
+     * {@link org.apache.causeway.applib.annotation.PropertyLayout#fieldSetId()}
+     * or
+     * {@link org.apache.causeway.applib.annotation.PropertyLayout#fieldSetName()}
+     * are retained in the source code of said class in order to bind
+     * members to the regions of the grid.
      * @param grid
      * @param domainClass
      */
diff --git a/api/applib/src/main/java/org/apache/causeway/applib/services/keyvaluestore/KeyValueSessionStore.java b/api/applib/src/main/java/org/apache/causeway/applib/services/keyvaluestore/KeyValueSessionStore.java
index e17334f7348..493366ad251 100644
--- a/api/applib/src/main/java/org/apache/causeway/applib/services/keyvaluestore/KeyValueSessionStore.java
+++ b/api/applib/src/main/java/org/apache/causeway/applib/services/keyvaluestore/KeyValueSessionStore.java
@@ -34,6 +34,7 @@
  *
  * @since 2.0 {@index}
  */
+@SuppressWarnings("javadoc")
 public interface KeyValueSessionStore {
 
     /**
diff --git a/api/applib/src/main/java/org/apache/causeway/applib/services/metamodel/MetaModelServiceMenu.java b/api/applib/src/main/java/org/apache/causeway/applib/services/metamodel/MetaModelServiceMenu.java
index 2a96db628cb..7de6e9dc51b 100644
--- a/api/applib/src/main/java/org/apache/causeway/applib/services/metamodel/MetaModelServiceMenu.java
+++ b/api/applib/src/main/java/org/apache/causeway/applib/services/metamodel/MetaModelServiceMenu.java
@@ -224,7 +224,7 @@ public class ActionDomainEvent extends MetaModelServiceMenu.ActionDomainEvent<do
             final String xml = zippedMetamodelBlob
                     .unZip(CommonMimeType.XML)
                     .toClob(UTF_8)
-                    .getChars()
+                    .chars()
                     .toString();
 
             final MetamodelDto rightMetamodelDto =  jaxbService.fromXml(MetamodelDto.class, xml);
diff --git a/api/applib/src/main/java/org/apache/causeway/applib/services/metamodel/objgraph/ObjectGraph.java b/api/applib/src/main/java/org/apache/causeway/applib/services/metamodel/objgraph/ObjectGraph.java
index 848eebd401e..e96c0824e40 100644
--- a/api/applib/src/main/java/org/apache/causeway/applib/services/metamodel/objgraph/ObjectGraph.java
+++ b/api/applib/src/main/java/org/apache/causeway/applib/services/metamodel/objgraph/ObjectGraph.java
@@ -144,9 +144,9 @@ public static interface Transformer {
     @UtilityClass
     public static class Transformers {
         @Getter(lazy = true)
-        private final Transformer relationMerger = new _ObjectGraphRelationMerger();
+        private final Transformer relationMerger = new ObjectGraphRelationMerger();
         public Transformer objectModifier(final @NonNull UnaryOperator<ObjectGraph.Object> modifier) {
-            return new _ObjectGraphObjectModifier(modifier);
+            return new ObjectGraphObjectModifier(modifier);
         }
     }
 
diff --git a/api/applib/src/main/java/org/apache/causeway/applib/services/metamodel/objgraph/_ObjectGraphObjectModifier.java b/api/applib/src/main/java/org/apache/causeway/applib/services/metamodel/objgraph/ObjectGraphObjectModifier.java
similarity index 84%
rename from api/applib/src/main/java/org/apache/causeway/applib/services/metamodel/objgraph/_ObjectGraphObjectModifier.java
rename to api/applib/src/main/java/org/apache/causeway/applib/services/metamodel/objgraph/ObjectGraphObjectModifier.java
index e01375a9b58..58de5b1d48e 100644
--- a/api/applib/src/main/java/org/apache/causeway/applib/services/metamodel/objgraph/_ObjectGraphObjectModifier.java
+++ b/api/applib/src/main/java/org/apache/causeway/applib/services/metamodel/objgraph/ObjectGraphObjectModifier.java
@@ -22,17 +22,12 @@
 import java.util.function.UnaryOperator;
 import java.util.stream.Collectors;
 
-import lombok.RequiredArgsConstructor;
-
-@RequiredArgsConstructor
-class _ObjectGraphObjectModifier implements ObjectGraph.Transformer {
-
-    final UnaryOperator<ObjectGraph.Object> modifier;
+record ObjectGraphObjectModifier(UnaryOperator<ObjectGraph.Object> operator) implements ObjectGraph.Transformer {
 
     @Override
     public ObjectGraph transform(final ObjectGraph g) {
         var modified = g.objects().stream()
-                .map(obj->Objects.requireNonNull(modifier.apply(obj),
+                .map(obj->Objects.requireNonNull(operator.apply(obj),
                         ()->"modifier returned null on non-null ObjectGraph.Object"))
                 .collect(Collectors.toList());
         g.objects().clear();
diff --git a/api/applib/src/main/java/org/apache/causeway/applib/services/metamodel/objgraph/_ObjectGraphRelationMerger.java b/api/applib/src/main/java/org/apache/causeway/applib/services/metamodel/objgraph/ObjectGraphRelationMerger.java
similarity index 98%
rename from api/applib/src/main/java/org/apache/causeway/applib/services/metamodel/objgraph/_ObjectGraphRelationMerger.java
rename to api/applib/src/main/java/org/apache/causeway/applib/services/metamodel/objgraph/ObjectGraphRelationMerger.java
index d1a8adf3db3..b6e89783a71 100644
--- a/api/applib/src/main/java/org/apache/causeway/applib/services/metamodel/objgraph/_ObjectGraphRelationMerger.java
+++ b/api/applib/src/main/java/org/apache/causeway/applib/services/metamodel/objgraph/ObjectGraphRelationMerger.java
@@ -26,7 +26,7 @@
 import org.apache.causeway.commons.internal.collections._Multimaps;
 import org.apache.causeway.commons.internal.collections._Multimaps.ListMultimap;
 
-class _ObjectGraphRelationMerger implements ObjectGraph.Transformer {
+record ObjectGraphRelationMerger() implements ObjectGraph.Transformer {
 
     @Override
     public ObjectGraph transform(final ObjectGraph objGraph) {
diff --git a/api/applib/src/main/java/org/apache/causeway/applib/services/registry/ServiceRegistry.java b/api/applib/src/main/java/org/apache/causeway/applib/services/registry/ServiceRegistry.java
index bddbd83122a..ecf7639e46f 100644
--- a/api/applib/src/main/java/org/apache/causeway/applib/services/registry/ServiceRegistry.java
+++ b/api/applib/src/main/java/org/apache/causeway/applib/services/registry/ServiceRegistry.java
@@ -96,11 +96,9 @@ default _SingletonBeanProvider lookupRegisteredBeanByIdElseFail(final LogicalTyp
 
     /**
      * Returns a domain service implementing the requested type.
-     *
      * <p>
      * If this lookup is ambiguous, the service annotated with highest priority is returned.
-     * see {@link Priority}
-     * </p>
+     * see {@link jakarta.annotation.Priority}
      */
     default <T> Optional<T> lookupService(final Class<T> serviceClass) {
         final Comparator<Object> comparator = InstanceByPriorityComparator.instance();
@@ -109,10 +107,8 @@ default <T> Optional<T> lookupService(final Class<T> serviceClass) {
 
     /**
      * Returns a domain service implementing the requested type.
-     *
      * <p>
      * If this lookup is ambiguous, then the provided comparator is used.
-     * </p>
      */
     default <T> Optional<T> lookupService(final Class<T> serviceClass, final Comparator<Object> comparator) {
         var bin = select(serviceClass);
@@ -152,9 +148,11 @@ default <T> T lookupServiceElseFail(final Class<T> serviceClass) {
 
     /**
      * Invalidates any cached service adapters that might hold a reference to
-     * the current {@link SpecificationLoader}. Particularly useful when discarding
-     * a meta-model instance, that is, purging the {@link ObjectSpecification} cache.
+     * the current {@link org.apache.causeway.core.metamodel.specloader.SpecificationLoader}. 
+     * Particularly useful when discarding
+     * a meta-model instance, that is, purging the {@link org.apache.causeway.core.metamodel.spec.ObjectSpecification} cache.
      */
+    @SuppressWarnings("javadoc")
     void clearRegisteredBeans();
 
 }
diff --git a/api/applib/src/main/java/org/apache/causeway/applib/services/wrapper/control/AsyncControl.java b/api/applib/src/main/java/org/apache/causeway/applib/services/wrapper/control/AsyncControl.java
index 4017f5eb6bc..c2054f52adb 100644
--- a/api/applib/src/main/java/org/apache/causeway/applib/services/wrapper/control/AsyncControl.java
+++ b/api/applib/src/main/java/org/apache/causeway/applib/services/wrapper/control/AsyncControl.java
@@ -21,12 +21,12 @@
 import java.time.ZoneId;
 import java.util.Locale;
 import java.util.concurrent.CancellationException;
-import java.util.concurrent.ExecutionException;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Future;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeoutException;
 
+import org.jspecify.annotations.NonNull;
 import org.jspecify.annotations.Nullable;
 
 import org.apache.causeway.applib.clock.VirtualClock;
@@ -35,7 +35,6 @@
 import org.apache.causeway.commons.internal.assertions._Assert;
 
 import lombok.Getter;
-import org.jspecify.annotations.NonNull;
 import lombok.SneakyThrows;
 import lombok.extern.log4j.Log4j2;