package data;

import java.io.Serializable;

/**
  * Condition used for filtering {@link DataBasket DataBaskets}.
  *
  * @author Steffen Zschaler
  * @version 2.0 14/06/1999
  * @since v2.0
  */
public interface DataBasketCondition extends DataBasketKeys, Serializable {

  /**
    * Return the main key that {@link DataBasketEntry DataBasketEntries} must have to
    * match the condition. Returning <code>null</code> means any main key.
    *
    * @override Always
    */
  public String getMainKey();

  /**
    * Return the secondary key that {@link DataBasketEntry DataBasketEntries} must have to
    * match the condition. Returning <code>null</code> means any secondary key.
    *
    * @override Always
    */
  public String getSecondaryKey();

  /**
    * Return the source for operations that match the condition. Returning <code>null</code>
    * means any source, other values mean exactly what they say, i.e. they are tested for
    * identity.
    *
    * @override Always
    */
  public DataBasketEntrySource getSource();

  /**
    * Return the destination for operations that match the condition. Returning
    * <code>null</code> means any destination, other values mean exactly what they say, i.e.
    * they are tested for identity.
    *
    * @override Always
    */
  public DataBasketEntryDestination getDestination();

  /**
    * Return the object for operations that match the condition. Returning <code>null</code>
    * means check each DataBasketEntry by calling {@link #match match()}, other values mean
    * exactly what they say, i.e. they are tested for identity.
    *
    * @override Always
    */
  public Object getValue();

  /**
    * Return true for DataBasketEntries that match the condition. This method is only called
    * for DataBasketEntries that have already been filtered by their main and secondary key,
    * as well as their source and destination. Additionally, it is only called if
    * {@link #getValue()} returns <code>null</code>.
    *
    * @override Always
    */
  public boolean match (DataBasketEntry dbe);
}