| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
package org.itracker.model; |
| 20 |
|
|
| 21 |
|
import java.io.Serializable; |
| 22 |
|
import java.util.Comparator; |
| 23 |
|
import java.util.Locale; |
| 24 |
|
|
| 25 |
|
import org.apache.commons.lang.builder.CompareToBuilder; |
| 26 |
|
import org.apache.commons.lang.builder.ToStringBuilder; |
| 27 |
|
import org.itracker.core.resources.ITrackerResources; |
| 28 |
|
import org.itracker.services.util.CustomFieldUtilities; |
| 29 |
|
|
| 30 |
|
|
| 31 |
|
|
| 32 |
|
|
| 33 |
|
@author |
| 34 |
|
@author |
| 35 |
|
|
|
|
|
| 42.3% |
Uncovered Elements: 15 (26) |
Complexity: 11 |
Complexity Density: 0.85 |
|
| 36 |
|
public class CustomFieldValue extends AbstractEntity { |
| 37 |
|
|
| 38 |
|
|
| 39 |
|
|
| 40 |
|
|
| 41 |
|
private static final long serialVersionUID = 1L; |
| 42 |
|
public static final Comparator<CustomFieldValue> NAME_COMPARATOR = new NameComparator(); |
| 43 |
|
public static final Comparator<CustomFieldValue> SORT_ORDER_COMPARATOR = new SortOrderComparator(); |
| 44 |
|
|
| 45 |
|
|
| 46 |
|
private CustomField customField; |
| 47 |
|
|
| 48 |
|
|
| 49 |
|
|
| 50 |
|
|
| 51 |
|
private String value; |
| 52 |
|
|
| 53 |
|
|
| 54 |
|
|
| 55 |
|
|
| 56 |
|
|
| 57 |
|
private int sortOrder; |
| 58 |
|
|
| 59 |
|
|
| 60 |
|
|
| 61 |
|
|
| 62 |
|
|
| 63 |
|
|
| 64 |
|
|
| 65 |
|
|
| 66 |
|
|
| 67 |
|
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
| 68 |
0
|
public CustomFieldValue() {... |
| 69 |
|
} |
| 70 |
|
|
| 71 |
|
|
| 72 |
|
|
| 73 |
|
@param |
| 74 |
|
@param |
| 75 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 76 |
2
|
public CustomFieldValue(CustomField customField, String value) {... |
| 77 |
2
|
setCustomField(customField); |
| 78 |
2
|
setValue(value); |
| 79 |
|
} |
| 80 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 81 |
0
|
public CustomField getCustomField() {... |
| 82 |
0
|
return (customField); |
| 83 |
|
} |
| 84 |
|
|
|
|
|
| 60% |
Uncovered Elements: 2 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 85 |
2
|
public void setCustomField(CustomField customField) {... |
| 86 |
2
|
if (customField == null) { |
| 87 |
0
|
throw new IllegalArgumentException("null customField"); |
| 88 |
|
} |
| 89 |
2
|
this.customField = customField; |
| 90 |
|
} |
| 91 |
|
|
| 92 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 93 |
0
|
public String getValue() {... |
| 94 |
0
|
return value; |
| 95 |
|
} |
| 96 |
|
|
| 97 |
|
|
| 98 |
|
|
| 99 |
|
@param |
| 100 |
|
|
|
|
|
| 60% |
Uncovered Elements: 2 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 101 |
2
|
public void setValue(String value) {... |
| 102 |
2
|
if (value == null) { |
| 103 |
0
|
throw new IllegalArgumentException("null value"); |
| 104 |
|
} |
| 105 |
2
|
this.value = value; |
| 106 |
|
} |
| 107 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 108 |
0
|
public int getSortOrder() {... |
| 109 |
0
|
return sortOrder; |
| 110 |
|
} |
| 111 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 112 |
0
|
public void setSortOrder(int sortOrder) {... |
| 113 |
0
|
this.sortOrder = sortOrder; |
| 114 |
|
} |
| 115 |
|
|
| 116 |
|
|
| 117 |
|
|
| 118 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 119 |
0
|
@Override... |
| 120 |
|
public String toString() { |
| 121 |
0
|
return new ToStringBuilder(this).append("id", getId()).append( |
| 122 |
|
"customField", getCustomField()).append("value", getValue()) |
| 123 |
|
.toString(); |
| 124 |
|
} |
| 125 |
|
|
| 126 |
|
|
| 127 |
|
|
| 128 |
|
|
| 129 |
|
|
| 130 |
|
|
| 131 |
|
|
| 132 |
|
|
| 133 |
|
|
| 134 |
|
|
| 135 |
|
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 1 |
|
| 136 |
|
private static class SortOrderComparator implements |
| 137 |
|
Comparator<CustomFieldValue>, Serializable { |
| 138 |
|
|
| 139 |
|
|
| 140 |
|
|
| 141 |
|
private static final long serialVersionUID = 1L; |
| 142 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 143 |
0
|
public int compare(CustomFieldValue a, CustomFieldValue b) {... |
| 144 |
0
|
return new CompareToBuilder().append(a.getSortOrder(), |
| 145 |
|
b.getSortOrder()) |
| 146 |
|
.toComparison(); |
| 147 |
|
} |
| 148 |
|
|
| 149 |
|
} |
| 150 |
|
|
| 151 |
|
|
| 152 |
|
|
| 153 |
|
|
| 154 |
|
|
| 155 |
|
|
| 156 |
|
|
| 157 |
|
|
| 158 |
|
|
| 159 |
|
|
| 160 |
|
|
| 161 |
|
|
| 162 |
|
|
| 163 |
|
|
|
|
|
| 66.7% |
Uncovered Elements: 2 (6) |
Complexity: 3 |
Complexity Density: 1 |
|
| 164 |
|
private static class NameComparator implements |
| 165 |
|
Comparator<CustomFieldValue>, Serializable { |
| 166 |
|
|
| 167 |
|
|
| 168 |
|
|
| 169 |
|
private static final long serialVersionUID = 1L; |
| 170 |
|
|
| 171 |
|
private final Locale locale; |
| 172 |
|
|
| 173 |
|
@deprecated |
| 174 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 175 |
1
|
private NameComparator() {... |
| 176 |
1
|
this(new Locale(ITrackerResources.getDefaultLocale())); |
| 177 |
|
} |
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 178 |
1
|
private NameComparator(Locale locale) {... |
| 179 |
1
|
this.locale = locale; |
| 180 |
|
} |
| 181 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 182 |
0
|
public int compare(CustomFieldValue a, CustomFieldValue b) {... |
| 183 |
|
|
| 184 |
|
|
| 185 |
0
|
return new CompareToBuilder() |
| 186 |
|
.append( |
| 187 |
|
CustomFieldUtilities.getCustomFieldOptionName(a,this.locale), |
| 188 |
|
CustomFieldUtilities.getCustomFieldOptionName(b,this.locale)) |
| 189 |
|
.append(a.getSortOrder(), b.getSortOrder()) |
| 190 |
|
.append(a.getId(), b.getId()).toComparison(); |
| 191 |
|
} |
| 192 |
|
|
| 193 |
|
} |
| 194 |
|
|
| 195 |
|
} |