1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.rendering.block.match

File CompositeBlockMatcher.java

 

Coverage histogram

../../../../../img/srcFileCovDistChart0.png
83% of files have more coverage

Code metrics

2
7
3
1
68
28
4
0.57
2.33
3
1.33

Classes

Class Line # Actions
CompositeBlockMatcher 33 7 0% 4 12
0.00%
 

Contributing tests

No tests hitting this source file were found.

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20    package org.xwiki.rendering.block.match;
21   
22    import java.util.ArrayList;
23    import java.util.List;
24   
25    import org.xwiki.rendering.block.Block;
26   
27    /**
28    * Implementation of {@link BlockMatcher} which matches blocks using passed matchers in series.
29    *
30    * @version $Id: 9011a50c3e8015c6527d7899d29f3bcef91bdb5a $
31    * @since 3.0M3
32    */
 
33    public class CompositeBlockMatcher implements BlockMatcher
34    {
35    /**
36    * The matchers to match in series.
37    */
38    private List<BlockMatcher> matchers = new ArrayList<BlockMatcher>();
39   
40    /**
41    * @param matchers list of matchers to add
42    */
 
43  0 toggle public CompositeBlockMatcher(List<BlockMatcher> matchers)
44    {
45  0 this.matchers.addAll(matchers);
46    }
47   
48    /**
49    * @param matchers vararg list of matchers to add
50    */
 
51  0 toggle public CompositeBlockMatcher(BlockMatcher... matchers)
52    {
53  0 for (BlockMatcher matcher : matchers) {
54  0 this.matchers.add(matcher);
55    }
56    }
57   
 
58  0 toggle @Override
59    public boolean match(Block block)
60    {
61  0 for (BlockMatcher matcher : this.matchers) {
62  0 if (!matcher.match(block)) {
63  0 return false;
64    }
65    }
66  0 return true;
67    }
68    }