1 | /* | |
2 | * Copyright 2006 - 2013 | |
3 | * Stefan Balev <stefan.balev@graphstream-project.org> | |
4 | * Julien Baudry <julien.baudry@graphstream-project.org> | |
5 | * Antoine Dutot <antoine.dutot@graphstream-project.org> | |
6 | * Yoann Pign�� <yoann.pigne@graphstream-project.org> | |
7 | * Guilhelm Savin <guilhelm.savin@graphstream-project.org> | |
8 | * | |
9 | * This file is part of GraphStream <http://graphstream-project.org>. | |
10 | * | |
11 | * GraphStream is a library whose purpose is to handle static or dynamic | |
12 | * graph, create them from scratch, file or any source and display them. | |
13 | * | |
14 | * This program is free software distributed under the terms of two licenses, the | |
15 | * CeCILL-C license that fits European law, and the GNU Lesser General Public | |
16 | * License. You can use, modify and/ or redistribute the software under the terms | |
17 | * of the CeCILL-C license as circulated by CEA, CNRS and INRIA at the following | |
18 | * URL <http://www.cecill.info> or under the terms of the GNU LGPL as published by | |
19 | * the Free Software Foundation, either version 3 of the License, or (at your | |
20 | * option) any later version. | |
21 | * | |
22 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY | |
23 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A | |
24 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. | |
25 | * | |
26 | * You should have received a copy of the GNU Lesser General Public License | |
27 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
28 | * | |
29 | * The fact that you are presently reading this means that you have had | |
30 | * knowledge of the CeCILL-C and LGPL licenses and that you accept their terms. | |
31 | */ | |
32 | package org.graphstream.util; | |
33 | ||
34 | import java.util.Collection; | |
35 | ||
36 | import org.graphstream.graph.Edge; | |
37 | import org.graphstream.graph.Element; | |
38 | import org.graphstream.graph.Node; | |
39 | ||
40 | public class Filters { | |
41 | public static <T extends Element> Filter<T> falseFilter() { | |
42 |
1
1. falseFilter : mutated return of Object value for org/graphstream/util/Filters::falseFilter to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return new Filter<T>() { |
43 | public boolean isAvailable(T e) { | |
44 |
1
1. isAvailable : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return false; |
45 | } | |
46 | }; | |
47 | } | |
48 | ||
49 | public static <T extends Element> Filter<T> trueFilter() { | |
50 |
1
1. trueFilter : mutated return of Object value for org/graphstream/util/Filters::trueFilter to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return new Filter<T>() { |
51 | public boolean isAvailable(T e) { | |
52 |
1
1. isAvailable : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return true; |
53 | } | |
54 | }; | |
55 | } | |
56 | ||
57 | public static <T extends Element> Filter<T> byAttributeFilter(String key, | |
58 | Object expectedValue) { | |
59 |
1
1. byAttributeFilter : mutated return of Object value for org/graphstream/util/Filters::byAttributeFilter to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return new ByAttributeFilter<T>(key, expectedValue); |
60 | } | |
61 | ||
62 | public static <T extends Element, U extends Element> Filter<Element> separateNodeAndEdgeFilter( | |
63 | Filter<T> nodeFilter, Filter<U> edgeFilter) { | |
64 |
1
1. separateNodeAndEdgeFilter : mutated return of Object value for org/graphstream/util/Filters::separateNodeAndEdgeFilter to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return new SeparateNodeEdgeFilter<T, U>(nodeFilter, edgeFilter); |
65 | } | |
66 | ||
67 | public static <T extends Element, U extends Element> Filter<T> byExtremitiesFilter( | |
68 | Filter<U> f) { | |
69 |
1
1. byExtremitiesFilter : mutated return of Object value for org/graphstream/util/Filters::byExtremitiesFilter to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return new ExtremitiesFilter<T, U>(f); |
70 | } | |
71 | ||
72 | public static <T extends Element> Filter<T> byIdFilter(String idPattern) { | |
73 |
1
1. byIdFilter : mutated return of Object value for org/graphstream/util/Filters::byIdFilter to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return new ByIdFilter<T>(idPattern); |
74 | } | |
75 | ||
76 | public static <T extends Element> Filter<T> isContained( | |
77 | final Collection<? extends T> set) { | |
78 |
1
1. isContained : mutated return of Object value for org/graphstream/util/Filters::isContained to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return new Filter<T>() { |
79 | public boolean isAvailable(T e) { | |
80 |
1
1. isAvailable : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return set.contains(e); |
81 | } | |
82 | }; | |
83 | } | |
84 | ||
85 | public static <T extends Element> Filter<T> isIdContained( | |
86 | final Collection<String> set) { | |
87 |
1
1. isIdContained : mutated return of Object value for org/graphstream/util/Filters::isIdContained to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return new Filter<T>() { |
88 | public boolean isAvailable(T e) { | |
89 |
1
1. isAvailable : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return set.contains(e.getId()); |
90 | } | |
91 | }; | |
92 | } | |
93 | ||
94 | public static <T extends Element> Filter<T> and(Filter<T> f1, Filter<T> f2) { | |
95 |
1
1. and : mutated return of Object value for org/graphstream/util/Filters::and to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return new AndFilter<T>(f1, f2); |
96 | } | |
97 | ||
98 | public static <T extends Element> Filter<T> or(Filter<T> f1, Filter<T> f2) { | |
99 |
1
1. or : mutated return of Object value for org/graphstream/util/Filters::or to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return new OrFilter<T>(f1, f2); |
100 | } | |
101 | ||
102 | public static <T extends Element> Filter<T> xor(Filter<T> f1, Filter<T> f2) { | |
103 |
1
1. xor : mutated return of Object value for org/graphstream/util/Filters::xor to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return new XorFilter<T>(f1, f2); |
104 | } | |
105 | ||
106 | public static <T extends Element> Filter<T> not(Filter<T> f) { | |
107 |
1
1. not : mutated return of Object value for org/graphstream/util/Filters::not to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return new NotFilter<T>(f); |
108 | } | |
109 | ||
110 | static class ByAttributeFilter<T extends Element> implements Filter<T> { | |
111 | ||
112 | protected String key; | |
113 | protected Object value; | |
114 | ||
115 | ByAttributeFilter(String key, Object value) { | |
116 | this.key = key; | |
117 | this.value = value; | |
118 | } | |
119 | ||
120 | public boolean isAvailable(T e) { | |
121 |
3
1. isAvailable : negated conditional → NO_COVERAGE 2. isAvailable : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE 3. isAvailable : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return e.hasAttribute(key) |
122 |
2
1. isAvailable : negated conditional → NO_COVERAGE 2. isAvailable : negated conditional → NO_COVERAGE |
&& (value == null ? e.getAttribute(key) == null : value |
123 |
1
1. isAvailable : negated conditional → NO_COVERAGE |
.equals(e.getAttribute(key))); |
124 | } | |
125 | } | |
126 | ||
127 | static class ByIdFilter<T extends Element> implements Filter<T> { | |
128 | String nodePattern; | |
129 | String edgePattern; | |
130 | ||
131 | ByIdFilter(String pattern) { | |
132 | this(pattern, pattern); | |
133 | } | |
134 | ||
135 | ByIdFilter(String nodePattern, String edgePattern) { | |
136 | this.nodePattern = nodePattern; | |
137 | this.edgePattern = edgePattern; | |
138 | } | |
139 | ||
140 | public boolean isAvailable(Element e) { | |
141 |
1
1. isAvailable : negated conditional → NO_COVERAGE |
if (e instanceof Edge) |
142 |
1
1. isAvailable : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return e.getId().matches(edgePattern); |
143 | ||
144 |
1
1. isAvailable : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return e.getId().matches(nodePattern); |
145 | } | |
146 | } | |
147 | ||
148 | static class SeparateNodeEdgeFilter<T extends Element, U extends Element> | |
149 | implements Filter<Element> { | |
150 | ||
151 | Filter<T> nodeFilter; | |
152 | Filter<U> edgeFilter; | |
153 | ||
154 | SeparateNodeEdgeFilter(Filter<T> nodeFilter, Filter<U> edgeFilter) { | |
155 | this.nodeFilter = nodeFilter; | |
156 | this.edgeFilter = edgeFilter; | |
157 | } | |
158 | ||
159 | @SuppressWarnings("unchecked") | |
160 | public boolean isAvailable(Element e) { | |
161 |
1
1. isAvailable : negated conditional → NO_COVERAGE |
if (e instanceof Edge) |
162 |
1
1. isAvailable : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return edgeFilter.isAvailable((U) e); |
163 | ||
164 |
1
1. isAvailable : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return nodeFilter.isAvailable((T) e); |
165 | } | |
166 | } | |
167 | ||
168 | static class ExtremitiesFilter<T extends Element, U extends Element> | |
169 | implements Filter<T> { | |
170 | Filter<U> f; | |
171 | ||
172 | ExtremitiesFilter(Filter<U> f) { | |
173 | this.f = f; | |
174 | } | |
175 | ||
176 | @SuppressWarnings("unchecked") | |
177 | public boolean isAvailable(T e) { | |
178 |
1
1. isAvailable : negated conditional → NO_COVERAGE |
if (e instanceof Node) |
179 |
1
1. isAvailable : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return true; |
180 | ||
181 |
3
1. isAvailable : negated conditional → NO_COVERAGE 2. isAvailable : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE 3. isAvailable : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return f.isAvailable((U) ((Edge) e).getNode0()) |
182 |
1
1. isAvailable : negated conditional → NO_COVERAGE |
&& f.isAvailable((U) ((Edge) e).getNode1()); |
183 | } | |
184 | } | |
185 | ||
186 | static class AndFilter<T extends Element> implements Filter<T> { | |
187 | Filter<T> f1, f2; | |
188 | ||
189 | AndFilter(Filter<T> f1, Filter<T> f2) { | |
190 | this.f1 = f1; | |
191 | this.f2 = f2; | |
192 | } | |
193 | ||
194 | public boolean isAvailable(T e) { | |
195 |
4
1. isAvailable : negated conditional → NO_COVERAGE 2. isAvailable : negated conditional → NO_COVERAGE 3. isAvailable : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE 4. isAvailable : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return f1.isAvailable(e) && f2.isAvailable(e); |
196 | } | |
197 | } | |
198 | ||
199 | static class OrFilter<T extends Element> implements Filter<T> { | |
200 | Filter<T> f1, f2; | |
201 | ||
202 | OrFilter(Filter<T> f1, Filter<T> f2) { | |
203 | this.f1 = f1; | |
204 | this.f2 = f2; | |
205 | } | |
206 | ||
207 | public boolean isAvailable(T e) { | |
208 |
4
1. isAvailable : negated conditional → NO_COVERAGE 2. isAvailable : negated conditional → NO_COVERAGE 3. isAvailable : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE 4. isAvailable : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return f1.isAvailable(e) || f2.isAvailable(e); |
209 | } | |
210 | } | |
211 | ||
212 | static class XorFilter<T extends Element> implements Filter<T> { | |
213 | Filter<T> f1, f2; | |
214 | ||
215 | XorFilter(Filter<T> f1, Filter<T> f2) { | |
216 | this.f1 = f1; | |
217 | this.f2 = f2; | |
218 | } | |
219 | ||
220 | public boolean isAvailable(T e) { | |
221 |
2
1. isAvailable : Replaced XOR with AND → NO_COVERAGE 2. isAvailable : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return f1.isAvailable(e) ^ f2.isAvailable(e); |
222 | } | |
223 | } | |
224 | ||
225 | static class NotFilter<T extends Element> implements Filter<T> { | |
226 | Filter<T> f; | |
227 | ||
228 | NotFilter(Filter<T> f) { | |
229 | this.f = f; | |
230 | } | |
231 | ||
232 | public boolean isAvailable(T e) { | |
233 |
2
1. isAvailable : negated conditional → NO_COVERAGE 2. isAvailable : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return !f.isAvailable(e); |
234 | } | |
235 | } | |
236 | } | |
Mutations | ||
42 |
1.1 |
|
44 |
1.1 |
|
50 |
1.1 |
|
52 |
1.1 |
|
59 |
1.1 |
|
64 |
1.1 |
|
69 |
1.1 |
|
73 |
1.1 |
|
78 |
1.1 |
|
80 |
1.1 |
|
87 |
1.1 |
|
89 |
1.1 |
|
95 |
1.1 |
|
99 |
1.1 |
|
103 |
1.1 |
|
107 |
1.1 |
|
121 |
1.1 2.2 3.3 |
|
122 |
1.1 2.2 |
|
123 |
1.1 |
|
141 |
1.1 |
|
142 |
1.1 |
|
144 |
1.1 |
|
161 |
1.1 |
|
162 |
1.1 |
|
164 |
1.1 |
|
178 |
1.1 |
|
179 |
1.1 |
|
181 |
1.1 2.2 3.3 |
|
182 |
1.1 |
|
195 |
1.1 2.2 3.3 4.4 |
|
208 |
1.1 2.2 3.3 4.4 |
|
221 |
1.1 2.2 |
|
233 |
1.1 2.2 |