Aleksei Valikov wrote:
> Hi.
>
> This is probably a question for Kohsuke.
>
> I need to add a field outline to the class outline, progrmmatically (for
> instance, additional id or version attribute)
>
> Could you please comment on the code below:
>
> public static FieldOutline createAttributeField(
> ClassOutlineImpl classOutline, String name, final QName attName,
> final CTypeInfo typeInfo, final boolean required) {
> final CPropertyInfo propertyInfo = new CAttributePropertyInfo(name,
> null, new CCustomizations(), null, attName, typeInfo, required);
>
> propertyInfo.realization = new FieldRendererFactory().getDefault();
> final FieldOutline fieldOutline =
> propertyInfo.realization.generate(classOutline, propertyInfo);
> return fieldOutline;
> }
>
>
> I don't like the instantiation of the field renderer factory.
Ideally, you should be using FieldRendererFactory set to the Options
object. IOW,
options.getFieldRendererFactory()
this allows a plugin to override the rendering behavior. Also, since you
don't have any customization, you can just pass in "null" instead of
"new CCustomizations()". Both will achieve the same effect but null is
bit more concise.
Otherwise it looks good.
--
Kohsuke Kawaguchi
Sun Microsystems kohsuke.kawaguchi_at_sun.com