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 function as loaded from meta XML: its name, native
27   * expression (SQL/CQL), and description. {@link org.synchronoss.cpo.core.meta.domain.CpoFunction}
28   * extends this with the runtime behavior (bound arguments).
29   *
30   * @author dberry
31   */
32  public class CpoFunctionBean implements java.io.Serializable {
33  
34    private static final long serialVersionUID = 1L;
35  
36    /*
37     * Properties
38     */
39    /** The name of this function. */
40    private String name;
41  
42    /** The native (SQL/CQL) expression this function evaluates to. */
43    private String expression;
44  
45    /** The description of this function. */
46    private String description;
47  
48    /** Creates an empty instance. */
49    public CpoFunctionBean() {}
50  
51    /*
52     * Getters and Setters
53     */
54  
55    /**
56     * Gets the name of this function.
57     *
58     * @return the function name
59     */
60    public String getName() {
61      return name;
62    }
63  
64    /**
65     * Sets the name of this function.
66     *
67     * @param name the function name
68     */
69    public void setName(String name) {
70      this.name = name;
71    }
72  
73    /**
74     * Gets the human-readable description of this function, as loaded from the meta XML.
75     *
76     * @return the description, or {@code null} if none was specified
77     */
78    public String getDescription() {
79      return description;
80    }
81  
82    /**
83     * Sets the human-readable description of this function.
84     *
85     * @param description the description
86     */
87    public void setDescription(String description) {
88      this.description = description;
89    }
90  
91    /**
92     * Gets the native (SQL/CQL) expression executed by this function.
93     *
94     * @return the native expression
95     */
96    public String getExpression() {
97      return expression;
98    }
99  
100   /**
101    * Sets the native (SQL/CQL) expression executed by this function.
102    *
103    * @param expression the native expression
104    */
105   public void setExpression(String expression) {
106     this.expression = expression;
107   }
108 
109   @Override
110   public String toString() {
111     StringBuilder str = new StringBuilder();
112     str.append("expression = " + getExpression() + "\n");
113     str.append("description = " + getDescription() + "\n");
114     return str.toString();
115   }
116 
117   @Override
118   public int hashCode() {
119     int result = 0;
120     result = 31 * result + getClass().getName().hashCode();
121     result = 31 * result + (getExpression() != null ? getExpression().hashCode() : 0);
122     result = 31 * result + (getDescription() != null ? getDescription().hashCode() : 0);
123     return result;
124   }
125 
126   @Override
127   public boolean equals(Object o) {
128     if (this == o) return true;
129 
130     if (o == null || getClass() != o.getClass()) return false;
131 
132     CpoFunctionBean that = (CpoFunctionBean) o;
133 
134     if (getExpression() != null
135         ? !getExpression().equals(that.getExpression())
136         : that.getExpression() != null) return false;
137 
138     return getDescription() != null
139         ? getDescription().equals(that.getDescription())
140         : that.getDescription() == null;
141   }
142 }