##### Coverage Report - org.jbehave.core.steps.ChainedRow

Classes in this File | Line Coverage | Branch Coverage | Complexity
ChainedRow |
100% | 9/9
100% | 6/6
| 2.5;2.5

1 |  |
     package org.jbehave.core.steps;
2 |  |
3 |  |
     import java.util.HashMap;
4 |  |
     import java.util.Map;
5 |  |
6 |  |
     /**
7 |  |
      * Implementation of Row that chains delegate Rows in resolving requests for
8 |  |
      * values.
9 |  |
      */
10 |  |
     public class ChainedRow implements Row {
11 |  |
         private final Row[] delegates;
12 |  |
13 | 14 |
         public ChainedRow(Row... delegates) {
14 | 14 |
             this.delegates = delegates;
15 | 14 |
         }
16 |  |
17 |  |
         /**
18 |  |
          * Returns values aggregated from all the delegates, without overriding
19 |  |
          * values that already exist.
20 |  |
          *
21 |  |
          * @return The Map of aggregated values
22 |  |
          */
23 |  |
         public Map<String, String> values() {
24 | 17 |
             Map<String, String> values = new HashMap<String, String>();
25 | 51 |
             for (Row each : delegates) {
26 | 34 |
                 for (String name : each.values().keySet()) {
27 | 32 |
                     if (!values.containsKey(name)) {
28 | 31 |
                         values.put(name, each.values().get(name));
29 |  |
                     }
30 |  |
                 }
31 |  |
             }
32 | 17 |
             return values;
33 |  |
         }
34 |  |
35 |  |
     }