In any nuisance action in which a farming operation is alleged to be a nuisance, a prevailing defendant shall recover the aggregate amount of costs and expenses determined by the court to have been reasonably incurred in the defense of the nuisance action, together with a reasonable amount for attorney fees. For the purposes of this Section, a prevailing defendant is a defendant in a lawsuit in whose favor a final court order or judgment is rendered. A defendant shall not be considered to have prevailed if, prior to a final court order or judgment, he or she enters into a negotiated settlement agreement or takes any corrective or other action that renders unnecessary a final court order or judgment.
740 ILCS 70/4.5