| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
package org.fest.swing.driver; |
| 17 |
|
|
| 18 |
|
import static java.lang.String.valueOf; |
| 19 |
|
import static org.fest.util.Strings.concat; |
| 20 |
|
|
| 21 |
|
import javax.swing.JComboBox; |
| 22 |
|
|
| 23 |
|
import org.fest.swing.annotation.RunsInCurrentThread; |
| 24 |
|
|
| 25 |
|
|
| 26 |
|
@link |
| 27 |
|
|
| 28 |
|
|
| 29 |
|
|
| 30 |
|
|
| 31 |
|
|
| 32 |
|
@author |
| 33 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (19) |
Complexity: 7 |
Complexity Density: 0.7 |
|
| 34 |
|
final class JComboBoxItemIndexValidator { |
| 35 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (14) |
Complexity: 5 |
Complexity Density: 0.62 |
|
| 36 |
18
|
@RunsInCurrentThread... |
| 37 |
|
static void validateIndex(JComboBox comboBox, int index) { |
| 38 |
2
|
if (index < 0) throw invalidIndex(concat(itemIndex(index), " should not be less than zero")); |
| 39 |
16
|
int itemCount = comboBox.getItemCount(); |
| 40 |
1
|
if (itemCount == 0) throw invalidIndex("JComboBox is empty"); |
| 41 |
13
|
if (index >= 0 && index < itemCount) return; |
| 42 |
2
|
throw invalidIndex(concat( |
| 43 |
|
itemIndex(index), " should be between [", valueOf(0), "] and [", valueOf(itemCount - 1), "] (inclusive)")); |
| 44 |
|
} |
| 45 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 46 |
4
|
private static String itemIndex(int index) {... |
| 47 |
4
|
return concat("Item index (", valueOf(index), ")"); |
| 48 |
|
} |
| 49 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 50 |
5
|
private static IndexOutOfBoundsException invalidIndex(String msg) {... |
| 51 |
5
|
throw new IndexOutOfBoundsException(msg); |
| 52 |
|
} |
| 53 |
|
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
| 54 |
|
private JComboBoxItemIndexValidator() {}... |
| 55 |
|
} |