1 /*
2  * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * This code is free software; you can redistribute it and/or modify it
6  * under the terms of the GNU General Public License version 2 only, as
7  * published by the Free Software Foundation.
8  *
9  * This code is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12  * version 2 for more details (a copy is included in the LICENSE file that
13  * accompanied this code).
14  *
15  * You should have received a copy of the GNU General Public License version
16  * 2 along with this work; if not, write to the Free Software Foundation,
17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18  *
19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20  * or visit www.oracle.com if you need additional information or have any
21  * questions.
22  *
23  */
24 package com.sun.hotspot.igv.filter;
25 
26 import java.util.Collections;
27 import java.util.HashSet;
28 import java.util.Set;
29 
30 /**
31  *
32  * @author Thomas Wuerthinger
33  */
34 public class FilterSetting {
35 
36     private Set<Filter> filters;
37     private String name;
38 
FilterSetting()39     public FilterSetting() {
40         this(null);
41     }
42 
FilterSetting(String name)43     public FilterSetting(String name) {
44         this.name = name;
45         filters = new HashSet<>();
46     }
47 
getFilters()48     public Set<Filter> getFilters() {
49         return Collections.unmodifiableSet(filters);
50     }
51 
addFilter(Filter f)52     public void addFilter(Filter f) {
53         assert !filters.contains(f);
54         filters.add(f);
55     }
56 
removeFilter(Filter f)57     public void removeFilter(Filter f) {
58         assert filters.contains(f);
59         filters.remove(f);
60     }
61 
containsFilter(Filter f)62     public boolean containsFilter(Filter f) {
63         return filters.contains(f);
64     }
65 
getName()66     public String getName() {
67         return name;
68     }
69 
setName(String name)70     public void setName(String name) {
71         this.name = name;
72     }
73 
getFilterCount()74     public int getFilterCount() {
75         return filters.size();
76     }
77 
78     @Override
toString()79     public String toString() {
80         return getName();
81     }
82 }
83