minify-html/java/src/main/java/in/wilsonl/minifyhtml/Configuration.java

104 lines
2.9 KiB
Java

package in.wilsonl.minifyhtml;
/**
* Class representing minification configuration.
*/
public class Configuration {
public final boolean keep_closing_tags;
public final boolean keep_comments;
public final boolean keep_html_and_head_opening_tags;
public final boolean keep_spaces_between_attributes;
public final boolean minify_css;
public final boolean minify_js;
public final boolean remove_bangs;
public final boolean remove_processing_instructions;
public Configuration(
boolean keep_closing_tags,
boolean keep_comments,
boolean keep_html_and_head_opening_tags,
boolean keep_spaces_between_attributes,
boolean minify_css,
boolean minify_js,
boolean remove_bangs,
boolean remove_processing_instructions
) {
this.keep_closing_tags = keep_closing_tags;
this.keep_comments = keep_comments;
this.keep_html_and_head_opening_tags = keep_html_and_head_opening_tags;
this.keep_spaces_between_attributes = keep_spaces_between_attributes;
this.minify_css = minify_css;
this.minify_js = minify_js;
this.remove_bangs = remove_bangs;
this.remove_processing_instructions = remove_processing_instructions;
}
/**
* Builder to help create configuration.
*/
public static class Builder {
private boolean keep_closing_tags = false;
private boolean keep_comments = false;
private boolean keep_html_and_head_opening_tags = false;
private boolean keep_spaces_between_attributes = false;
private boolean minify_css = false;
private boolean minify_js = false;
private boolean remove_bangs = false;
private boolean remove_processing_instructions = false;
public Builder setKeepClosingTags(boolean val) {
this.keep_closing_tags = val;
return this;
}
public Builder setKeepComments(boolean val) {
this.keep_comments = val;
return this;
}
public Builder setKeepHtmlAndHeadOpeningTags(boolean val) {
this.keep_html_and_head_opening_tags = val;
return this;
}
public Builder setKeepSpacesBetweenAttributes(boolean val) {
this.keep_spaces_between_attributes = val;
return this;
}
public Builder setMinifyCss(boolean val) {
this.minify_css = val;
return this;
}
public Builder setMinifyJs(boolean val) {
this.minify_js = val;
return this;
}
public Builder setRemoveBangs(boolean val) {
this.remove_bangs = val;
return this;
}
public Builder setRemoveProcessingInstructions(boolean val) {
this.remove_processing_instructions = val;
return this;
}
public Configuration build() {
return new Configuration(
this.keep_closing_tags,
this.keep_comments,
this.keep_html_and_head_opening_tags,
this.keep_spaces_between_attributes,
this.minify_css,
this.minify_js,
this.remove_bangs,
this.remove_processing_instructions
);
}
}
}