| 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 | 209 | 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 | 77248 | final MathVariant ivariant) { |
| 48 | 77248 | assert ivariant != null; |
| 49 | 77248 | this.codePoint = icodePoint; |
| 50 | 77248 | this.variant = ivariant; |
| 51 | 77248 | } |
| 52 | |
|
| 53 | |
|
| 54 | |
|
| 55 | |
|
| 56 | |
public final int getCodePoint() { |
| 57 | 123381 | return this.codePoint; |
| 58 | |
} |
| 59 | |
|
| 60 | |
|
| 61 | |
|
| 62 | |
|
| 63 | |
public final MathVariant getVariant() { |
| 64 | 93048 | return this.variant; |
| 65 | |
} |
| 66 | |
|
| 67 | |
|
| 68 | |
@Override |
| 69 | |
public int hashCode() { |
| 70 | |
final int prime = 31; |
| 71 | 85511 | int result = 1; |
| 72 | 85511 | result = prime * result + this.codePoint; |
| 73 | 85511 | result = prime * result + this.variant.hashCode(); |
| 74 | 85511 | return result; |
| 75 | |
} |
| 76 | |
|
| 77 | |
|
| 78 | |
@Override |
| 79 | |
public boolean equals(final Object obj) { |
| 80 | 96931 | if (this == obj) { |
| 81 | 35361 | return true; |
| 82 | |
} |
| 83 | 61570 | if (obj == null) { |
| 84 | 0 | return false; |
| 85 | |
} |
| 86 | 61570 | if (this.getClass() != obj.getClass()) { |
| 87 | 0 | return false; |
| 88 | |
} |
| 89 | 61570 | final CodePointAndVariant other = (CodePointAndVariant) obj; |
| 90 | 61570 | if (this.codePoint != other.codePoint) { |
| 91 | 3455 | return false; |
| 92 | |
} |
| 93 | 58115 | if (this.variant == null) { |
| 94 | 0 | if (other.variant != null) { |
| 95 | 0 | return false; |
| 96 | |
} |
| 97 | 58115 | } else if (!this.variant.equals(other.variant)) { |
| 98 | 0 | return false; |
| 99 | |
} |
| 100 | 58115 | return true; |
| 101 | |
} |
| 102 | |
|
| 103 | |
|
| 104 | |
@Override |
| 105 | |
public String toString() { |
| 106 | 0 | final StringBuilder b = new StringBuilder(); |
| 107 | 0 | b.append('['); |
| 108 | 0 | b.append("0x"); |
| 109 | 0 | b.append(Integer.toHexString(this.codePoint)); |
| 110 | 0 | b.append(' '); |
| 111 | 0 | b.append(this.variant.toString()); |
| 112 | 0 | b.append(']'); |
| 113 | 0 | return b.toString(); |
| 114 | |
} |
| 115 | |
} |