View Javadoc
1   package org.csveed.bean;
2   
3   import java.beans.PropertyDescriptor;
4   import java.lang.reflect.Field;
5   
6   import org.csveed.bean.conversion.Converter;
7   
8   public class BeanProperty {
9   
10      private PropertyDescriptor propertyDescriptor;
11  
12      private Field field;
13  
14      private Converter converter;
15  
16      private String columnName;
17  
18      private int columnIndex = -1;
19  
20      private boolean required;
21  
22      private boolean dynamicColumnProperty;
23  
24      @SuppressWarnings("unchecked")
25      public Class<? extends Number> getNumberClass() {
26          if (Number.class.isAssignableFrom(propertyDescriptor.getPropertyType())) {
27              return (Class<? extends Number>)propertyDescriptor.getPropertyType();
28          }
29          return null;
30      }
31  
32      public PropertyDescriptor getPropertyDescriptor() {
33          return propertyDescriptor;
34      }
35  
36      public void setPropertyDescriptor(PropertyDescriptor propertyDescriptor) {
37          this.propertyDescriptor = propertyDescriptor;
38      }
39  
40      public Converter getConverter() {
41          return converter;
42      }
43  
44      public void setConverter(Converter converter) {
45          this.converter = converter;
46      }
47  
48      public String getColumnName() {
49          return columnName;
50      }
51  
52      public void setColumnName(String columnName) {
53          this.columnName = columnName;
54      }
55  
56      public boolean isRequired() {
57          return required;
58      }
59  
60      public void setRequired(boolean required) {
61          this.required = required;
62      }
63  
64      public int getColumnIndex() {
65          return columnIndex;
66      }
67  
68      public void setColumnIndex(int columnIndex) {
69          this.columnIndex = columnIndex;
70      }
71  
72      public Field getField() {
73          return field;
74      }
75  
76      public void setField(Field field) {
77          this.field = field;
78      }
79  
80      public String getPropertyName() {
81          return propertyDescriptor.getName();
82      }
83  
84      public void setDynamicColumnProperty(boolean dynamicColumnProperty) {
85          this.dynamicColumnProperty = dynamicColumnProperty;
86      }
87  
88      public boolean isDynamicColumnProperty() {
89          return this.dynamicColumnProperty;
90      }
91  
92      @Override
93      public int hashCode() {
94          return getPropertyName().hashCode();
95      }
96  
97      @Override
98      public boolean equals(Object obj) {
99          if (!(obj instanceof BeanProperty)) {
100             return false;
101         }
102         BeanProperty/../org/csveed/bean/BeanProperty.html#BeanProperty">BeanProperty other = (BeanProperty)obj;
103         return getPropertyName().equals(other.getPropertyName());
104     }
105 
106     public String getPropertyType() {
107         return getConverter() != null ?
108                 getConverter().infoOnType() :
109                 getPropertyDescriptor().getPropertyType().getName();
110     }
111 
112 }