| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| CounterUtils |
|
| 1.3333333333333333;1.333 |
| 1 | package org.jtheque.films.stats.services.impl.utils; | |
| 2 | ||
| 3 | import org.jtheque.utils.count.Counter; | |
| 4 | import org.jtheque.utils.count.Counters; | |
| 5 | ||
| 6 | import java.util.Map; | |
| 7 | ||
| 8 | /* | |
| 9 | * This file is part of JTheque. | |
| 10 | * | |
| 11 | * JTheque is free software: you can redistribute it and/or modify | |
| 12 | * it under the terms of the GNU General Public License as published by | |
| 13 | * the Free Software Foundation, either version 3 of the License. | |
| 14 | * | |
| 15 | * JTheque is distributed in the hope that it will be useful, | |
| 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 18 | * GNU General Public License for more details. | |
| 19 | * | |
| 20 | * You should have received a copy of the GNU General Public License | |
| 21 | * along with JTheque. If not, see <http://www.gnu.org/licenses/>. | |
| 22 | */ | |
| 23 | ||
| 24 | /** | |
| 25 | * Utils class for the Counters. | |
| 26 | * | |
| 27 | * @author Baptiste Wicht | |
| 28 | */ | |
| 29 | public final class CounterUtils { | |
| 30 | /** | |
| 31 | * Create a new CounterUtils. This class in an utility class, it cannot be instantiated. | |
| 32 | */ | |
| 33 | private CounterUtils() { | |
| 34 | 0 | super(); |
| 35 | 0 | } |
| 36 | ||
| 37 | /** | |
| 38 | * Clear the map of all the counters but keep the generals counter. | |
| 39 | * | |
| 40 | * @param data The map of counters to clear. | |
| 41 | */ | |
| 42 | public static void clearButGenerals(Map<String, Counters> data) { | |
| 43 | 1 | Counters generals = data.get(StatsCalculator.GENERALS); |
| 44 | ||
| 45 | 1 | data.clear(); |
| 46 | ||
| 47 | 1 | data.put(StatsCalculator.GENERALS, generals); |
| 48 | 1 | } |
| 49 | ||
| 50 | /** | |
| 51 | * Clear all the counters. | |
| 52 | * | |
| 53 | * @param counters The counters to clear. | |
| 54 | */ | |
| 55 | public static void clear(Iterable<Counter> counters) { | |
| 56 | 1 | for (Counter c : counters) { |
| 57 | 2 | c.clear(); |
| 58 | } | |
| 59 | 1 | } |
| 60 | } |