MCPcopy Index your code
hub / github.com/clojure/clojure / TaggedLiteral

Class TaggedLiteral

src/jvm/clojure/lang/TaggedLiteral.java:13–64  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11package clojure.lang;
12
13public class TaggedLiteral implements ILookup {
14
15public static final Keyword TAG_KW = Keyword.intern("tag");
16public static final Keyword FORM_KW = Keyword.intern("form");
17
18public final Symbol tag;
19public final Object form;
20
21public static TaggedLiteral create(Symbol tag, Object form) {
22 return new TaggedLiteral(tag, form);
23}
24
25private TaggedLiteral(Symbol tag, Object form){
26 this.tag = tag;
27 this.form = form;
28}
29
30public Object valAt(Object key) {
31 return valAt(key, null);
32}
33
34public Object valAt(Object key, Object notFound) {
35 if (FORM_KW.equals(key)) {
36 return this.form;
37 } else if (TAG_KW.equals(key)) {
38 return this.tag;
39 } else {
40 return notFound;
41 }
42}
43
44@Override
45public boolean equals(Object o) {
46 if (this == o) return true;
47 if (o == null || getClass() != o.getClass()) return false;
48
49 TaggedLiteral that = (TaggedLiteral) o;
50
51 if (form != null ? !form.equals(that.form) : that.form != null) return false;
52 if (tag != null ? !tag.equals(that.tag) : that.tag != null) return false;
53
54 return true;
55}
56
57@Override
58public int hashCode() {
59 int result = Util.hash(tag);
60 result = 31 * result + Util.hash(form);
61 return result;
62}
63
64}

Callers

nothing calls this directly

Calls 1

internMethod · 0.95

Tested by

no test coverage detected