Skip to content

Commit

Permalink
deprecate IBaseDataObjectHelper.clone() that allows partial clones. (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
jdcove2 authored Dec 5, 2024
1 parent 504c492 commit 50dd247
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/main/java/emissary/core/IBaseDataObjectHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
public static IBaseDataObject clone(final IBaseDataObject iBaseDataObject, final boolean fullClone) {
Validate.notNull(iBaseDataObject, "Required: iBaseDataObject not null");

Expand Down
13 changes: 13 additions & 0 deletions src/test/java/emissary/core/IBaseDataObjectHelperTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> 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));
Expand Down

0 comments on commit 50dd247

Please sign in to comment.