package gw.lob.common.schedule uses java.util.ArrayList uses entity.Clause uses gw.api.domain.Schedule uses java.util.List @Export /** * Defines common behaviors for schedule helper classes */ abstract class AbstractScheduleHelper { /** * Return a list of item scheduled item for a {@link PolicyLine} * * @param line the PolicyLine that has 0 to n items * @param the type of elements returned by the returned list * @return a {@link java.util.List} of items that are used by this PolicyLine */ function getScheduledItemsForPolicyLine(line : T) : List { return getScheduledItemsForAllCoverables(line) } /** * Subclasses of this object need to implement this method to return a list of scheduled items * used by this PolicyLine * * @param line the PolicyLine that has 0 to n items * @param the type of elements returned by the returned list * @return a {@link java.util.List} of items that are used by this PolicyLine */ abstract function getScheduledItemsForAllCoverables(line : T) : List /** * This is a default implementation that returns the Coverages, Conditions * and Exclusions used by a Coverable * * @param aCoverable the Coverable that has 0 to n items * @param the type of elements returned by the returned list * @return a {@link java.util.List} of items that are used by this Coverable */ function getScheduledItemsForCoverable(aCoverable : Coverable) : List { var results = new ArrayList() results.addAll(iterateAndDowncastSchedules(aCoverable.CoveragesFromCoverable)) results.addAll(iterateAndDowncastSchedules(aCoverable.ConditionsFromCoverable)) results.addAll(iterateAndDowncastSchedules(aCoverable.ExclusionsFromCoverable)) return results } /** * Subclasses of this object need to implement this method to return a list of current and future scheduled items * used by this PolicyLine * * @param line the PolicyLine that has 0 to n items * @param the type of elements returned by the returned list * @return a {@link java.util.List} of current and future scheduled items that are used by this Coverable */ abstract function getCurrentAndFutureScheduledItemsForPolicyLine(line : T) : List /** * This is a default implementation that returns a list of scheduled items used by the clauses downcast to the kind * of objects K * * @param clauseArray the Clauses that have 0 to n items * @param the type of elements returned by the returned list * @return a {@link java.util.List} of scheduled items used by the any of the clauses in clauseArray */ private function iterateAndDowncastSchedules(clauseArray : Clause[]) : List { var results = new ArrayList() for (aClause in clauseArray){ if (Schedule.Type.isAssignableFrom(typeof aClause)){ var items = (aClause as Schedule).ScheduledItems items.each(\il-> results.add(il as K)) } } return results } }