public final class JaxbGroup extends Object
A convenient utility class that enables on-fly creation of JAXB annotated collections of elements, for example:
@XmlRootElement
public class Page {
@XmlElement
public Object getEmployees() {
Collection<Employee> employees = this.retrieve();
return JaxbGroup.build(employees, "employee");
}
}
It's even more convenient in combination with JaxbBundle, for
example:
@XmlRootElement
public class Page {
@XmlElement
public Object getEmployee() {
return new JaxbBundle("employee")
.attr("age", "45")
.add("depts", JaxbGroup.build(this.depts(), "dept"))
.up()
.element();
}
}
The class is immutable and thread-safe.
| Constructor and Description |
|---|
JaxbGroup()
Public ctor, for JAXB (always throws a runtime exception).
|
| Modifier and Type | Method and Description |
|---|---|
static Object |
build(Collection<?> grp,
String name)
Creates a new JAXB-annotated collection of elements.
|
Collection<?> |
getGroup()
Get group of elements.
|
public JaxbGroup()
@NotNull public static Object build(@NotNull(message="group can\'t be NULL") Collection<?> grp, @NotNull(message="name can\'t be NULL") String name)
grp - Group of elements (JAXB-annotated)name - Name of parent XML element@NotNull(message="collection is never NULL") public Collection<?> getGroup()
Copyright © 2011–2014 ReXSL.com. All rights reserved.