Ejemplo n.º 1
0
 /**
  * Creates a comparator that inverts the comparison
  * of the given comparator.  If you pass in <code>null</code>,
  * the ReverseComparator defaults to reversing the
  * natural order, as per
  * {@link java.util.Collections#reverseOrder()}</b>.
  *
  * @param comparator Comparator to reverse
  */
 public ReverseComparator(java.util.Comparator <Object> comparator)
 {
     if (comparator != null)
     {
         this.comparator = comparator;
     }
     else
     {
         this.comparator = ComparableComparator.getInstance();
     }
 }
 /**
  *  Construct an instance that sorts <code>null</code> higher or lower than
  *  any non-<code>null</code> object it is compared with.  When comparing
  *  two non-<code>null</code> objects, the {@link ComparableComparator} is
  *  used.
  *
  *  @param nullsAreHigh a <code>true</code> value indicates that
  *  <code>null</code> should be compared as higher than a
  *  non-<code>null</code> object.  A <code>false</code> value indicates
  *  that <code>null</code> should be compared as lower than a
  *  non-<code>null</code> object.
  **/
 public NullComparator(bool nullsAreHigh)
     : this(ComparableComparator.getInstance(), nullsAreHigh)
 {
 }
        //-----------------------------------------------------------------------

        /**
         *  Construct an instance that sorts <code>null</code> higher than any
         *  non-<code>null</code> object it is compared with. When comparing two
         *  non-<code>null</code> objects, the {@link ComparableComparator} is
         *  used.
         **/
        public NullComparator()
            : this(ComparableComparator.getInstance(), true)
        {
        }