01: package com.jidesoft.grouper;
02:
03: import com.jidesoft.comparator.ComparatorContext;
04: import com.jidesoft.converter.ConverterContext;
05:
06: /**
07: * An interface that can convert a object to a group so that the objects that has the same group can be grouped together.
08: * We suggest you extends {@link com.jidesoft.grouper.AbstractObjectGrouper} if you want to create your own ObjectGrouper
09: * in case we add new methods to this interface due to requirement changes.
10: */
11: public interface ObjectGrouper {
12: /**
13: * Gets the group value after this value is grouped. If two objects return the same value
14: * in this getGroupValue method, the two objects are considered as one group.
15: * We assume all values returned from this method are of the same type which is returned in {@link #getType()}.
16: *
17: * @param value the value
18: * @return the value after grouped.
19: */
20: Object getValue(Object value);
21:
22: /**
23: * Gets the group value type. It should be the type of the value that is returned from the getGroupValue.
24: *
25: * @return the group value type.
26: */
27: Class<?> getType();
28:
29: /**
30: * Gets the name of this object grouper.
31: *
32: * @return the name of this grouper.
33: */
34: String getName();
35:
36: /**
37: * Gets the converter context for the value returned from this object grouper.
38: * This converter context will be used to find the ObjectConverter that will convert
39: * the value returned from {@link #getValue(Object)} method to String so that it can be displayed somewhere.
40: *
41: * @return the converter context.
42: */
43: ConverterContext getConverterContext();
44:
45: /**
46: * Gets the comparator context for the value returned from this object grouper.
47: * This comprator context will be used to find the ObjectComparator that will sort the
48: * values return from {@link #getValue(Object)} method whenever sorting is needed.
49: *
50: * @return the converter context.
51: */
52: ComparatorContext getComparatorContext();
53: }
|