Clover Coverage Report - FEST Swing 1.2
Coverage timestamp: Tue Jun 1 2010 15:19:25 PDT
../../../../img/srcFileCovDistChart10.png 0% of files have more coverage
7   54   5   2.33
2   22   0.71   3
3     1.67  
1    
7.7% of code in this file is excluded from these metrics.
 
  JListItemIndexValidator       Line # 34 7 7.7% 5 0 100% 1.0
 
No Tests
 
1    /*
2    * Created on Oct 31, 2008
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5    * in compliance with the License. You may obtain a copy of the License at
6    *
7    * http://www.apache.org/licenses/LICENSE-2.0
8    *
9    * Unless required by applicable law or agreed to in writing, software distributed under the License
10    * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11    * or implied. See the License for the specific language governing permissions and limitations under
12    * the License.
13    *
14    * Copyright @2008-2010 the original author or authors.
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.JList;
22   
23    import org.fest.swing.annotation.RunsInCurrentThread;
24   
25    /**
26    * Understands verification that a given number is a valid index of an item in a <code>{@link JList}</code>.
27    * <p>
28    * <b>Note:</b> Methods in this class are <b>not</b> executed in the event dispatch thread (EDT.) Clients are
29    * responsible for invoking them in the EDT.
30    * </p>
31    *
32    * @author Alex Ruiz
33    */
 
34    final class JListItemIndexValidator {
35   
 
36  112 toggle @RunsInCurrentThread
37    static void validateIndex(JList list, int index) {
38  112 validateIndex(index, list.getModel().getSize());
39    }
40   
 
41  21 toggle @RunsInCurrentThread
42    static void validateIndices(final JList list, int...indices) {
43  21 int itemCount = list.getModel().getSize();
44  39 for (int index : indices) validateIndex(index, itemCount);
45    }
46   
 
47  151 toggle private static void validateIndex(int index, int itemCount) {
48  132 if (index >= 0 && index < itemCount) return;
49  19 throw new IndexOutOfBoundsException(concat(
50    "Item index (", valueOf(index), ") should be between [", valueOf(0), "] and [", valueOf(itemCount - 1), "] (inclusive)"));
51    }
52   
 
53    toggle private JListItemIndexValidator() {}
54    }