| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
package org.devacfr.maven.skins.reflow.model; |
| 20 |
|
|
| 21 |
|
import javax.annotation.Nonnull; |
| 22 |
|
|
| 23 |
|
import java.util.List; |
| 24 |
|
|
| 25 |
|
import com.google.common.base.Joiner; |
| 26 |
|
import com.google.common.base.Strings; |
| 27 |
|
import com.google.common.collect.FluentIterable; |
| 28 |
|
import com.google.common.collect.Lists; |
| 29 |
|
import org.devacfr.maven.skins.reflow.HtmlTool; |
| 30 |
|
import org.devacfr.maven.skins.reflow.ISkinConfig; |
| 31 |
|
|
| 32 |
|
import static com.google.common.collect.FluentIterable.concat; |
| 33 |
|
import static java.util.Objects.requireNonNull; |
| 34 |
|
|
| 35 |
|
|
| 36 |
|
|
| 37 |
|
|
| 38 |
|
@author |
| 39 |
|
@since |
| 40 |
|
|
| |
|
| 92% |
Uncovered Elements: 2 (25) |
Complexity: 9 |
Complexity Density: 0,6 |
|
| 41 |
|
public abstract class Component { |
| 42 |
|
|
| 43 |
|
|
| 44 |
|
private String cssClass; |
| 45 |
|
|
| 46 |
|
|
| 47 |
|
private final List<String> cssOptions = Lists.newArrayList(); |
| 48 |
|
|
| 49 |
|
|
| 50 |
|
private final List<Component> children = Lists.newArrayList(); |
| 51 |
|
|
| 52 |
|
|
| 53 |
|
@return@link |
| 54 |
|
|
| |
|
| 60% |
Uncovered Elements: 2 (5) |
Complexity: 2 |
Complexity Density: 0,67 |
|
| 55 |
14 |
@Nonnull... |
| 56 |
|
public String getCssClass() { |
| 57 |
14 |
if (Strings.isNullOrEmpty(cssClass)) { |
| 58 |
14 |
return ""; |
| 59 |
|
} |
| 60 |
0 |
return cssClass; |
| 61 |
|
} |
| 62 |
|
|
| 63 |
|
|
| 64 |
|
@param |
| 65 |
|
|
| 66 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 67 |
48 |
protected void setCssClass(final String cssClass) {... |
| 68 |
48 |
this.cssClass = cssClass; |
| 69 |
|
} |
| 70 |
|
|
| 71 |
|
|
| 72 |
|
|
| 73 |
|
|
| 74 |
|
|
| 75 |
|
|
| 76 |
|
|
| 77 |
|
|
| 78 |
|
@return@link |
| 79 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 80 |
15 |
@Nonnull... |
| 81 |
|
public final String getCssOptions() { |
| 82 |
15 |
return concat(this.cssOptions, |
| 83 |
|
concat(FluentIterable.from(children).transform(component -> component.cssOptions))).join(Joiner.on(' ')); |
| 84 |
|
} |
| 85 |
|
|
| 86 |
|
|
| 87 |
|
|
| 88 |
|
|
| 89 |
|
@param |
| 90 |
|
|
| 91 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 92 |
32 |
protected void addChildren(final Component... components) {... |
| 93 |
32 |
this.children.addAll(Lists.newArrayList(components)); |
| 94 |
|
} |
| 95 |
|
|
| 96 |
|
|
| 97 |
|
|
| 98 |
|
|
| 99 |
|
@param |
| 100 |
|
|
| 101 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 102 |
38 |
protected final void addCssOptions(@Nonnull final String... cssOptions) {... |
| 103 |
38 |
this.cssOptions.addAll(Lists.newArrayList(cssOptions)); |
| 104 |
|
} |
| 105 |
|
|
| 106 |
|
|
| 107 |
|
|
| 108 |
|
|
| 109 |
|
@param |
| 110 |
|
|
| 111 |
|
@param |
| 112 |
|
|
| 113 |
|
@return |
| 114 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0,17 |
|
| 115 |
25 |
protected String onPreRender(@Nonnull final ISkinConfig skinConfig, @Nonnull final String bodyContent) {... |
| 116 |
25 |
final StringBuilder str = new StringBuilder(bodyContent); |
| 117 |
25 |
this.children.forEach(component -> { |
| 118 |
25 |
final String content = str.toString(); |
| 119 |
25 |
str.setLength(0); |
| 120 |
25 |
str.append(component.onPreRender(skinConfig, content)); |
| 121 |
|
}); |
| 122 |
25 |
return str.toString(); |
| 123 |
|
} |
| 124 |
|
|
| 125 |
|
|
| 126 |
|
@link |
| 127 |
|
|
| 128 |
|
@param |
| 129 |
|
|
| 130 |
|
@return@link |
| 131 |
|
@since |
| 132 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 133 |
5 |
protected HtmlTool getHtmlTool(@Nonnull final ISkinConfig skinConfig) {... |
| 134 |
5 |
return requireNonNull(skinConfig).getToolbox("htmlTool", HtmlTool.class); |
| 135 |
|
} |
| 136 |
|
|
| 137 |
|
|
| 138 |
|
@param |
| 139 |
|
|
| 140 |
|
@return |
| 141 |
|
@since |
| 142 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 143 |
6 |
@Nonnull... |
| 144 |
|
protected String getBodyContent(@Nonnull final ISkinConfig skinConfig) { |
| 145 |
6 |
return requireNonNull(skinConfig).getContextValue("bodyContent", String.class); |
| 146 |
|
} |
| 147 |
|
} |