View Javadoc
1   /*
2    * Copyright (c) 2011-2024 PrimeFaces Extensions
3    *
4    *  Permission is hereby granted, free of charge, to any person obtaining a copy
5    *  of this software and associated documentation files (the "Software"), to deal
6    *  in the Software without restriction, including without limitation the rights
7    *  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8    *  copies of the Software, and to permit persons to whom the Software is
9    *  furnished to do so, subject to the following conditions:
10   *
11   *  The above copyright notice and this permission notice shall be included in
12   *  all copies or substantial portions of the Software.
13   *
14   *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   *  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   *  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   *  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   *  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   *  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20   *  THE SOFTWARE.
21   */
22  package org.primefaces.extensions.model.dynaform;
23  
24  import java.util.Objects;
25  
26  /**
27   * Class representing a label inside of <code>DynaForm</code>.
28   *
29   * @author Oleg Varaksin / last modified by $Author$
30   * @version $Revision$
31   * @since 0.5
32   */
33  public class DynaFormLabel extends AbstractDynaFormElement {
34  
35      private static final long serialVersionUID = 1L;
36  
37      private final String value;
38      private final boolean escape;
39      private DynaFormControl forControl;
40      private String targetClientId;
41      private boolean targetRequired = false;
42      private boolean targetValid = true;
43      private String styleClass;
44  
45      public DynaFormLabel(String value, boolean escape, int colspan, int rowspan, int row, int column, boolean extended) {
46          super(colspan, rowspan, row, column, extended);
47  
48          this.value = value;
49          this.escape = escape;
50      }
51  
52      public String getValue() {
53          return value;
54      }
55  
56      public boolean isEscape() {
57          return escape;
58      }
59  
60      public DynaFormControl getForControl() {
61          return forControl;
62      }
63  
64      public void setForControl(DynaFormControl forControl) {
65          this.forControl = forControl;
66      }
67  
68      public String getTargetClientId() {
69          return targetClientId;
70      }
71  
72      public void setTargetClientId(String targetClientId) {
73          this.targetClientId = targetClientId;
74      }
75  
76      public boolean isTargetRequired() {
77          return targetRequired;
78      }
79  
80      public void setTargetRequired(boolean targetRequired) {
81          this.targetRequired = targetRequired;
82      }
83  
84      public boolean isTargetValid() {
85          return targetValid;
86      }
87  
88      public void setTargetValid(boolean targetValid) {
89          this.targetValid = targetValid;
90      }
91  
92      public String getStyleClass() {
93          return styleClass;
94      }
95  
96      public void setStyleClass(final String styleClass) {
97          this.styleClass = styleClass;
98      }
99  
100     @Override
101     public String toString() {
102         return "DynaFormLabel{" + "value=" + value + ", escape=" + escape + ", forControl=" + forControl
103                     + ", targetClientId=" + targetClientId + ", targetRequired=" + targetRequired
104                     + ", targetValid=" + targetValid + ", styleClass=" + styleClass + '}';
105     }
106 
107     @Override
108     public boolean equals(Object o) {
109         if (this == o) {
110             return true;
111         }
112         if (!(o instanceof DynaFormLabel)) {
113             return false;
114         }
115         if (!super.equals(o)) {
116             return false;
117         }
118         DynaFormLabel that = (DynaFormLabel) o;
119         return isEscape() == that.isEscape() &&
120                     isTargetRequired() == that.isTargetRequired() &&
121                     isTargetValid() == that.isTargetValid() &&
122                     Objects.equals(getValue(), that.getValue()) &&
123                     Objects.equals(getTargetClientId(), that.getTargetClientId()) &&
124                     Objects.equals(getStyleClass(), that.getStyleClass());
125     }
126 
127     @Override
128     public int hashCode() {
129         return Objects.hash(super.hashCode(), getValue(), isEscape(), getTargetClientId(), isTargetRequired(), isTargetValid(), getStyleClass());
130     }
131 }