cdm.base.datetime.functions.AppendDateToList Maven / Gradle / Ivy
package cdm.base.datetime.functions;
import com.google.inject.ImplementedBy;
import com.rosetta.model.lib.functions.RosettaFunction;
import com.rosetta.model.lib.records.Date;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@ImplementedBy(AppendDateToList.AppendDateToListDefault.class)
public abstract class AppendDateToList implements RosettaFunction {
/**
* @param origDates List of dates.
* @param newDate Date to add to the list.
* @return newList The newly increased list.
*/
public List evaluate(List origDates, Date newDate) {
List newList = doEvaluate(origDates, newDate);
return newList;
}
protected abstract List doEvaluate(List origDates, Date newDate);
public static class AppendDateToListDefault extends AppendDateToList {
@Override
protected List doEvaluate(List origDates, Date newDate) {
if (origDates == null) {
origDates = Collections.emptyList();
}
List newList = new ArrayList<>();
return assignOutput(newList, origDates, newDate);
}
protected List assignOutput(List newList, List origDates, Date newDate) {
newList = new ArrayList<>(origDates);
if (newDate == null) {
newList.addAll(Collections.emptyList());
} else {
newList.addAll(Collections.singletonList(newDate));
}
return newList;
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy