diff --git a/src/main/java/j2html/TagCreator.java b/src/main/java/j2html/TagCreator.java index eb2dabd..a10a4ae 100644 --- a/src/main/java/j2html/TagCreator.java +++ b/src/main/java/j2html/TagCreator.java @@ -11,11 +11,12 @@ public class TagCreator { /** * Creates a DomContent object containing HTML using a mapping function on a collection - * Intended usage: each(numbers, n -> li(n.toString())) + * Intended usage: {@literal each(numbers, n -> li(n.toString()))} * + * @param The derived generic parameter type * @param collection the collection to iterate over, ex: a list of values "1, 2, 3" - * @param mapper the mapping function, ex: "n -> li(n.toString())" - * @return unsafeHtml containing mapped data (ex. docs:
  • 1
  • 2
  • 3
  • ) + * @param mapper the mapping function, ex: {@literal "n -> li(n.toString())"} + * @return unsafeHtml containing mapped data {@literal (ex. docs:
  • 1
  • 2
  • 3
  • )} */ public static DomContent each(Collection collection, Function mapper) { return unsafeHtml(collection.stream().map(mapper.andThen(DomContent::render)).collect(Collectors.joining())); @@ -23,10 +24,11 @@ public class TagCreator { /** * Filters a collection to a list, to be used with {@link j2html.TagCreator#each} - * Intended usage: each(filter(numbers, n -> n % 2 == 0), n -> li(n.toString())) + * Intended usage: {@literal each(filter(numbers, n -> n % 2 == 0), n -> li(n.toString()))} * + * @param The derived generic parameter type * @param collection the collection to filter, ex: a list of values "1, 2, 3" - * @param filter the filter predicate, ex: "n -> n % 2 == 0" + * @param filter the filter predicate, {@literal ex: "n -> n % 2 == 0"} * @return the filtered collection as a list (ex. docs: 2) */ public static List filter(Collection collection, Predicate filter) { diff --git a/src/main/java/j2html/tags/ContainerTag.java b/src/main/java/j2html/tags/ContainerTag.java index 00569de..7926281 100644 --- a/src/main/java/j2html/tags/ContainerTag.java +++ b/src/main/java/j2html/tags/ContainerTag.java @@ -12,9 +12,10 @@ public class ContainerTag extends Tag { this.children = new ArrayList<>(); } + + /** * Appends a DomContent-object to the end of this element - * * @param child DomContent-object to be appended * @return itself for easy chaining */ @@ -26,17 +27,22 @@ public class ContainerTag extends Tag { return this; } + + /** * Call with-method based on condition * {@link #with(DomContent child)} + * @param condition the condition to use + * @param child DomContent-object to be appended if condition met + * @return itself for easy chaining */ public ContainerTag condWith(boolean condition, DomContent child) { return condition ? this.with(child) : this; } + /** * Appends a list of DomContent-objects to the end of this element - * * @param children DomContent-objects to be appended * @return itself for easy chaining */ @@ -49,17 +55,22 @@ public class ContainerTag extends Tag { return this; } + + /** * Call with-method based on condition - * {@link #with(List children)} + * {@link #with(java.lang.Iterable)} + * @param condition the condition to use + * @param children DomContent-objects to be appended if condition met + * @return itself for easy chaining */ public ContainerTag condWith(boolean condition, Iterable children) { return condition ? this.with(children) : this; } + /** * Appends the DomContent-objects to the end of this element - * * @param children DomContent-objects to be appended * @return itself for easy chaining */ @@ -70,17 +81,21 @@ public class ContainerTag extends Tag { return this; } + /** * Call with-method based on condition * {@link #with(DomContent... children)} + * @param condition the condition to use + * @param children DomContent-objects to be appended if condition met + * @return itself for easy chaining */ public ContainerTag condWith(boolean condition, DomContent... children) { return condition ? this.with(children) : this; } + /** * Appends a Text-object to this element - * * @param text the text to be appended * @return itself for easy chaining */ @@ -88,8 +103,10 @@ public class ContainerTag extends Tag { return with(new Text(text)); } + /** * Render the ContainerTag and its children + * @return the rendered string */ @Override public String render() { diff --git a/src/main/java/j2html/tags/Tag.java b/src/main/java/j2html/tags/Tag.java index 205ab74..5824263 100644 --- a/src/main/java/j2html/tags/Tag.java +++ b/src/main/java/j2html/tags/Tag.java @@ -13,6 +13,7 @@ public abstract class Tag> extends DomContent { this.attributes = new ArrayList<>(); } + String renderOpenTag() { StringBuilder sb = new StringBuilder("<").append( tagName ); for (Attribute attribute : attributes) { @@ -22,13 +23,15 @@ public abstract class Tag> extends DomContent { return sb.toString(); } + String renderCloseTag() { return ""; } + + /** * Sets an attribute on an element - * * @param name the attribute * @param value the attribute value */ @@ -45,9 +48,10 @@ public abstract class Tag> extends DomContent { return attributes.add(new Attribute(name, value)); } + + /** * Sets a custom attribute - * * @param attribute the attribute name * @param value the attribute value * @return itself for easy chaining @@ -57,17 +61,24 @@ public abstract class Tag> extends DomContent { return (T) this; } + + /** * Call attr-method based on condition * {@link #attr(String attribute, String value)} + * @param condition the condition + * @param attribute the attribute name + * @param value the attribute value + * @return itself for easy chaining */ public T condAttr(boolean condition, String attribute, String value) { return (condition ? attr(attribute, value) : (T) this); } + + /** * Convenience methods that call attr with predefined attributes - * * @return itself for easy chaining */ public T isAutoComplete() { return attr(Attr.AUTOCOMPLETE, null); } diff --git a/src/main/java/j2html/utils/CSSMin.java b/src/main/java/j2html/utils/CSSMin.java index 288b174..cd7b31b 100644 --- a/src/main/java/j2html/utils/CSSMin.java +++ b/src/main/java/j2html/utils/CSSMin.java @@ -66,10 +66,11 @@ public class CSSMin { static boolean debugLogging = false; + /** - * Minify CSS from a reader to a printstream. - * - * @param input Where to read the CSS from + * Minify supplied CSS. + * @param input the CSS + * @return the compressed version */ public static String compress(String input) { try {