1 package org.andromda.utils.beans.comparators;
2
3 import java.io.Serializable;
4 import java.util.Comparator;
5
6
7
8
9
10
11 class NumberComparator
12 implements Comparator,
13 Serializable
14 {
15 private static final long serialVersionUID = 34L;
16
17
18
19
20
21
22
23
24 public int compare(
25 final Object objectA,
26 final Object objectB)
27 {
28 final Number aAsNumber = (Number)objectA;
29 final Number bAsNumber = (Number)objectB;
30 int result = 0;
31 if (aAsNumber.doubleValue() > bAsNumber.doubleValue())
32 {
33 result = 1;
34 }
35 else if (aAsNumber.doubleValue() < bAsNumber.doubleValue())
36 {
37 result = -1;
38 }
39 return result;
40 }
41 }