View Javadoc
1   package org.pojomatic.internal;
2   
3   import java.lang.reflect.AccessibleObject;
4   import java.lang.reflect.AnnotatedElement;
5   import java.lang.reflect.Member;
6   
7   import org.pojomatic.PropertyElement;
8   
9   public abstract class AbstractPropertyElement<E extends AccessibleObject & Member>
10  implements PropertyElement {
11    protected final E element;
12    private final String name;
13  
14    protected AbstractPropertyElement(E element, String name) {
15      this.element = element;
16      this.name = name;
17    }
18  
19    @Override
20    public String getName() {
21      return name;
22    }
23  
24    /* (non-Javadoc)
25     * @see org.pojomatic.PropertyElement#getElement()
26     */
27    @Override
28    public AnnotatedElement getElement() {
29      return this.element;
30    }
31  
32    @Override
33    public Class<?> getDeclaringClass() {
34      return element.getDeclaringClass();
35    }
36  
37    @Override
38    public int hashCode() {
39      return element.hashCode();
40    }
41  
42    @Override
43    public boolean equals(Object obj) {
44      if (this == obj) {
45        return true;
46      }
47      if (obj == null) {
48        return false;
49      }
50      if (getClass() != obj.getClass()) {
51        return false;
52      }
53      final AbstractPropertyElement<?> other = (AbstractPropertyElement<?>) obj;
54      return element.equals(other.element);
55    }
56  
57    @Override
58    public String toString() {
59      return element.toString();
60    }
61  }