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

File OrBlockMatcher.java

 

Coverage histogram

../../../../../img/srcFileCovDistChart10.png
0% of files have more coverage

Code metrics

2
9
3
1
71
30
4
0.44
3
3
1.33

Classes

Class Line # Actions
OrBlockMatcher 34 9 0% 4 0
1.0100%
 

Contributing tests

This file is covered by 13 tests. .

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 org.xwiki.rendering.block.match.BlockMatcher} which matches blocks by matching with any
29    * of the configured matchers. This is different from {@link CompositeBlockMatcher} which does an {@code AND}.
30    *
31    * @version $Id: d3ead87adea751c53f85cfcc92ce7c90017a4763 $
32    * @since 4.3M2
33    */
 
34    public class OrBlockMatcher implements BlockMatcher
35    {
36    /**
37    * The matchers to match against.
38    */
39    private List<BlockMatcher> matchers = new ArrayList<BlockMatcher>();
40   
41    /**
42    * @param matchers list of matchers to add
43    */
 
44  1 toggle public OrBlockMatcher(List<BlockMatcher> matchers)
45    {
46  1 this.matchers.addAll(matchers);
47    }
48   
49    /**
50    * @param matchers vararg list of matchers to add
51    */
 
52  22 toggle public OrBlockMatcher(BlockMatcher... matchers)
53    {
54  22 for (BlockMatcher matcher : matchers) {
55  62 this.matchers.add(matcher);
56    }
57    }
58   
 
59  48 toggle @Override
60    public boolean match(Block block)
61    {
62  48 boolean result = false;
63  48 for (BlockMatcher matcher : this.matchers) {
64  111 if (matcher.match(block)) {
65  15 result = true;
66  15 break;
67    }
68    }
69  48 return result;
70    }
71    }