Merge pull request #39 from dellgreen/java8doclintFixs
updated javadoc comments to pass doclint checks in java 8
This commit is contained in:
@@ -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 <T> 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: <li>1</li><li>2</li><li>3</li>)
|
||||
* @param mapper the mapping function, ex: {@literal "n -> li(n.toString())"}
|
||||
* @return unsafeHtml containing mapped data {@literal (ex. docs: <li>1</li><li>2</li><li>3</li>)}
|
||||
*/
|
||||
public static <T> DomContent each(Collection<T> collection, Function<? super T, DomContent> 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 <T> 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 <T> List<T> filter(Collection<T> collection, Predicate<? super T> filter) {
|
||||
|
||||
@@ -12,9 +12,10 @@ public class ContainerTag extends Tag<ContainerTag> {
|
||||
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<ContainerTag> {
|
||||
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<ContainerTag> {
|
||||
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<? extends DomContent> 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<ContainerTag> {
|
||||
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<ContainerTag> {
|
||||
return with(new Text(text));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Render the ContainerTag and its children
|
||||
* @return the rendered string
|
||||
*/
|
||||
@Override
|
||||
public String render() {
|
||||
|
||||
@@ -13,6 +13,7 @@ public abstract class Tag<T extends Tag<T>> 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<T extends Tag<T>> extends DomContent {
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
|
||||
String renderCloseTag() {
|
||||
return "</" + tagName + ">";
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Sets an attribute on an element
|
||||
*
|
||||
* @param name the attribute
|
||||
* @param value the attribute value
|
||||
*/
|
||||
@@ -45,9 +48,10 @@ public abstract class Tag<T extends Tag<T>> 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<T extends Tag<T>> 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); }
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user