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

danhaywood pushed a commit to branch 
ISIS-2468/remove-Collection-mementoSerialization
in repository https://gitbox.apache.org/repos/asf/isis.git

commit 085314f785017cdb1e2d77633faea5693b04749b
Author: danhaywood <[email protected]>
AuthorDate: Thu Nov 26 06:51:18 2020 +0000

    ISIS-2468 : removes @Collection#mementoSerialization and associated 
NotPersistedFacet (for OTMA)
---
 .../applib-ant/examples/annotation/Collection.java | 13 ----
 .../adoc/modules/applib-ant/pages/Collection.adoc  |  5 --
 .../pages/Collection/mementoSerialization.adoc     | 42 ----------
 .../pages/Property/mementoSerialization.adoc       |  1 +
 .../apache/isis/applib/annotation/Collection.java  | 13 ----
 .../CollectionAnnotationFacetFactory.java          | 27 ++-----
 .../NotPersistedFacetForCollectionAnnotation.java  | 55 -------------
 .../metamodel/spec/feature/ObjectAssociation.java  |  7 +-
 .../spec/feature/OneToOneAssociation.java          |  7 ++
 .../specimpl/OneToManyAssociationDefault.java      | 43 +++++------
 .../specimpl/OneToOneAssociationMixedIn.java       | 10 +--
 .../core/metamodel/util/snapshot/XmlSnapshot.java  | 89 +++++++++-------------
 ...stedAnnotationOnCollectionFacetFactoryTest.java | 71 -----------------
 13 files changed, 75 insertions(+), 308 deletions(-)

diff --git 
a/api/applib/src/main/adoc/modules/applib-ant/examples/annotation/Collection.java
 
b/api/applib/src/main/adoc/modules/applib-ant/examples/annotation/Collection.java
index 28fdd31..e342352 100644
--- 
a/api/applib/src/main/adoc/modules/applib-ant/examples/annotation/Collection.java
+++ 
b/api/applib/src/main/adoc/modules/applib-ant/examples/annotation/Collection.java
@@ -98,19 +98,6 @@ public @interface Collection {
 
     // end::refguide[]
     /**
-     * Indicates whether the collecion should be included or excluded from 
mementos.
-     *
-     * <p>
-     *     To ensure that the collection is actually not persisted in the 
objectstore,
-     *     also annotate with the JDO annotation {@link 
javax.jdo.annotations.NotPersistent}.
-     * </p>
-     */
-    // tag::refguide[]
-    MementoSerialization mementoSerialization()                 // <.>
-            default MementoSerialization.NOT_SPECIFIED;
-
-    // end::refguide[]
-    /**
      * The type-of the elements held within the collection.
      *
      * @return
diff --git a/api/applib/src/main/adoc/modules/applib-ant/pages/Collection.adoc 
b/api/applib/src/main/adoc/modules/applib-ant/pages/Collection.adoc
index f644766..0fc7006 100644
--- a/api/applib/src/main/adoc/modules/applib-ant/pages/Collection.adoc
+++ b/api/applib/src/main/adoc/modules/applib-ant/pages/Collection.adoc
@@ -26,10 +26,6 @@ If `editing()` is `DISABLED`, provides a reason as to why.
 +
 Indicates where (in the UI) the collection should be hidden from the user.
 
-<.> xref:refguide:applib-ant:Collection.adoc#mementoSerialization[`memento()`]
-+
-Whether to include/exclude in snapshots. +
-
 <.> xref:refguide:applib-ant:Collection.adoc#typeOf[`typeOf()`]
 +
 Hints as to the run-time type of the objects within that collection (as a 
fallback)
@@ -76,5 +72,4 @@ so that boilerplate-busting tools such as 
link:https://projectlombok.org/[Projec
 include::Collection/domainEvent.adoc[leveloffset=+1]
 include::Collection/editing.adoc[leveloffset=+1]
 include::Collection/hidden.adoc[leveloffset=+1]
-include::Collection/mementoSerialization.adoc[leveloffset=+1]
 include::Collection/typeOf.adoc[leveloffset=+1]
diff --git 
a/api/applib/src/main/adoc/modules/applib-ant/pages/Collection/mementoSerialization.adoc
 
b/api/applib/src/main/adoc/modules/applib-ant/pages/Collection/mementoSerialization.adoc
deleted file mode 100644
index 09918db..0000000
--- 
a/api/applib/src/main/adoc/modules/applib-ant/pages/Collection/mementoSerialization.adoc
+++ /dev/null
@@ -1,42 +0,0 @@
-[#mementoSerialization]
-= `mementoSerialization()`
-
-:Notice: 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 ag [...]
-:page-partial:
-
-
-
-The `mementoSerialization` attribute indicates that the collection should be 
included or excluded from any snapshots generated by the 
xref:refguide:applib-svc:XmlSnapshotService.adoc[`XmlSnapshotService`].
-
-For example:
-
-[source,java]
-----
-import lombok.Getter;
-import lombok.Setter;
-
-public class Customer {
-
-    @Collection(mementoSerialization=EXCLUDED)
-    @Getter @Setter
-    private SortedSet<Order> previousOrders = ...
-
-}
-----
-
-
-Alternatively, if the collection is derived, then providing only a "getter" 
will also work:
-
-[source,java]
-----
-public class Customer {
-
-    public SortedSet<Order> getPreviousOrders() {...}
-    ...
-}
-----
-
-== See also
-
-This attribute is also supported for 
xref:refguide:applib-ant:Property.adoc#mementoSerialization[properties].
-
diff --git 
a/api/applib/src/main/adoc/modules/applib-ant/pages/Property/mementoSerialization.adoc
 
b/api/applib/src/main/adoc/modules/applib-ant/pages/Property/mementoSerialization.adoc
index c8cc4e4..8b584a7 100644
--- 
a/api/applib/src/main/adoc/modules/applib-ant/pages/Property/mementoSerialization.adoc
+++ 
b/api/applib/src/main/adoc/modules/applib-ant/pages/Property/mementoSerialization.adoc
@@ -4,6 +4,7 @@
 :Notice: 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 ag [...]
 :page-partial:
 
+CAUTION: this documentation may be inaccurate.
 
 The `mementoSerialization` attribute indicates whether the property should be 
included/excluded from any snapshots generated by the 
xref:refguide:applib-svc:XmlSnapshotService.adoc[`XmlSnapshotService`].
 
diff --git 
a/api/applib/src/main/java/org/apache/isis/applib/annotation/Collection.java 
b/api/applib/src/main/java/org/apache/isis/applib/annotation/Collection.java
index 28fdd31..e342352 100644
--- a/api/applib/src/main/java/org/apache/isis/applib/annotation/Collection.java
+++ b/api/applib/src/main/java/org/apache/isis/applib/annotation/Collection.java
@@ -98,19 +98,6 @@ public @interface Collection {
 
     // end::refguide[]
     /**
-     * Indicates whether the collecion should be included or excluded from 
mementos.
-     *
-     * <p>
-     *     To ensure that the collection is actually not persisted in the 
objectstore,
-     *     also annotate with the JDO annotation {@link 
javax.jdo.annotations.NotPersistent}.
-     * </p>
-     */
-    // tag::refguide[]
-    MementoSerialization mementoSerialization()                 // <.>
-            default MementoSerialization.NOT_SPECIFIED;
-
-    // end::refguide[]
-    /**
      * The type-of the elements held within the collection.
      *
      * @return
diff --git 
a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/collections/collection/CollectionAnnotationFacetFactory.java
 
b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/collections/collection/CollectionAnnotationFacetFactory.java
index a7e6ab7..0b3806a 100644
--- 
a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/collections/collection/CollectionAnnotationFacetFactory.java
+++ 
b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/collections/collection/CollectionAnnotationFacetFactory.java
@@ -48,7 +48,6 @@ import 
org.apache.isis.core.metamodel.facets.collections.collection.modify.Colle
 import 
org.apache.isis.core.metamodel.facets.collections.collection.modify.CollectionRemoveFromFacetForDomainEventFromAbstract;
 import 
org.apache.isis.core.metamodel.facets.collections.collection.modify.CollectionRemoveFromFacetForDomainEventFromCollectionAnnotation;
 import 
org.apache.isis.core.metamodel.facets.collections.collection.modify.CollectionRemoveFromFacetForDomainEventFromDefault;
-import 
org.apache.isis.core.metamodel.facets.collections.collection.notpersisted.NotPersistedFacetForCollectionAnnotation;
 import 
org.apache.isis.core.metamodel.facets.collections.collection.typeof.TypeOfFacetOnCollectionFromCollectionAnnotation;
 import 
org.apache.isis.core.metamodel.facets.collections.modify.CollectionAddToFacet;
 import 
org.apache.isis.core.metamodel.facets.collections.modify.CollectionRemoveFromFacet;
@@ -67,15 +66,14 @@ public class CollectionAnnotationFacetFactory extends 
FacetFactoryAbstract {
 
     @Override
     public void process(final ProcessMethodContext processMethodContext) {
-        
+
         val collectionIfAny = 
processMethodContext.synthesizeOnMethodOrMixinType(Collection.class);
-        
+
         inferIntentWhenOnTypeLevel(processMethodContext, collectionIfAny);
-        
+
         processModify(processMethodContext, collectionIfAny);
         processHidden(processMethodContext, collectionIfAny);
         processEditing(processMethodContext, collectionIfAny);
-        processNotPersisted(processMethodContext, collectionIfAny);
         processTypeOf(processMethodContext, collectionIfAny);
     }
 
@@ -86,9 +84,9 @@ public class CollectionAnnotationFacetFactory extends 
FacetFactoryAbstract {
 
         //          XXX[1998] this condition would allow 'intent inference' 
only when @Property is found at type level
         //          val isPropertyMethodLevel = 
processMethodContext.synthesizeOnMethod(Property.class).isPresent();
-        //          if(isPropertyMethodLevel) return; 
+        //          if(isPropertyMethodLevel) return;
 
-        //[1998] if @Collection detected on method or type level infer:    
+        //[1998] if @Collection detected on method or type level infer:
         //@Action(semantics=SAFE)
         //@ActionLayout(contributed=ASSOCIATION) ... it seems, is already 
allowed for mixins
         val facetedMethod = processMethodContext.getFacetHolder();
@@ -116,7 +114,7 @@ public class CollectionAnnotationFacetFactory extends 
FacetFactoryAbstract {
         //
         // Set up CollectionDomainEventFacet, which will act as the 
hiding/disabling/validating advisor
         //
-        
+
 
         // search for @Collection(domainEvent=...)
         val collectionDomainEventFacet = collectionIfAny
@@ -158,13 +156,13 @@ public class CollectionAnnotationFacetFactory extends 
FacetFactoryAbstract {
 
             if(collectionDomainEventFacet instanceof 
CollectionDomainEventFacetForCollectionAnnotation) {
                 replacementFacet = new 
CollectionAddToFacetForDomainEventFromCollectionAnnotation(
-                        collectionDomainEventFacet.getEventType(), 
getterFacet, collectionAddToFacet, 
+                        collectionDomainEventFacet.getEventType(), 
getterFacet, collectionAddToFacet,
                         collectionDomainEventFacet, holder, 
getServiceRegistry());
             } else
                 // default
             {
                 replacementFacet = new 
CollectionAddToFacetForDomainEventFromDefault(
-                        collectionDomainEventFacet.getEventType(), 
getterFacet, 
+                        collectionDomainEventFacet.getEventType(), getterFacet,
                         collectionAddToFacet, collectionDomainEventFacet, 
holder, getServiceRegistry());
             }
             super.addFacet(replacementFacet);
@@ -219,15 +217,6 @@ public class CollectionAnnotationFacetFactory extends 
FacetFactoryAbstract {
         super.addFacet(facet);
     }
 
-    void processNotPersisted(final ProcessMethodContext processMethodContext, 
Optional<Collection> collectionIfAny) {
-        val holder = processMethodContext.getFacetHolder();
-
-        // search for @Collection(notPersisted=...)
-        val facet = 
NotPersistedFacetForCollectionAnnotation.create(collectionIfAny, holder);
-
-        super.addFacet(facet);
-    }
-
 
     void processTypeOf(final ProcessMethodContext processMethodContext, 
Optional<Collection> collectionIfAny) {
 
diff --git 
a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/collections/collection/notpersisted/NotPersistedFacetForCollectionAnnotation.java
 
b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/collections/collection/notpersisted/NotPersistedFacetForCollectionAnnotation.java
deleted file mode 100644
index 8f154d7..0000000
--- 
a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/collections/collection/notpersisted/NotPersistedFacetForCollectionAnnotation.java
+++ /dev/null
@@ -1,55 +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.isis.core.metamodel.facets.collections.collection.notpersisted;
-
-import java.util.Optional;
-
-import org.apache.isis.applib.annotation.Collection;
-import org.apache.isis.applib.annotation.MementoSerialization;
-import org.apache.isis.core.metamodel.facetapi.FacetHolder;
-import 
org.apache.isis.core.metamodel.facets.propcoll.notpersisted.NotPersistedFacet;
-import 
org.apache.isis.core.metamodel.facets.propcoll.notpersisted.NotPersistedFacetAbstract;
-
-public class NotPersistedFacetForCollectionAnnotation extends 
NotPersistedFacetAbstract {
-
-    public NotPersistedFacetForCollectionAnnotation(final FacetHolder holder) {
-        super(holder);
-    }
-
-    public static NotPersistedFacet create(
-            final Optional<Collection> collectionIfAny,
-            final FacetHolder holder) {
-
-        return collectionIfAny
-                .map(Collection::mementoSerialization)
-                .filter(mementoSerialization -> mementoSerialization != 
MementoSerialization.NOT_SPECIFIED)
-                .map(mementoSerialization -> {
-                    switch (mementoSerialization) {
-                    case INCLUDED:
-                        return null;
-                    case EXCLUDED:
-                        return new 
NotPersistedFacetForCollectionAnnotation(holder);
-                    default:
-                    }
-                    throw new IllegalStateException("mementoSerialization '" + 
mementoSerialization + "' not recognized");
-                })
-                .orElse(null);
-    }
-}
diff --git 
a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/spec/feature/ObjectAssociation.java
 
b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/spec/feature/ObjectAssociation.java
index fe21a44..8380d79 100644
--- 
a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/spec/feature/ObjectAssociation.java
+++ 
b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/spec/feature/ObjectAssociation.java
@@ -66,7 +66,7 @@ public interface ObjectAssociation extends ObjectMember, 
CurrentHolder {
      */
     @Override
     ManagedObject get(
-            ManagedObject owner, 
+            ManagedObject owner,
             InteractionInitiatedBy interactionInitiatedBy);
 
     //Instance get(final Instance owner, final InteractionInitiatedBy 
interactionInitiatedBy);
@@ -111,11 +111,6 @@ public interface ObjectAssociation extends ObjectMember, 
CurrentHolder {
 
     int getAutoCompleteMinLength();
 
-    /**
-     * Returns true if calculated from other data in the object, that is, 
should
-     * not be persisted.
-     */
-    boolean isNotPersisted();
 
     /**
      * Returns <code>true</code> if this field on the specified object is 
deemed
diff --git 
a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/spec/feature/OneToOneAssociation.java
 
b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/spec/feature/OneToOneAssociation.java
index 18038bc..a926af5 100644
--- 
a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/spec/feature/OneToOneAssociation.java
+++ 
b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/spec/feature/OneToOneAssociation.java
@@ -50,6 +50,13 @@ public interface OneToOneAssociation extends 
ObjectAssociation, OneToOneFeature,
             final InteractionInitiatedBy interactionInitiatedBy);
 
 
+    /**
+     * Returns true if calculated from other data in the object, that is, 
should
+     * not be persisted.
+     */
+    boolean isNotPersisted();
+
+
 
     default String getCssClass(String prefix) {
         final String ownerSpecId = 
getOnType().getSpecId().asString().replace(".", "-");
diff --git 
a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/specimpl/OneToManyAssociationDefault.java
 
b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/specimpl/OneToManyAssociationDefault.java
index 5a861e7..a68e06d 100644
--- 
a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/specimpl/OneToManyAssociationDefault.java
+++ 
b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/specimpl/OneToManyAssociationDefault.java
@@ -49,7 +49,7 @@ import 
org.apache.isis.core.metamodel.spec.feature.OneToManyAssociation;
 
 import lombok.val;
 
-public class OneToManyAssociationDefault 
+public class OneToManyAssociationDefault
 extends ObjectAssociationAbstract implements OneToManyAssociation {
 
     public OneToManyAssociationDefault(final FacetedMethod facetedMethod) {
@@ -74,7 +74,7 @@ extends ObjectAssociationAbstract implements 
OneToManyAssociation {
 
     @Override
     public VisibilityContext createVisibleInteractionContext(
-            final ManagedObject ownerAdapter, 
+            final ManagedObject ownerAdapter,
             final InteractionInitiatedBy interactionInitiatedBy,
             final Where where) {
         return new CollectionVisibilityContext(
@@ -84,7 +84,7 @@ extends ObjectAssociationAbstract implements 
OneToManyAssociation {
 
     @Override
     public UsabilityContext createUsableInteractionContext(
-            final ManagedObject ownerAdapter, 
+            final ManagedObject ownerAdapter,
             final InteractionInitiatedBy interactionInitiatedBy,
             final Where where) {
         return new CollectionUsabilityContext(
@@ -150,10 +150,6 @@ extends ObjectAssociationAbstract implements 
OneToManyAssociation {
         return InteractionUtils.isValidResult(this, validityContext);
     }
 
-    private boolean readWrite() {
-        return !isNotPersisted();
-    }
-
 
 
     // -- get, isEmpty, add, clear
@@ -168,11 +164,11 @@ extends ObjectAssociationAbstract implements 
OneToManyAssociation {
         if (collection == null) {
             return null;
         }
-        
+
         val objectManager = super.getObjectManager();
-        
+
         super.getServiceInjector().injectServicesInto(collection);
-        
+
         return objectManager.adapt(collection);
     }
 
@@ -191,19 +187,16 @@ extends ObjectAssociationAbstract implements 
OneToManyAssociation {
             final ManagedObject ownerAdapter,
             final ManagedObject referencedAdapter,
             final InteractionInitiatedBy interactionInitiatedBy) {
-        
+
         if (referencedAdapter == null) {
             throw new IllegalArgumentException("Can't use null to add an item 
to a collection");
         }
-        if (readWrite()) {
-            
-            EntityUtil.requiresWhenFirstIsBookmarkableSecondIsAttached(
-                    ownerAdapter, 
-                    referencedAdapter);
-                    
-            val facet = getFacet(CollectionAddToFacet.class);
-            facet.add(ownerAdapter, referencedAdapter, interactionInitiatedBy);
-        }
+        EntityUtil.requiresWhenFirstIsBookmarkableSecondIsAttached(
+                ownerAdapter,
+                referencedAdapter);
+
+        val facet = getFacet(CollectionAddToFacet.class);
+        facet.add(ownerAdapter, referencedAdapter, interactionInitiatedBy);
     }
 
     @Override
@@ -214,10 +207,8 @@ extends ObjectAssociationAbstract implements 
OneToManyAssociation {
         if (referencedAdapter == null) {
             throw new IllegalArgumentException("element should not be null");
         }
-        if (readWrite()) {
-            final CollectionRemoveFromFacet facet = 
getFacet(CollectionRemoveFromFacet.class);
-            facet.remove(ownerAdapter, referencedAdapter, 
interactionInitiatedBy);
-        }
+        final CollectionRemoveFromFacet facet = 
getFacet(CollectionRemoveFromFacet.class);
+        facet.remove(ownerAdapter, referencedAdapter, interactionInitiatedBy);
     }
 
     public void removeAllAssociations(final ManagedObject ownerAdapter) {
@@ -242,7 +233,7 @@ extends ObjectAssociationAbstract implements 
OneToManyAssociation {
     public Can<ManagedObject> getChoices(
             final ManagedObject ownerAdapter,
             final InteractionInitiatedBy interactionInitiatedBy) {
-        
+
         return Can.empty();
     }
 
@@ -262,7 +253,7 @@ extends ObjectAssociationAbstract implements 
OneToManyAssociation {
             ManagedObject object,
             String searchArg,
             final InteractionInitiatedBy interactionInitiatedBy) {
-        
+
         return Can.empty();
     }
 
diff --git 
a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/specimpl/OneToOneAssociationMixedIn.java
 
b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/specimpl/OneToOneAssociationMixedIn.java
index e0f0dfb..093cdb6 100644
--- 
a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/specimpl/OneToOneAssociationMixedIn.java
+++ 
b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/specimpl/OneToOneAssociationMixedIn.java
@@ -84,10 +84,8 @@ public class OneToOneAssociationMixedIn extends 
OneToOneAssociationDefault imple
         //
         // ensure the contributed property cannot be modified
         //
-        final NotPersistedFacet notPersistedFacet = new 
NotPersistedFacetAbstract(this) {};
         final DisabledFacet disabledFacet = disabledFacet();
 
-        FacetUtil.addFacet(notPersistedFacet);
         FacetUtil.addFacet(disabledFacet);
 
         //
@@ -96,9 +94,9 @@ public class OneToOneAssociationMixedIn extends 
OneToOneAssociationDefault imple
         // These could include everything under @Property(...) because the
         // PropertyAnnotationFacetFactory is also run against actions.
         //
-        
+
         FacetUtil.copyFacets(mixinAction.getFacetedMethod(), facetHolder);
-        
+
 
         // adjust name if necessary
         final String name = getName();
@@ -115,7 +113,7 @@ public class OneToOneAssociationMixedIn extends 
OneToOneAssociationDefault imple
 
         identifier = 
Identifier.actionIdentifier(mixedInType.getCorrespondingClass().getName(), 
getId(), memberParameterNames);
     }
-    
+
     @Override
     protected InteractionHead headFor(final ManagedObject mixedInAdapter) {
         val mixinAdapter = mixinAdapterFor(mixinType, mixedInAdapter);
@@ -138,7 +136,7 @@ public class OneToOneAssociationMixedIn extends 
OneToOneAssociationDefault imple
             final InteractionInitiatedBy interactionInitiatedBy) {
 
         val head = headFor(mixedInAdapter);
-        
+
         return getPublisherDispatchService().withPublishingSuppressed(
                 () -> mixinAction.executeInternal(head, Can.empty(), 
interactionInitiatedBy)
         );
diff --git 
a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/util/snapshot/XmlSnapshot.java
 
b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/util/snapshot/XmlSnapshot.java
index 2880f79..adf1a40 100644
--- 
a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/util/snapshot/XmlSnapshot.java
+++ 
b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/util/snapshot/XmlSnapshot.java
@@ -23,6 +23,7 @@ import java.util.Collections;
 import java.util.Enumeration;
 import java.util.List;
 import java.util.Map;
+import java.util.Objects;
 import java.util.StringTokenizer;
 import java.util.UUID;
 import java.util.Vector;
@@ -68,20 +69,33 @@ import lombok.extern.log4j.Log4j2;
  * Initially designed to allow snapshots to be easily created.
  *
  * <p>
- * Typical use:
+ * Typical use, returning customer's fields, titles of simple references,
+ * number of items in collections:
  *
  * <pre>
- * XmlSnapshot snapshot = new XmlSnapshot(customer); // where customer is a
- * // reference to an
- * // ObjectAdapter
- * Element customerAsXml = snapshot.toXml(); // returns customer's fields, 
titles
- * // of simple references, number of
- * // items in collections
- * snapshot.include(&quot;placeOfBirth&quot;); // navigates to another object 
represented by
- * // simple reference &quot;placeOfBirth&quot;
- * snapshot.include(&quot;orders/product&quot;); // navigates to all 
&lt;tt&gt;Order&lt;/tt&gt;s of
- * // &lt;tt&gt;Customer&lt;/tt&gt;, and from them for
- * // their &lt;tt&gt;Product&lt;/tt&gt;s
+ *      XmlSnapshot snapshot = new XmlSnapshot(customer);
+ *      Element customerAsXml = snapshot.toXml();
+ * </pre>
+ *
+ * <p>
+ * More complex use, navigates to another object represented by a simple
+ * reference:
+ *
+ * <pre>
+ *      XmlSnapshot snapshot = new XmlSnapshot(customer);
+ *      snapshot.include(&quot;placeOfBirth&quot;);
+ *      Element customerAsXml = snapshot.toXml();
+ * </pre>
+ *
+ * <p>
+ * More complex still, navigating to all <code>Order</code>s of
+ *  <code>Customer</code>, and from them for
+ *  their <code>Product</code>s
+ *
+ * <pre>
+ *      XmlSnapshot snapshot = new XmlSnapshot(customer);
+ *      snapshot.include(&quot;orders/product&quot;);
+ *      Element customerAsXml = snapshot.toXml();
  * </pre>
  */
 @Log4j2
@@ -654,30 +668,16 @@ public class XmlSnapshot implements Snapshot {
             }
 
             // Skip field if we have seen the name already
-            // This is a workaround for getLastActivity(). This method exists
-            // in AbstractObjectAdapter, but is not (at some level) being 
picked
-            // up
-            // by the dot-net reflector as a property. On the other hand it 
does
-            // exist as a field in the meta model (ObjectSpecification).
-            //
-            // Now, to re-expose the lastactivity field for .Net, a
-            // deriveLastActivity()
-            // has been added to BusinessObject. This caused another field of
-            // the
-            // same name, ultimately breaking the XSD.
             for (int j = 0; j < i; j++) {
-                if (fieldName.equals(fields.get(i).getName())) {
+                if (Objects.equals(fieldName, fields.get(i).getName())) {
                     log.debug("objectToElement(NO): {} SKIPPED", log("field", 
fieldName));
                     continue eachField;
                 }
             }
 
-            Element xmlFieldElement = 
getXmlDocument().createElementNS(schema.getUri(), // scoped
-                    // by
-                    // namespace
-                    // of class of
-                    // containing object
-                    schema.getPrefix() + ":" + fieldName);
+            Element xmlFieldElement = getXmlDocument().createElementNS(
+                    schema.getUri(), // scoped by namespace of class
+                    /* of containing object*/ schema.getPrefix() + ":" + 
fieldName);
 
             Element xsdFieldElement = null;
 
@@ -696,10 +696,7 @@ public class XmlSnapshot implements Snapshot {
                 }
 
                 final OneToOneAssociation valueAssociation = 
((OneToOneAssociation) field);
-                final Element xmlValueElement = xmlFieldElement; // more
-                // meaningful
-                // locally
-                // scoped name
+                final Element xmlValueElement = xmlFieldElement; // more 
meaningful locally scoped name
 
                 ManagedObject value;
                 try {
@@ -746,11 +743,7 @@ public class XmlSnapshot implements Snapshot {
 
                 final OneToOneAssociation oneToOneAssociation = 
((OneToOneAssociation) field);
                 final String fullyQualifiedClassName = nos.getFullIdentifier();
-                final Element xmlReferenceElement = xmlFieldElement; // more
-                // meaningful
-                // locally
-                // scoped
-                // name
+                final Element xmlReferenceElement = xmlFieldElement; // more 
meaningful locally scoped name
 
                 ManagedObject referencedObjectAdapter;
 
@@ -784,11 +777,7 @@ public class XmlSnapshot implements Snapshot {
                 }
 
                 final OneToManyAssociation oneToManyAssociation = 
(OneToManyAssociation) field;
-                final Element xmlCollectionElement = xmlFieldElement; // more
-                // meaningful
-                // locally
-                // scoped
-                // name
+                final Element xmlCollectionElement = xmlFieldElement; // more 
meaningful locally scoped name
 
                 ManagedObject collection;
                 try {
@@ -816,9 +805,7 @@ public class XmlSnapshot implements Snapshot {
                 continue;
             }
 
-            if (xsdFieldElement != null) {
-                Place.setXsdElement(xmlFieldElement, xsdFieldElement);
-            }
+            Place.setXsdElement(xmlFieldElement, xsdFieldElement);
 
             // XML
             if (log.isDebugEnabled()) {
@@ -827,12 +814,10 @@ public class XmlSnapshot implements Snapshot {
             xmlFieldElement = mergeTree(element, xmlFieldElement);
 
             // XSD
-            if (xsdFieldElement != null) {
-                if (log.isDebugEnabled()) {
-                    log.debug("objectToElement(NO): adding XS element for 
field to schema");
-                }
-                schema.addFieldXsElement(xsElement, xsdFieldElement);
+            if (log.isDebugEnabled()) {
+                log.debug("objectToElement(NO): adding XS element for field to 
schema");
             }
+            schema.addFieldXsElement(xsElement, xsdFieldElement);
         }
 
         return place;
diff --git 
a/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/collections/collection/NotPersistedAnnotationOnCollectionFacetFactoryTest.java
 
b/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/collections/collection/NotPersistedAnnotationOnCollectionFacetFactoryTest.java
deleted file mode 100644
index dbb2cb9..0000000
--- 
a/core/metamodel/src/test/java/org/apache/isis/core/metamodel/facets/collections/collection/NotPersistedAnnotationOnCollectionFacetFactoryTest.java
+++ /dev/null
@@ -1,71 +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.isis.core.metamodel.facets.collections.collection;
-
-import java.lang.reflect.Method;
-
-import org.apache.isis.applib.annotation.Collection;
-import org.apache.isis.applib.annotation.MementoSerialization;
-import org.apache.isis.core.metamodel.facetapi.Facet;
-import org.apache.isis.core.metamodel.facets.AbstractFacetFactoryTest;
-import org.apache.isis.core.metamodel.facets.FacetFactory;
-import 
org.apache.isis.core.metamodel.facets.collections.collection.notpersisted.NotPersistedFacetForCollectionAnnotation;
-import 
org.apache.isis.core.metamodel.facets.propcoll.notpersisted.NotPersistedFacet;
-
-import lombok.val;
-
-public class NotPersistedAnnotationOnCollectionFacetFactoryTest extends 
AbstractFacetFactoryTest {
-
-    private CollectionAnnotationFacetFactory facetFactory;
-
-    @Override
-    public void setUp() throws Exception {
-        super.setUp();
-        facetFactory = new CollectionAnnotationFacetFactory();
-    }
-    
-    private static void processNotPersisted(
-            CollectionAnnotationFacetFactory facetFactory, 
FacetFactory.ProcessMethodContext processMethodContext) {
-        val collectionIfAny = 
processMethodContext.synthesizeOnMethod(Collection.class);
-        facetFactory.processNotPersisted(processMethodContext, 
collectionIfAny);
-    }
-
-    public void testNotPersistedAnnotationPickedUpOnCollection() {
-
-        class Order {
-        }
-        class Customer {
-            @Collection(mementoSerialization = MementoSerialization.EXCLUDED)
-            public java.util.Collection<Order> getOrders() {
-                return null;
-            }
-        }
-        final Method method = findMethod(Customer.class, "getOrders");
-
-        processNotPersisted(facetFactory, new 
FacetFactory.ProcessMethodContext(Customer.class, null, method, methodRemover, 
facetedMethod));
-
-        final Facet facet = facetedMethod.getFacet(NotPersistedFacet.class);
-        assertNotNull(facet);
-        assertTrue(facet instanceof NotPersistedFacetForCollectionAnnotation);
-
-        assertNoMethodsRemoved();
-    }
-
-}

Reply via email to