MCPcopy Create free account
hub / github.com/amazon-ion/ion-java / SymbolTokenImpl

Class SymbolTokenImpl

src/main/java/com/amazon/ion/impl/SymbolTokenImpl.java:22–91  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

20
21
22final class SymbolTokenImpl
23 implements _Private_SymbolToken
24{
25 private final String myText;
26 private final int mySid;
27
28 SymbolTokenImpl(String text, int sid)
29 {
30 assert text != null || sid >= 0 : "Neither text nor sid is defined";
31
32 myText = text;
33 mySid = sid;
34 }
35
36 SymbolTokenImpl(int sid)
37 {
38 assert sid >= 0 : "sid is undefined";
39
40 myText = null;
41 mySid = sid;
42 }
43
44
45 public String getText()
46 {
47 return myText;
48 }
49
50 public String assumeText()
51 {
52 if (myText == null) throw new UnknownSymbolException(mySid);
53 return myText;
54 }
55
56 public int getSid()
57 {
58 return mySid;
59 }
60
61 @Override
62 public String toString()
63 {
64 return "SymbolToken::{text:" + myText + ",id:" + mySid + "}";
65 }
66
67 /*
68 * TODO amazon-ion/ion-java#126
69 *Equals and hashCode must be symmetric.
70 *Two symboltokens are only equal when text1 equals text2 (including null == null)
71 *This is an incomplete solution, needs to be updated as symboltokens are fleshed out.
72 */
73
74 @Override
75 public boolean equals(Object o) {
76 if (this == o) return true;
77 if (o == null || !(o instanceof SymbolToken)) return false;
78
79 SymbolToken other = (SymbolToken) o;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…