in maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/component/TrinidadComponentGenerator.java [293:381]
public void writePropertyListMethods(
PrettyWriter out,
PropertyBean property) throws IOException
{
String propName = property.getPropertyName();
String propKey = Util.getConstantNameFromProperty(propName, "_KEY");
String propertyClass = property.getPropertyClass();
if (!"java.util.List".equals(propertyClass))
{
getLog().error("Invalid list type: " + propertyClass);
return;
}
// Look for the generic type - if it doesn't exist, then
// we'll be an Object.
String[] params = property.getPropertyClassParameters();
if ((params == null) || (params.length == 0))
propertyClass = "java.lang.Object";
else
propertyClass = params[0];
propertyClass = Util.getClassFromFullClass(propertyClass);
String singularName = getSingular(propName);
String propVar = Util.getVariableFromName(singularName);
String description = property.getDescription();
String addMethod = Util.getPrefixedPropertyName("add", singularName);
String removeMethod = Util.getPrefixedPropertyName("remove", singularName);
String getMethod = Util.getPrefixedPropertyName("get", propName);
out.println();
out.println("/**");
if (description != null)
{
out.println(" * Adds a " + convertMultilineComment(description));
}
out.println(" */");
if (property.getDeprecated() != null)
{
out.println("@Deprecated");
}
out.println("final public void " + addMethod + "(" + propertyClass + " " +
propVar + ")");
out.println("{");
out.indent();
out.println("if (" + propVar + " == null)");
out.println(" throw new NullPointerException();");
out.println();
out.println("getFacesBean().addEntry(" + propKey + ", " + propVar + ");");
out.unindent();
out.println("}");
out.println();
out.println("/**");
if (description != null)
{
out.println(" * Removes a " + convertMultilineComment(description));
}
out.println(" */");
out.println("final public void " + removeMethod + "(" + propertyClass + " " +
propVar + ")");
out.println("{");
out.indent();
out.println("if (" + propVar + " == null)");
out.println(" throw new NullPointerException();");
out.println();
out.println("getFacesBean().removeEntry(" + propKey + ", " + propVar + ");");
out.unindent();
out.println("}");
out.println();
out.println("/**");
if (description != null)
{
out.println(" * Gets all " + convertMultilineComment(description));
}
out.println(" */");
if (property.getDeprecated() != null)
{
out.println("@Deprecated");
}
out.println("final public " + propertyClass + "[] " + getMethod + "()");
out.println("{");
out.indent();
out.println("return (" + propertyClass + "[]) getFacesBean().getEntries(");
out.println(" " + propKey + ", " + propertyClass + ".class);");
out.unindent();
out.println("}");
}