4A Server -  2.0
 All Classes Namespaces Files Functions Variables Enumerator
DefaultSettings.java
Go to the documentation of this file.
1 /*
2  * Project: Server for annotations sharing
3  * Author: Ing. Jaroslav Dytrych idytrych@fit.vutbr.cz
4  * File: DefaultSettings.java
5  * Description: Class representing parameter of default user settings
6  */
7 
8 /**
9  * @file DefaultSettings.java
10  *
11  * @brief Class representing parameter of default user settings
12  */
13 
14 package cz.vutbr.fit.knot.annotations.entity;
15 
16 import java.io.Serializable;
17 import javax.persistence.*;
18 
19 /**
20  * Class representing parameter of default user settings
21  *
22  * @brief Class representing parameter of default user settings
23  * @author Martin Petr (xpetrm05)
24  */
25 @Entity
26 @Table(name = "defaultSettings")
27 @NamedQueries({
28  @NamedQuery(name = "DefaultSettings.findAll", query = "SELECT s FROM DefaultSettings s"),
29  @NamedQuery(name = "DefaultSettings.findById", query = "SELECT s FROM DefaultSettings s WHERE s.id = :id"),
30  @NamedQuery(name = "DefaultSettings.findByName", query = "SELECT s FROM DefaultSettings s WHERE s.name = :name"),
31  @NamedQuery(name = "DefaultSettings.findByValue", query = "SELECT s FROM DefaultSettings s WHERE s.value = :value")})
32 public class DefaultSettings implements Serializable{
33  private static final long serialVersionUID = 1L;
34  /** Id of parameter of user settings */
35  @Id
36  @GeneratedValue(strategy = GenerationType.IDENTITY)
37  @Basic(optional = false)
38  @Column(name = "id")
39  private Integer id;
40 
41  /** Name of parameter of user settings */
42  @Basic(optional = false)
43  @Column(name = "name")
44  private String name;
45 
46  /** Value of parameter of user settings */
47  @Basic(optional = false)
48  @Column(name = "paramValue")
49  private String value;
50 
51  /** Description of parameter of user settings */
52  @Basic(optional = true)
53  @Lob
54  @Column(name = "description")
55  private String description;
56 
57  /**
58  * Constructor
59  */
60  public DefaultSettings() {
61  }
62 
63  /**
64  * Constructor
65  *
66  * @param id Id of parameter of user settings
67  */
68  public DefaultSettings(Integer id) {
69  this.id = id;
70  }
71 
72  /**
73  * Constructor
74  *
75  * @param name Name of parameter
76  * @param value Value of parameter
77  */
78  public DefaultSettings(String name, String value) {
79  this.name = name;
80  this.value = value;
81  this.description = "";
82  }
83 
84  /**
85  * Constructor
86  *
87  * @param name Name of parameter
88  * @param value Value of parameter
89  * @param description Description of parameter
90  */
91  public DefaultSettings(String name, String value, String description) {
92  this.name = name;
93  this.value = value;
94  this.description = description;
95  }
96 
97  /**
98  * Gets id of parameter of user settings
99  *
100  * @return id of parameter of user settings
101  */
102  public Integer getId() {
103  return id;
104  }
105 
106  /**
107  * Sets id of parameter of user settings
108  *
109  * @param id id of parameter of user settings
110  */
111  public void setId(Integer id) {
112  this.id = id;
113  }
114 
115  /**
116  * Gets name of parameter
117  *
118  * @return Returns name of parameter
119  */
120  public String getName() {
121  return name;
122  }
123 
124  /**
125  * Sets name of parameter
126  *
127  * @param name Name of parameter
128  */
129  public void setName(String name) {
130  this.name = name;
131  }
132 
133  /**
134  * Gets value of parameter
135  *
136  * @return Returns value of parameter
137  */
138  public String getValue() {
139  return value;
140  }
141 
142  /**
143  * Sets value of parameter
144  *
145  * @param value Value of parameter
146  */
147  public void setValue(String value) {
148  this.value = value;
149  }
150 
151  /**
152  * Gets description of parameter
153  *
154  * @return Returns description of parameter
155  */
156  public String getDescription() {
157  return description;
158  }
159 
160  /**
161  * Sets description of parameter
162  *
163  * @param description Description of parameter
164  */
165  public void setDescription(String description) {
166  this.description = description;
167  }
168 
169  /**
170  * Method returns true wether value is string with annotation style
171  *
172  * @return true if value is annotation style
173  */
174  public boolean isStyleSetting(){
175  String[] result = name.split(":");
176  if(result.length == 2) return true;
177  else return false;
178  }
179 
180  @Override
181  public int hashCode() {
182  int hash = 0;
183  hash += (id != null ? id.hashCode() : 0);
184  return hash;
185  }
186 
187  /**
188  * Compares this with other object and returns, whether objects are same type
189  * and have same id.
190  *
191  * @param object Object to compare with
192  * @return If object is same type and have same id, returns true, false otherwise
193  */
194  @Override
195  public boolean equals(Object object) {
196  if (!(object instanceof Settings)) {
197  return false;
198  }
199  DefaultSettings other = (DefaultSettings) object;
200  if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
201  return false;
202  }
203  return true;
204  }
205 
206  @Override
207  public String toString() {
208  return "cz.vutbr.fit.knot.annotations.entity.DefaultSettings[id=" + id + "]";
209  }
210 } // public class DefaultSettings
Class representing parameter of user settings.
Definition: Settings.java:45
Class representing parameter of default user settings.
DefaultSettings(String name, String value, String description)