Ejemplo n.º 1
0
 public List<DomainObject> getChildren(Class<? extends DomainObject>... types) {
   final List<DomainObject> result = new ArrayList<DomainObject>();
   for (DomainObject p : getChildren()) {
     final String name = p.getProperty(DomainObject.ClassType);
     if (name != null && Utils.isContainProperty(name, types)) {
       result.add(p);
     }
   }
   return result;
 }
Ejemplo n.º 2
0
 private void checkArguments(DomainObject object) {
   if (object == null) {
     throw new IllegalArgumentException("This container cannot contain 'null' elements");
   }
   final Children children = getClass().getAnnotation(Children.class);
   if (children == null || check(children.types(), object.getClass(), children.allowSubtypes())) {
     throw new IllegalArgumentException(
         String.format(
             "The container '%s' cannot contain elements with type '%s'",
             getClass().getName(), object.getClass().getName()));
   }
 }