org.seedstack.business.assembler.LegacyBaseAssembler Maven / Gradle / Ivy
/*
* Copyright © 2013-2018, The SeedStack authors
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package org.seedstack.business.assembler;
import org.seedstack.business.domain.AggregateRoot;
@Deprecated
public abstract class LegacyBaseAssembler, D> extends BaseAssembler
implements LegacyAssembler {
@Override
public D assembleDtoFromAggregate(A sourceAggregate) {
D newDto = createDto();
doAssembleDtoFromAggregate(newDto, sourceAggregate);
return newDto;
}
protected abstract void doAssembleDtoFromAggregate(D targetDto, A sourceAggregate);
protected abstract void doMergeAggregateWithDto(A targetAggregate, D sourceDto);
@Override
public void mergeAggregateIntoDto(A sourceAggregate, D targetDto) {
doAssembleDtoFromAggregate(targetDto, sourceAggregate);
}
@Override
public void mergeDtoIntoAggregate(D sourceDto, A targetAggregate) {
doMergeAggregateWithDto(targetAggregate, sourceDto);
}
}