1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package net.sourceforge.jeuclid.elements.support.text;
20
21 import java.io.Serializable;
22
23 import net.sourceforge.jeuclid.elements.support.attributes.MathVariant;
24
25
26
27
28 public class CodePointAndVariant implements Serializable {
29
30
31
32 private static final long serialVersionUID = 1L;
33
34 private final int codePoint;
35
36 private final MathVariant variant;
37
38
39
40
41
42
43
44
45
46 public CodePointAndVariant(final int icodePoint,
47 final MathVariant ivariant) {
48 assert ivariant != null;
49 this.codePoint = icodePoint;
50 this.variant = ivariant;
51 }
52
53
54
55
56 public final int getCodePoint() {
57 return this.codePoint;
58 }
59
60
61
62
63 public final MathVariant getVariant() {
64 return this.variant;
65 }
66
67
68 @Override
69 public int hashCode() {
70 final int prime = 31;
71 int result = 1;
72 result = prime * result + this.codePoint;
73 result = prime * result + this.variant.hashCode();
74 return result;
75 }
76
77
78 @Override
79 public boolean equals(final Object obj) {
80 if (this == obj) {
81 return true;
82 }
83 if (obj == null) {
84 return false;
85 }
86 if (this.getClass() != obj.getClass()) {
87 return false;
88 }
89 final CodePointAndVariant other = (CodePointAndVariant) obj;
90 if (this.codePoint != other.codePoint) {
91 return false;
92 }
93 if (this.variant == null) {
94 if (other.variant != null) {
95 return false;
96 }
97 } else if (!this.variant.equals(other.variant)) {
98 return false;
99 }
100 return true;
101 }
102
103
104 @Override
105 public String toString() {
106 final StringBuilder b = new StringBuilder();
107 b.append('[');
108 b.append("0x");
109 b.append(Integer.toHexString(this.codePoint));
110 b.append(' ');
111 b.append(this.variant.toString());
112 b.append(']');
113 return b.toString();
114 }
115 }