< prev index next >

src/com/sun/javatest/report/TestResultsByTitleComparator.java

Print this page
rev 145 : 7902237: Fixing raw use of parameterized class
Reviewed-by: jjg


  13  * This code is distributed in the hope that it will be useful, but WITHOUT
  14  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  15  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  16  * version 2 for more details (a copy is included in the LICENSE file that
  17  * accompanied this code).
  18  *
  19  * You should have received a copy of the GNU General Public License version
  20  * 2 along with this work; if not, write to the Free Software Foundation,
  21  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  22  *
  23  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  24  * or visit www.oracle.com if you need additional information or have any
  25  * questions.
  26  */
  27 package com.sun.javatest.report;
  28 
  29 import java.util.Comparator;
  30 
  31 import com.sun.javatest.TestResult;
  32 
  33 class TestResultsByTitleComparator implements Comparator {
  34     public int compare(Object o1, Object o2) {
  35         TestResult tr1 = (TestResult)o1;
  36         TestResult tr2 = (TestResult)o2;
  37 
  38         return compare(tr1.getTestName(), tr2.getTestName());
  39     }
  40 
  41     private static int compare(String a, String b) {
  42         if (a == null && b == null)
  43             return 0;
  44 
  45         if (a == null)
  46             return -1;
  47 
  48         if (b == null)
  49             return +1;
  50 
  51         return a.compareTo(b);
  52      }
  53 }


  13  * This code is distributed in the hope that it will be useful, but WITHOUT
  14  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  15  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  16  * version 2 for more details (a copy is included in the LICENSE file that
  17  * accompanied this code).
  18  *
  19  * You should have received a copy of the GNU General Public License version
  20  * 2 along with this work; if not, write to the Free Software Foundation,
  21  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  22  *
  23  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  24  * or visit www.oracle.com if you need additional information or have any
  25  * questions.
  26  */
  27 package com.sun.javatest.report;
  28 
  29 import java.util.Comparator;
  30 
  31 import com.sun.javatest.TestResult;
  32 
  33 class TestResultsByTitleComparator implements Comparator<TestResult> {
  34     public int compare(TestResult tr1, TestResult tr2) {


  35 
  36         return compare(tr1.getTestName(), tr2.getTestName());
  37     }
  38 
  39     private static int compare(String a, String b) {
  40         if (a == null && b == null)
  41             return 0;
  42 
  43         if (a == null)
  44             return -1;
  45 
  46         if (b == null)
  47             return +1;
  48 
  49         return a.compareTo(b);
  50      }
  51 }
< prev index next >