Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate IBaseDataObjectHelper.clone() that allows partial clones. #1018

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
* @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
Loading