universe@80: /* universe@80: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. universe@80: * universe@80: * Copyright 2018 Mike Becker. All rights reserved. universe@80: * universe@80: * Redistribution and use in source and binary forms, with or without universe@80: * modification, are permitted provided that the following conditions are met: universe@80: * universe@80: * 1. Redistributions of source code must retain the above copyright universe@80: * notice, this list of conditions and the following disclaimer. universe@80: * universe@80: * 2. Redistributions in binary form must reproduce the above copyright universe@80: * notice, this list of conditions and the following disclaimer in the universe@80: * documentation and/or other materials provided with the distribution. universe@80: * universe@80: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" universe@80: * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE universe@80: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE universe@80: * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE universe@80: * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR universe@80: * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF universe@80: * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS universe@80: * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN universe@80: * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) universe@80: * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE universe@80: * POSSIBILITY OF SUCH DAMAGE. universe@80: * universe@80: */ universe@80: package de.uapcore.lightpit.entities; universe@80: universe@80: public class VersionStatistics { universe@80: universe@80: private final Version version; universe@80: private int[][] issueCount; universe@80: universe@80: private int[] rowTotals = null; universe@80: private int[] columnTotals = null; universe@80: private int total = -1; universe@80: universe@80: public VersionStatistics(Version version) { universe@80: this.version = version; universe@80: issueCount = new int[IssueCategory.values().length][IssueStatus.values().length]; universe@80: } universe@80: universe@80: public Version getVersion() { universe@80: return version; universe@80: } universe@80: universe@80: public void setIssueCount(IssueCategory category, IssueStatus status, int count) { universe@80: issueCount[category.ordinal()][status.ordinal()] = count; universe@80: total = -1; universe@80: rowTotals = columnTotals = null; universe@80: } universe@80: universe@80: public int[][] getIssueCount() { universe@80: return issueCount; universe@80: } universe@80: universe@80: public int[] getRowTotals() { universe@80: if (rowTotals != null) return rowTotals; universe@80: final int cn = IssueCategory.values().length; universe@80: final int sn = IssueStatus.values().length; universe@80: final var totals = new int[cn]; universe@80: for (int i = 0 ; i < cn ; i++) { universe@80: totals[i] = 0; universe@80: for (int j = 0 ; j < sn ; j++) { universe@80: totals[i] += issueCount[i][j]; universe@80: } universe@80: } universe@80: return rowTotals = totals; universe@80: } universe@80: universe@80: public int[] getColumnTotals() { universe@80: if (columnTotals != null) return columnTotals; universe@80: final int cn = IssueCategory.values().length; universe@80: final int sn = IssueStatus.values().length; universe@80: final var totals = new int[sn]; universe@80: for (int i = 0 ; i < sn ; i++) { universe@80: totals[i] = 0; universe@80: for (int j = 0 ; j < cn ; j++) { universe@80: totals[i] += issueCount[j][i]; universe@80: } universe@80: } universe@80: return columnTotals = totals; universe@80: } universe@80: universe@80: public int getTotal() { universe@80: if (this.total >= 0) { universe@80: return this.total; universe@80: } universe@80: int total = 0; universe@80: final int cn = IssueCategory.values().length; universe@80: final int sn = IssueStatus.values().length; universe@80: for (int i = 0 ; i < sn ; i++) { universe@80: for (int j = 0 ; j < cn ; j++) { universe@80: total += issueCount[j][i]; universe@80: } universe@80: } universe@80: return this.total = total; universe@80: } universe@80: }