View Javadoc
1   package org.synchronoss.cpo.core.meta.bean;
2   
3   /*-
4    * [[
5    * core
6    * ==
7    * Copyright (C) 2003 - 2026 Exaxis LLC, Synchronoss Technologies Inc
8    * ==
9    * This program is free software: you can redistribute it and/or modify
10   * it under the terms of the GNU Lesser General Public License as
11   * published by the Free Software Foundation, either version 3 of the
12   * License, or (at your option) any later version.
13   *
14   * This program is distributed in the hope that it will be useful,
15   * but WITHOUT ANY WARRANTY; without even the implied warranty of
16   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17   * GNU General Lesser Public License for more details.
18   *
19   * You should have received a copy of the GNU General Lesser Public
20   * License along with this program.  If not, see
21   * <http://www.gnu.org/licenses/lgpl-3.0.html>.
22   * ]]
23   */
24  
25  /**
26   * Plain-data holder for the fields of a CPO attribute as loaded from meta XML: the Java-side
27   * name/type, the datastore-side name/type, and an optional {@code CpoTransform} class name. {@link
28   * org.synchronoss.cpo.core.meta.domain.CpoAttribute} extends this with the runtime behavior
29   * (reflective getter/setter resolution, transform instantiation, etc).
30   *
31   * @author dberry
32   */
33  public class CpoAttributeBean implements java.io.Serializable {
34  
35    private static final long serialVersionUID = 1L;
36  
37    /*
38     * Properties
39     */
40    /** The name of the Java bean property. */
41    private String javaName;
42  
43    /** The fully-qualified Java type of the bean property. */
44    private String javaType;
45  
46    /** The name of the datastore-side column/field. */
47    private String dataName;
48  
49    /** The native datastore type of the column/field. */
50    private String dataType;
51  
52    /** The fully-qualified class name of a custom {@code CpoTransform}, if any. */
53    private String transformClassName;
54  
55    /** The description of this attribute. */
56    private String description;
57  
58    /** Creates an empty instance. */
59    public CpoAttributeBean() {}
60  
61    /*
62     * Getters and Setters
63     */
64  
65    /**
66     * Gets the name of the datastore-side column/field this attribute binds to.
67     *
68     * @return the datastore-side name
69     */
70    public String getDataName() {
71      return dataName;
72    }
73  
74    /**
75     * Sets the name of the datastore-side column/field this attribute binds to.
76     *
77     * @param dataName the datastore-side name
78     */
79    public void setDataName(String dataName) {
80      this.dataName = dataName;
81    }
82  
83    /**
84     * Gets the name of the native datastore data type of this attribute.
85     *
86     * @return the native data type name
87     */
88    public String getDataType() {
89      return dataType;
90    }
91  
92    /**
93     * Sets the name of the native datastore data type of this attribute.
94     *
95     * @param dataType the native data type name
96     */
97    public void setDataType(String dataType) {
98      this.dataType = dataType;
99    }
100 
101   /**
102    * Gets the human-readable description of this attribute, as loaded from the meta XML.
103    *
104    * @return the description, or {@code null} if none was specified
105    */
106   public String getDescription() {
107     return description;
108   }
109 
110   /**
111    * Sets the human-readable description of this attribute.
112    *
113    * @param description the description
114    */
115   public void setDescription(String description) {
116     this.description = description;
117   }
118 
119   /**
120    * Gets the name of the JavaBean property this attribute binds to.
121    *
122    * @return the JavaBean property name
123    */
124   public String getJavaName() {
125     return javaName;
126   }
127 
128   /**
129    * Sets the name of the JavaBean property this attribute binds to.
130    *
131    * @param javaName the JavaBean property name
132    */
133   public void setJavaName(String javaName) {
134     this.javaName = javaName;
135   }
136 
137   /**
138    * Gets the Java type name of the bound JavaBean property.
139    *
140    * @return the Java type name
141    */
142   public String getJavaType() {
143     return javaType;
144   }
145 
146   /**
147    * Sets the Java type name of the bound JavaBean property.
148    *
149    * @param javaType the Java type name
150    */
151   public void setJavaType(String javaType) {
152     this.javaType = javaType;
153   }
154 
155   /**
156    * Gets the fully-qualified class name of the {@code CpoTransform} to apply to this attribute's
157    * value, if any.
158    *
159    * @return the transform class name, or {@code null} if no transform is configured
160    */
161   public String getTransformClassName() {
162     return transformClassName;
163   }
164 
165   /**
166    * Sets the fully-qualified class name of the {@code CpoTransform} to apply to this attribute's
167    * value.
168    *
169    * @param transformClassName the transform class name
170    */
171   public void setTransformClassName(String transformClassName) {
172     this.transformClassName = transformClassName;
173   }
174 
175   @Override
176   public boolean equals(Object o) {
177     if (this == o) return true;
178 
179     if (o == null || getClass() != o.getClass()) return false;
180 
181     CpoAttributeBean that = (CpoAttributeBean) o;
182 
183     if (getJavaName() != null
184         ? !getJavaName().equals(that.getJavaName())
185         : that.getJavaName() != null) return false;
186 
187     if (getJavaType() != null
188         ? !getJavaType().equals(that.getJavaType())
189         : that.getJavaType() != null) return false;
190 
191     if (getDataName() != null
192         ? !getDataName().equals(that.getDataName())
193         : that.getDataName() != null) return false;
194 
195     if (getDataType() != null
196         ? !getDataType().equals(that.getDataType())
197         : that.getDataType() != null) return false;
198 
199     if (getTransformClassName() != null
200         ? !getTransformClassName().equals(that.getTransformClassName())
201         : that.getTransformClassName() != null) return false;
202 
203     return getDescription() != null
204         ? getDescription().equals(that.getDescription())
205         : that.getDescription() == null;
206   }
207 
208   @Override
209   public int hashCode() {
210     int result = 0;
211     result = 31 * result + getClass().getName().hashCode();
212     result = 31 * result + (getJavaName() != null ? getJavaName().hashCode() : 0);
213     result = 31 * result + (getJavaType() != null ? getJavaType().hashCode() : 0);
214     result = 31 * result + (getDataName() != null ? getDataName().hashCode() : 0);
215     result = 31 * result + (getDataType() != null ? getDataType().hashCode() : 0);
216     result =
217         31 * result + (getTransformClassName() != null ? getTransformClassName().hashCode() : 0);
218     result = 31 * result + (getDescription() != null ? getDescription().hashCode() : 0);
219     return result;
220   }
221 
222   @Override
223   public String toString() {
224     StringBuilder str = new StringBuilder();
225     str.append("javaName = " + getJavaName() + "\n");
226     str.append("javaType = " + getJavaType() + "\n");
227     str.append("dataName = " + getDataName() + "\n");
228     str.append("dataType = " + getDataType() + "\n");
229     str.append("transformClass = " + getTransformClassName() + "\n");
230     str.append("description = " + getDescription() + "\n");
231     return str.toString();
232   }
233 }