View Javadoc

1   package net.sf.chainedoptions;
2   
3   import java.util.List;
4   
5   /***
6    * Interface for a strategy that is responsible for sorting and filtering the
7    * list of available options and providing a reasonable default value. The
8    * strategy may also adjust the list of options, for example by adding an option
9    * representing any of the available options, like for example an ANY_REGION
10   * option, which comes in handy in some search pages.
11   * 
12   * @author Mattias Arthursson
13   * @author Ulrik Sandberg
14   */
15  public interface ChainedOptionStrategy {
16      /***
17       * Sorts the given list of options. May also adjust the list of options by
18       * adding or removing entries.
19       * 
20       * @param options
21       *            List of LabelValueBean objects to adjust and sort.
22       * @param context
23       *            may contain any context that might be interesting for the
24       *            Strategy for fitering or adding values. E.g. the Request
25       *            object might be passed as context for the Strategy in order to
26       *            hide some options depending on user access.
27       * 
28       * @return A sorted list of LabelValueBean objects.
29       * @see LabelValueBean
30       */
31      List adjustAndSort(List options, Object context);
32  
33      /***
34       * Provides the default value of the given list of options.
35       * 
36       * @param options
37       *            List of LabelValueBean objects where the default value must be
38       *            found.
39       * @param context
40       *            may contain any context that might be interesting for the
41       *            Strategy to select the default value.
42       * 
43       * @return A value representing the default value of the given list of
44       *         options.
45       */
46      String getDefaultValue(List options, Object context);
47  }