1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.logging.log4j.core.impl;
18
19 import java.io.Serializable;
20
21 import org.apache.logging.log4j.core.pattern.PlainTextRenderer;
22 import org.apache.logging.log4j.core.pattern.TextRenderer;
23
24
25
26
27 public final class ExtendedClassInfo implements Serializable {
28
29 private static final long serialVersionUID = 1L;
30
31 private final boolean exact;
32
33 private final String location;
34
35 private final String version;
36
37
38
39
40
41
42
43
44 public ExtendedClassInfo(final boolean exact, final String location, final String version) {
45 super();
46 this.exact = exact;
47 this.location = location;
48 this.version = version;
49 }
50
51 @Override
52 public boolean equals(final Object obj) {
53 if (this == obj) {
54 return true;
55 }
56 if (obj == null) {
57 return false;
58 }
59 if (!(obj instanceof ExtendedClassInfo)) {
60 return false;
61 }
62 final ExtendedClassInfo other = (ExtendedClassInfo) obj;
63 if (this.exact != other.exact) {
64 return false;
65 }
66 if (this.location == null) {
67 if (other.location != null) {
68 return false;
69 }
70 } else if (!this.location.equals(other.location)) {
71 return false;
72 }
73 if (this.version == null) {
74 if (other.version != null) {
75 return false;
76 }
77 } else if (!this.version.equals(other.version)) {
78 return false;
79 }
80 return true;
81 }
82
83 public boolean getExact() {
84 return this.exact;
85 }
86
87 public String getLocation() {
88 return this.location;
89 }
90
91 public String getVersion() {
92 return this.version;
93 }
94
95 @Override
96 public int hashCode() {
97 final int prime = 31;
98 int result = 1;
99 result = prime * result + (this.exact ? 1231 : 1237);
100 result = prime * result + ((this.location == null) ? 0 : this.location.hashCode());
101 result = prime * result + ((this.version == null) ? 0 : this.version.hashCode());
102 return result;
103 }
104
105 public void renderOn(final StringBuilder output, final TextRenderer textRenderer) {
106 if (!this.exact) {
107 textRenderer.render("~", output, "ExtraClassInfo.Inexact");
108 }
109 textRenderer.render("[", output, "ExtraClassInfo.Container");
110 textRenderer.render(this.location, output, "ExtraClassInfo.Location");
111 textRenderer.render(":", output, "ExtraClassInfo.ContainerSeparator");
112 textRenderer.render(this.version, output, "ExtraClassInfo.Version");
113 textRenderer.render("]", output, "ExtraClassInfo.Container");
114 }
115
116 @Override
117 public String toString() {
118 final StringBuilder sb = new StringBuilder();
119 renderOn(sb, PlainTextRenderer.getInstance());
120 return sb.toString();
121 }
122
123 }