1. Project Clover database Sat Feb 2 2019 06:45:20 CET
  2. Package com.xpn.xwiki.objects

File BaseStringProperty.java

 

Coverage histogram

../../../../img/srcFileCovDistChart10.png
0% of files have more coverage

Code metrics

8
18
7
1
98
56
11
0.61
2.57
7
1.57

Classes

Class Line # Actions
BaseStringProperty 29 18 0% 11 2
0.9393939493.9%
 

Contributing tests

This file is covered by 196 tests. .

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20    package com.xpn.xwiki.objects;
21   
22    import com.google.common.base.Objects;
23   
24    import org.apache.commons.lang3.builder.HashCodeBuilder;
25   
26    /**
27    * Base string XProperty which all types of string XProperties extend. $Id: dae591acb6da1c957fe1420a59f8d1c7e4cf3790 $
28    */
 
29    public class BaseStringProperty extends BaseProperty
30    {
31    /** The value of the string. */
32    private String value;
33   
 
34  23223682 toggle @Override
35    public String getValue()
36    {
37    // A null String does not make much sense (the whole property would not be in the xobject in that case) and we
38    // have to make sure something saved as empty string will come back as such in Oracle (which has a very
39    // annoying "empty string is stored as null" behavior)
40  23226687 return this.value != null ? this.value : "";
41    }
42   
 
43  8974881 toggle @Override
44    public void setValue(Object value)
45    {
46  8974983 setValueDirty(value);
47  8975006 this.value = (String) value;
48    }
49   
 
50  891627 toggle @Override
51    public String toText()
52    {
53  891627 return getValue();
54    }
55   
 
56  78522 toggle @Override
57    public boolean equals(Object obj)
58    {
59    // Same Java object, they sure are equal.
60  78522 if (this == obj) {
61  1 return true;
62    }
63   
64  78521 if (!super.equals(obj)) {
65  1 return false;
66    }
67   
68  78520 if (!(obj instanceof BaseStringProperty)) {
69  0 return false;
70    }
71   
72  78520 return Objects.equal(this.getValue(), ((BaseStringProperty) obj).getValue());
73    }
74   
 
75  2 toggle @Override
76    public int hashCode()
77    {
78  2 HashCodeBuilder builder = new HashCodeBuilder();
79   
80  2 builder.appendSuper(super.hashCode());
81  2 builder.append(getValue());
82   
83  2 return builder.toHashCode();
84    }
85   
 
86  7243206 toggle @Override
87    public BaseStringProperty clone()
88    {
89  7243220 return (BaseStringProperty) super.clone();
90    }
91   
 
92  7243146 toggle @Override
93    protected void cloneInternal(BaseProperty clone)
94    {
95  7243163 BaseStringProperty property = (BaseStringProperty) clone;
96  7243160 property.setValue(getValue());
97    }
98    }