| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
package uk.me.parabola.imgfmt.app.srt; |
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
public class CombinedSortKey<T> implements SortKey<T> { |
| 23 |
private final SortKey<T> key; |
| 24 |
private final int first; |
| 25 |
private final int second; |
| 26 |
|
| 27 |
public CombinedSortKey(SortKey<T> obj, int first, int second) { |
| 28 |
this.key = obj; |
| 29 |
this.first = first; |
| 30 |
this.second = second; |
| 31 |
} |
| 32 |
|
| 33 |
public T getObject() { |
| 34 |
return key.getObject(); |
| 35 |
} |
| 36 |
|
| 37 |
public int compareTo(SortKey<T> o) { |
| 38 |
CombinedSortKey<T> other = (CombinedSortKey<T>) o; |
| 39 |
int res = key.compareTo(other.key); |
| 40 |
if (res == 0) { |
| 41 |
res = Integer.compare(first, other.first); |
| 42 |
if (res == 0) { |
| 43 |
res = Integer.compare(second, other.second); |
| 44 |
} |
| 45 |
} |
| 46 |
return res; |
| 47 |
} |
| 48 |
} |