From 7b690d0d00f97a736f5dc074040258e7bd4299a0 Mon Sep 17 00:00:00 2001 From: James Cover jdcove2 Date: Mon, 2 Dec 2024 19:36:09 +0000 Subject: [PATCH 1/2] Deprecate IBaseDataObjectHelper.clone() that allows partial clones. --- .../java/emissary/core/IBaseDataObjectHelper.java | 12 ++++++++++++ .../emissary/core/IBaseDataObjectHelperTest.java | 13 +++++++++++++ 2 files changed, 25 insertions(+) diff --git a/src/main/java/emissary/core/IBaseDataObjectHelper.java b/src/main/java/emissary/core/IBaseDataObjectHelper.java index 7a9687cdac..39c3222ffd 100644 --- a/src/main/java/emissary/core/IBaseDataObjectHelper.java +++ b/src/main/java/emissary/core/IBaseDataObjectHelper.java @@ -37,15 +37,27 @@ private InternalIdBaseDataObject(final UUID internalId) { private IBaseDataObjectHelper() {} + /** + * Clones an IBaseDataObject. + * + * @param iBaseDataObject the IBaseDataObject to be cloned. + * @return the clone of the IBaseDataObject passed in. + */ + public static IBaseDataObject clone(final IBaseDataObject iBaseDataObject) { + return clone(iBaseDataObject, true); + } + /** * Clones an IBaseDataObject equivalently to emissary.core.BaseDataObject.clone(), which duplicates some attributes. * * A "fullClone" duplicates all attributes. * + * @deprecated * @param iBaseDataObject the IBaseDataObject to be cloned. * @param fullClone specifies if all fields should be cloned. * @return the clone of the IBaseDataObject passed in. */ + @Deprecated public static IBaseDataObject clone(final IBaseDataObject iBaseDataObject, final boolean fullClone) { Validate.notNull(iBaseDataObject, "Required: iBaseDataObject not null"); diff --git a/src/test/java/emissary/core/IBaseDataObjectHelperTest.java b/src/test/java/emissary/core/IBaseDataObjectHelperTest.java index 68155ec09e..d7f7c62af2 100644 --- a/src/test/java/emissary/core/IBaseDataObjectHelperTest.java +++ b/src/test/java/emissary/core/IBaseDataObjectHelperTest.java @@ -108,6 +108,19 @@ private static void verifyCloneAssertions(final Method method, final Object obj1 } + @Test + void testOneArgClone() { + final IBaseDataObject originalIbdo = new BaseDataObject(new byte[123], "Filename", "form", "filetype"); + final IBaseDataObject clonedIbdo = IBaseDataObjectHelper.clone(originalIbdo); + final List differences = new ArrayList<>(); + final DiffCheckConfiguration diffCheckConfiguration = + DiffCheckConfiguration.configure().enableData().enableInternalId().enableTimestamp().enableTransformHistory().build(); + + IBaseDataObjectDiffHelper.diff(originalIbdo, clonedIbdo, differences, diffCheckConfiguration); + + assertEquals(0, differences.size()); + } + @Test void testCloneArguments() { assertNotNull(IBaseDataObjectHelper.clone(new BaseDataObject(), false)); From a1a342f303e638a7ba0dbccd5ff2657cbc0d0f33 Mon Sep 17 00:00:00 2001 From: James Cover jdcove2 Date: Wed, 4 Dec 2024 16:34:33 +0000 Subject: [PATCH 2/2] Changes from PR feedback. --- src/main/java/emissary/core/IBaseDataObjectHelper.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/emissary/core/IBaseDataObjectHelper.java b/src/main/java/emissary/core/IBaseDataObjectHelper.java index 39c3222ffd..7eff3909eb 100644 --- a/src/main/java/emissary/core/IBaseDataObjectHelper.java +++ b/src/main/java/emissary/core/IBaseDataObjectHelper.java @@ -52,12 +52,12 @@ public static IBaseDataObject clone(final IBaseDataObject iBaseDataObject) { * * A "fullClone" duplicates all attributes. * - * @deprecated + * @deprecated prefer {@link #clone(IBaseDataObject)} * @param iBaseDataObject the IBaseDataObject to be cloned. * @param fullClone specifies if all fields should be cloned. * @return the clone of the IBaseDataObject passed in. */ - @Deprecated + @Deprecated(forRemoval = true) public static IBaseDataObject clone(final IBaseDataObject iBaseDataObject, final boolean fullClone) { Validate.notNull(iBaseDataObject, "Required: iBaseDataObject not null");