This is an automated email from the ASF dual-hosted git repository. ahuber pushed a commit to branch 3937-grid.api.overhaul in repository https://gitbox.apache.org/repos/asf/causeway.git
commit 7a2a5ef10e30d924fbdda3861976e011e42b90cc Author: Andi Huber <[email protected]> AuthorDate: Mon Oct 27 15:41:28 2025 +0100 CAUSEWAY-2297: removes Grid --- api/applib/src/main/java/module-info.java | 2 - .../apache/causeway/applib/layout/grid/Grid.java | 66 ---------------------- .../applib/layout/grid/bootstrap/BSGrid.java | 21 +++++-- .../applib/services/grid/GridLoaderService.java | 5 +- .../applib/services/grid/GridMarshaller.java | 3 +- .../causeway/applib/services/grid/GridService.java | 7 +-- .../applib/services/grid/GridSystemService.java | 3 +- .../applib/services/layout/LayoutExportStyle.java | 4 +- .../services/layout/LayoutServiceDefault.java | 9 ++- 9 files changed, 29 insertions(+), 91 deletions(-) diff --git a/api/applib/src/main/java/module-info.java b/api/applib/src/main/java/module-info.java index 25561f08d28..2cff49c4aa3 100644 --- a/api/applib/src/main/java/module-info.java +++ b/api/applib/src/main/java/module-info.java @@ -37,7 +37,6 @@ exports org.apache.causeway.applib.jaxb; exports org.apache.causeway.applib.layout.component; exports org.apache.causeway.applib.layout.grid.bootstrap; - exports org.apache.causeway.applib.layout.grid; exports org.apache.causeway.applib.layout.links; exports org.apache.causeway.applib.layout.menubars.bootstrap; exports org.apache.causeway.applib.layout.menubars; @@ -151,7 +150,6 @@ opens org.apache.causeway.applib.annotation; opens org.apache.causeway.applib.layout.component; opens org.apache.causeway.applib.layout.grid.bootstrap; - opens org.apache.causeway.applib.layout.grid; opens org.apache.causeway.applib.layout.links; opens org.apache.causeway.applib.layout.menubars.bootstrap; opens org.apache.causeway.applib.layout.menubars; diff --git a/api/applib/src/main/java/org/apache/causeway/applib/layout/grid/Grid.java b/api/applib/src/main/java/org/apache/causeway/applib/layout/grid/Grid.java deleted file mode 100644 index f3592af66ec..00000000000 --- a/api/applib/src/main/java/org/apache/causeway/applib/layout/grid/Grid.java +++ /dev/null @@ -1,66 +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.layout.grid; - -import java.io.Serializable; -import java.util.Map; -import java.util.stream.Stream; - -import org.apache.causeway.applib.annotation.Programmatic; -import org.apache.causeway.applib.layout.component.ActionLayoutData; -import org.apache.causeway.applib.layout.component.CollectionLayoutData; -import org.apache.causeway.applib.layout.component.PropertyLayoutData; -import org.apache.causeway.applib.services.layout.LayoutService; - -/** - * All top-level page layout classes should implement this interface. - * - * <p>It is used by the {@link LayoutService} as a common based type for any layouts read in from XML. - * - * @since 1.x revised for 4.0 {@index} - */ -@Deprecated -@Programmatic -public interface Grid { - - Class<?> domainClass(); - - /** - * Arbitrary additional 'runtime' data attributed to this grid, - * but not part of the DTO specification. - * @since 4.0 - */ - Map<String, Serializable> attributes(); - - /** - * Indicates whether or not this grid is a fallback. - * {@code True}, if this Grid originates from - * {@link org.apache.causeway.applib.services.grid.GridSystemService#defaultGrid(Class)}. - * <p> - * Governs meta-model facet precedence, that is, - * facets from annotations should overrule those from fallback XML grids. - */ - boolean isFallback(); - boolean isNormalized(); - - Stream<PropertyLayoutData> streamPropertyLayoutData(); - Stream<CollectionLayoutData> streamCollectionLayoutData(); - Stream<ActionLayoutData> streamActionLayoutData(); - -} diff --git a/api/applib/src/main/java/org/apache/causeway/applib/layout/grid/bootstrap/BSGrid.java b/api/applib/src/main/java/org/apache/causeway/applib/layout/grid/bootstrap/BSGrid.java index 5638d4aa404..b170688657d 100644 --- a/api/applib/src/main/java/org/apache/causeway/applib/layout/grid/bootstrap/BSGrid.java +++ b/api/applib/src/main/java/org/apache/causeway/applib/layout/grid/bootstrap/BSGrid.java @@ -35,7 +35,6 @@ import org.apache.causeway.applib.layout.component.ActionLayoutData; import org.apache.causeway.applib.layout.component.CollectionLayoutData; import org.apache.causeway.applib.layout.component.PropertyLayoutData; -import org.apache.causeway.applib.layout.grid.Grid; import org.apache.causeway.applib.mixins.dto.Dto; import lombok.Getter; @@ -51,11 +50,26 @@ @XmlRootElement(name = "grid") @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "grid", propOrder = {"rows", "metadataErrors"}) -public final class BSGrid implements Grid, BSElement, Dto, BSRowOwner { +public final class BSGrid implements BSElement, Dto, BSRowOwner { private static final long serialVersionUID = 1L; @XmlTransient @Getter @Accessors(fluent=true) @Setter private Class<?> domainClass; + + /** + * Indicates whether or not this grid is a fallback. + * {@code True}, if this Grid originates from + * {@link org.apache.causeway.applib.services.grid.GridSystemService#defaultGrid(Class)}. + * <p> + * Governs meta-model facet precedence, that is, + * facets from annotations should overrule those from fallback XML grids. + */ @XmlTransient @Getter @Setter private boolean fallback; + + /** + * Arbitrary additional 'runtime' data attributed to this grid, + * but not part of the DTO specification. + * @since 4.0 + */ @XmlTransient @Getter @Accessors(fluent=true) private final Map<String, Serializable> attributes = Map.of(); @XmlTransient @Getter @Setter private boolean normalized; @@ -75,7 +89,6 @@ public void visit(final BSElementVisitor visitor) { new BSWalker(this).walk(visitor); } - @Override public Stream<PropertyLayoutData> streamPropertyLayoutData() { final var properties = new ArrayList<PropertyLayoutData>(); visit(new BSElementVisitor() { @@ -87,7 +100,6 @@ public void visit(final PropertyLayoutData propertyLayoutData) { return properties.stream(); } - @Override public Stream<CollectionLayoutData> streamCollectionLayoutData() { final var collections = new ArrayList<CollectionLayoutData>(); visit(new BSElementVisitor() { @@ -99,7 +111,6 @@ public void visit(final CollectionLayoutData collectionLayoutData) { return collections.stream(); } - @Override public Stream<ActionLayoutData> streamActionLayoutData() { final var actions = new ArrayList<ActionLayoutData>(); visit(new BSElementVisitor() { diff --git a/api/applib/src/main/java/org/apache/causeway/applib/services/grid/GridLoaderService.java b/api/applib/src/main/java/org/apache/causeway/applib/services/grid/GridLoaderService.java index 623f3c67d10..bd892fb882e 100644 --- a/api/applib/src/main/java/org/apache/causeway/applib/services/grid/GridLoaderService.java +++ b/api/applib/src/main/java/org/apache/causeway/applib/services/grid/GridLoaderService.java @@ -24,7 +24,6 @@ import org.jspecify.annotations.NonNull; import org.jspecify.annotations.Nullable; -import org.apache.causeway.applib.layout.grid.Grid; import org.apache.causeway.applib.layout.grid.bootstrap.BSGrid; import org.apache.causeway.applib.mixins.metamodel.Object_rebuildMetamodel; import org.apache.causeway.applib.value.NamedWithMimeType.CommonMimeType; @@ -60,7 +59,7 @@ public interface GridLoaderService { boolean existsFor(Class<?> domainClass, EnumSet<CommonMimeType> supportedFormats); /** - * Optionally returns a new instance of a {@link Grid}, + * Optionally returns a new instance of a {@link BSGrid}, * based on whether the underlying resource could be found, loaded and parsed. * * <p>The layout alternative will typically be specified through a @@ -76,7 +75,7 @@ Optional<BSGrid> load( @NonNull GridMarshaller marshaller); /** - * Optionally returns a new instance of a {@link Grid}, + * Optionally returns a new instance of a {@link BSGrid}, * based on whether the underlying resource could be found, loaded and parsed. * * @throws UnsupportedOperationException - when format is not supported diff --git a/api/applib/src/main/java/org/apache/causeway/applib/services/grid/GridMarshaller.java b/api/applib/src/main/java/org/apache/causeway/applib/services/grid/GridMarshaller.java index 6e2678791bd..1fa32a5234f 100644 --- a/api/applib/src/main/java/org/apache/causeway/applib/services/grid/GridMarshaller.java +++ b/api/applib/src/main/java/org/apache/causeway/applib/services/grid/GridMarshaller.java @@ -23,14 +23,13 @@ import org.jspecify.annotations.NonNull; import org.jspecify.annotations.Nullable; -import org.apache.causeway.applib.layout.grid.Grid; import org.apache.causeway.applib.layout.grid.bootstrap.BSGrid; import org.apache.causeway.applib.services.marshal.Marshaller; import org.apache.causeway.applib.value.NamedWithMimeType.CommonMimeType; import org.apache.causeway.commons.functional.Try; /** - * Supports {@link Grid} marshaling and unmarshaling. + * Supports {@link BSGrid} marshaling and unmarshaling. * * @apiNote almost a copy of {@link Marshaller} * diff --git a/api/applib/src/main/java/org/apache/causeway/applib/services/grid/GridService.java b/api/applib/src/main/java/org/apache/causeway/applib/services/grid/GridService.java index 7da28a7fe09..2be3e9d9046 100644 --- a/api/applib/src/main/java/org/apache/causeway/applib/services/grid/GridService.java +++ b/api/applib/src/main/java/org/apache/causeway/applib/services/grid/GridService.java @@ -22,7 +22,6 @@ import org.apache.causeway.applib.annotation.CollectionLayout; import org.apache.causeway.applib.annotation.DomainObjectLayout; import org.apache.causeway.applib.annotation.PropertyLayout; -import org.apache.causeway.applib.layout.grid.Grid; import org.apache.causeway.applib.layout.grid.bootstrap.BSGrid; import org.apache.causeway.applib.services.layout.LayoutExportStyle; import org.apache.causeway.commons.internal.exceptions._Exceptions; @@ -61,7 +60,7 @@ public interface GridService { boolean existsFor(Class<?> domainClass); /** - * Returns a new instance of a {@link Grid} for the specified domain class, + * Returns a new instance of a {@link BSGrid} for the specified domain class, * for example as loaded from a <code>layout.xml</code> file. * * <p>If non exists, returns <code>null</code>. (The caller can then @@ -113,7 +112,7 @@ public interface GridService { BSGrid normalize(BSGrid grid); /** - * Modifies the provided {@link Grid} with additional metadata, broadly speaking corresponding to the + * Modifies the provided {@link BSGrid} with additional metadata, broadly speaking corresponding to the * {@link DomainObjectLayout}, {@link ActionLayout}, {@link PropertyLayout} and {@link CollectionLayout}. * * <p>If a 'complete' grid is persisted as the <code>layout.xml</code>, then there should be no need @@ -123,7 +122,7 @@ public interface GridService { BSGrid complete(BSGrid grid); /** - * Modifies the provided {@link Grid}, removing all metadata except the basic grid structure. + * Modifies the provided {@link BSGrid}, removing all metadata except the basic grid structure. * * <p>If a 'minimal' grid is persisted as the <code>layout.xml</code>, then the expectation is that * most of the layout annotations ({@link DomainObjectLayout}, {@link ActionLayout}, {@link PropertyLayout}, 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 7737534c74f..2a0ec6532b1 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 @@ -18,7 +18,6 @@ */ package org.apache.causeway.applib.services.grid; -import org.apache.causeway.applib.layout.grid.Grid; import org.apache.causeway.applib.layout.grid.bootstrap.BSGrid; /** @@ -35,7 +34,7 @@ public interface GridSystemService { /** - * The concrete subclass of {@link Grid} supported by this implementation. + * The concrete subclass of {@link BSGrid} supported by this implementation. * * <p>There can be multiple implementations of this service, this indicates * the base class used by the implementation. diff --git a/api/applib/src/main/java/org/apache/causeway/applib/services/layout/LayoutExportStyle.java b/api/applib/src/main/java/org/apache/causeway/applib/services/layout/LayoutExportStyle.java index 09d88aaa280..a830f000683 100644 --- a/api/applib/src/main/java/org/apache/causeway/applib/services/layout/LayoutExportStyle.java +++ b/api/applib/src/main/java/org/apache/causeway/applib/services/layout/LayoutExportStyle.java @@ -19,7 +19,7 @@ package org.apache.causeway.applib.services.layout; import org.apache.causeway.applib.annotation.Value; -import org.apache.causeway.applib.layout.grid.Grid; +import org.apache.causeway.applib.layout.grid.bootstrap.BSGrid; /** * Format option when generating a layout file (while prototyping). @@ -35,7 +35,7 @@ public enum LayoutExportStyle { /** * Format that yields a full representation for the <code>layout.xml</code>, * such that any layout metadata annotations could be removed from the code, - * without affecting the resulting {@link Grid}, when loaded from <code>layout.xml</code>. + * without affecting the resulting {@link BSGrid}, when loaded from <code>layout.xml</code>. */ COMPLETE, diff --git a/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/services/layout/LayoutServiceDefault.java b/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/services/layout/LayoutServiceDefault.java index 01640bdc3c0..abafd08d4fa 100644 --- a/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/services/layout/LayoutServiceDefault.java +++ b/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/services/layout/LayoutServiceDefault.java @@ -31,7 +31,7 @@ import org.springframework.stereotype.Service; import org.apache.causeway.applib.annotation.PriorityPrecedence; -import org.apache.causeway.applib.layout.grid.Grid; +import org.apache.causeway.applib.layout.grid.bootstrap.BSGrid; import org.apache.causeway.applib.services.grid.GridService; import org.apache.causeway.applib.services.layout.LayoutExportStyle; import org.apache.causeway.applib.services.layout.LayoutService; @@ -129,10 +129,9 @@ private Try<String> tryGridToFormatted( gridToFormatted(gridService.toGridForExport(domainClass, style), format)); } - private String gridToFormatted(final @Nullable Grid grid, final CommonMimeType format) { - if(grid==null) { - return null; - } + private String gridToFormatted(final @Nullable BSGrid grid, final CommonMimeType format) { + if(grid==null) return null; + return gridService.marshaller().marshal(_Casts.uncheckedCast(grid), format); }
