
biz.gabrys.maven.plugins.css.splitter.split.StyleRuleSplitter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of css-splitter-maven-plugin
Show all versions of css-splitter-maven-plugin
Splits CSS stylesheets to smaller files ("parts") which contain maximum X rules.
/*
* CSS Splitter Maven Plugin
* http://css-splitter-maven-plugin.projects.gabrys.biz/
*
* Copyright (c) 2015 Adam Gabrys
*
* This file is licensed under the BSD 3-Clause (the "License").
* You may not use this file except in compliance with the License.
* You may obtain:
* - a copy of the License at project page
* - a template of the License at https://opensource.org/licenses/BSD-3-Clause
*/
package biz.gabrys.maven.plugins.css.splitter.split;
import java.util.List;
import biz.gabrys.maven.plugins.css.splitter.css.type.StyleProperty;
import biz.gabrys.maven.plugins.css.splitter.css.type.StyleRule;
class StyleRuleSplitter extends AbstractRuleSplitter {
private final NeighborsManager neighborsManager;
StyleRuleSplitter() {
this(new NeighborsManager());
}
// fot tests
StyleRuleSplitter(final NeighborsManager neighborsManager) {
super(StyleRule.class);
this.neighborsManager = neighborsManager;
}
@Override
protected boolean isSplittable2(final StyleRule rule) {
return rule.isSplittable();
}
@Override
protected SplitResult split2(final StyleRule rule, final int splitAfter) {
final List properties = rule.getProperties();
final StyleRule first = new StyleRule(rule.getSelectors(), properties.subList(0, splitAfter));
final StyleRule second = new StyleRule(rule.getSelectors(), properties.subList(splitAfter, properties.size()));
neighborsManager.fill(rule, first, second);
return new SplitResult(first, second);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy