{
for (JavaClassSource javaSource : targets.getValue())
{
UIContext uiContext = context.getUIContext();
Project project = getSelectedProject(uiContext);
JavaSourceFacet javaSourceFacet = project.getFacet(JavaSourceFacet.class);
if (!javaSource.hasMethodSignature("hashCode"))
{
if (generateEqualsAndHashCode.getValue())
{
if (javaSource.getField("id") != null)
{
Refactory.createHashCode(javaSource, javaSource.getField("id"));
}
else
{
Refactory.createHashCode(javaSource, (FieldSource<?>[]) javaSource.getFields().toArray(new FieldSource[javaSource.getFields().size()]));
}
}
}
if(!javaSource.hasMethodSignature("equals", Object.class)) {
if (generateEqualsAndHashCode.getValue())
{
if (javaSource.getField("id") != null)
{
Refactory.createEquals(javaSource, javaSource.getField("id"));
}
else
{
Refactory.createEquals(javaSource, (FieldSource<?>[]) javaSource.getFields().toArray(new FieldSource[javaSource.getFields().size()]));
}
}
}
javaSourceFacet.saveJavaSource(javaSource);
}
return null;