Source:
private void applyChanges(Sample target, Sample source) throws IOException { target.setDescription(source.getDescription()); target.setSampleType(source.getSampleType()); target.setReceivedDate(source.getReceivedDate()); target.setQcPassed(source.getQcPassed()); target.setScientificName(source.getScientificName()); target.setTaxonIdentifier(source.getTaxonIdentifier()); if (!target.getAlias().equals(source.getAlias()) && (!isDetailedSample(target) || (isDetailedSample(target) && !((SampleAdditionalInfo) target).hasNonStandardAlias()))) { validateAliasUniqueness(source.getAlias()); } target.setAlias(source.getAlias()); target.setDescription(source.getDescription()); target.setEmpty(source.isEmpty()); target.setVolume(source.getVolume()); if (!isStringBlankOrNull(source.getIdentificationBarcode())) { target.setIdentificationBarcode(source.getIdentificationBarcode()); } if (isDetailedSample(target)) { sampleAdditionalInfoService.applyChanges((SampleAdditionalInfo) target, (SampleAdditionalInfo) source); if (isIdentitySample(target)) { Identity iTarget = (Identity) target; Identity iSource = (Identity) source; iTarget.setInternalName(iSource.getInternalName()); iTarget.setExternalName(iSource.getExternalName()); } if (isTissueSample(target)) { sampleTissueService.applyChanges((SampleTissue) target, (SampleTissue) source); } if (isTissueProcessingSample(target)) { applyChanges((SampleTissueProcessing) target, (SampleTissueProcessing) source); } if (isAliquotSample(target)) { SampleAliquot saTarget = (SampleAliquot) target; SampleAliquot saSource = (SampleAliquot) source; saTarget.setSamplePurpose(saSource.getSamplePurpose()); } if (isStockSample(target)) { SampleStock ssTarget = (SampleStock) target; SampleStock ssSource = (SampleStock) source; ssTarget.setStrStatus(ssSource.getStrStatus()); ssTarget.setConcentration(ssSource.getConcentration()); ssTarget.setDNAseTreated(ssSource.getDNAseTreated()); } } }

Target:
private void applyChanges(Sample target, Sample source) throws IOException { target.setDescription(source.getDescription()); target.setSampleType(source.getSampleType()); target.setReceivedDate(source.getReceivedDate()); target.setQcPassed(source.getQcPassed()); target.setScientificName(source.getScientificName()); target.setTaxonIdentifier(source.getTaxonIdentifier()); if (!target.getAlias().equals(source.getAlias()) && (!isDetailedSample(target) || (isDetailedSample(target) && !((SampleAdditionalInfo) target).hasNonStandardAlias()))) { validateAliasUniqueness(source.getAlias()); } target.setAlias(source.getAlias()); target.setDescription(source.getDescription()); target.setEmpty(source.isEmpty()); target.setVolume(source.getVolume()); target.setIdentificationBarcode(source.getIdentificationBarcode()); if (isDetailedSample(target)) { sampleAdditionalInfoService.applyChanges((SampleAdditionalInfo) target, (SampleAdditionalInfo) source); if (isIdentitySample(target)) { Identity iTarget = (Identity) target; Identity iSource = (Identity) source; iTarget.setInternalName(iSource.getInternalName()); iTarget.setExternalName(iSource.getExternalName()); } if (isTissueSample(target)) { sampleTissueService.applyChanges((SampleTissue) target, (SampleTissue) source); } if (isTissueProcessingSample(target)) { applyChanges((SampleTissueProcessing) target, (SampleTissueProcessing) source); } if (isAliquotSample(target)) { SampleAliquot saTarget = (SampleAliquot) target; SampleAliquot saSource = (SampleAliquot) source; saTarget.setSamplePurpose(saSource.getSamplePurpose()); } if (isStockSample(target)) { SampleStock ssTarget = (SampleStock) target; SampleStock ssSource = (SampleStock) source; ssTarget.setStrStatus(ssSource.getStrStatus()); ssTarget.setConcentration(ssSource.getConcentration()); ssTarget.setDNAseTreated(ssSource.getDNAseTreated()); } } }