public Element getElement() {
ensureValidity();
Element dep = new Element("requires", "");
if (m_specification != null) {
dep.addAttribute(new Attribute("specification", m_specification));
}
if (m_filter != null) {
dep.addAttribute(new Attribute("filter", m_filter));
}
if (m_field != null) {
dep.addAttribute(new Attribute("field", m_field));
}
if (m_parameterIndex != -1) {
dep.addAttribute(new Attribute("constructor-parameter",
Integer.toString(m_parameterIndex)));
}
if (m_bind != null) {
Element cb = new Element("callback", "");
cb.addAttribute(new Attribute("type", "bind"));
cb.addAttribute(new Attribute("method", m_bind));
dep.addElement(cb);
}
if (m_unbind != null) {
Element cb = new Element("callback", "");
cb.addAttribute(new Attribute("type", "unbind"));
cb.addAttribute(new Attribute("method", m_unbind));
dep.addElement(cb);
}
if (m_modified != null) {
Element cb = new Element("callback", "");
cb.addAttribute(new Attribute("type", "modified"));
cb.addAttribute(new Attribute("method", m_modified));
dep.addElement(cb);
}
if (m_comparator != null) {
dep.addAttribute(new Attribute("comparator", m_comparator));
}
if (m_di != null) {
dep.addAttribute(new Attribute("default-implementation", m_di));
}
if (m_from != null) {
dep.addAttribute(new Attribute("from", m_from));
}
if (m_id != null) {
dep.addAttribute(new Attribute("id", m_id));
}
if (! m_nullable) {
dep.addAttribute(new Attribute("nullable", "false"));
}
if (m_optional) {
dep.addAttribute(new Attribute("optional", "true"));
}
if (m_aggregate) {
dep.addAttribute(new Attribute("aggregate", "true"));
}
if (! m_proxy) {
dep.addAttribute(new Attribute("proxy", "false"));
}
if (m_policy != -1) {
if (m_policy == DYNAMIC) {
dep.addAttribute(new Attribute("policy", "dynamic"));
} else if (m_policy == STATIC) {
dep.addAttribute(new Attribute("policy", "static"));
} else if (m_policy == DYNAMIC_PRIORITY) {
dep.addAttribute(new Attribute("policy", "dynamic-priority"));
}
// No other possibilities.
}
return dep;
}