diff --git a/src/main/java/emissary/core/IBaseDataObjectHelper.java b/src/main/java/emissary/core/IBaseDataObjectHelper.java index 7a9687cda..7eff3909e 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 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(forRemoval = true) 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 68155ec09..d7f7c62af 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));