1
11 package com.thoughtworks.xstream.core.util;
12
13 public final class FastField {
14 private final String name;
15 private final String declaringClass;
16
17 public FastField(String definedIn, String name) {
18 this.name = name;
19 this.declaringClass = definedIn;
20 }
21
22 public FastField(Class definedIn, String name) {
23 this(definedIn == null ? null : definedIn.getName(), name);
24 }
25
26 public String getName() {
27 return this.name;
28 }
29
30 public String getDeclaringClass() {
31 return this.declaringClass;
32 }
33
34 public boolean equals(Object obj) {
35 if (this == obj) {
36 return true;
37 }
38 if (obj == null) {
39 return false;
40 }
41 if (obj instanceof FastField) {
42 final FastField field = (FastField)obj;
43 if ((declaringClass == null && field.declaringClass != null)
44 || (declaringClass != null && field.declaringClass == null)) {
45 return false;
46 }
47 return name.equals(field.getName())
48 && (declaringClass == null || declaringClass.equals(field.getDeclaringClass()));
49 }
50 return false;
51 }
52
53 public int hashCode() {
54 return name.hashCode() ^ (declaringClass == null ? 0 : declaringClass.hashCode());
55 }
56
57 public String toString() {
58 return (declaringClass == null ? "" : declaringClass + ".") + name;
59 }
60 }