You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@causeway.apache.org by da...@apache.org on 2024/06/20 15:09:47 UTC

(causeway) 01/01: Merge branch 'maintenance-branch' into pre-merge

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

danhaywood pushed a commit to branch pre-merge
in repository https://gitbox.apache.org/repos/asf/causeway.git

commit 6891a0f23c2a9ab383705ada433e10c62f69e296
Merge: 86e7d3d3f9 0f66f74512
Author: Dan Haywood <da...@haywood-associates.co.uk>
AuthorDate: Thu Jun 20 16:09:08 2024 +0100

    Merge branch 'maintenance-branch' into pre-merge

 .../metamodel/interactions/InteractionContext.java |   9 -
 .../core/metamodel/object/MmSortUtils.java         |  44 ++-
 .../objectlifecycle/PropertyChangeRecord.java      |   2 +-
 .../core/metamodel/util/snapshot/XmlSnapshot.java  |  10 +-
 .../publish/EntityChangesPublisherDefault.java     |  13 +-
 .../changetracking/EntityChangeTrackerDefault.java | 321 +++++++++++++++------
 .../changetracking/_ChangingEntitiesFactory.java   |  92 ------
 7 files changed, 264 insertions(+), 227 deletions(-)

diff --cc core/metamodel/src/main/java/org/apache/causeway/core/metamodel/object/MmSortUtils.java
index 347c827cf0,0000000000..f087a4c3ac
mode 100644,000000..100644
--- a/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/object/MmSortUtils.java
+++ b/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/object/MmSortUtils.java
@@@ -1,84 -1,0 +1,80 @@@
 +/*
 + *  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.core.metamodel.object;
 +
 +import java.util.Comparator;
 +import java.util.Objects;
 +
 +import org.springframework.lang.Nullable;
 +
 +import org.apache.causeway.commons.internal.base._Objects;
 +import org.apache.causeway.core.metamodel.consent.InteractionInitiatedBy;
 +import org.apache.causeway.core.metamodel.spec.feature.ObjectAssociation;
 +
 +import lombok.val;
 +import lombok.experimental.UtilityClass;
 +
 +@UtilityClass
 +public class MmSortUtils {
 +
 +    public enum SortDirection {
 +        ASCENDING,
 +        DESCENDING;
 +    }
 +
 +    public Comparator<ManagedObject> orderingBy(final ObjectAssociation sortProperty, final SortDirection sortDirection) {
 +        final Comparator<ManagedObject> comparator = (sortDirection != SortDirection.DESCENDING)
 +                ? NATURAL_NULL_FIRST
 +                : NATURAL_NULL_FIRST.reversed();
 +
 +        return (p, q) -> {
-             val pSort = sortProperty.get(p, InteractionInitiatedBy.FRAMEWORK);
-             val qSort = sortProperty.get(q, InteractionInitiatedBy.FRAMEWORK);
++            val pSort = sortProperty.get(p, InteractionInitiatedBy.PASS_THROUGH);
++            val qSort = sortProperty.get(q, InteractionInitiatedBy.PASS_THROUGH);
 +            return comparator.compare(pSort, qSort);
 +        };
 +    }
 +
 +    public int compare(final @Nullable ManagedObject p, final @Nullable ManagedObject q) {
 +        return NATURAL_NULL_FIRST.compare(p, q);
 +    }
 +
 +    // -- PREDEFINED COMPARATOR
 +
-     final Comparator<ManagedObject> NATURAL_NULL_FIRST = new Comparator<ManagedObject>(){
-         @SuppressWarnings({"rawtypes" })
-         @Override
-         public int compare(final @Nullable ManagedObject a, final @Nullable ManagedObject b) {
-             val aPojo = MmUnwrapUtils.single(a);
-             val bPojo = MmUnwrapUtils.single(b);
-             if(Objects.equals(aPojo, bPojo)) {
-                 return 0;
-             }
-             if((aPojo==null
-                     || aPojo instanceof Comparable)
-                 && (bPojo==null
-                         || bPojo instanceof Comparable)) {
-                 return _Objects.compareNullsFirst((Comparable)aPojo, (Comparable)bPojo);
-             }
-             final int hashCompare = Integer.compare(Objects.hashCode(aPojo), Objects.hashCode(bPojo));
-             if(hashCompare!=0) {
-                 return hashCompare;
-             }
-             //XXX on hash-collision we return an arbitrary non-equal relation (unspecified behavior)
-             return -1;
-         }
++    final Comparator<ManagedObject> NATURAL_NULL_FIRST = (a, b) -> {
 +
++        val aPojo = MmUnwrapUtils.single(a);
++        val bPojo = MmUnwrapUtils.single(b);
++        if(Objects.equals(aPojo, bPojo)) {
++            return 0;
++        }
++        if((aPojo==null
++                || aPojo instanceof Comparable)
++            && (bPojo==null
++                    || bPojo instanceof Comparable)) {
++            return _Objects.compareNullsFirst((Comparable)aPojo, (Comparable)bPojo);
++        }
++        final int hashCompare = Integer.compare(Objects.hashCode(aPojo), Objects.hashCode(bPojo));
++        if(hashCompare!=0) {
++            return hashCompare;
++        }
++        //XXX on hash-collision we return an arbitrary non-equal relation (unspecified behavior)
++        return -1;
 +    };
 +
 +}