src/main/java/de/uapcore/lightpit/entities/VersionStatistics.java

Sun, 21 Jun 2020 11:38:16 +0200

author
Mike Becker <universe@uap-core.de>
date
Sun, 21 Jun 2020 11:38:16 +0200
changeset 88
1438e5a22c55
parent 80
27a25f32048e
permissions
-rw-r--r--

simplifies version overviews by removing "scheduled issues"

universe@80 1 /*
universe@80 2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
universe@80 3 *
universe@80 4 * Copyright 2018 Mike Becker. All rights reserved.
universe@80 5 *
universe@80 6 * Redistribution and use in source and binary forms, with or without
universe@80 7 * modification, are permitted provided that the following conditions are met:
universe@80 8 *
universe@80 9 * 1. Redistributions of source code must retain the above copyright
universe@80 10 * notice, this list of conditions and the following disclaimer.
universe@80 11 *
universe@80 12 * 2. Redistributions in binary form must reproduce the above copyright
universe@80 13 * notice, this list of conditions and the following disclaimer in the
universe@80 14 * documentation and/or other materials provided with the distribution.
universe@80 15 *
universe@80 16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
universe@80 17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
universe@80 18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
universe@80 19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
universe@80 20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
universe@80 21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
universe@80 22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
universe@80 23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
universe@80 24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
universe@80 25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
universe@80 26 * POSSIBILITY OF SUCH DAMAGE.
universe@80 27 *
universe@80 28 */
universe@80 29 package de.uapcore.lightpit.entities;
universe@80 30
universe@80 31 public class VersionStatistics {
universe@80 32
universe@80 33 private final Version version;
universe@80 34 private int[][] issueCount;
universe@80 35
universe@80 36 private int[] rowTotals = null;
universe@80 37 private int[] columnTotals = null;
universe@80 38 private int total = -1;
universe@80 39
universe@80 40 public VersionStatistics(Version version) {
universe@80 41 this.version = version;
universe@80 42 issueCount = new int[IssueCategory.values().length][IssueStatus.values().length];
universe@80 43 }
universe@80 44
universe@80 45 public Version getVersion() {
universe@80 46 return version;
universe@80 47 }
universe@80 48
universe@80 49 public void setIssueCount(IssueCategory category, IssueStatus status, int count) {
universe@80 50 issueCount[category.ordinal()][status.ordinal()] = count;
universe@80 51 total = -1;
universe@80 52 rowTotals = columnTotals = null;
universe@80 53 }
universe@80 54
universe@80 55 public int[][] getIssueCount() {
universe@80 56 return issueCount;
universe@80 57 }
universe@80 58
universe@80 59 public int[] getRowTotals() {
universe@80 60 if (rowTotals != null) return rowTotals;
universe@80 61 final int cn = IssueCategory.values().length;
universe@80 62 final int sn = IssueStatus.values().length;
universe@80 63 final var totals = new int[cn];
universe@80 64 for (int i = 0 ; i < cn ; i++) {
universe@80 65 totals[i] = 0;
universe@80 66 for (int j = 0 ; j < sn ; j++) {
universe@80 67 totals[i] += issueCount[i][j];
universe@80 68 }
universe@80 69 }
universe@80 70 return rowTotals = totals;
universe@80 71 }
universe@80 72
universe@80 73 public int[] getColumnTotals() {
universe@80 74 if (columnTotals != null) return columnTotals;
universe@80 75 final int cn = IssueCategory.values().length;
universe@80 76 final int sn = IssueStatus.values().length;
universe@80 77 final var totals = new int[sn];
universe@80 78 for (int i = 0 ; i < sn ; i++) {
universe@80 79 totals[i] = 0;
universe@80 80 for (int j = 0 ; j < cn ; j++) {
universe@80 81 totals[i] += issueCount[j][i];
universe@80 82 }
universe@80 83 }
universe@80 84 return columnTotals = totals;
universe@80 85 }
universe@80 86
universe@80 87 public int getTotal() {
universe@80 88 if (this.total >= 0) {
universe@80 89 return this.total;
universe@80 90 }
universe@80 91 int total = 0;
universe@80 92 final int cn = IssueCategory.values().length;
universe@80 93 final int sn = IssueStatus.values().length;
universe@80 94 for (int i = 0 ; i < sn ; i++) {
universe@80 95 for (int j = 0 ; j < cn ; j++) {
universe@80 96 total += issueCount[j][i];
universe@80 97 }
universe@80 98 }
universe@80 99 return this.total = total;
universe@80 100 }
universe@80 101 }

mercurial