File tree Expand file tree Collapse file tree 2 files changed +7
-59
lines changed
src/main/java/com/maxmind/db Expand file tree Collapse file tree 2 files changed +7
-59
lines changed Original file line number Diff line number Diff line change 66 * of the value.
77 *
88 * @param <T> the type of value
9+ * @param offset the offset of the value in the database file
10+ * @param cls the class of the value
11+ * @param type the type of the value
912 */
10- public final class CacheKey <T > {
11- private final int offset ;
12- private final Class <T > cls ;
13- private final java .lang .reflect .Type type ;
14-
15- CacheKey (int offset , Class <T > cls , java .lang .reflect .Type type ) {
16- this .offset = offset ;
17- this .cls = cls ;
18- this .type = type ;
19- }
20-
21- int getOffset () {
22- return this .offset ;
23- }
24-
25- Class <T > getCls () {
26- return this .cls ;
27- }
28-
29- java .lang .reflect .Type getType () {
30- return this .type ;
31- }
32-
33- @ Override
34- public boolean equals (Object o ) {
35- if (o == null ) {
36- return false ;
37- }
38-
39- CacheKey other = (CacheKey ) o ;
40-
41- if (this .offset != other .offset ) {
42- return false ;
43- }
44-
45- if (this .cls == null ) {
46- if (other .cls != null ) {
47- return false ;
48- }
49- } else if (!this .cls .equals (other .cls )) {
50- return false ;
51- }
52-
53- if (this .type == null ) {
54- return other .type == null ;
55- }
56- return this .type .equals (other .type );
57- }
58-
59- @ Override
60- public int hashCode () {
61- int result = offset ;
62- result = 31 * result + (cls == null ? 0 : cls .hashCode ());
63- result = 31 * result + (type == null ? 0 : type .hashCode ());
64- return result ;
65- }
13+ public record CacheKey <T >(int offset , Class <T > cls , java .lang .reflect .Type type ) {
6614}
Original file line number Diff line number Diff line change @@ -73,16 +73,16 @@ <T> T decode(int offset, Class<T> cls) throws IOException {
7373 }
7474
7575 private <T > DecodedValue decode (CacheKey <T > key ) throws IOException {
76- int offset = key .getOffset ();
76+ int offset = key .offset ();
7777 if (offset >= this .buffer .capacity ()) {
7878 throw new InvalidDatabaseException (
7979 "The MaxMind DB file's data section contains bad data: "
8080 + "pointer larger than the database." );
8181 }
8282
8383 this .buffer .position (offset );
84- Class <T > cls = key .getCls ();
85- return decode (cls , key .getType ());
84+ Class <T > cls = key .cls ();
85+ return decode (cls , key .type ());
8686 }
8787
8888 private <T > DecodedValue decode (Class <T > cls , java .lang .reflect .Type genericType )
You can’t perform that action at this time.
0 commit comments