001/* 002 * Sonar, open source software quality management tool. 003 * Copyright (C) 2008-2012 SonarSource 004 * mailto:contact AT sonarsource DOT com 005 * 006 * Sonar is free software; you can redistribute it and/or 007 * modify it under the terms of the GNU Lesser General Public 008 * License as published by the Free Software Foundation; either 009 * version 3 of the License, or (at your option) any later version. 010 * 011 * Sonar is distributed in the hope that it will be useful, 012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 014 * Lesser General Public License for more details. 015 * 016 * You should have received a copy of the GNU Lesser General Public 017 * License along with Sonar; if not, write to the Free Software 018 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 019 */ 020package org.sonar.core.filter; 021 022import com.google.common.collect.Lists; 023 024import java.util.Collection; 025import java.util.List; 026 027/** 028 * @since 3.1 029 */ 030public final class FilterDto { 031 private Long id; 032 private Long userId; 033 private String defaultView; 034 private Boolean favourites; 035 private String key; 036 private String name; 037 private Long pageSize; 038 private Long periodIndex; 039 private Long resourceId; 040 private Boolean shared; 041 private List<CriterionDto> criteria = Lists.newArrayList(); 042 private List<FilterColumnDto> filterColumns = Lists.newArrayList(); 043 044 /** 045 * Add a {@link CriterionDto} to the list. 046 * 047 * @param criterion the criterion to add 048 */ 049 public FilterDto add(CriterionDto criterion) { 050 criteria.add(criterion); 051 return this; 052 } 053 054 /** 055 * Add a {@link FilterColumnDto} to the list. 056 * 057 * @param filterColumn the column to add 058 */ 059 public FilterDto add(FilterColumnDto filterColumn) { 060 filterColumns.add(filterColumn); 061 return this; 062 } 063 064 /** 065 * @return the column list 066 */ 067 public Collection<FilterColumnDto> getColumns() { 068 return filterColumns; 069 } 070 071 /** 072 * @return the criterion list 073 */ 074 public Collection<CriterionDto> getCriteria() { 075 return criteria; 076 } 077 078 /** 079 * @return the defaut view 080 */ 081 public String getDefaultView() { 082 return defaultView; 083 } 084 085 /** 086 * @return <code>true</code> if the filter returns only favourites 087 */ 088 public Boolean getFavourites() { 089 return favourites; 090 } 091 092 /** 093 * @return the column list 094 */ 095 public List<FilterColumnDto> getFilterColumns() { 096 return filterColumns; 097 } 098 099 /** 100 * @return the id 101 */ 102 public Long getId() { 103 return id; 104 } 105 106 /** 107 * @return the key 108 */ 109 public String getKey() { 110 return key; 111 } 112 113 /** 114 * @return the name 115 */ 116 public String getName() { 117 return name; 118 } 119 120 /** 121 * @return the page size 122 */ 123 public Long getPageSize() { 124 return pageSize; 125 } 126 127 /** 128 * @return the period index 129 */ 130 public Long getPeriodIndex() { 131 return periodIndex; 132 } 133 134 /** 135 * @return the resource id 136 */ 137 public Long getResourceId() { 138 return resourceId; 139 } 140 141 /** 142 * @return <code>true</code> if the filter is shared 143 */ 144 public Boolean getShared() { 145 return shared; 146 } 147 148 /** 149 * @return the user id 150 */ 151 public Long getUserId() { 152 return userId; 153 } 154 155 /** 156 * @return <code>true</code> if the filter displays only favourite resources. 157 */ 158 public Boolean isFavourites() { 159 return favourites; 160 } 161 162 /** 163 * @return <code>true</code> if the filter is shared 164 */ 165 public Boolean isShared() { 166 return shared; 167 } 168 169 /** 170 * @param defaultView the defaultView to set 171 */ 172 public FilterDto setDefaultView(String defaultView) { 173 this.defaultView = defaultView; 174 return this; 175 } 176 177 /** 178 * @param favourites the favourites to set 179 */ 180 public FilterDto setFavourites(Boolean favourites) { 181 this.favourites = favourites; 182 return this; 183 } 184 185 /** 186 * @param key the key to set 187 */ 188 public FilterDto setKey(String key) { 189 this.key = key; 190 return this; 191 } 192 193 /** 194 * @param name the name to set 195 */ 196 public FilterDto setName(String name) { 197 this.name = name; 198 return this; 199 } 200 201 public FilterDto setPageSize(Long pageSize) { 202 this.pageSize = pageSize; 203 return this; 204 } 205 206 /** 207 * @param shared the shared to set 208 */ 209 public FilterDto setShared(Boolean shared) { 210 this.shared = shared; 211 return this; 212 } 213}