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
20   101   11   2.86
8   36   0.55   3.5
7     1.57  
2    
 
  TableCell       Line # 29 18 0% 9 0 100% 1.0
  TableCell.TableCellBuilder       Line # 56 2 0% 2 0 100% 1.0
 
No Tests
 
1    /*
2    * Created on Mar 2, 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.data;
17   
18    import static java.lang.String.valueOf;
19    import static org.fest.util.Objects.HASH_CODE_PRIME;
20    import static org.fest.util.Strings.concat;
21   
22    import javax.swing.JTable;
23   
24    /**
25    * Understands a cell in a <code>{@link JTable}</code>.
26    *
27    * @author Alex Ruiz
28    */
 
29    public class TableCell {
30   
31    /** The row of the cell. */
32    public final int row;
33   
34    /** The column of the cell. */
35    public final int column;
36   
37    /**
38    * Starting point for the creation of a <code>{@link TableCell}</code>.
39    * <p>
40    * Example:
41    * <pre>
42    * // import static org.fest.swing.data.TableCell.row;
43    * TableCell cell = row(5).column(3);
44    * </pre>
45    * </p>
46    * @param row the row index of the table cell to create.
47    * @return the created builder.
48    */
 
49  124 toggle public static TableCellBuilder row(int row) { return new TableCellBuilder(row); }
50   
51    /**
52    * Understands creation of <code>{@link TableCell}</code>s.
53    *
54    * @author Alex Ruiz
55    */
 
56    public static class TableCellBuilder {
57    private final int row;
58   
 
59  124 toggle TableCellBuilder(int row) { this.row = row; }
60   
61    /**
62    * Creates a new table cell using the row index specified in <code>{@link TableCellBuilder#row(int)}</code> and the
63    * column index specified as the argument in this method.
64    * @param column the column index of the table cell to create.
65    * @return the created table cell.
66    */
 
67  124 toggle public TableCell column(int column) { return new TableCell(row, column); }
68    }
69   
70    /**
71    * Creates a new </code>{@link TableCell}</code>.
72    * @param row the row of the cell.
73    * @param column the column of the cell.
74    */
 
75  132 toggle protected TableCell(int row, int column) {
76  132 this.row = row;
77  132 this.column = column;
78    }
79   
80    /** ${@inheritDoc} */
 
81  55 toggle @Override public boolean equals(Object obj) {
82  44 if (this == obj) return true;
83  1 if (obj == null) return false;
84  1 if (!(obj instanceof TableCell)) return false;
85  9 TableCell other = (TableCell) obj;
86  1 if (row != other.row) return false;
87  8 return column == other.column;
88    }
89   
90    /** ${@inheritDoc} */
 
91  2 toggle @Override public int hashCode() {
92  2 int result = 1;
93  2 result = HASH_CODE_PRIME * result + column;
94  2 result = HASH_CODE_PRIME * result + row;
95  2 return result;
96    }
97   
 
98  13 toggle @Override public String toString() {
99  13 return concat("[row=", valueOf(row), ", column=", valueOf(column), "]");
100    }
101    }