ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/tck/Item.java
Revision: 1.2
Committed: Wed Jan 27 02:15:36 2021 UTC (3 years, 3 months ago) by jsr166
Branch: MAIN
Changes since 1.1: +3 -1 lines
Log Message:
use javadoc comment

File Contents

# Content
1 /*
2 * Written by Doug Lea with assistance from members of JCP JSR-166
3 * Expert Group and released to the public domain, as explained at
4 * http://creativecommons.org/publicdomain/zero/1.0/
5 */
6
7 import java.util.Comparator;
8 import java.io.Serializable;
9
10 /**
11 * A simple element class for collections etc
12 */
13 public final class Item extends Number implements Comparable<Item>, Serializable {
14 public final int value;
15 public Item(int v) { value = v; }
16 public Item(Item i) { value = i.value; }
17 public Item(Integer i) { value = i.intValue(); }
18 public static Item valueOf(int i) { return new Item(i); }
19
20 public int intValue() { return value; }
21 public long longValue() { return (long)value; }
22 public float floatValue() { return (float)value; }
23 public double doubleValue() { return (double)value; }
24
25 public boolean equals(Object x) {
26 return (x instanceof Item) && ((Item)x).value == value;
27 }
28 public boolean equals(int b) {
29 return value == b;
30 }
31 public int compareTo(Item x) {
32 int a = value, b = x.value;
33 return (a == b) ? 0 : (a < b) ? -1 : 1;
34 }
35 public int compareTo(int b) {
36 int a = value;
37 return (a == b) ? 0 : (a < b) ? -1 : 1;
38 }
39
40 public int hashCode() { return value; }
41 public String toString() { return Integer.toString(value); }
42 public static int compare(Item x, Item y) {
43 int a = x.value, b = y.value;
44 return (a == b) ? 0 : (a < b) ? -1 : 1;
45 }
46 public static int compare(Item x, int b) {
47 int a = x.value;
48 return (a == b) ? 0 : (a < b) ? -1 : 1;
49 }
50 public static int compare(int a, Item y) {
51 int b = y.value;
52 return (a == b) ? 0 : (a < b) ? -1 : 1;
53 }
54 public static int compare(int a, int b) {
55 return (a == b) ? 0 : (a < b) ? -1 : 1;
56 }
57
58 public static Comparator<Item> comparator() { return new Cpr(); }
59 public static class Cpr implements Comparator<Item> {
60 public int compare(Item x, Item y) {
61 int a = x.value, b = y.value;
62 return (a == b) ? 0 : (a < b) ? -1 : 1;
63 }
64 }
65 }