]> git.mxchange.org Git - jproduct-core.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Sat, 25 Apr 2020 16:21:18 +0000 (18:21 +0200)
committerRoland Häder <roland@mxchange.org>
Sat, 25 Apr 2020 16:21:18 +0000 (18:21 +0200)
- added utilities method copyCategoryData()

Signed-off-by: Roland Häder <roland@mxchange.org>
src/org/mxchange/jproduct/model/category/Categories.java

index 1eb1f6326924e9b7e5e0b15693757b2cccad544c..272c84608fa1aa57134ce2321ce17386acf65fc4 100644 (file)
@@ -57,6 +57,33 @@ public class Categories implements Serializable {
                return category1.compareTo(category2);
        }
 
+       /**
+        * Copies all data from source category to target category
+        * <p>
+        * @param sourceCategory Source category instance
+        * @param targetCategory Target category instance
+        */
+       public static void copyCategoryData (final Category sourceCategory, final Category targetCategory) {
+               // Category should be valid
+               if (null == sourceCategory) {
+                       // Throw NPE
+                       throw new NullPointerException("sourceCategory is null"); //NOI18N
+               } else if (null == targetCategory) {
+                       // Throw NPE
+                       throw new NullPointerException("targetCategory is null"); //NOI18N
+               } else if (Objects.equals(sourceCategory, targetCategory)) {
+                       // Is exactly the same!
+                       throw new IllegalArgumentException("sourcerCategory and targetCategory are the same."); //NOI18N
+               }
+
+               // Copy all:
+               targetCategory.setCategoryEntryCreated(sourceCategory.getCategoryEntryCreated());
+               targetCategory.setCategoryEntryUpdated(sourceCategory.getCategoryEntryUpdated());
+               targetCategory.setCategoryI18nKey(sourceCategory.getCategoryI18nKey());
+               targetCategory.setCategoryId(sourceCategory.getCategoryId());
+               targetCategory.setCategoryShownInStatistics(sourceCategory.getCategoryShownInStatistics());
+       }
+
        /**
         * Utility classes should have no instances
         */