public static boolean isNegative(Query q){
  if (!(q instanceof BooleanQuery))   return false;
  BooleanQuery bq=(BooleanQuery)q;
  Collection<BooleanClause> clauses=bq.clauses();
  if (clauses.size() == 0)   return false;
  for (  BooleanClause clause : clauses) {
    if (!clause.isProhibited())     return false;
  }
  return true;
}

public static boolean isNegative ( Query q ) { if ( ! ( q instanceof BooleanQuery ) ) return false ; BooleanQuery bq = ( BooleanQuery ) q ; Collection < BooleanClause > clauses = bq . clauses ( ) ; if ( clauses . size ( ) == 0 ) return false ; for ( BooleanClause clause : clauses ) { if ( ! clause . isProhibited ( ) ) return false ; } return true ; }
return true if this query has no positive components
