示例#1
0
 /**
  * @param date the date which they should have been active
  * @return a {@link Collection} with the {@link CountrySubdivision} that were active on the given
  *     date and of the
  */
 public Collection<CountrySubdivision> getChildrenValidAt(LocalDate date) {
   Collection<Unit> units = getChildUnits().collect(Collectors.toList());
   Collection<CountrySubdivision> children = new ArrayList<CountrySubdivision>();
   for (Unit unit : units) {
     final AccountabilityType type = getOrCreateAccountabilityType();
     unit.getParentAccountabilityStream()
         .filter(a -> a.getAccountabilityType() == type && a.isActive(date))
         .forEach(a -> children.add((CountrySubdivision) unit.getGeographicLocation()));
   }
   return children;
 }
示例#2
0
 public CountrySubdivision getChildByCode(String... codes) {
   String code = codes[0];
   for (Unit subdivision : getChildUnits().collect(Collectors.toList())) {
     CountrySubdivision geographicLocation =
         (CountrySubdivision) subdivision.getGeographicLocation();
     if (geographicLocation.getCode().equals(code)) {
       if (codes.length > 1) {
         return geographicLocation.getChildByCode(
             Arrays.asList(codes).subList(1, codes.length).toArray(new String[0]));
       }
       return geographicLocation;
     }
   }
   return null;
 }