/*
 * Copyright (C) 2008 XStream Committers.
 * All rights reserved.
 *
 * The software in this package is published under the terms of the BSD
 * style license a copy of which has been included with this distribution in
 * the LICENSE.txt file.
 *
 * Created on 13. October 2008 by Joerg Schaible
 */
package com.thoughtworks.xstream.core.util;

public final class FastField {
    private final String name;
    private final Class declaringClass;

    public FastField(Class definedIn, String name) {
        this.name = name;
        this.declaringClass = definedIn;
    }

    public String getName() {
        return this.name;
    }

    public Class getDeclaringClass() {
        return this.declaringClass;
    }

    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (this == null) {
            return false;
        }
        if (obj.getClass() == FastField.class) {
            final FastField field = (FastField)obj;
            return name.equals(field.getName())
                && declaringClass.equals(field.getDeclaringClass());
        }
        return false;
    }

    public int hashCode() {
        return name.hashCode() ^ declaringClass.hashCode();
    }

    public String toString() {
        return declaringClass.getName() + "[" + name + "]";
    }
}
@@ -17,16 +17,22 @@
 (C) 2008
+, 2010
  XStream
@@ -988,16 +988,212 @@
 ld)obj;%0A
+            if ((declaringClass == null && field.declaringClass != null)%0A                %7C%7C (declaringClass != null && field.declaringClass == null)) %7B%0A                return false;%0A            %7D%0A
         
@@ -1250,16 +1250,43 @@
       &&
+ (declaringClass == null %7C%7C
  declari
@@ -1326,16 +1326,17 @@
 Class())
+)
 ;%0A      
@@ -1428,16 +1428,46 @@
 Code() %5E
+ (declaringClass == null ? 0 :
  declari
@@ -1484,16 +1484,17 @@
 shCode()
+)
 ;%0A    %7D%0A
@@ -1539,16 +1539,47 @@
   return
+ (declaringClass == null ? %22%22 :
  declari
@@ -1603,23 +1603,18 @@
  + %22
-%5B%22
+.%22)
  + name
- + %22%5D%22
 ;%0A  

Allow null as defining class.