All Downloads are FREE. Search and download functionalities are using the official Maven repository.

jadex.bridge.nonfunctional.search.CountThresholdSearchTerminationDecider Maven / Gradle / Ivy

Go to download

Jadex bridge is a base package for kernels and platforms, i.e., it is used by both and provides commonly used interfaces and classes for active components and their management.

There is a newer version: 4.0.267
Show newest version
package jadex.bridge.nonfunctional.search;

import java.util.Collection;

import jadex.commons.future.IFuture;

/**
 *  Service search ranking decider based on a simple service count threshold.
 */
public class CountThresholdSearchTerminationDecider implements IRankingSearchTerminationDecider
{
	/** The threshold of found services after which the ranking starts. */
	protected int threshold;
	
	/**
	 *  Creates the decider.
	 *  @param threshold The threshold of found services after which the ranking starts.
	 */
	public CountThresholdSearchTerminationDecider(int threshold)
	{
		this.threshold = threshold;
	}
	
	/**
	 *  Decides if the search should start ranking.
	 */
	public IFuture isStartRanking(Collection currentresults, IServiceEvaluator evaluator)
	{
		return currentresults.size()>=threshold ? IFuture.TRUE : IFuture.FALSE;
	}
}