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())); } }