1. Project Clover database Sat Feb 2 2019 06:45:20 CET
  2. Package org.xwiki.rendering.block

File AbstractMacroBlock.java

 

Coverage histogram

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

Code metrics

4
23
7
1
129
60
9
0.39
3.29
7
1.29

Classes

Class Line # Actions
AbstractMacroBlock 34 23 0% 9 0
1.0100%
 

Contributing tests

This file is covered by 376 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;
21   
22    import java.util.List;
23    import java.util.Map;
24   
25    import org.apache.commons.lang3.builder.EqualsBuilder;
26    import org.apache.commons.lang3.builder.HashCodeBuilder;
27   
28    /**
29    * Common class to MacroBlock and MacroMakerBlock.
30    *
31    * @version $Id: 26b4b8e5dc68497dfd9d71236f64c7eab88dfeb9 $
32    * @since 10.0
33    */
 
34    public abstract class AbstractMacroBlock extends AbstractBlock
35    {
36    /**
37    * @see #getId
38    */
39    private String id;
40   
41    /**
42    * The macro content for macro that have content. Otherwise it's null.
43    */
44    private String content;
45   
46    /**
47    * The macro is located in a inline content (like paragraph, etc.).
48    */
49    private boolean inline;
50   
51    /**
52    * @param childrenBlocks the list of children blocks of the block to construct
53    * @param parameters the parameters to set
54    * @param id the name of the macro
55    * @param content the content of the macro
56    * @param inline indicate if the macro is located in a inline content
57    */
 
58  793847 toggle public AbstractMacroBlock(List<? extends Block> childrenBlocks, Map<String, String> parameters, String id,
59    String content, boolean inline)
60    {
61  793849 super(childrenBlocks, parameters);
62   
63  793845 this.id = id;
64  793844 this.content = content;
65  793838 this.inline = inline;
66    }
67   
68    /**
69    * @return the macro content.
70    */
 
71  2440655 toggle public String getContent()
72    {
73  2440732 return content;
74    }
75   
76    /**
77    * @return the macro identifier.
78    */
 
79  4677524 toggle public String getId()
80    {
81  4677573 return id;
82    }
83   
84    /**
85    * @return if true the macro is located in a inline content (like paragraph, etc.).
86    */
 
87  2442584 toggle public boolean isInline()
88    {
89  2442588 return inline;
90    }
91   
 
92  28 toggle @Override
93    public boolean equals(Object obj)
94    {
95  28 if (this == obj) {
96  8 return true;
97    }
98   
99  20 if (!super.equals(obj)) {
100  7 return false;
101    }
102   
103  13 return equals((AbstractMacroBlock) obj);
104    }
105   
 
106  13 toggle private boolean equals(AbstractMacroBlock obj)
107    {
108  13 EqualsBuilder builder = new EqualsBuilder();
109   
110  13 builder.append(getContent(), obj.getContent());
111  13 builder.append(getId(), obj.getId());
112  13 builder.append(isInline(), obj.isInline());
113   
114  13 return builder.isEquals();
115    }
116   
 
117  4 toggle @Override
118    public int hashCode()
119    {
120  4 HashCodeBuilder builder = new HashCodeBuilder();
121   
122  4 builder.appendSuper(super.hashCode());
123  4 builder.append(getContent());
124  4 builder.append(getId());
125  4 builder.append(isInline());
126   
127  4 return builder.toHashCode();
128    }
129    }