001/*-------------------------------------------------------------------------+ 002| | 003| Copyright 2005-2011 the ConQAT Project | 004| | 005| Licensed under the Apache License, Version 2.0 (the "License"); | 006| you may not use this file except in compliance with the License. | 007| You may obtain a copy of the License at | 008| | 009| http://www.apache.org/licenses/LICENSE-2.0 | 010| | 011| Unless required by applicable law or agreed to in writing, software | 012| distributed under the License is distributed on an "AS IS" BASIS, | 013| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 014| See the License for the specific language governing permissions and | 015| limitations under the License. | 016+-------------------------------------------------------------------------*/ 017package org.conqat.engine.index.shared; 018 019import java.util.ArrayList; 020import java.util.List; 021 022import org.conqat.lib.commons.js_export.ExportToJavaScript; 023 024import com.fasterxml.jackson.annotation.JsonCreator; 025import com.fasterxml.jackson.annotation.JsonProperty; 026 027/** 028 * Summary of findings for a container or element. Holds a category name and a 029 * list of {@link FindingsSummaryGroupInfo}s. 030 */ 031@ExportToJavaScript 032public class FindingsSummaryCategoryInfo extends FindingsSummaryInfoBase { 033 034 private static final long serialVersionUID = 1L; 035 036 /** The name of the JSON property name for {@link #categoryName}. */ 037 private static final String CATEGORY_NAME_PROPERTY = "categoryName"; 038 039 /** The name of the finding category */ 040 @JsonProperty(CATEGORY_NAME_PROPERTY) 041 private final String categoryName; 042 043 /** The finding group infos */ 044 @JsonProperty("groupInfos") 045 private final List<FindingsSummaryGroupInfo> groupInfos = new ArrayList<>(); 046 047 /** Constructor */ 048 @JsonCreator 049 public FindingsSummaryCategoryInfo(@JsonProperty(CATEGORY_NAME_PROPERTY) String categoryName) { 050 this.categoryName = categoryName; 051 } 052 053 /** Returns the finding category. */ 054 public String getCategoryName() { 055 return categoryName; 056 } 057 058 /** Returns the group infos. */ 059 public List<FindingsSummaryGroupInfo> getGroupInfos() { 060 return groupInfos; 061 } 062 063 /** Adds the given group info to this category info. */ 064 public void addGroupInfo(FindingsSummaryGroupInfo groupInfo) { 065 count += groupInfo.getCount(); 066 countRed += groupInfo.getCountRed(); 067 this.groupInfos.add(groupInfo); 068 } 069 070}