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

ntimofeev pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cayenne.git


The following commit(s) were added to refs/heads/master by this push:
     new fc376affb Cleanup warnings
fc376affb is described below

commit fc376affb50c185d60d85797ce5966dcba52c53e
Author: Nikita Timofeev <[email protected]>
AuthorDate: Tue Jul 9 16:17:18 2024 +0400

    Cleanup warnings
---
 .../apache/cayenne/util/DeepMergeOperation.java    | 47 ++++++++++------------
 1 file changed, 22 insertions(+), 25 deletions(-)

diff --git 
a/cayenne/src/main/java/org/apache/cayenne/util/DeepMergeOperation.java 
b/cayenne/src/main/java/org/apache/cayenne/util/DeepMergeOperation.java
index fe5c781ac..a3e1c24a9 100644
--- a/cayenne/src/main/java/org/apache/cayenne/util/DeepMergeOperation.java
+++ b/cayenne/src/main/java/org/apache/cayenne/util/DeepMergeOperation.java
@@ -58,7 +58,7 @@ public class DeepMergeOperation {
     public <T extends Persistent> T merge(T peerInParentContext) {
         ClassDescriptor descriptor = entityResolver
                 
.getClassDescriptor(peerInParentContext.getObjectId().getEntityName());
-        return merge(peerInParentContext, descriptor, new HashMap<ObjectId, 
Persistent>());
+        return merge(peerInParentContext, descriptor, new HashMap<>());
     }
 
     private <T extends Persistent> T merge(
@@ -75,7 +75,9 @@ public class DeepMergeOperation {
 
         Persistent seenTarget = seen.get(id);
         if (seenTarget != null) {
-            return (T) seenTarget;
+            @SuppressWarnings("unchecked")
+            T castTarget = (T) seenTarget;
+            return castTarget;
         }
 
         final T target = shallowMergeOperation.merge(peerInParentContext);
@@ -87,16 +89,13 @@ public class DeepMergeOperation {
             public boolean visitToOne(ToOneProperty property) {
 
                 if (!property.isFault(peerInParentContext)) {
-                    Persistent destinationSource = (Persistent) property
-                            .readProperty(peerInParentContext);
-
-                    Object destinationTarget = destinationSource != null ? 
merge(
-                            destinationSource,
-                            property.getTargetDescriptor(),
-                            seen) : null;
-
-                    Object oldTarget = property.isFault(target) ? null : 
property
-                            .readProperty(target);
+                    Persistent destinationSource = (Persistent) 
property.readProperty(peerInParentContext);
+                    Object destinationTarget = destinationSource != null
+                            ? merge(destinationSource, 
property.getTargetDescriptor(), seen)
+                            : null;
+                    Object oldTarget = property.isFault(target)
+                            ? null
+                            : property.readProperty(target);
                     property.writePropertyDirectly(target, oldTarget, 
destinationTarget);
                 }
 
@@ -109,29 +108,27 @@ public class DeepMergeOperation {
                     Object targetValue;
 
                     if (property instanceof ToManyMapProperty) {
-                        Map<?, ?> map = (Map) value;
-                        Map targetMap = new HashMap();
+                        Map<?, ?> map = (Map<?, ?>) value;
+                        Map<Object, Object> targetMap = new HashMap<>();
 
-                        for (Entry entry : map.entrySet()) {
+                        for (Entry<?, ?> entry : map.entrySet()) {
                             Object destinationSource = entry.getValue();
-                            Object destinationTarget = destinationSource != 
null ? merge(
-                                    (Persistent) destinationSource,
-                                    property.getTargetDescriptor(),
-                                    seen) : null;
+                            Object destinationTarget = destinationSource != 
null
+                                    ? merge((Persistent) destinationSource, 
property.getTargetDescriptor(), seen)
+                                    : null;
 
                             targetMap.put(entry.getKey(), destinationTarget);
                         }
                         targetValue = targetMap;
                     }
                     else {
-                        Collection collection = (Collection) value;
-                        Collection targetCollection = new 
ArrayList(collection.size());
+                        Collection<?> collection = (Collection<?>) value;
+                        Collection<Object> targetCollection = new 
ArrayList<>(collection.size());
 
                         for (Object destinationSource : collection) {
-                            Object destinationTarget = destinationSource != 
null ? merge(
-                                    (Persistent) destinationSource,
-                                    property.getTargetDescriptor(),
-                                    seen) : null;
+                            Object destinationTarget = destinationSource != 
null
+                                    ? merge((Persistent) destinationSource, 
property.getTargetDescriptor(), seen)
+                                    : null;
 
                             targetCollection.add(destinationTarget);
                         }

Reply via email to