
biz.gabrys.maven.plugins.css.splitter.split.MultipleRuleSplitter 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.ArrayList;
import java.util.List;
import biz.gabrys.maven.plugins.css.splitter.css.type.NodeRule;
class MultipleRuleSplitter implements RuleSplitter {
private final List splitters;
MultipleRuleSplitter(final List splitters) {
this.splitters = new ArrayList(splitters);
}
@Override
public boolean isSplittable(final NodeRule rule) {
for (final RuleSplitter splitter : splitters) {
if (splitter.isSplittable(rule)) {
return true;
}
}
return false;
}
@Override
public SplitResult split(final NodeRule rule, final int splitAfter) {
for (final RuleSplitter splitter : splitters) {
if (splitter.isSplittable(rule)) {
return splitter.split(rule, splitAfter);
}
}
throw new IllegalArgumentException(String.format("The rule is unsplittable! Code:%n%s", rule));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy