| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
package org.fest.swing.util; |
| 17 |
|
|
| 18 |
|
import static org.fest.swing.util.Strings.areEqualOrMatch; |
| 19 |
|
import static org.fest.util.Arrays.format; |
| 20 |
|
import static org.fest.util.Arrays.isEmpty; |
| 21 |
|
import static org.fest.util.Strings.quote; |
| 22 |
|
|
| 23 |
|
|
| 24 |
|
|
| 25 |
|
|
| 26 |
|
|
| 27 |
|
@author |
| 28 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (31) |
Complexity: 10 |
Complexity Density: 0.62 |
|
| 29 |
|
public class StringTextMatcher implements TextMatcher { |
| 30 |
|
|
| 31 |
|
private final String[] values; |
| 32 |
|
|
| 33 |
|
|
| 34 |
|
@link |
| 35 |
|
@param |
| 36 |
|
@throws |
| 37 |
|
@throws |
| 38 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (9) |
Complexity: 3 |
Complexity Density: 0.6 |
|
| 39 |
89
|
public StringTextMatcher(String...values) {... |
| 40 |
3
|
if (values == null) throw new NullPointerException("The array of values should not be null"); |
| 41 |
3
|
if (isEmpty(values)) throw new IllegalArgumentException("The array of values should not be empty"); |
| 42 |
83
|
this.values = values; |
| 43 |
|
} |
| 44 |
|
|
| 45 |
|
|
| 46 |
|
|
| 47 |
|
|
| 48 |
|
@param |
| 49 |
|
@return |
| 50 |
|
|
| 51 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
| 52 |
348
|
public boolean isMatching(String text) {... |
| 53 |
348
|
for (String value : values) |
| 54 |
65
|
if (areEqualOrMatch(value, text)) return true; |
| 55 |
283
|
return false; |
| 56 |
|
} |
| 57 |
|
|
| 58 |
|
|
| 59 |
|
|
| 60 |
|
|
| 61 |
|
@return |
| 62 |
|
|
| 63 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 64 |
10
|
public String description() {... |
| 65 |
9
|
if (onlyOneValue()) return "value"; |
| 66 |
1
|
return "values"; |
| 67 |
|
} |
| 68 |
|
|
| 69 |
|
|
| 70 |
|
|
| 71 |
|
@return |
| 72 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 73 |
10
|
public String formattedValues() {... |
| 74 |
9
|
if (onlyOneValue()) return quote(values[0]); |
| 75 |
1
|
return format(values); |
| 76 |
|
} |
| 77 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 78 |
20
|
private boolean onlyOneValue() {... |
| 79 |
20
|
return values.length == 1; |
| 80 |
|
} |
| 81 |
|
} |