You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ItemSorter.java 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. @VaadinApache2LicenseForJavaFiles@
  3. */
  4. package com.vaadin.data.util;
  5. import java.io.Serializable;
  6. import java.util.Comparator;
  7. import com.vaadin.data.Container;
  8. import com.vaadin.data.Container.Sortable;
  9. /**
  10. * An item comparator which is compatible with the {@link Sortable} interface.
  11. * The <code>ItemSorter</code> interface can be used in <code>Sortable</code>
  12. * implementations to provide a custom sorting method.
  13. */
  14. public interface ItemSorter extends Comparator<Object>, Cloneable, Serializable {
  15. /**
  16. * Sets the parameters for an upcoming sort operation. The parameters
  17. * determine what container to sort and how the <code>ItemSorter</code>
  18. * sorts the container.
  19. *
  20. * @param container
  21. * The container that will be sorted. The container must contain
  22. * the propertyIds given in the <code>propertyId</code>
  23. * parameter.
  24. * @param propertyId
  25. * The property ids used for sorting. The property ids must exist
  26. * in the container and should only be used if they are also
  27. * sortable, i.e include in the collection returned by
  28. * <code>container.getSortableContainerPropertyIds()</code>. See
  29. * {@link Sortable#sort(Object[], boolean[])} for more
  30. * information.
  31. * @param ascending
  32. * Sorting order flags for each property id. See
  33. * {@link Sortable#sort(Object[], boolean[])} for more
  34. * information.
  35. */
  36. void setSortProperties(Container.Sortable container, Object[] propertyId,
  37. boolean[] ascending);
  38. /**
  39. * Compares its two arguments for order. Returns a negative integer, zero,
  40. * or a positive integer as the first argument is less than, equal to, or
  41. * greater than the second.
  42. * <p>
  43. * The parameters for the <code>ItemSorter</code> <code>compare()</code>
  44. * method must always be item ids which exist in the container set using
  45. * {@link #setSortProperties(Sortable, Object[], boolean[])}.
  46. *
  47. * @see Comparator#compare(Object, Object)
  48. */
  49. @Override
  50. int compare(Object itemId1, Object itemId2);
  51. }