cdm.base.datetime.functions.BusinessCenterHolidaysMultiple Maven / Gradle / Ivy
package cdm.base.datetime.functions;
import cdm.base.datetime.BusinessCenterEnum;
import com.google.inject.ImplementedBy;
import com.rosetta.model.lib.functions.RosettaFunction;
import com.rosetta.model.lib.mapper.MapperC;
import com.rosetta.model.lib.mapper.MapperListOfLists;
import com.rosetta.model.lib.records.Date;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import javax.inject.Inject;
import static com.rosetta.model.lib.expression.ExpressionOperators.*;
@ImplementedBy(BusinessCenterHolidaysMultiple.BusinessCenterHolidaysMultipleDefault.class)
public abstract class BusinessCenterHolidaysMultiple implements RosettaFunction {
// RosettaFunction dependencies
//
@Inject protected BusinessCenterHolidays businessCenterHolidays;
/**
* @param businessCenters The business centers for which the holiday list is required.
* @return holidayDates The combined list of holidays in all of the supplied business centers.
*/
public List evaluate(List businessCenters) {
List holidayDates = doEvaluate(businessCenters);
return holidayDates;
}
protected abstract List doEvaluate(List businessCenters);
public static class BusinessCenterHolidaysMultipleDefault extends BusinessCenterHolidaysMultiple {
@Override
protected List doEvaluate(List businessCenters) {
if (businessCenters == null) {
businessCenters = Collections.emptyList();
}
List holidayDates = new ArrayList<>();
return assignOutput(holidayDates, businessCenters);
}
protected List assignOutput(List holidayDates, List businessCenters) {
final MapperListOfLists thenResult0 = MapperC.of(businessCenters)
.mapItemToList(item -> MapperC.of(businessCenterHolidays.evaluate(item.get())));
final MapperC thenResult1 = thenResult0
.flattenList();
final MapperC thenResult2 = distinct(thenResult1);
holidayDates.addAll(thenResult2
.sort().getMulti());
return holidayDates;
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy