KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > opensymphony > workflow > spi > ejb > StepComparator


1 /*
2  * Copyright (c) 2002-2003 by OpenSymphony
3  * All rights reserved.
4  */

5 package com.opensymphony.workflow.spi.ejb;
6
7 import com.opensymphony.workflow.spi.Step;
8
9 import java.util.Comparator JavaDoc;
10
11
12 /**
13  * Utility class to order steps in a descending order.
14  *
15  * @author <a HREF="mailto:plightbo@hotmail.com">Pat Lightbody</a>
16  */

17 public class StepComparator implements Comparator JavaDoc {
18     //~ Methods ////////////////////////////////////////////////////////////////
19

20     public int compare(Object JavaDoc o1, Object JavaDoc o2) {
21         Step step1 = (Step) o1;
22         Step step2 = (Step) o2;
23
24         if (step1.getId() > step2.getId()) {
25             return -1;
26         } else if (step1.getId() < step2.getId()) {
27             return 1;
28         } else {
29             return 0;
30         }
31     }
32 }
33
Popular Tags